-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
21 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,27 @@ | ||
package gocv | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"unsafe" | ||
) | ||
|
||
func mcb(event int, x int, y int, flags int, userdata interface{}) { | ||
name := *(userdata.(*string)) | ||
fmt.Println(name, event, x, y, flags) | ||
type mouseHandlerUserData struct { | ||
name string | ||
} | ||
|
||
func TestMouseCallback(t *testing.T) { | ||
//t.Skip("TODO: figure out how to implement a test that can exercise the GUI") | ||
func mouseHandler(event int, x int, y int, flags int, userdata interface{}) {} | ||
|
||
// Comment'd out just for the sake of testing | ||
// changes on this feature or until we find a | ||
// proper way to run this test. | ||
func TestMouseHandler(t *testing.T) { | ||
windowName := "mouse" | ||
|
||
w := NewWindow("mouse") | ||
w := NewWindow(windowName) | ||
defer w.Close() | ||
|
||
name := "gocv" | ||
|
||
w.SetMouseCallback(mcb, &name) | ||
|
||
m := IMRead("images/face-detect.jpg", IMReadColor) | ||
defer m.Close() | ||
|
||
outer_for: | ||
for { | ||
w.IMShow(m) | ||
switch w.WaitKey(5) { | ||
case 'q': | ||
break outer_for | ||
} | ||
udata := mouseHandlerUserData{ | ||
name: "gocv", | ||
} | ||
|
||
w.SetMouseHandler(mouseHandler, &udata) | ||
go_onmouse_dispatcher(1, 2, 3, 4, unsafe.Pointer(&windowName)) | ||
|
||
} |