mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-04-26 13:48:49 +08:00
Adding basic test coverage to opencv
This commit is contained in:
parent
22839c4d21
commit
eee92acd30
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
*.test
|
||||
*.swp
|
||||
profile.cov
|
||||
count.out
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func initTestCameraDriver() *CameraDriver {
|
||||
return NewCameraDriver("bot", 0)
|
||||
return NewCameraDriver("bot", "")
|
||||
}
|
||||
|
||||
func TestCameraDriverStart(t *testing.T) {
|
||||
@ -15,14 +15,24 @@ func TestCameraDriverStart(t *testing.T) {
|
||||
gobot.Assert(t, d.Start(), true)
|
||||
}
|
||||
|
||||
func TestCameraDriverStartPanic(t *testing.T) {
|
||||
recovered := false
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
recovered = true
|
||||
}
|
||||
}()
|
||||
|
||||
NewCameraDriver("bot", false).Start()
|
||||
gobot.Expect(t, recovered, true)
|
||||
}
|
||||
|
||||
func TestCameraDriverHalt(t *testing.T) {
|
||||
t.SkipNow()
|
||||
d := initTestCameraDriver()
|
||||
gobot.Assert(t, d.Halt(), true)
|
||||
}
|
||||
|
||||
func TestCameraDriverInit(t *testing.T) {
|
||||
t.SkipNow()
|
||||
d := initTestCameraDriver()
|
||||
gobot.Assert(t, d.Init(), true)
|
||||
}
|
||||
|
BIN
platforms/opencv/test.png
Normal file
BIN
platforms/opencv/test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
@ -1,8 +1,11 @@
|
||||
package opencv
|
||||
|
||||
import (
|
||||
cv "github.com/hybridgroup/go-opencv/opencv"
|
||||
"github.com/hybridgroup/gobot"
|
||||
"testing"
|
||||
"path"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func initTestWindowDriver() *WindowDriver {
|
||||
@ -16,13 +19,21 @@ func TestWindowDriverStart(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWindowDriverHalt(t *testing.T) {
|
||||
t.SkipNow()
|
||||
d := initTestWindowDriver()
|
||||
gobot.Assert(t, d.Halt(), true)
|
||||
}
|
||||
|
||||
func TestWindowDriverInit(t *testing.T) {
|
||||
t.SkipNow()
|
||||
d := initTestWindowDriver()
|
||||
gobot.Assert(t, d.Init(), true)
|
||||
}
|
||||
|
||||
func TestWindowDriverShowImage(t *testing.T) {
|
||||
t.SkipNow()
|
||||
d := initTestWindowDriver()
|
||||
_, currentfile, _, _ := runtime.Caller(0)
|
||||
image := cv.LoadImage(path.Join(path.Dir(currentfile), "test.png"))
|
||||
|
||||
d.Start()
|
||||
d.ShowImage(image)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user