forked from getlantern/systray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
systray_test.go
64 lines (56 loc) · 1.29 KB
/
systray_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
package systray
import (
"log"
"testing"
"time"
)
func TestRun(t *testing.T) {
if err := SetIconPath("example/icon/iconwin.ico"); err != nil {
t.Fatalf("Can't set icon: %s", err)
}
if err := SetTitle("Test title с кириллицей"); err != nil {
t.Fatalf("Can't set title: %s", err)
}
bSomeBtn := AddMenuItem("Йа Кнопко", "", ItemCheckable)
AddSeparator()
bQuit := AddMenuItem("Quit", "Quit the whole app", ItemDefault)
go func() {
for {
select {
case <-bSomeBtn.OnClickCh():
t.Log("Btn clicked")
case <-bQuit.OnClickCh():
t.Log("Quit reqested")
Quit()
}
}
}()
time.AfterFunc(3*time.Second, Quit)
Run(nil, nil)
}
func ExampleRun() {
if err := SetIconPath("example/icon/iconwin.ico"); err != nil {
log.Fatalf("Can't set icon: %s", err)
}
if err := SetTitle("Test title с кириллицей"); err != nil {
log.Fatalf("Can't set title: %s", err)
}
bBtn := AddMenuItem("Йа Кнопко", "", ItemCheckable)
AddSeparator()
bQuit := AddMenuItem("Quit", "Quit the whole app", ItemDefault)
go func() {
for {
select {
case <-bBtn.OnClickCh():
log.Println("Btn clicked")
case <-bQuit.OnClickCh():
log.Println("Quit reqested")
Quit()
}
}
}()
onReady := func() {
log.Println("Systray started")
}
Run(onReady, nil)
}