-
Notifications
You must be signed in to change notification settings - Fork 17
/
progressIndicator_test.go
59 lines (48 loc) · 1.46 KB
/
progressIndicator_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
package gocoa
import (
"fmt"
"testing"
)
func TestNewProgressIndicator(t *testing.T) {
InitApplication()
OnApplicationDidFinishLaunching(func() {
fmt.Println("App running!")
})
wnd := NewWindow("Hello World!", 150, 150, 300, 200)
indicator := NewProgressIndicator(0, 0, 100, 50)
if indicator.progressIndicatorPtr == nil {
t.Fatalf("pointer to C indicator is nil!")
}
if indicator.GetValue() != 0.00 {
t.Fatalf("indicator has not set the default value, but has value %f!", indicator.GetValue())
}
wnd.AddProgressIndicator(indicator)
indicator.SetValue(66.00)
indicator.IncrementBy(5.00)
indicator.IncrementBy(-20.00)
TerminateApplication()
}
func TestSetValue(t *testing.T) {
indicator := NewProgressIndicator(0, 0, 100, 50)
indicator.SetLimits(0.00, 100.00)
indicator.SetValue(33.00)
if indicator.GetValue() != 33.00 {
t.Fatalf("indicator did not update the value, but has value %f!", indicator.GetValue())
}
}
func TestIncrementBy(t *testing.T) {
indicator := NewProgressIndicator(0, 0, 100, 50)
indicator.SetLimits(0.00, 100.00)
indicator.IncrementBy(1.00)
indicator.IncrementBy(1.00)
indicator.IncrementBy(1.00)
indicator.IncrementBy(1.00)
indicator.IncrementBy(1.00)
if indicator.GetValue() != 5.00 {
t.Fatalf("indicator did not increment the value but %f!", indicator.GetValue())
}
indicator.IncrementBy(-1.00)
if indicator.GetValue() != 4.00 {
t.Fatalf("indicator did not decrement the value but %f!", indicator.GetValue())
}
}