-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaskbar_test.go
82 lines (72 loc) · 1.6 KB
/
taskbar_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
package taskbar_test
import (
"os"
"strconv"
"testing"
"github.com/bibelin/taskbar"
)
const desktop = "my.app.desktop"
func TestLibunity(t *testing.T) {
os.Setenv("GO_TASKBAR_BACKEND", "libunity")
if _, res := os.LookupEnv("GITHUB_ACTIONS"); res {
os.Setenv("XDG_SESSION_TYPE", "wayland")
}
tb, err := taskbar.Connect(desktop, 0)
if err != nil {
t.Fatal(err)
}
defer tb.Disconnect()
if err = tb.SetProgress(50); err != nil {
t.Fatal(err)
}
if err = tb.SetCount(1); err != nil {
t.Fatal(err)
}
if err = tb.SetPulse(true); err != nil {
t.Fatal(err)
}
}
func TestXapp(t *testing.T) {
if _, res := os.LookupEnv("GITHUB_ACTIONS"); res {
t.Skip("Running in Github workflow, skipping the test.")
}
os.Setenv("GO_TASKBAR_BACKEND", "xapp")
xid, err := strconv.ParseInt(os.Getenv("GO_TASKBAR_TEST_XID"), 10, 0)
if err != nil {
t.Fatalf("Error getting GO_TASKBAR_TEST_XID: %v\n You need to set it to valid xid to pass the test.", err)
}
tb, err := taskbar.Connect(desktop, int(xid))
if err != nil {
t.Fatal(err)
}
defer tb.Disconnect()
if err = tb.SetProgress(50); err != nil {
t.Fatal(err)
}
if err = tb.SetCount(1); err != nil {
t.Fatal(err)
}
if err = tb.SetPulse(true); err != nil {
t.Fatal(err)
}
}
func TestBackendsFail(t *testing.T) {
os.Setenv("GO_TASKBAR_BACKEND", "libunity")
tb, err := taskbar.Connect("", 123)
if err == nil {
t.Fail()
}
errs := tb.Disconnect()
if errs == nil {
t.Fail()
}
os.Setenv("GO_TASKBAR_BACKEND", "xapp")
tb, err = taskbar.Connect(desktop, 0)
if err == nil {
t.Fail()
}
errs = tb.Disconnect()
if errs == nil {
t.Fail()
}
}