6 proc
= subprocess
.Popen(sys
.argv
[1], stdin
=subprocess
.PIPE
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
8 LEFT
, RIGHT
, TOP
, BOTTOM
= 0, 1, 2, 3
12 proc
.stdin
.write('%s\n' % line
)
15 line
= proc
.stdout
.readline().rstrip('\n')
17 return line
.split(' ')
21 assert(line
[0] == 'layout')
24 send('getui %s width' % layout
)
26 assert(line
[0] == '0')
28 send('getui %s height' % layout
)
30 assert(line
[0] == '0')
32 send('getui %s border-size' % layout
)
34 assert(line
[0] == '0')
38 assert(len(line
) == 1)
40 send('geom_set_min 80 60')
43 assert(line
[0] == '80')
44 assert(line
[1] == '60')
47 send('init 800 600 4')
49 assert(line
[0] == 'new-tile')
52 send('get_layout %s' % tile1
)
54 assert(line
[0] == layout
)
56 send('getui %s width' % layout
)
58 assert(line
[0] == '800')
60 send('getui %s height' % layout
)
62 assert(line
[0] == '600')
64 send('getui %s border-size' % layout
)
66 assert(line
[0] == '4')
68 send('getb %s valid' % tile1
)
70 assert(line
[0] == '1')
72 send('get_geometry_hints %s' % tile1
)
75 assert(line
[0] == '80')
76 assert(line
[1] == '60')
78 send('getui %s x' % tile1
)
80 assert(line
[0] == '0')
82 send('getui %s y' % tile1
)
84 assert(line
[0] == '0')
86 send('getui %s width' % tile1
)
88 assert(line
[0] == '800')
90 send('getui %s height' % tile1
)
92 assert(line
[0] == '600')
94 send('get_tile_at_position 400 300')
96 assert(line
[0] == tile1
)
98 send('get_tile_at_position 801 601')
100 assert(line
[0] == '(nil)')
102 send('get_tile_at_position -10 300')
104 assert(line
[0] == '(nil)')
106 send('get_tiles_in_rectangle 400 300 10 10')
108 assert(line
[0] == tile1
)
109 assert(len(line
) == 2)
111 send('get_tiles_in_rectangle 801 601 10 10')
113 assert(len(line
) == 1)
117 assert(line
[0] == tile1
)
118 assert(len(line
) == 2)
120 #try to split the layout when tile1 has a minimum size of 800x600
121 send('geom_set_min 800 600')
122 send('set_geometry_hints %s' % tile1
)
123 send('geom_unset_min')
125 send('split %s %s' % (tile1
, LEFT
))
127 assert(line
[0] == '(nil)')
129 send('geom_set_min 80 60')
130 send('set_geometry_hints %s' % tile1
)
132 #try to split the layout creating a new tile with a minimum size of 800x600
133 send('geom_set_min 800 600')
135 send('split %s %s' % (tile1
, LEFT
))
137 assert(line
[0] == '(nil)')
139 send('geom_unset_min')
142 send('geom_set_min 80 60')
143 send('split %s %s' % (tile1
, LEFT
))
145 assert(line
[0] == 'configure' and line
[1] == tile1
)
147 assert(line
[0] == 'new-tile')
150 assert(line
[0] == tile2
)
152 send('getui %s width' % tile2
)
153 tile2_width
= int(getline()[0])
154 send('getui %s x' % tile1
)
155 tile1_x
= int(getline()[0])
156 assert(tile1_x
== tile2_width
+ 4)
158 send('getb %s valid' % tile2
)
160 assert(line
[0] == '1')
162 send('get_layout %s' % tile2
)
164 assert(line
[0] == layout
)
167 send('geom_set_min 80 60')
168 send('split %s %s' % (tile1
, BOTTOM
))
170 assert(line
[0] == 'configure' and line
[1] == tile1
)
172 assert(line
[0] == 'new-tile')
175 assert(line
[0] == tile3
)
177 send('getui %s height' % tile1
)
178 tile1_height
= int(getline()[0])
179 send('getui %s y' % tile3
)
180 tile3_y
= int(getline()[0])
181 assert(tile3_y
== tile1_height
+ 4)
184 send('resize %s 0 0 600 600' % tile2
)
185 expected_configures
= set([tile1
, tile2
, tile3
])
186 configured_tiles
= set()
187 for i
in range(len(expected_configures
)):
189 assert(line
[0] == 'configure')
190 configured_tiles
.add(line
[1])
191 assert(configured_tiles
== expected_configures
)
193 send('getui %s width' % tile2
)
195 assert(line
[0] == '600')
197 send('getui %s x' % tile1
)
199 assert(line
[0] == '604')
201 send('getui %s x' % tile3
)
203 assert(line
[0] == '604')
205 send('getui %s width' % tile1
)
207 assert(line
[0] == '196')
209 send('getui %s width' % tile3
)
211 assert(line
[0] == '196')
214 send('resize_preview %s 400 0 400 400' % tile1
)
216 assert(line
== ['400', '0', '400', '400'])
218 send('resize %s 400 0 400 400' % tile1
)
219 expected_configures
= set([tile1
, tile2
, tile3
])
220 configured_tiles
= set()
221 for i
in range(len(expected_configures
)):
223 assert(line
[0] == 'configure')
224 configured_tiles
.add(line
[1])
225 assert(configured_tiles
== expected_configures
)
227 send('getui %s width' % tile2
)
229 assert(line
[0] == '396')
231 send('getui %s x' % tile1
)
233 assert(line
[0] == '400')
235 send('getui %s x' % tile3
)
237 assert(line
[0] == '400')
239 send('getui %s width' % tile1
)
241 assert(line
[0] == '400')
243 send('getui %s width' % tile3
)
245 assert(line
[0] == '400')
247 send('getui %s height' % tile1
)
249 assert(line
[0] == '400')
251 send('getui %s y' % tile3
)
253 assert(line
[0] == '404')
255 send('getui %s height' % tile3
)
257 assert(line
[0] == '196')
260 send('resize %s 0 0 800 600' % tile1
)
261 deleted_tiles
= set()
262 expected_deletes
= set([tile2
, tile3
])
263 for i
in range(len(expected_deletes
)):
265 assert(line
[0] == 'delete')
266 deleted_tiles
.add(line
[1])
267 assert(deleted_tiles
== expected_deletes
)
269 assert(line
[0] == 'configure')
270 assert(line
[1] == tile1
)
272 for i
in expected_deletes
:
273 send('getb %s valid' % i
)
275 assert(line
[0] == '0')
277 send('getui %s x' % tile1
)
279 assert(line
[0] == '0')
281 send('getui %s y' % tile1
)
283 assert(line
[0] == '0')
285 send('getui %s width' % tile1
)
287 assert(line
[0] == '800')
289 send('getui %s height' % tile1
)
291 assert(line
[0] == '600')
294 send('split %s %s' % (tile1
, RIGHT
))
296 assert(line
[0] == 'configure' and line
[1] == tile1
)
298 assert(line
[0] == 'new-tile')
301 assert(line
[0] == tile2
)
303 send('split %s %s' % (tile2
, BOTTOM
))
305 assert(line
[0] == 'configure' and line
[1] == tile2
)
307 assert(line
[0] == 'new-tile')
310 assert(line
[0] == tile3
)
312 send('split %s %s' % (tile3
, BOTTOM
))
314 assert(line
[0] == 'configure' and line
[1] == tile3
)
316 assert(line
[0] == 'new-tile')
319 assert(line
[0] == tile4
)
321 send('resize %s 200 200 600 300' % tile3
)
322 expected_configures
= set([tile1
, tile2
, tile3
, tile4
])
323 configured_tiles
= set()
324 for i
in range(len(expected_configures
)):
326 assert(line
[0] == 'configure')
327 configured_tiles
.add(line
[1])
328 assert(configured_tiles
== expected_configures
)
330 send('getui %s width' % tile1
)
332 assert(line
[0] == '196')
334 for t
in (tile2
, tile3
, tile4
):
335 send('getui %s x' % t
)
337 assert(line
[0] == '200')
339 send('getui %s width' % t
)
341 assert(line
[0] == '600')
344 send('resize %s 0 200 800 300' % tile3
)
345 expected_configures
= set([tile1
, tile3
, tile4
])
346 configured_tiles
= set()
347 for i
in range(len(expected_configures
)):
349 assert(line
[0] == 'configure')
350 configured_tiles
.add(line
[1])
351 assert(configured_tiles
== expected_configures
)
353 send('getui %s height' % tile1
)
355 assert(line
[0] == '196')
357 send('getui %s x' % tile3
)
359 assert(line
[0] == '0')
361 send('getui %s width' % tile3
)
363 assert(line
[0] == '800')
365 send('getui %s x' % tile4
)
367 assert(line
[0] == '0')
369 send('getui %s width' % tile4
)
371 assert(line
[0] == '800')
374 send('layout_resize 640 480 2')
375 expected_configures
= set([tile1
, tile2
, tile3
, tile4
])
376 configured_tiles
= set()
377 for i
in range(len(expected_configures
)):
379 assert(line
[0] == 'configure')
380 configured_tiles
.add(line
[1])
381 assert(configured_tiles
== expected_configures
)
383 send('getui %s x' % tile1
)
385 assert(line
[0] == '0')
387 send('getui %s width' % tile1
)
389 tile1_width
= int(line
[0])
391 send('getui %s x' % tile2
)
394 assert(x
== tile1_width
+2)
397 for t
in (tile2
, tile3
, tile4
):
398 send('getui %s x' % t
)
402 send('getui %s width' % t
)
405 assert(x
+width
== 640)
407 send('getui %s y' % t
)
410 assert(y
== prev_bottom
+2)
412 send('getui %s height' % t
)
414 height
= int(line
[0])
415 prev_bottom
= y
+height
417 assert(prev_bottom
== 480)
419 #block resize (preview)
420 send('split %s %s' % (tile3
, LEFT
))
422 assert(line
[0] == 'configure' and line
[1] == tile3
)
424 assert(line
[0] == 'new-tile')
427 assert(line
[0] == tile5
)
429 send('getui %s x' % tile3
)
432 send('getui %s y' % tile3
)
435 send('getui %s width' % tile3
)
438 send('getui %s height' % tile3
)
440 height
= int(line
[0])
442 send('getui %s x' % tile2
)
444 tile2_x
= int(line
[0])
446 send('resize_block %s %s %s %s %s %s' % (tile3
, LEFT
, x
, y
, width
, height
))
449 newwidth
= int(line
[2])
450 assert(tile2_x
== newx
)
451 assert(newx
+newwidth
== 640)
453 send('geom_unset_min')
454 send('set_geometry_hints %s' % tile1
)
455 send('geom_set_min 20 20')
456 send('get_geometry_hints %s' % tile1
)
459 assert(line
[0] == 'unset')
463 deleted_tiles
= set()
464 expected_deletes
= set([tile1
, tile2
, tile3
, tile4
, tile5
])
465 for i
in range(len(expected_deletes
)):
467 assert(line
[0] == 'delete')
468 deleted_tiles
.add(line
[1])
469 assert(deleted_tiles
== expected_deletes
)
471 for i
in expected_deletes
:
472 send('getb %s valid' % i
)
474 assert(line
[0] == '0')
478 assert(len(line
) == 1)
483 result
, stdout
, stderr
= proc
.wait(), proc
.stdout
.read(), proc
.stderr
.read()
485 print("%s\n%s\n%s" % (result
, stdout
, stderr
));
491 f
= open(sys
.argv
[2], 'w')