-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathevent_test.go
executable file
·132 lines (107 loc) · 1.83 KB
/
event_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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package client
import (
"testing"
)
var (
h = &FakeEventHandler{}
c = &FakeClient{}
)
type FakeClient struct {
DummyIPC
}
type FakeEventHandler struct {
DummyEvHandler
}
func (f FakeClient) Receive() ([]ReceivedData, error) {
return []ReceivedData{
{
Type: EventWorkspace,
Data: "1",
},
{
Type: EventFocusedMonitor,
Data: "1,1",
// TODO I only have one monitor, so I didn't check this
},
{
Type: EventActiveWindow,
Data: "jetbrains-goland,hyprland-ipc-ipc – ipc.go",
},
{
Type: EventFullscreen,
Data: "1",
},
{
Type: EventMonitorRemoved,
Data: "1",
// TODO I only have one monitor, so I didn't check this
},
{
Type: EventMonitorAdded,
Data: "1",
// TODO I only have one monitor, so I didn't check this
},
{
Type: EventCreateWorkspace,
Data: "1",
},
{
Type: EventDestroyWorkspace,
Data: "1",
},
{
Type: EventMoveWorkspace,
Data: "1,1",
// TODO I only have one monitor, so I didn't check this
},
{
Type: EventActiveLayout,
Data: "AT Translated Set 2 keyboard,Russian",
},
{
Type: EventOpenWindow,
Data: "80e62df0,2,jetbrains-goland,win430",
},
{
Type: EventCloseWindow,
Data: "80e62df0",
},
{
Type: EventMoveWindow,
Data: "80e62df0,1",
},
{
Type: EventOpenLayer,
Data: "wofi",
},
{
Type: EventCloseLayer,
Data: "wofi",
},
{
Type: EventSubMap,
Data: "1",
// idk
},
{
Type: EventScreencast,
Data: "1,0",
},
}, nil
}
func TestSubscribe(t *testing.T) {
err := SubscribeWithoutLoop(c, h, GetAllEvents()...)
if err != nil {
t.Error(err)
}
}
func SubscribeWithoutLoop(c IPC, ev EventHandler, events ...EventType) error {
msg, err := c.Receive()
if err != nil {
return err
}
for _, data := range msg {
processEvent(ev, data, events)
}
return nil
}