robot_info_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT
  2. // file at the top-level directory of this distribution and at
  3. // https://github.com/go-vgo/robotgo/blob/master/LICENSE
  4. //
  5. // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  6. // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  7. // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
  8. // option. This file may not be copied, modified, or distributed
  9. // except according to those terms.
  10. package robotgo_test
  11. import (
  12. "fmt"
  13. "log"
  14. "runtime"
  15. "testing"
  16. "github.com/go-vgo/robotgo"
  17. "github.com/vcaesar/tt"
  18. )
  19. func TestGetVer(t *testing.T) {
  20. fmt.Println("go version: ", runtime.Version())
  21. ver := robotgo.GetVersion()
  22. tt.Expect(t, robotgo.Version, ver)
  23. }
  24. func TestGetScreenSize(t *testing.T) {
  25. x, y := robotgo.GetScreenSize()
  26. log.Println("Get screen size: ", x, y)
  27. rect := robotgo.GetScreenRect()
  28. fmt.Println("Get screen rect: ", rect)
  29. x, y = robotgo.Location()
  30. fmt.Println("Get location: ", x, y)
  31. }
  32. func TestGetSysScale(t *testing.T) {
  33. s := robotgo.SysScale()
  34. log.Println("SysScale: ", s)
  35. f := robotgo.ScaleF()
  36. log.Println("scale: ", f)
  37. }
  38. func TestGetTitle(t *testing.T) {
  39. // just exercise the function, it used to crash with a segfault + "Maximum
  40. // number of clients reached"
  41. for i := 0; i < 128; i++ {
  42. robotgo.GetTitle()
  43. }
  44. }