forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
window_driver_test.go
50 lines (41 loc) · 1.08 KB
/
window_driver_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package opencv
import (
"path"
"runtime"
"strings"
"testing"
"gobot.io/x/gobot"
"gobot.io/x/gobot/gobottest"
"gocv.io/x/gocv"
)
var _ gobot.Driver = (*WindowDriver)(nil)
func initTestWindowDriver() *WindowDriver {
d := NewWindowDriver()
return d
}
func TestWindowDriver(t *testing.T) {
d := initTestWindowDriver()
gobottest.Assert(t, d.Name(), "Window")
gobottest.Assert(t, d.Connection(), (gobot.Connection)(nil))
}
func TestWindowDriverName(t *testing.T) {
d := initTestWindowDriver()
gobottest.Assert(t, strings.HasPrefix(d.Name(), "Window"), true)
d.SetName("NewName")
gobottest.Assert(t, d.Name(), "NewName")
}
func TestWindowDriverStart(t *testing.T) {
d := initTestWindowDriver()
gobottest.Assert(t, d.Start(), nil)
}
func TestWindowDriverHalt(t *testing.T) {
d := initTestWindowDriver()
gobottest.Assert(t, d.Halt(), nil)
}
func TestWindowDriverShowImage(t *testing.T) {
d := initTestWindowDriver()
_, currentfile, _, _ := runtime.Caller(0)
image := gocv.IMRead(path.Join(path.Dir(currentfile), "lena-256x256.jpg"), gocv.IMReadColor)
d.Start()
d.ShowImage(image)
}