diff --git a/platforms/opencv/test_helper.go b/platforms/opencv/test_helper.go index 2f39f19c..d995c89e 100644 --- a/platforms/opencv/test_helper.go +++ b/platforms/opencv/test_helper.go @@ -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 } diff --git a/platforms/opencv/window_driver.go b/platforms/opencv/window_driver.go index 8f95072c..70a697e5 100644 --- a/platforms/opencv/window_driver.go +++ b/platforms/opencv/window_driver.go @@ -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 } diff --git a/platforms/opencv/window_driver_test.go b/platforms/opencv/window_driver_test.go index df02da43..6a099041 100644 --- a/platforms/opencv/window_driver_test.go +++ b/platforms/opencv/window_driver_test.go @@ -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) {