2014-04-28 07:58:34 +08:00
|
|
|
package opencv
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
import (
|
2014-07-24 07:38:46 +08:00
|
|
|
"path"
|
|
|
|
"runtime"
|
2017-04-06 17:01:57 +08:00
|
|
|
"strings"
|
2014-07-24 07:38:46 +08:00
|
|
|
"testing"
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/gobottest"
|
2017-10-19 00:13:40 +08:00
|
|
|
"gocv.io/x/gocv"
|
2014-04-26 18:11:51 +08:00
|
|
|
)
|
|
|
|
|
2016-08-27 17:56:01 +08:00
|
|
|
var _ gobot.Driver = (*WindowDriver)(nil)
|
|
|
|
|
2014-06-14 07:01:39 +08:00
|
|
|
func initTestWindowDriver() *WindowDriver {
|
2016-10-01 23:53:39 +08:00
|
|
|
d := NewWindowDriver()
|
2014-07-24 07:54:39 +08:00
|
|
|
return d
|
2014-06-14 04:45:50 +08:00
|
|
|
}
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-12-20 03:57:35 +08:00
|
|
|
func TestWindowDriver(t *testing.T) {
|
|
|
|
d := initTestWindowDriver()
|
2016-10-01 23:53:39 +08:00
|
|
|
gobottest.Assert(t, d.Name(), "Window")
|
2016-02-22 13:21:24 +08:00
|
|
|
gobottest.Assert(t, d.Connection(), (gobot.Connection)(nil))
|
2014-12-20 03:57:35 +08:00
|
|
|
}
|
2016-10-01 23:53:39 +08:00
|
|
|
|
2017-04-06 17:01:57 +08:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2014-06-14 07:01:39 +08:00
|
|
|
func TestWindowDriverStart(t *testing.T) {
|
|
|
|
d := initTestWindowDriver()
|
2016-11-08 03:06:55 +08:00
|
|
|
gobottest.Assert(t, d.Start(), nil)
|
2014-06-14 04:45:50 +08:00
|
|
|
}
|
|
|
|
|
2014-06-14 07:01:39 +08:00
|
|
|
func TestWindowDriverHalt(t *testing.T) {
|
|
|
|
d := initTestWindowDriver()
|
2016-11-08 03:06:55 +08:00
|
|
|
gobottest.Assert(t, d.Halt(), nil)
|
2014-06-14 04:45:50 +08:00
|
|
|
}
|
2014-07-17 05:37:58 +08:00
|
|
|
|
|
|
|
func TestWindowDriverShowImage(t *testing.T) {
|
|
|
|
d := initTestWindowDriver()
|
2014-07-24 07:38:46 +08:00
|
|
|
_, currentfile, _, _ := runtime.Caller(0)
|
2017-10-05 23:05:10 +08:00
|
|
|
image := gocv.IMRead(path.Join(path.Dir(currentfile), "lena-256x256.jpg"), gocv.IMReadColor)
|
2014-07-24 07:38:46 +08:00
|
|
|
d.Start()
|
|
|
|
d.ShowImage(image)
|
2014-07-17 05:37:58 +08:00
|
|
|
}
|