-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathwindow_driver_test.go
55 lines (44 loc) · 1.13 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
51
52
53
54
55
//go:build gocv
// +build gocv
package opencv
import (
"path"
"runtime"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gobot.io/x/gobot/v2"
"gocv.io/x/gocv"
)
var _ gobot.Driver = (*WindowDriver)(nil)
func initTestWindowDriver() *WindowDriver {
d := NewWindowDriver()
return d
}
func TestWindowDriver(t *testing.T) {
d := initTestWindowDriver()
assert.Equal(t, "Window", d.Name())
assert.Equal(t, (gobot.Connection)(nil), d.Connection())
}
func TestWindowDriverName(t *testing.T) {
d := initTestWindowDriver()
assert.True(t, strings.HasPrefix(d.Name(), "Window"))
d.SetName("NewName")
assert.Equal(t, "NewName", d.Name())
}
func TestWindowDriverStart(t *testing.T) {
d := initTestWindowDriver()
require.NoError(t, d.Start())
}
func TestWindowDriverHalt(t *testing.T) {
d := initTestWindowDriver()
require.NoError(t, d.Halt())
}
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)
}