forked from paradoxxxzero/qtile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_bar.py
219 lines (187 loc) · 6.37 KB
/
test_bar.py
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import libpry, time
import libqtile.layout, libqtile.bar, libqtile.widget, libqtile.manager
from libqtile.command import _Call
import utils
theme = libqtile.manager.Theme({}, specials={'stack': {'border_width': 10}})
class GBConfig:
keys = []
groups = ["a", "b", "c", "d"]
layouts = [libqtile.layout.stack.Stack(stacks=1)]
screens = [
libqtile.manager.Screen(
top = libqtile.bar.Bar(
[
libqtile.widget.ClickableIcon("myicon",
"/usr/share/pixmaps/xterm_32x32.xpm",
_Call([('group', 'd')], 'toscreen')
)
],
20,
),
bottom=libqtile.bar.Bar(
[
libqtile.widget.GroupBox(),
libqtile.widget.WindowName(),
libqtile.widget.TextBox("text", text="default", width=100),
libqtile.widget.MeasureBox("measure", width=100),
],
20
),
)
]
theme = None
class uWidgets(utils.QtileTests):
config = GBConfig()
def test_draw(self):
self.testWindow("one")
b = self.c.bar["bottom"].info()
assert b["widgets"][0]["name"] == "GroupBox"
def test_event(self):
self.c.group["b"].toscreen()
self.c.log()
def test_textbox(self):
assert "text" in self.c.list_widgets()
self.c.widget["text"].update("testing")
assert self.c.widget["text"].get() == "testing"
def test_groupbox_click(self):
self.c.group["c"].toscreen()
assert self.c.groups()["a"]["screen"] == None
self.c.bar["bottom"].fake_click(0, "bottom", 10, 10)
assert self.c.groups()["a"]["screen"] == 0
def test_clickableicon(self):
self.c.group["a"].toscreen()
assert self.c.groups()["d"]["screen"] == None
self.c.bar["top"].fake_click(0, "top", 10, 10)
assert self.c.groups()["d"]["screen"] == 0
def test_measurebox(self):
libpry.raises("out of range", self.c.widget["measure"].update, 200)
libpry.raises("out of range", self.c.widget["measure"].update, -1)
self.c.widget["measure"].update(0)
self.c.widget["measure"].update(10)
self.c.widget["measure"].update(30)
self.c.widget["measure"].update(50)
self.c.widget["measure"].update(80)
self.c.widget["measure"].update(100)
class GeomConf:
keys = []
groups = ["a", "b", "c", "d"]
layouts = [libqtile.layout.stack.Stack(stacks=1)]
screens = [
libqtile.manager.Screen(
left=libqtile.bar.Gap(10),
right=libqtile.bar.Gap(10),
top=libqtile.bar.Bar([], 10),
bottom=libqtile.bar.Bar([], 10),
)
]
theme = None
class uBarGeometry(utils.QtileTests):
config = GeomConf()
def test_geometry(self):
self.testWindow("one")
g = self.c.screens()[0]["gaps"]
assert g["top"] == (0, 0, 800, 10)
assert g["bottom"] == (0, 590, 800, 10)
assert g["left"] == (0, 10, 10, 580)
assert g["right"] == (790, 10, 10, 580)
assert len(self.c.windows()) == 1
geom = self.c.windows()[0]
assert geom["x"] == 10
assert geom["y"] == 10
assert geom["width"] == 760
assert geom["height"] == 560
internal = self.c.internal()
assert len(internal) == 2
wid = self.c.bar["bottom"].info()["window"]
assert self.c.window[wid].inspect()
class ErrConf(GeomConf):
screens = [
libqtile.manager.Screen(left=libqtile.bar.Bar([], 10))
]
class uBarErr(utils._QtileTruss):
def test_err(self):
config = ErrConf()
self.qtileRaises("top or the bottom of the screen", config)
class TestWidget(libqtile.widget.base._Widget):
def _configure(self, qtile, bar, event, theme):
libqtile.widget.base._Widget._configure(self, qtile, bar, event, theme)
self.width = 10
def draw(self): pass
class OffsetConf(GeomConf):
screens = [
libqtile.manager.Screen(
bottom=libqtile.bar.Bar(
[
TestWidget(),
libqtile.widget.Spacer(),
TestWidget()
],
10
)
)
]
class uOffsetCalculation(utils._QtileTruss):
def setUp(self):
utils._QtileTruss.setUp(self)
self.conf = GeomConf()
def tearDown(self):
utils._QtileTruss.tearDown(self)
self.stopQtile()
def test_basic(self):
self.conf.screens = [
libqtile.manager.Screen(
bottom=libqtile.bar.Bar(
[
TestWidget(),
libqtile.widget.Spacer(),
TestWidget()
],
10
)
)
]
self.startQtile(self.conf)
i = self.c.bar["bottom"].info()
assert i["widgets"][0]["offset"] == 0
assert i["widgets"][1]["offset"] == 10
assert i["widgets"][1]["width"] == 780
assert i["widgets"][2]["offset"] == 790
def test_singlespacer(self):
self.conf.screens = [
libqtile.manager.Screen(
bottom=libqtile.bar.Bar(
[
libqtile.widget.Spacer(),
],
10
)
)
]
self.startQtile(self.conf)
i = self.c.bar["bottom"].info()
assert i["widgets"][0]["offset"] == 0
assert i["widgets"][0]["width"] == 800
def test_nospacer(self):
self.conf.screens = [
libqtile.manager.Screen(
bottom=libqtile.bar.Bar(
[
TestWidget(),
TestWidget()
],
10
)
)
]
self.startQtile(self.conf)
i = self.c.bar["bottom"].info()
assert i["widgets"][0]["offset"] == 0
assert i["widgets"][1]["offset"] == 10
tests = [
utils.xfactory(xinerama=True), [
uBarGeometry(),
uWidgets(),
uBarErr(),
uOffsetCalculation()
]
]