1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-24 13:48:49 +08:00
hybridgroup.gobot/platforms/opencv/window_driver_test.go

56 lines
1.1 KiB
Go
Raw Normal View History

//go:build gocv
// +build gocv
2014-04-27 16:58:34 -07:00
package opencv
import (
2014-07-23 16:38:46 -07:00
"path"
"runtime"
"strings"
2014-07-23 16:38:46 -07:00
"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)
2014-06-13 16:01:39 -07:00
func initTestWindowDriver() *WindowDriver {
d := NewWindowDriver()
2014-07-23 16:54:39 -07:00
return d
2014-06-13 13:45:50 -07:00
}
2014-12-19 11:57:35 -08:00
func TestWindowDriver(t *testing.T) {
d := initTestWindowDriver()
assert.Equal(t, "Window", d.Name())
assert.Equal(t, (gobot.Connection)(nil), d.Connection())
2014-12-19 11:57:35 -08:00
}
func TestWindowDriverName(t *testing.T) {
d := initTestWindowDriver()
assert.True(t, strings.HasPrefix(d.Name(), "Window"))
d.SetName("NewName")
assert.Equal(t, "NewName", d.Name())
}
2014-06-13 16:01:39 -07:00
func TestWindowDriverStart(t *testing.T) {
d := initTestWindowDriver()
require.NoError(t, d.Start())
2014-06-13 13:45:50 -07:00
}
2014-06-13 16:01:39 -07:00
func TestWindowDriverHalt(t *testing.T) {
d := initTestWindowDriver()
require.NoError(t, d.Halt())
2014-06-13 13:45:50 -07:00
}
2014-07-16 16:37:58 -05:00
func TestWindowDriverShowImage(t *testing.T) {
d := initTestWindowDriver()
2014-07-23 16:38:46 -07:00
_, currentfile, _, _ := runtime.Caller(0)
image := gocv.IMRead(path.Join(path.Dir(currentfile), "lena-256x256.jpg"), gocv.IMReadColor)
2014-07-23 16:38:46 -07:00
d.Start()
d.ShowImage(image)
2014-07-16 16:37:58 -05:00
}