forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
highgui_test.go
96 lines (76 loc) · 1.98 KB
/
highgui_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Do not run these tests on mac OS X. They fail with errors suggesting the GUI
// should only be touched from the main thread.
// +build !darwin
package gocv
import (
"testing"
)
func TestWindow(t *testing.T) {
window := NewWindow("test")
if window == nil {
t.Error("Unable to create Window")
}
if window.name != "test" {
t.Error("Invalid Window name")
}
val := window.WaitKey(1)
if val != -1 {
t.Error("Invalid WaitKey")
}
if !window.IsOpen() {
t.Error("Window should have been open")
}
window.SetWindowProperty(WindowPropertyFullscreen, WindowFullscreen)
prop := int(window.GetWindowProperty(WindowPropertyFullscreen))
if prop != WindowFullscreen {
t.Error("Window property should have been fullscreen")
}
window.SetWindowTitle("My new title")
window.MoveWindow(100, 100)
window.ResizeWindow(100, 100)
window.Close()
if window.IsOpen() {
t.Error("Window should have been closed")
}
}
func TestIMShow(t *testing.T) {
window := NewWindow("imshow")
if window == nil {
t.Error("Unable to create IMShow Window")
}
img := IMRead("images/face-detect.jpg", IMReadColor)
if img.Empty() {
t.Error("Invalid Mat in IMShow")
}
defer img.Close()
// TODO: some way to determine if the call succeeded
window.IMShow(img)
val := WaitKey(1)
if val != -1 {
t.Error("Invalid for IMShow")
}
window.Close()
if window.IsOpen() {
t.Error("IMShow window should have been closed")
}
}
func TestSelectROI(t *testing.T) {
t.Skip("TODO: figure out how to implement a test that can exercise the GUI")
}
func TestSelectROIs(t *testing.T) {
t.Skip("TODO: figure out how to implement a test that can exercise the GUI")
}
func TestTrackbar(t *testing.T) {
window := NewWindow("trackbar")
defer window.Close()
tracker := window.CreateTrackbar("trackme", 100)
if tracker.GetPos() != 0 {
t.Error("Trackbar pos should have been 0")
}
tracker.SetMin(10)
tracker.SetMax(150)
tracker.SetPos(50)
if tracker.GetPos() != 50 {
t.Error("Trackbar pos should have been 50")
}
}