Mock out window creation in test
This commit is contained in:
parent
c081f46609
commit
201b54d56e
|
@ -16,3 +16,11 @@ func (c *testCapture) RetrieveFrame(i int) *cv.IplImage {
|
|||
func (c *testCapture) GrabFrame() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
type window interface {
|
||||
ShowImage(*cv.IplImage)
|
||||
}
|
||||
|
||||
type testWindow struct{}
|
||||
|
||||
func (w *testWindow) ShowImage(i *cv.IplImage) { return }
|
||||
|
|
|
@ -7,7 +7,8 @@ import (
|
|||
|
||||
type WindowDriver struct {
|
||||
gobot.Driver
|
||||
window *cv.Window
|
||||
window window
|
||||
start func(*WindowDriver)
|
||||
}
|
||||
|
||||
func NewWindowDriver(name string) *WindowDriver {
|
||||
|
@ -16,12 +17,15 @@ func NewWindowDriver(name string) *WindowDriver {
|
|||
name,
|
||||
"WindowDriver",
|
||||
),
|
||||
start: func(w *WindowDriver) {
|
||||
w.window = cv.NewWindow(w.Name(), cv.CV_WINDOW_NORMAL)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WindowDriver) Start() bool {
|
||||
cv.StartWindowThread()
|
||||
w.window = cv.NewWindow(w.Name(), cv.CV_WINDOW_NORMAL)
|
||||
w.start(w)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,11 @@ import (
|
|||
)
|
||||
|
||||
func initTestWindowDriver() *WindowDriver {
|
||||
return NewWindowDriver("bot")
|
||||
d := NewWindowDriver("bot")
|
||||
d.start = func(w *WindowDriver) {
|
||||
w.window = &testWindow{}
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func TestWindowDriverStart(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue