~bennabiy/+junk/python-xlib

« back to all changes in this revision

Viewing changes to .pc/python3.patch/test/test_requests_be.py

  • Committer: Package Import Robot
  • Author(s): Andrew Shadura, Ramkumar Ramachandra, Andrew Shadura
  • Date: 2015-08-13 08:14:19 UTC
  • mfrom: (6.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20150813081419-hdefinnghp2iydkx
Tags: 0.14+20091101-3
[ Ramkumar Ramachandra ]
* Remove useless debugging output (Closes: #565996)

[ Andrew Shadura ]
* Switch to 3.0 (quilt) format.
* Rename patches.
* Use debhelper 9 in its short form.
* Use pybuild.
* Bump Standards-Version.
* Don't build or install PostScript documentation and info files.
* Use system-provided texi2html instead of a shipped version
  (Closes: #795057).
* Update debian/copyright (Closes: #795057).
* Don't install Makefile or texi2html with the documentation.
* Set executable bit for examples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import sys, os
 
4
sys.path.insert(1, os.path.join(sys.path[0], '..'))
 
5
 
 
6
import string
 
7
import unittest
 
8
from Xlib.protocol import request, rq, event
 
9
import Xlib.protocol.event
 
10
 
 
11
import struct
 
12
import array
 
13
 
 
14
class CmpArray:
 
15
    def __init__(self, *args, **kws):
 
16
        self.array = apply(array.array, args, kws)
 
17
 
 
18
    def __len__(self):
 
19
        return len(self.array)
 
20
 
 
21
    def __getslice__(self, x, y):
 
22
        return list(self.array[x:y])
 
23
 
 
24
    def __getattr__(self, attr):
 
25
        return getattr(self.array, attr)
 
26
 
 
27
    def __cmp__(self, other):
 
28
        return cmp(self.array.tolist(), other)
 
29
 
 
30
rq.array = CmpArray
 
31
 
 
32
def tohex(bin):
 
33
    bin = string.join(map(lambda c: '\\x%02x' % ord(c), bin), '')
 
34
 
 
35
    bins = []
 
36
    for i in range(0, len(bin), 16):
 
37
        bins.append(bin[i:i+16])
 
38
 
 
39
    bins2 = []
 
40
    for i in range(0, len(bins), 2):
 
41
        try:
 
42
            bins2.append("'%s' '%s'" % (bins[i], bins[i + 1]))
 
43
        except IndexError:
 
44
            bins2.append("'%s'" % bins[i])
 
45
 
 
46
    return string.join(bins2, ' \\\n            ')
 
47
 
 
48
class DummyDisplay:
 
49
    def get_resource_class(self, x):
 
50
        return None
 
51
 
 
52
    event_classes = Xlib.protocol.event.event_class
 
53
dummy_display = DummyDisplay()
 
54
 
 
55
 
 
56
def check_endian():
 
57
    if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 1:
 
58
        sys.stderr.write('Big-endian tests, skipping on this system.\n')
 
59
        sys.exit(0)
 
60
 
 
61
 
 
62
 
 
63
class TestCreateWindow(unittest.TestCase):
 
64
    def setUp(self):
 
65
        self.req_args_0 = {
 
66
            'height': 38608,
 
67
            'window_class': 0,
 
68
            'border_width': 34451,
 
69
            'visual': 398069779,
 
70
            'x': -20771,
 
71
            'y': -4049,
 
72
            'parent': 1960526158,
 
73
            'attrs': {'backing_pixel': 561400151, 'cursor': 1442692293, 'background_pixmap': 1583833923, 'border_pixmap': 1992559786, 'backing_planes': 1454152605, 'win_gravity': 3, 'backing_store': 2, 'event_mask': 368242204, 'save_under': 0, 'background_pixel': 209127175, 'colormap': 377416705, 'border_pixel': 2135465356, 'bit_gravity': 0, 'do_not_propagate_mask': 597142897, 'override_redirect': 0},
 
74
            'wid': 1828913444,
 
75
            'depth': 186,
 
76
            'width': 51466,
 
77
            }
 
78
        self.req_bin_0 = '\x01\xba\x00\x17' '\x6d\x03\x01\x24' \
 
79
            '\x74\xdb\x41\x4e' '\xae\xdd\xf0\x2f' \
 
80
            '\xc9\x0a\x96\xd0' '\x86\x93\x00\x00' \
 
81
            '\x17\xba\x10\x13' '\x00\x00\x7f\xff' \
 
82
            '\x5e\x67\x63\x43' '\x0c\x77\x07\x07' \
 
83
            '\x76\xc4\x0c\xaa' '\x7f\x48\x9d\x8c' \
 
84
            '\x00\x00\x00\x00' '\x03\x00\x00\x00' \
 
85
            '\x02\x00\x00\x00' '\x56\xac\x9b\x9d' \
 
86
            '\x21\x76\x49\x57' '\x00\x00\x00\x00' \
 
87
            '\x00\x00\x00\x00' '\x15\xf2\xee\x1c' \
 
88
            '\x23\x97\xad\x71' '\x16\x7e\xec\x01' \
 
89
            '\x55\xfd\xbc\xc5'
 
90
 
 
91
 
 
92
    def testPackRequest0(self):
 
93
        bin = apply(request.CreateWindow._request.to_binary, (), self.req_args_0)
 
94
        try:
 
95
            assert bin == self.req_bin_0
 
96
        except AssertionError:
 
97
            raise AssertionError(tohex(bin))
 
98
 
 
99
    def testUnpackRequest0(self):
 
100
        args, remain = request.CreateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
101
        try:
 
102
            assert len(remain) == 0
 
103
        except AssertionError:
 
104
            raise AssertionError(tohex(remain))
 
105
        try:
 
106
            assert args == self.req_args_0
 
107
        except AssertionError:
 
108
            raise AssertionError(args)
 
109
 
 
110
 
 
111
class TestChangeWindowAttributes(unittest.TestCase):
 
112
    def setUp(self):
 
113
        self.req_args_0 = {
 
114
            'window': 1813552124,
 
115
            'attrs': {'backing_pixel': 59516078, 'cursor': 1682969315, 'background_pixmap': 370313360, 'border_pixmap': 1158771722, 'backing_planes': 1432315664, 'win_gravity': 3, 'backing_store': 1, 'event_mask': 1054128649, 'save_under': 0, 'background_pixel': 1953340842, 'colormap': 1462101672, 'border_pixel': 287436510, 'bit_gravity': 10, 'do_not_propagate_mask': 1283834625, 'override_redirect': 0},
 
116
            }
 
117
        self.req_bin_0 = '\x02\x00\x00\x12' '\x6c\x18\x9b\xfc' \
 
118
            '\x00\x00\x7f\xff' '\x16\x12\x88\x90' \
 
119
            '\x74\x6d\x9d\xaa' '\x45\x11\x74\x0a' \
 
120
            '\x11\x21\xee\xde' '\x0a\x00\x00\x00' \
 
121
            '\x03\x00\x00\x00' '\x01\x00\x00\x00' \
 
122
            '\x55\x5f\x67\x10' '\x03\x8c\x24\xae' \
 
123
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
124
            '\x3e\xd4\xba\x09' '\x4c\x85\xc3\x01' \
 
125
            '\x57\x25\xe6\xa8' '\x64\x50\x12\xe3'
 
126
 
 
127
 
 
128
    def testPackRequest0(self):
 
129
        bin = apply(request.ChangeWindowAttributes._request.to_binary, (), self.req_args_0)
 
130
        try:
 
131
            assert bin == self.req_bin_0
 
132
        except AssertionError:
 
133
            raise AssertionError(tohex(bin))
 
134
 
 
135
    def testUnpackRequest0(self):
 
136
        args, remain = request.ChangeWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
137
        try:
 
138
            assert len(remain) == 0
 
139
        except AssertionError:
 
140
            raise AssertionError(tohex(remain))
 
141
        try:
 
142
            assert args == self.req_args_0
 
143
        except AssertionError:
 
144
            raise AssertionError(args)
 
145
 
 
146
 
 
147
class TestGetWindowAttributes(unittest.TestCase):
 
148
    def setUp(self):
 
149
        self.req_args_0 = {
 
150
            'window': 1931593850,
 
151
            }
 
152
        self.req_bin_0 = '\x03\x00\x00\x02' '\x73\x21\xc8\x7a'
 
153
 
 
154
        self.reply_args_0 = {
 
155
            'sequence_number': 60057,
 
156
            'backing_pixel': 136561993,
 
157
            'your_event_mask': 1332399119,
 
158
            'map_is_installed': 0,
 
159
            'visual': 687387929,
 
160
            'backing_bit_planes': 990144409,
 
161
            'backing_store': 147,
 
162
            'win_class': 18284,
 
163
            'map_state': 185,
 
164
            'save_under': 0,
 
165
            'all_event_masks': 270223628,
 
166
            'colormap': 1161384334,
 
167
            'win_gravity': 157,
 
168
            'bit_gravity': 253,
 
169
            'do_not_propagate_mask': 33787,
 
170
            'override_redirect': 0,
 
171
            }
 
172
        self.reply_bin_0 = '\x01\x93\xea\x99' '\x00\x00\x00\x03' \
 
173
            '\x28\xf8\xb5\x19' '\x47\x6c\xfd\x9d' \
 
174
            '\x3b\x04\x67\x99' '\x08\x23\xc5\x49' \
 
175
            '\x00\x00\xb9\x00' '\x45\x39\x51\x8e' \
 
176
            '\x10\x1b\x49\x0c' '\x4f\x6a\xcc\x0f' \
 
177
            '\x83\xfb\x00\x00'
 
178
 
 
179
 
 
180
    def testPackRequest0(self):
 
181
        bin = apply(request.GetWindowAttributes._request.to_binary, (), self.req_args_0)
 
182
        try:
 
183
            assert bin == self.req_bin_0
 
184
        except AssertionError:
 
185
            raise AssertionError(tohex(bin))
 
186
 
 
187
    def testUnpackRequest0(self):
 
188
        args, remain = request.GetWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
189
        try:
 
190
            assert len(remain) == 0
 
191
        except AssertionError:
 
192
            raise AssertionError(tohex(remain))
 
193
        try:
 
194
            assert args == self.req_args_0
 
195
        except AssertionError:
 
196
            raise AssertionError(args)
 
197
 
 
198
    def testPackReply0(self):
 
199
        bin = apply(request.GetWindowAttributes._reply.to_binary, (), self.reply_args_0)
 
200
        try:
 
201
            assert bin == self.reply_bin_0
 
202
        except AssertionError:
 
203
            raise AssertionError(tohex(bin))
 
204
 
 
205
    def testUnpackReply0(self):
 
206
        args, remain = request.GetWindowAttributes._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
207
        try:
 
208
            assert len(remain) == 0
 
209
        except AssertionError:
 
210
            raise AssertionError(tohex(remain))
 
211
        try:
 
212
            assert args == self.reply_args_0
 
213
        except AssertionError:
 
214
            raise AssertionError(args)
 
215
 
 
216
 
 
217
class TestDestroyWindow(unittest.TestCase):
 
218
    def setUp(self):
 
219
        self.req_args_0 = {
 
220
            'window': 1622184267,
 
221
            }
 
222
        self.req_bin_0 = '\x04\x00\x00\x02' '\x60\xb0\x91\x4b'
 
223
 
 
224
 
 
225
    def testPackRequest0(self):
 
226
        bin = apply(request.DestroyWindow._request.to_binary, (), self.req_args_0)
 
227
        try:
 
228
            assert bin == self.req_bin_0
 
229
        except AssertionError:
 
230
            raise AssertionError(tohex(bin))
 
231
 
 
232
    def testUnpackRequest0(self):
 
233
        args, remain = request.DestroyWindow._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
234
        try:
 
235
            assert len(remain) == 0
 
236
        except AssertionError:
 
237
            raise AssertionError(tohex(remain))
 
238
        try:
 
239
            assert args == self.req_args_0
 
240
        except AssertionError:
 
241
            raise AssertionError(args)
 
242
 
 
243
 
 
244
class TestDestroySubWindows(unittest.TestCase):
 
245
    def setUp(self):
 
246
        self.req_args_0 = {
 
247
            'window': 1000376476,
 
248
            }
 
249
        self.req_bin_0 = '\x05\x00\x00\x02' '\x3b\xa0\x88\x9c'
 
250
 
 
251
 
 
252
    def testPackRequest0(self):
 
253
        bin = apply(request.DestroySubWindows._request.to_binary, (), self.req_args_0)
 
254
        try:
 
255
            assert bin == self.req_bin_0
 
256
        except AssertionError:
 
257
            raise AssertionError(tohex(bin))
 
258
 
 
259
    def testUnpackRequest0(self):
 
260
        args, remain = request.DestroySubWindows._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
261
        try:
 
262
            assert len(remain) == 0
 
263
        except AssertionError:
 
264
            raise AssertionError(tohex(remain))
 
265
        try:
 
266
            assert args == self.req_args_0
 
267
        except AssertionError:
 
268
            raise AssertionError(args)
 
269
 
 
270
 
 
271
class TestChangeSaveSet(unittest.TestCase):
 
272
    def setUp(self):
 
273
        self.req_args_0 = {
 
274
            'window': 1577523459,
 
275
            'mode': 0,
 
276
            }
 
277
        self.req_bin_0 = '\x06\x00\x00\x02' '\x5e\x07\x19\x03'
 
278
 
 
279
 
 
280
    def testPackRequest0(self):
 
281
        bin = apply(request.ChangeSaveSet._request.to_binary, (), self.req_args_0)
 
282
        try:
 
283
            assert bin == self.req_bin_0
 
284
        except AssertionError:
 
285
            raise AssertionError(tohex(bin))
 
286
 
 
287
    def testUnpackRequest0(self):
 
288
        args, remain = request.ChangeSaveSet._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
289
        try:
 
290
            assert len(remain) == 0
 
291
        except AssertionError:
 
292
            raise AssertionError(tohex(remain))
 
293
        try:
 
294
            assert args == self.req_args_0
 
295
        except AssertionError:
 
296
            raise AssertionError(args)
 
297
 
 
298
 
 
299
class TestReparentWindow(unittest.TestCase):
 
300
    def setUp(self):
 
301
        self.req_args_0 = {
 
302
            'parent': 72188776,
 
303
            'window': 1300734112,
 
304
            'x': -5207,
 
305
            'y': -22675,
 
306
            }
 
307
        self.req_bin_0 = '\x07\x00\x00\x04' '\x4d\x87\xa0\xa0' \
 
308
            '\x04\x4d\x83\x68' '\xeb\xa9\xa7\x6d'
 
309
 
 
310
 
 
311
    def testPackRequest0(self):
 
312
        bin = apply(request.ReparentWindow._request.to_binary, (), self.req_args_0)
 
313
        try:
 
314
            assert bin == self.req_bin_0
 
315
        except AssertionError:
 
316
            raise AssertionError(tohex(bin))
 
317
 
 
318
    def testUnpackRequest0(self):
 
319
        args, remain = request.ReparentWindow._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
320
        try:
 
321
            assert len(remain) == 0
 
322
        except AssertionError:
 
323
            raise AssertionError(tohex(remain))
 
324
        try:
 
325
            assert args == self.req_args_0
 
326
        except AssertionError:
 
327
            raise AssertionError(args)
 
328
 
 
329
 
 
330
class TestMapWindow(unittest.TestCase):
 
331
    def setUp(self):
 
332
        self.req_args_0 = {
 
333
            'window': 61469476,
 
334
            }
 
335
        self.req_bin_0 = '\x08\x00\x00\x02' '\x03\xa9\xf3\x24'
 
336
 
 
337
 
 
338
    def testPackRequest0(self):
 
339
        bin = apply(request.MapWindow._request.to_binary, (), self.req_args_0)
 
340
        try:
 
341
            assert bin == self.req_bin_0
 
342
        except AssertionError:
 
343
            raise AssertionError(tohex(bin))
 
344
 
 
345
    def testUnpackRequest0(self):
 
346
        args, remain = request.MapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
347
        try:
 
348
            assert len(remain) == 0
 
349
        except AssertionError:
 
350
            raise AssertionError(tohex(remain))
 
351
        try:
 
352
            assert args == self.req_args_0
 
353
        except AssertionError:
 
354
            raise AssertionError(args)
 
355
 
 
356
 
 
357
class TestMapSubwindows(unittest.TestCase):
 
358
    def setUp(self):
 
359
        self.req_args_0 = {
 
360
            'window': 818738118,
 
361
            }
 
362
        self.req_bin_0 = '\x09\x00\x00\x02' '\x30\xcc\xf3\xc6'
 
363
 
 
364
 
 
365
    def testPackRequest0(self):
 
366
        bin = apply(request.MapSubwindows._request.to_binary, (), self.req_args_0)
 
367
        try:
 
368
            assert bin == self.req_bin_0
 
369
        except AssertionError:
 
370
            raise AssertionError(tohex(bin))
 
371
 
 
372
    def testUnpackRequest0(self):
 
373
        args, remain = request.MapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
374
        try:
 
375
            assert len(remain) == 0
 
376
        except AssertionError:
 
377
            raise AssertionError(tohex(remain))
 
378
        try:
 
379
            assert args == self.req_args_0
 
380
        except AssertionError:
 
381
            raise AssertionError(args)
 
382
 
 
383
 
 
384
class TestUnmapWindow(unittest.TestCase):
 
385
    def setUp(self):
 
386
        self.req_args_0 = {
 
387
            'window': 1923663468,
 
388
            }
 
389
        self.req_bin_0 = '\x0a\x00\x00\x02' '\x72\xa8\xc6\x6c'
 
390
 
 
391
 
 
392
    def testPackRequest0(self):
 
393
        bin = apply(request.UnmapWindow._request.to_binary, (), self.req_args_0)
 
394
        try:
 
395
            assert bin == self.req_bin_0
 
396
        except AssertionError:
 
397
            raise AssertionError(tohex(bin))
 
398
 
 
399
    def testUnpackRequest0(self):
 
400
        args, remain = request.UnmapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
401
        try:
 
402
            assert len(remain) == 0
 
403
        except AssertionError:
 
404
            raise AssertionError(tohex(remain))
 
405
        try:
 
406
            assert args == self.req_args_0
 
407
        except AssertionError:
 
408
            raise AssertionError(args)
 
409
 
 
410
 
 
411
class TestUnmapSubwindows(unittest.TestCase):
 
412
    def setUp(self):
 
413
        self.req_args_0 = {
 
414
            'window': 999740194,
 
415
            }
 
416
        self.req_bin_0 = '\x0b\x00\x00\x02' '\x3b\x96\xd3\x22'
 
417
 
 
418
 
 
419
    def testPackRequest0(self):
 
420
        bin = apply(request.UnmapSubwindows._request.to_binary, (), self.req_args_0)
 
421
        try:
 
422
            assert bin == self.req_bin_0
 
423
        except AssertionError:
 
424
            raise AssertionError(tohex(bin))
 
425
 
 
426
    def testUnpackRequest0(self):
 
427
        args, remain = request.UnmapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
428
        try:
 
429
            assert len(remain) == 0
 
430
        except AssertionError:
 
431
            raise AssertionError(tohex(remain))
 
432
        try:
 
433
            assert args == self.req_args_0
 
434
        except AssertionError:
 
435
            raise AssertionError(args)
 
436
 
 
437
 
 
438
class TestConfigureWindow(unittest.TestCase):
 
439
    def setUp(self):
 
440
        self.req_args_0 = {
 
441
            'window': 190634459,
 
442
            'attrs': {'height': 57788, 'stack_mode': 2, 'border_width': -320, 'width': 53674, 'x': -2248, 'y': -29960, 'sibling': 1012823324},
 
443
            }
 
444
        self.req_bin_0 = '\x0c\x00\x00\x0a' '\x0b\x5c\xd9\xdb' \
 
445
            '\x00\x7f\x00\x00' '\xf7\x38\x00\x00' \
 
446
            '\x8a\xf8\x00\x00' '\xd1\xaa\x00\x00' \
 
447
            '\xe1\xbc\x00\x00' '\xfe\xc0\x00\x00' \
 
448
            '\x3c\x5e\x75\x1c' '\x02\x00\x00\x00'
 
449
 
 
450
 
 
451
    def testPackRequest0(self):
 
452
        bin = apply(request.ConfigureWindow._request.to_binary, (), self.req_args_0)
 
453
        try:
 
454
            assert bin == self.req_bin_0
 
455
        except AssertionError:
 
456
            raise AssertionError(tohex(bin))
 
457
 
 
458
    def testUnpackRequest0(self):
 
459
        args, remain = request.ConfigureWindow._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
460
        try:
 
461
            assert len(remain) == 0
 
462
        except AssertionError:
 
463
            raise AssertionError(tohex(remain))
 
464
        try:
 
465
            assert args == self.req_args_0
 
466
        except AssertionError:
 
467
            raise AssertionError(args)
 
468
 
 
469
 
 
470
class TestCirculateWindow(unittest.TestCase):
 
471
    def setUp(self):
 
472
        self.req_args_0 = {
 
473
            'window': 1712979067,
 
474
            'direction': 1,
 
475
            }
 
476
        self.req_bin_0 = '\x0d\x01\x00\x02' '\x66\x19\xfc\x7b'
 
477
 
 
478
 
 
479
    def testPackRequest0(self):
 
480
        bin = apply(request.CirculateWindow._request.to_binary, (), self.req_args_0)
 
481
        try:
 
482
            assert bin == self.req_bin_0
 
483
        except AssertionError:
 
484
            raise AssertionError(tohex(bin))
 
485
 
 
486
    def testUnpackRequest0(self):
 
487
        args, remain = request.CirculateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
488
        try:
 
489
            assert len(remain) == 0
 
490
        except AssertionError:
 
491
            raise AssertionError(tohex(remain))
 
492
        try:
 
493
            assert args == self.req_args_0
 
494
        except AssertionError:
 
495
            raise AssertionError(args)
 
496
 
 
497
 
 
498
class TestGetGeometry(unittest.TestCase):
 
499
    def setUp(self):
 
500
        self.req_args_0 = {
 
501
            'drawable': 680179490,
 
502
            }
 
503
        self.req_bin_0 = '\x0e\x00\x00\x02' '\x28\x8a\xb7\x22'
 
504
 
 
505
        self.reply_args_0 = {
 
506
            'height': 64954,
 
507
            'sequence_number': 39469,
 
508
            'root': 609586545,
 
509
            'border_width': 496,
 
510
            'x': -1253,
 
511
            'y': -11180,
 
512
            'depth': 204,
 
513
            'width': 38433,
 
514
            }
 
515
        self.reply_bin_0 = '\x01\xcc\x9a\x2d' '\x00\x00\x00\x00' \
 
516
            '\x24\x55\x8d\x71' '\xfb\x1b\xd4\x54' \
 
517
            '\x96\x21\xfd\xba' '\x01\xf0\x00\x00' \
 
518
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
519
 
 
520
 
 
521
    def testPackRequest0(self):
 
522
        bin = apply(request.GetGeometry._request.to_binary, (), self.req_args_0)
 
523
        try:
 
524
            assert bin == self.req_bin_0
 
525
        except AssertionError:
 
526
            raise AssertionError(tohex(bin))
 
527
 
 
528
    def testUnpackRequest0(self):
 
529
        args, remain = request.GetGeometry._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
530
        try:
 
531
            assert len(remain) == 0
 
532
        except AssertionError:
 
533
            raise AssertionError(tohex(remain))
 
534
        try:
 
535
            assert args == self.req_args_0
 
536
        except AssertionError:
 
537
            raise AssertionError(args)
 
538
 
 
539
    def testPackReply0(self):
 
540
        bin = apply(request.GetGeometry._reply.to_binary, (), self.reply_args_0)
 
541
        try:
 
542
            assert bin == self.reply_bin_0
 
543
        except AssertionError:
 
544
            raise AssertionError(tohex(bin))
 
545
 
 
546
    def testUnpackReply0(self):
 
547
        args, remain = request.GetGeometry._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
548
        try:
 
549
            assert len(remain) == 0
 
550
        except AssertionError:
 
551
            raise AssertionError(tohex(remain))
 
552
        try:
 
553
            assert args == self.reply_args_0
 
554
        except AssertionError:
 
555
            raise AssertionError(args)
 
556
 
 
557
 
 
558
class TestQueryTree(unittest.TestCase):
 
559
    def setUp(self):
 
560
        self.req_args_0 = {
 
561
            'window': 2052496265,
 
562
            }
 
563
        self.req_bin_0 = '\x0f\x00\x00\x02' '\x7a\x56\x9b\x89'
 
564
 
 
565
        self.reply_args_0 = {
 
566
            'sequence_number': 33887,
 
567
            'children': [1795767666, 1494491557, 748301378, 729512097, 1262057849, 64238195, 1088261715],
 
568
            'root': 1856577120,
 
569
            'parent': 2105827407,
 
570
            }
 
571
        self.reply_bin_0 = '\x01\x00\x84\x5f' '\x00\x00\x00\x07' \
 
572
            '\x6e\xa9\x1e\x60' '\x7d\x84\x60\x4f' \
 
573
            '\x00\x07\x00\x00' '\x00\x00\x00\x00' \
 
574
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
575
            '\x6b\x09\x3d\x72' '\x59\x14\x21\xa5' \
 
576
            '\x2c\x9a\x2c\x42' '\x2b\x7b\x78\xa1' \
 
577
            '\x4b\x39\x79\x79' '\x03\xd4\x32\x73' \
 
578
            '\x40\xdd\x8e\x53'
 
579
 
 
580
 
 
581
    def testPackRequest0(self):
 
582
        bin = apply(request.QueryTree._request.to_binary, (), self.req_args_0)
 
583
        try:
 
584
            assert bin == self.req_bin_0
 
585
        except AssertionError:
 
586
            raise AssertionError(tohex(bin))
 
587
 
 
588
    def testUnpackRequest0(self):
 
589
        args, remain = request.QueryTree._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
590
        try:
 
591
            assert len(remain) == 0
 
592
        except AssertionError:
 
593
            raise AssertionError(tohex(remain))
 
594
        try:
 
595
            assert args == self.req_args_0
 
596
        except AssertionError:
 
597
            raise AssertionError(args)
 
598
 
 
599
    def testPackReply0(self):
 
600
        bin = apply(request.QueryTree._reply.to_binary, (), self.reply_args_0)
 
601
        try:
 
602
            assert bin == self.reply_bin_0
 
603
        except AssertionError:
 
604
            raise AssertionError(tohex(bin))
 
605
 
 
606
    def testUnpackReply0(self):
 
607
        args, remain = request.QueryTree._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
608
        try:
 
609
            assert len(remain) == 0
 
610
        except AssertionError:
 
611
            raise AssertionError(tohex(remain))
 
612
        try:
 
613
            assert args == self.reply_args_0
 
614
        except AssertionError:
 
615
            raise AssertionError(args)
 
616
 
 
617
 
 
618
class TestInternAtom(unittest.TestCase):
 
619
    def setUp(self):
 
620
        self.req_args_0 = {
 
621
            'only_if_exists': 0,
 
622
            'name': 'fuzzy_prop',
 
623
            }
 
624
        self.req_bin_0 = '\x10\x00\x00\x05' '\x00\x0a\x00\x00' \
 
625
            '\x66\x75\x7a\x7a' '\x79\x5f\x70\x72' \
 
626
            '\x6f\x70\x00\x00'
 
627
 
 
628
        self.reply_args_0 = {
 
629
            'atom': 48723297,
 
630
            'sequence_number': 35223,
 
631
            }
 
632
        self.reply_bin_0 = '\x01\x00\x89\x97' '\x00\x00\x00\x00' \
 
633
            '\x02\xe7\x75\x61' '\x00\x00\x00\x00' \
 
634
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
635
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
636
 
 
637
 
 
638
    def testPackRequest0(self):
 
639
        bin = apply(request.InternAtom._request.to_binary, (), self.req_args_0)
 
640
        try:
 
641
            assert bin == self.req_bin_0
 
642
        except AssertionError:
 
643
            raise AssertionError(tohex(bin))
 
644
 
 
645
    def testUnpackRequest0(self):
 
646
        args, remain = request.InternAtom._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
647
        try:
 
648
            assert len(remain) == 0
 
649
        except AssertionError:
 
650
            raise AssertionError(tohex(remain))
 
651
        try:
 
652
            assert args == self.req_args_0
 
653
        except AssertionError:
 
654
            raise AssertionError(args)
 
655
 
 
656
    def testPackReply0(self):
 
657
        bin = apply(request.InternAtom._reply.to_binary, (), self.reply_args_0)
 
658
        try:
 
659
            assert bin == self.reply_bin_0
 
660
        except AssertionError:
 
661
            raise AssertionError(tohex(bin))
 
662
 
 
663
    def testUnpackReply0(self):
 
664
        args, remain = request.InternAtom._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
665
        try:
 
666
            assert len(remain) == 0
 
667
        except AssertionError:
 
668
            raise AssertionError(tohex(remain))
 
669
        try:
 
670
            assert args == self.reply_args_0
 
671
        except AssertionError:
 
672
            raise AssertionError(args)
 
673
 
 
674
 
 
675
class TestGetAtomName(unittest.TestCase):
 
676
    def setUp(self):
 
677
        self.req_args_0 = {
 
678
            'atom': 1022286544,
 
679
            }
 
680
        self.req_bin_0 = '\x11\x00\x00\x02' '\x3c\xee\xda\xd0'
 
681
 
 
682
        self.reply_args_0 = {
 
683
            'sequence_number': 22699,
 
684
            'name': 'WM_CLASS',
 
685
            }
 
686
        self.reply_bin_0 = '\x01\x00\x58\xab' '\x00\x00\x00\x02' \
 
687
            '\x00\x08\x00\x00' '\x00\x00\x00\x00' \
 
688
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
689
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
690
            '\x57\x4d\x5f\x43' '\x4c\x41\x53\x53'
 
691
 
 
692
 
 
693
    def testPackRequest0(self):
 
694
        bin = apply(request.GetAtomName._request.to_binary, (), self.req_args_0)
 
695
        try:
 
696
            assert bin == self.req_bin_0
 
697
        except AssertionError:
 
698
            raise AssertionError(tohex(bin))
 
699
 
 
700
    def testUnpackRequest0(self):
 
701
        args, remain = request.GetAtomName._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
702
        try:
 
703
            assert len(remain) == 0
 
704
        except AssertionError:
 
705
            raise AssertionError(tohex(remain))
 
706
        try:
 
707
            assert args == self.req_args_0
 
708
        except AssertionError:
 
709
            raise AssertionError(args)
 
710
 
 
711
    def testPackReply0(self):
 
712
        bin = apply(request.GetAtomName._reply.to_binary, (), self.reply_args_0)
 
713
        try:
 
714
            assert bin == self.reply_bin_0
 
715
        except AssertionError:
 
716
            raise AssertionError(tohex(bin))
 
717
 
 
718
    def testUnpackReply0(self):
 
719
        args, remain = request.GetAtomName._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
720
        try:
 
721
            assert len(remain) == 0
 
722
        except AssertionError:
 
723
            raise AssertionError(tohex(remain))
 
724
        try:
 
725
            assert args == self.reply_args_0
 
726
        except AssertionError:
 
727
            raise AssertionError(args)
 
728
 
 
729
 
 
730
class TestChangeProperty(unittest.TestCase):
 
731
    def setUp(self):
 
732
        self.req_args_0 = {
 
733
            'mode': 0,
 
734
            'data': (8, ''),
 
735
            'property': 2085394193,
 
736
            'window': 266197951,
 
737
            'type': 1343008022,
 
738
            }
 
739
        self.req_bin_0 = '\x12\x00\x00\x06' '\x0f\xdd\xdb\xbf' \
 
740
            '\x7c\x4c\x97\x11' '\x50\x0c\xad\x16' \
 
741
            '\x08\x00\x00\x00' '\x00\x00\x00\x00'
 
742
 
 
743
        self.req_args_1 = {
 
744
            'mode': 2,
 
745
            'data': (8, 'foo'),
 
746
            'property': 449719979,
 
747
            'window': 1522118044,
 
748
            'type': 121096013,
 
749
            }
 
750
        self.req_bin_1 = '\x12\x02\x00\x07' '\x5a\xb9\xad\x9c' \
 
751
            '\x1a\xce\x2e\xab' '\x07\x37\xc7\x4d' \
 
752
            '\x08\x00\x00\x00' '\x00\x00\x00\x03' \
 
753
            '\x66\x6f\x6f\x00'
 
754
 
 
755
        self.req_args_2 = {
 
756
            'mode': 2,
 
757
            'data': (8, 'zoom'),
 
758
            'property': 1009841498,
 
759
            'window': 286324270,
 
760
            'type': 1547457396,
 
761
            }
 
762
        self.req_bin_2 = '\x12\x02\x00\x07' '\x11\x10\xf6\x2e' \
 
763
            '\x3c\x30\xf5\x5a' '\x5c\x3c\x53\x74' \
 
764
            '\x08\x00\x00\x00' '\x00\x00\x00\x04' \
 
765
            '\x7a\x6f\x6f\x6d'
 
766
 
 
767
        self.req_args_3 = {
 
768
            'mode': 0,
 
769
            'data': (16, []),
 
770
            'property': 426983104,
 
771
            'window': 1964921608,
 
772
            'type': 692879036,
 
773
            }
 
774
        self.req_bin_3 = '\x12\x00\x00\x06' '\x75\x1e\x53\x08' \
 
775
            '\x19\x73\x3e\xc0' '\x29\x4c\x7e\xbc' \
 
776
            '\x10\x00\x00\x00' '\x00\x00\x00\x00'
 
777
 
 
778
        self.req_args_4 = {
 
779
            'mode': 0,
 
780
            'data': (16, [1, 2, 3]),
 
781
            'property': 801006756,
 
782
            'window': 560040176,
 
783
            'type': 2030208993,
 
784
            }
 
785
        self.req_bin_4 = '\x12\x00\x00\x08' '\x21\x61\x88\xf0' \
 
786
            '\x2f\xbe\x64\xa4' '\x79\x02\x87\xe1' \
 
787
            '\x10\x00\x00\x00' '\x00\x00\x00\x03' \
 
788
            '\x00\x01\x00\x02' '\x00\x03\x00\x00'
 
789
 
 
790
        self.req_args_5 = {
 
791
            'mode': 0,
 
792
            'data': (16, [1, 2, 3, 4]),
 
793
            'property': 1401687842,
 
794
            'window': 2016421454,
 
795
            'type': 434059096,
 
796
            }
 
797
        self.req_bin_5 = '\x12\x00\x00\x08' '\x78\x30\x26\x4e' \
 
798
            '\x53\x8c\x0f\x22' '\x19\xdf\x37\x58' \
 
799
            '\x10\x00\x00\x00' '\x00\x00\x00\x04' \
 
800
            '\x00\x01\x00\x02' '\x00\x03\x00\x04'
 
801
 
 
802
        self.req_args_6 = {
 
803
            'mode': 2,
 
804
            'data': (32, []),
 
805
            'property': 1008934075,
 
806
            'window': 461926013,
 
807
            'type': 613217208,
 
808
            }
 
809
        self.req_bin_6 = '\x12\x02\x00\x06' '\x1b\x88\x6e\x7d' \
 
810
            '\x3c\x23\x1c\xbb' '\x24\x8c\xf3\xb8' \
 
811
            '\x20\x00\x00\x00' '\x00\x00\x00\x00'
 
812
 
 
813
        self.req_args_7 = {
 
814
            'mode': 1,
 
815
            'data': (32, [1, 2, 3]),
 
816
            'property': 1472503640,
 
817
            'window': 367636986,
 
818
            'type': 1085552939,
 
819
            }
 
820
        self.req_bin_7 = '\x12\x01\x00\x09' '\x15\xe9\xb1\xfa' \
 
821
            '\x57\xc4\x9f\x58' '\x40\xb4\x39\x2b' \
 
822
            '\x20\x00\x00\x00' '\x00\x00\x00\x03' \
 
823
            '\x00\x00\x00\x01' '\x00\x00\x00\x02' \
 
824
            '\x00\x00\x00\x03'
 
825
 
 
826
 
 
827
    def testPackRequest0(self):
 
828
        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_0)
 
829
        try:
 
830
            assert bin == self.req_bin_0
 
831
        except AssertionError:
 
832
            raise AssertionError(tohex(bin))
 
833
 
 
834
    def testUnpackRequest0(self):
 
835
        args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
836
        try:
 
837
            assert len(remain) == 0
 
838
        except AssertionError:
 
839
            raise AssertionError(tohex(remain))
 
840
        try:
 
841
            assert args == self.req_args_0
 
842
        except AssertionError:
 
843
            raise AssertionError(args)
 
844
 
 
845
    def testPackRequest1(self):
 
846
        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_1)
 
847
        try:
 
848
            assert bin == self.req_bin_1
 
849
        except AssertionError:
 
850
            raise AssertionError(tohex(bin))
 
851
 
 
852
    def testUnpackRequest1(self):
 
853
        args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_1, dummy_display, 1)
 
854
        try:
 
855
            assert len(remain) == 0
 
856
        except AssertionError:
 
857
            raise AssertionError(tohex(remain))
 
858
        try:
 
859
            assert args == self.req_args_1
 
860
        except AssertionError:
 
861
            raise AssertionError(args)
 
862
 
 
863
    def testPackRequest2(self):
 
864
        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_2)
 
865
        try:
 
866
            assert bin == self.req_bin_2
 
867
        except AssertionError:
 
868
            raise AssertionError(tohex(bin))
 
869
 
 
870
    def testUnpackRequest2(self):
 
871
        args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_2, dummy_display, 1)
 
872
        try:
 
873
            assert len(remain) == 0
 
874
        except AssertionError:
 
875
            raise AssertionError(tohex(remain))
 
876
        try:
 
877
            assert args == self.req_args_2
 
878
        except AssertionError:
 
879
            raise AssertionError(args)
 
880
 
 
881
    def testPackRequest3(self):
 
882
        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_3)
 
883
        try:
 
884
            assert bin == self.req_bin_3
 
885
        except AssertionError:
 
886
            raise AssertionError(tohex(bin))
 
887
 
 
888
    def testUnpackRequest3(self):
 
889
        args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_3, dummy_display, 1)
 
890
        try:
 
891
            assert len(remain) == 0
 
892
        except AssertionError:
 
893
            raise AssertionError(tohex(remain))
 
894
        try:
 
895
            assert args == self.req_args_3
 
896
        except AssertionError:
 
897
            raise AssertionError(args)
 
898
 
 
899
    def testPackRequest4(self):
 
900
        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_4)
 
901
        try:
 
902
            assert bin == self.req_bin_4
 
903
        except AssertionError:
 
904
            raise AssertionError(tohex(bin))
 
905
 
 
906
    def testUnpackRequest4(self):
 
907
        args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_4, dummy_display, 1)
 
908
        try:
 
909
            assert len(remain) == 0
 
910
        except AssertionError:
 
911
            raise AssertionError(tohex(remain))
 
912
        try:
 
913
            assert args == self.req_args_4
 
914
        except AssertionError:
 
915
            raise AssertionError(args)
 
916
 
 
917
    def testPackRequest5(self):
 
918
        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_5)
 
919
        try:
 
920
            assert bin == self.req_bin_5
 
921
        except AssertionError:
 
922
            raise AssertionError(tohex(bin))
 
923
 
 
924
    def testUnpackRequest5(self):
 
925
        args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_5, dummy_display, 1)
 
926
        try:
 
927
            assert len(remain) == 0
 
928
        except AssertionError:
 
929
            raise AssertionError(tohex(remain))
 
930
        try:
 
931
            assert args == self.req_args_5
 
932
        except AssertionError:
 
933
            raise AssertionError(args)
 
934
 
 
935
    def testPackRequest6(self):
 
936
        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_6)
 
937
        try:
 
938
            assert bin == self.req_bin_6
 
939
        except AssertionError:
 
940
            raise AssertionError(tohex(bin))
 
941
 
 
942
    def testUnpackRequest6(self):
 
943
        args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_6, dummy_display, 1)
 
944
        try:
 
945
            assert len(remain) == 0
 
946
        except AssertionError:
 
947
            raise AssertionError(tohex(remain))
 
948
        try:
 
949
            assert args == self.req_args_6
 
950
        except AssertionError:
 
951
            raise AssertionError(args)
 
952
 
 
953
    def testPackRequest7(self):
 
954
        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_7)
 
955
        try:
 
956
            assert bin == self.req_bin_7
 
957
        except AssertionError:
 
958
            raise AssertionError(tohex(bin))
 
959
 
 
960
    def testUnpackRequest7(self):
 
961
        args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_7, dummy_display, 1)
 
962
        try:
 
963
            assert len(remain) == 0
 
964
        except AssertionError:
 
965
            raise AssertionError(tohex(remain))
 
966
        try:
 
967
            assert args == self.req_args_7
 
968
        except AssertionError:
 
969
            raise AssertionError(args)
 
970
 
 
971
 
 
972
class TestDeleteProperty(unittest.TestCase):
 
973
    def setUp(self):
 
974
        self.req_args_0 = {
 
975
            'property': 506897017,
 
976
            'window': 381870530,
 
977
            }
 
978
        self.req_bin_0 = '\x13\x00\x00\x03' '\x16\xc2\xe1\xc2' \
 
979
            '\x1e\x36\xa2\x79'
 
980
 
 
981
 
 
982
    def testPackRequest0(self):
 
983
        bin = apply(request.DeleteProperty._request.to_binary, (), self.req_args_0)
 
984
        try:
 
985
            assert bin == self.req_bin_0
 
986
        except AssertionError:
 
987
            raise AssertionError(tohex(bin))
 
988
 
 
989
    def testUnpackRequest0(self):
 
990
        args, remain = request.DeleteProperty._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
991
        try:
 
992
            assert len(remain) == 0
 
993
        except AssertionError:
 
994
            raise AssertionError(tohex(remain))
 
995
        try:
 
996
            assert args == self.req_args_0
 
997
        except AssertionError:
 
998
            raise AssertionError(args)
 
999
 
 
1000
 
 
1001
class TestGetProperty(unittest.TestCase):
 
1002
    def setUp(self):
 
1003
        self.req_args_0 = {
 
1004
            'delete': 0,
 
1005
            'long_offset': 1563462862,
 
1006
            'type': 1556454304,
 
1007
            'property': 1007774483,
 
1008
            'window': 1477792536,
 
1009
            'long_length': 1346507413,
 
1010
            }
 
1011
        self.req_bin_0 = '\x14\x00\x00\x06' '\x58\x15\x53\x18' \
 
1012
            '\x3c\x11\x6b\x13' '\x5c\xc5\x9b\xa0' \
 
1013
            '\x5d\x30\x8c\xce' '\x50\x42\x12\x95'
 
1014
 
 
1015
        self.reply_args_0 = {
 
1016
            'value': (8, ''),
 
1017
            'sequence_number': 30606,
 
1018
            'property_type': 1392423916,
 
1019
            'bytes_after': 2046056935,
 
1020
            }
 
1021
        self.reply_bin_0 = '\x01\x08\x77\x8e' '\x00\x00\x00\x00' \
 
1022
            '\x52\xfe\xb3\xec' '\x79\xf4\x59\xe7' \
 
1023
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1024
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
1025
 
 
1026
        self.reply_args_1 = {
 
1027
            'value': (8, 'foo'),
 
1028
            'sequence_number': 44279,
 
1029
            'property_type': 186441230,
 
1030
            'bytes_after': 469299413,
 
1031
            }
 
1032
        self.reply_bin_1 = '\x01\x08\xac\xf7' '\x00\x00\x00\x01' \
 
1033
            '\x0b\x1c\xde\x0e' '\x1b\xf8\xf0\xd5' \
 
1034
            '\x00\x00\x00\x03' '\x00\x00\x00\x00' \
 
1035
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1036
            '\x66\x6f\x6f\x00'
 
1037
 
 
1038
        self.reply_args_2 = {
 
1039
            'value': (8, 'zoom'),
 
1040
            'sequence_number': 12674,
 
1041
            'property_type': 1802804296,
 
1042
            'bytes_after': 1968158856,
 
1043
            }
 
1044
        self.reply_bin_2 = '\x01\x08\x31\x82' '\x00\x00\x00\x01' \
 
1045
            '\x6b\x74\x9c\x48' '\x75\x4f\xb8\x88' \
 
1046
            '\x00\x00\x00\x04' '\x00\x00\x00\x00' \
 
1047
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1048
            '\x7a\x6f\x6f\x6d'
 
1049
 
 
1050
        self.reply_args_3 = {
 
1051
            'value': (16, []),
 
1052
            'sequence_number': 25311,
 
1053
            'property_type': 536196393,
 
1054
            'bytes_after': 1874157309,
 
1055
            }
 
1056
        self.reply_bin_3 = '\x01\x10\x62\xdf' '\x00\x00\x00\x00' \
 
1057
            '\x1f\xf5\xb5\x29' '\x6f\xb5\x5e\xfd' \
 
1058
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1059
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
1060
 
 
1061
        self.reply_args_4 = {
 
1062
            'value': (16, [1, 2, 3]),
 
1063
            'sequence_number': 22665,
 
1064
            'property_type': 1046879880,
 
1065
            'bytes_after': 1952710167,
 
1066
            }
 
1067
        self.reply_bin_4 = '\x01\x10\x58\x89' '\x00\x00\x00\x02' \
 
1068
            '\x3e\x66\x1e\x88' '\x74\x63\xfe\x17' \
 
1069
            '\x00\x00\x00\x03' '\x00\x00\x00\x00' \
 
1070
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1071
            '\x00\x01\x00\x02' '\x00\x03\x00\x00'
 
1072
 
 
1073
        self.reply_args_5 = {
 
1074
            'value': (16, [1, 2, 3, 4]),
 
1075
            'sequence_number': 19028,
 
1076
            'property_type': 1014173132,
 
1077
            'bytes_after': 1791090668,
 
1078
            }
 
1079
        self.reply_bin_5 = '\x01\x10\x4a\x54' '\x00\x00\x00\x02' \
 
1080
            '\x3c\x73\x0d\xcc' '\x6a\xc1\xdf\xec' \
 
1081
            '\x00\x00\x00\x04' '\x00\x00\x00\x00' \
 
1082
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1083
            '\x00\x01\x00\x02' '\x00\x03\x00\x04'
 
1084
 
 
1085
        self.reply_args_6 = {
 
1086
            'value': (32, []),
 
1087
            'sequence_number': 47226,
 
1088
            'property_type': 2053870497,
 
1089
            'bytes_after': 1727548898,
 
1090
            }
 
1091
        self.reply_bin_6 = '\x01\x20\xb8\x7a' '\x00\x00\x00\x00' \
 
1092
            '\x7a\x6b\x93\xa1' '\x66\xf8\x4d\xe2' \
 
1093
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1094
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
1095
 
 
1096
        self.reply_args_7 = {
 
1097
            'value': (32, [1, 2, 3]),
 
1098
            'sequence_number': 37094,
 
1099
            'property_type': 704363625,
 
1100
            'bytes_after': 1957409055,
 
1101
            }
 
1102
        self.reply_bin_7 = '\x01\x20\x90\xe6' '\x00\x00\x00\x03' \
 
1103
            '\x29\xfb\xbc\x69' '\x74\xab\xb1\x1f' \
 
1104
            '\x00\x00\x00\x03' '\x00\x00\x00\x00' \
 
1105
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1106
            '\x00\x00\x00\x01' '\x00\x00\x00\x02' \
 
1107
            '\x00\x00\x00\x03'
 
1108
 
 
1109
 
 
1110
    def testPackRequest0(self):
 
1111
        bin = apply(request.GetProperty._request.to_binary, (), self.req_args_0)
 
1112
        try:
 
1113
            assert bin == self.req_bin_0
 
1114
        except AssertionError:
 
1115
            raise AssertionError(tohex(bin))
 
1116
 
 
1117
    def testUnpackRequest0(self):
 
1118
        args, remain = request.GetProperty._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1119
        try:
 
1120
            assert len(remain) == 0
 
1121
        except AssertionError:
 
1122
            raise AssertionError(tohex(remain))
 
1123
        try:
 
1124
            assert args == self.req_args_0
 
1125
        except AssertionError:
 
1126
            raise AssertionError(args)
 
1127
 
 
1128
    def testPackReply0(self):
 
1129
        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_0)
 
1130
        try:
 
1131
            assert bin == self.reply_bin_0
 
1132
        except AssertionError:
 
1133
            raise AssertionError(tohex(bin))
 
1134
 
 
1135
    def testUnpackReply0(self):
 
1136
        args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
1137
        try:
 
1138
            assert len(remain) == 0
 
1139
        except AssertionError:
 
1140
            raise AssertionError(tohex(remain))
 
1141
        try:
 
1142
            assert args == self.reply_args_0
 
1143
        except AssertionError:
 
1144
            raise AssertionError(args)
 
1145
 
 
1146
    def testPackReply1(self):
 
1147
        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_1)
 
1148
        try:
 
1149
            assert bin == self.reply_bin_1
 
1150
        except AssertionError:
 
1151
            raise AssertionError(tohex(bin))
 
1152
 
 
1153
    def testUnpackReply1(self):
 
1154
        args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_1, dummy_display, 1)
 
1155
        try:
 
1156
            assert len(remain) == 0
 
1157
        except AssertionError:
 
1158
            raise AssertionError(tohex(remain))
 
1159
        try:
 
1160
            assert args == self.reply_args_1
 
1161
        except AssertionError:
 
1162
            raise AssertionError(args)
 
1163
 
 
1164
    def testPackReply2(self):
 
1165
        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_2)
 
1166
        try:
 
1167
            assert bin == self.reply_bin_2
 
1168
        except AssertionError:
 
1169
            raise AssertionError(tohex(bin))
 
1170
 
 
1171
    def testUnpackReply2(self):
 
1172
        args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_2, dummy_display, 1)
 
1173
        try:
 
1174
            assert len(remain) == 0
 
1175
        except AssertionError:
 
1176
            raise AssertionError(tohex(remain))
 
1177
        try:
 
1178
            assert args == self.reply_args_2
 
1179
        except AssertionError:
 
1180
            raise AssertionError(args)
 
1181
 
 
1182
    def testPackReply3(self):
 
1183
        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_3)
 
1184
        try:
 
1185
            assert bin == self.reply_bin_3
 
1186
        except AssertionError:
 
1187
            raise AssertionError(tohex(bin))
 
1188
 
 
1189
    def testUnpackReply3(self):
 
1190
        args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_3, dummy_display, 1)
 
1191
        try:
 
1192
            assert len(remain) == 0
 
1193
        except AssertionError:
 
1194
            raise AssertionError(tohex(remain))
 
1195
        try:
 
1196
            assert args == self.reply_args_3
 
1197
        except AssertionError:
 
1198
            raise AssertionError(args)
 
1199
 
 
1200
    def testPackReply4(self):
 
1201
        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_4)
 
1202
        try:
 
1203
            assert bin == self.reply_bin_4
 
1204
        except AssertionError:
 
1205
            raise AssertionError(tohex(bin))
 
1206
 
 
1207
    def testUnpackReply4(self):
 
1208
        args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_4, dummy_display, 1)
 
1209
        try:
 
1210
            assert len(remain) == 0
 
1211
        except AssertionError:
 
1212
            raise AssertionError(tohex(remain))
 
1213
        try:
 
1214
            assert args == self.reply_args_4
 
1215
        except AssertionError:
 
1216
            raise AssertionError(args)
 
1217
 
 
1218
    def testPackReply5(self):
 
1219
        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_5)
 
1220
        try:
 
1221
            assert bin == self.reply_bin_5
 
1222
        except AssertionError:
 
1223
            raise AssertionError(tohex(bin))
 
1224
 
 
1225
    def testUnpackReply5(self):
 
1226
        args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_5, dummy_display, 1)
 
1227
        try:
 
1228
            assert len(remain) == 0
 
1229
        except AssertionError:
 
1230
            raise AssertionError(tohex(remain))
 
1231
        try:
 
1232
            assert args == self.reply_args_5
 
1233
        except AssertionError:
 
1234
            raise AssertionError(args)
 
1235
 
 
1236
    def testPackReply6(self):
 
1237
        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_6)
 
1238
        try:
 
1239
            assert bin == self.reply_bin_6
 
1240
        except AssertionError:
 
1241
            raise AssertionError(tohex(bin))
 
1242
 
 
1243
    def testUnpackReply6(self):
 
1244
        args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_6, dummy_display, 1)
 
1245
        try:
 
1246
            assert len(remain) == 0
 
1247
        except AssertionError:
 
1248
            raise AssertionError(tohex(remain))
 
1249
        try:
 
1250
            assert args == self.reply_args_6
 
1251
        except AssertionError:
 
1252
            raise AssertionError(args)
 
1253
 
 
1254
    def testPackReply7(self):
 
1255
        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_7)
 
1256
        try:
 
1257
            assert bin == self.reply_bin_7
 
1258
        except AssertionError:
 
1259
            raise AssertionError(tohex(bin))
 
1260
 
 
1261
    def testUnpackReply7(self):
 
1262
        args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_7, dummy_display, 1)
 
1263
        try:
 
1264
            assert len(remain) == 0
 
1265
        except AssertionError:
 
1266
            raise AssertionError(tohex(remain))
 
1267
        try:
 
1268
            assert args == self.reply_args_7
 
1269
        except AssertionError:
 
1270
            raise AssertionError(args)
 
1271
 
 
1272
 
 
1273
class TestListProperties(unittest.TestCase):
 
1274
    def setUp(self):
 
1275
        self.req_args_0 = {
 
1276
            'window': 91262675,
 
1277
            }
 
1278
        self.req_bin_0 = '\x15\x00\x00\x02' '\x05\x70\x8e\xd3'
 
1279
 
 
1280
        self.reply_args_0 = {
 
1281
            'atoms': [580972634, 926488735, 714741529, 408777797, 679906858, 705092899, 2063243279, 893967755, 1591182471, 571137996, 1677110101, 1783836762, 1678219148, 1992402577, 871298793, 1182885899, 1155013854, 1822076326, 2117552706, 1972668469, 1660227078, 1523268962, 694042433],
 
1282
            'sequence_number': 42191,
 
1283
            }
 
1284
        self.reply_bin_0 = '\x01\x00\xa4\xcf' '\x00\x00\x00\x17' \
 
1285
            '\x00\x17\x00\x00' '\x00\x00\x00\x00' \
 
1286
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1287
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1288
            '\x22\xa0\xf0\x5a' '\x37\x39\x18\x9f' \
 
1289
            '\x2a\x9a\x17\x19' '\x18\x5d\x74\x45' \
 
1290
            '\x28\x86\x8e\x2a' '\x2a\x06\xdd\x23' \
 
1291
            '\x7a\xfa\x98\x0f' '\x35\x48\xdd\x8b' \
 
1292
            '\x5e\xd7\x84\x87' '\x22\x0a\xdf\xcc' \
 
1293
            '\x63\xf6\xab\x55' '\x6a\x53\x30\x5a' \
 
1294
            '\x64\x07\x97\x8c' '\x76\xc1\xa6\x91' \
 
1295
            '\x33\xee\xf6\xe9' '\x46\x81\x68\x0b' \
 
1296
            '\x44\xd8\x1c\xde' '\x6c\x9a\xad\xa6' \
 
1297
            '\x7e\x37\x4a\x42' '\x75\x94\x88\x35' \
 
1298
            '\x62\xf5\x0e\x06' '\x5a\xcb\x3d\x62' \
 
1299
            '\x29\x5e\x3f\x41'
 
1300
 
 
1301
 
 
1302
    def testPackRequest0(self):
 
1303
        bin = apply(request.ListProperties._request.to_binary, (), self.req_args_0)
 
1304
        try:
 
1305
            assert bin == self.req_bin_0
 
1306
        except AssertionError:
 
1307
            raise AssertionError(tohex(bin))
 
1308
 
 
1309
    def testUnpackRequest0(self):
 
1310
        args, remain = request.ListProperties._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1311
        try:
 
1312
            assert len(remain) == 0
 
1313
        except AssertionError:
 
1314
            raise AssertionError(tohex(remain))
 
1315
        try:
 
1316
            assert args == self.req_args_0
 
1317
        except AssertionError:
 
1318
            raise AssertionError(args)
 
1319
 
 
1320
    def testPackReply0(self):
 
1321
        bin = apply(request.ListProperties._reply.to_binary, (), self.reply_args_0)
 
1322
        try:
 
1323
            assert bin == self.reply_bin_0
 
1324
        except AssertionError:
 
1325
            raise AssertionError(tohex(bin))
 
1326
 
 
1327
    def testUnpackReply0(self):
 
1328
        args, remain = request.ListProperties._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
1329
        try:
 
1330
            assert len(remain) == 0
 
1331
        except AssertionError:
 
1332
            raise AssertionError(tohex(remain))
 
1333
        try:
 
1334
            assert args == self.reply_args_0
 
1335
        except AssertionError:
 
1336
            raise AssertionError(args)
 
1337
 
 
1338
 
 
1339
class TestSetSelectionOwner(unittest.TestCase):
 
1340
    def setUp(self):
 
1341
        self.req_args_0 = {
 
1342
            'selection': 2071258139,
 
1343
            'window': 1190911777,
 
1344
            'time': 1606660593,
 
1345
            }
 
1346
        self.req_bin_0 = '\x16\x00\x00\x04' '\x46\xfb\xdf\x21' \
 
1347
            '\x7b\x74\xe4\x1b' '\x5f\xc3\xb1\xf1'
 
1348
 
 
1349
 
 
1350
    def testPackRequest0(self):
 
1351
        bin = apply(request.SetSelectionOwner._request.to_binary, (), self.req_args_0)
 
1352
        try:
 
1353
            assert bin == self.req_bin_0
 
1354
        except AssertionError:
 
1355
            raise AssertionError(tohex(bin))
 
1356
 
 
1357
    def testUnpackRequest0(self):
 
1358
        args, remain = request.SetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1359
        try:
 
1360
            assert len(remain) == 0
 
1361
        except AssertionError:
 
1362
            raise AssertionError(tohex(remain))
 
1363
        try:
 
1364
            assert args == self.req_args_0
 
1365
        except AssertionError:
 
1366
            raise AssertionError(args)
 
1367
 
 
1368
 
 
1369
class TestGetSelectionOwner(unittest.TestCase):
 
1370
    def setUp(self):
 
1371
        self.req_args_0 = {
 
1372
            'selection': 819576555,
 
1373
            }
 
1374
        self.req_bin_0 = '\x17\x00\x00\x02' '\x30\xd9\xbe\xeb'
 
1375
 
 
1376
        self.reply_args_0 = {
 
1377
            'sequence_number': 14152,
 
1378
            'owner': 1922331178,
 
1379
            }
 
1380
        self.reply_bin_0 = '\x01\x00\x37\x48' '\x00\x00\x00\x00' \
 
1381
            '\x72\x94\x72\x2a' '\x00\x00\x00\x00' \
 
1382
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1383
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
1384
 
 
1385
 
 
1386
    def testPackRequest0(self):
 
1387
        bin = apply(request.GetSelectionOwner._request.to_binary, (), self.req_args_0)
 
1388
        try:
 
1389
            assert bin == self.req_bin_0
 
1390
        except AssertionError:
 
1391
            raise AssertionError(tohex(bin))
 
1392
 
 
1393
    def testUnpackRequest0(self):
 
1394
        args, remain = request.GetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1395
        try:
 
1396
            assert len(remain) == 0
 
1397
        except AssertionError:
 
1398
            raise AssertionError(tohex(remain))
 
1399
        try:
 
1400
            assert args == self.req_args_0
 
1401
        except AssertionError:
 
1402
            raise AssertionError(args)
 
1403
 
 
1404
    def testPackReply0(self):
 
1405
        bin = apply(request.GetSelectionOwner._reply.to_binary, (), self.reply_args_0)
 
1406
        try:
 
1407
            assert bin == self.reply_bin_0
 
1408
        except AssertionError:
 
1409
            raise AssertionError(tohex(bin))
 
1410
 
 
1411
    def testUnpackReply0(self):
 
1412
        args, remain = request.GetSelectionOwner._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
1413
        try:
 
1414
            assert len(remain) == 0
 
1415
        except AssertionError:
 
1416
            raise AssertionError(tohex(remain))
 
1417
        try:
 
1418
            assert args == self.reply_args_0
 
1419
        except AssertionError:
 
1420
            raise AssertionError(args)
 
1421
 
 
1422
 
 
1423
class TestConvertSelection(unittest.TestCase):
 
1424
    def setUp(self):
 
1425
        self.req_args_0 = {
 
1426
            'property': 2137791927,
 
1427
            'time': 1594653142,
 
1428
            'target': 1972273672,
 
1429
            'selection': 125139929,
 
1430
            'requestor': 300355135,
 
1431
            }
 
1432
        self.req_bin_0 = '\x18\x00\x00\x06' '\x11\xe7\x0e\x3f' \
 
1433
            '\x07\x75\x7b\xd9' '\x75\x8e\x82\x08' \
 
1434
            '\x7f\x6c\x1d\xb7' '\x5f\x0c\x79\xd6'
 
1435
 
 
1436
 
 
1437
    def testPackRequest0(self):
 
1438
        bin = apply(request.ConvertSelection._request.to_binary, (), self.req_args_0)
 
1439
        try:
 
1440
            assert bin == self.req_bin_0
 
1441
        except AssertionError:
 
1442
            raise AssertionError(tohex(bin))
 
1443
 
 
1444
    def testUnpackRequest0(self):
 
1445
        args, remain = request.ConvertSelection._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1446
        try:
 
1447
            assert len(remain) == 0
 
1448
        except AssertionError:
 
1449
            raise AssertionError(tohex(remain))
 
1450
        try:
 
1451
            assert args == self.req_args_0
 
1452
        except AssertionError:
 
1453
            raise AssertionError(args)
 
1454
 
 
1455
 
 
1456
class TestSendEvent(unittest.TestCase):
 
1457
    def setUp(self):
 
1458
        self.req_args_0 = {
 
1459
            'event': Xlib.protocol.event.Expose(height = 64784, sequence_number = 0, type = 12, x = 52546, y = 56316, window = 1322187412, width = 16612, count = 14164),
 
1460
            'propagate': 1,
 
1461
            'destination': 1369243800,
 
1462
            'event_mask': 1594482936,
 
1463
            }
 
1464
        self.req_bin_0 = '\x19\x01\x00\x0b' '\x51\x9d\x00\x98' \
 
1465
            '\x5f\x09\xe0\xf8' '\x0c\x00\x00\x00' \
 
1466
            '\x4e\xce\xfa\x94' '\xcd\x42\xdb\xfc' \
 
1467
            '\x40\xe4\xfd\x10' '\x37\x54\x00\x00' \
 
1468
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1469
            '\x00\x00\x00\x00'
 
1470
 
 
1471
 
 
1472
    def testPackRequest0(self):
 
1473
        bin = apply(request.SendEvent._request.to_binary, (), self.req_args_0)
 
1474
        try:
 
1475
            assert bin == self.req_bin_0
 
1476
        except AssertionError:
 
1477
            raise AssertionError(tohex(bin))
 
1478
 
 
1479
    def testUnpackRequest0(self):
 
1480
        args, remain = request.SendEvent._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1481
        try:
 
1482
            assert len(remain) == 0
 
1483
        except AssertionError:
 
1484
            raise AssertionError(tohex(remain))
 
1485
        try:
 
1486
            assert args == self.req_args_0
 
1487
        except AssertionError:
 
1488
            raise AssertionError(args)
 
1489
 
 
1490
 
 
1491
class TestGrabPointer(unittest.TestCase):
 
1492
    def setUp(self):
 
1493
        self.req_args_0 = {
 
1494
            'owner_events': 1,
 
1495
            'grab_window': 2104857020,
 
1496
            'confine_to': 1988278615,
 
1497
            'event_mask': 2075,
 
1498
            'pointer_mode': 0,
 
1499
            'time': 1316427724,
 
1500
            'keyboard_mode': 1,
 
1501
            'cursor': 17101598,
 
1502
            }
 
1503
        self.req_bin_0 = '\x1a\x01\x00\x06' '\x7d\x75\x91\xbc' \
 
1504
            '\x08\x1b\x00\x01' '\x76\x82\xb9\x57' \
 
1505
            '\x01\x04\xf3\x1e' '\x4e\x77\x17\xcc'
 
1506
 
 
1507
        self.reply_args_0 = {
 
1508
            'sequence_number': 47539,
 
1509
            'status': 149,
 
1510
            }
 
1511
        self.reply_bin_0 = '\x01\x95\xb9\xb3' '\x00\x00\x00\x00' \
 
1512
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1513
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1514
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
1515
 
 
1516
 
 
1517
    def testPackRequest0(self):
 
1518
        bin = apply(request.GrabPointer._request.to_binary, (), self.req_args_0)
 
1519
        try:
 
1520
            assert bin == self.req_bin_0
 
1521
        except AssertionError:
 
1522
            raise AssertionError(tohex(bin))
 
1523
 
 
1524
    def testUnpackRequest0(self):
 
1525
        args, remain = request.GrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1526
        try:
 
1527
            assert len(remain) == 0
 
1528
        except AssertionError:
 
1529
            raise AssertionError(tohex(remain))
 
1530
        try:
 
1531
            assert args == self.req_args_0
 
1532
        except AssertionError:
 
1533
            raise AssertionError(args)
 
1534
 
 
1535
    def testPackReply0(self):
 
1536
        bin = apply(request.GrabPointer._reply.to_binary, (), self.reply_args_0)
 
1537
        try:
 
1538
            assert bin == self.reply_bin_0
 
1539
        except AssertionError:
 
1540
            raise AssertionError(tohex(bin))
 
1541
 
 
1542
    def testUnpackReply0(self):
 
1543
        args, remain = request.GrabPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
1544
        try:
 
1545
            assert len(remain) == 0
 
1546
        except AssertionError:
 
1547
            raise AssertionError(tohex(remain))
 
1548
        try:
 
1549
            assert args == self.reply_args_0
 
1550
        except AssertionError:
 
1551
            raise AssertionError(args)
 
1552
 
 
1553
 
 
1554
class TestUngrabPointer(unittest.TestCase):
 
1555
    def setUp(self):
 
1556
        self.req_args_0 = {
 
1557
            'time': 209008422,
 
1558
            }
 
1559
        self.req_bin_0 = '\x1b\x00\x00\x02' '\x0c\x75\x37\x26'
 
1560
 
 
1561
 
 
1562
    def testPackRequest0(self):
 
1563
        bin = apply(request.UngrabPointer._request.to_binary, (), self.req_args_0)
 
1564
        try:
 
1565
            assert bin == self.req_bin_0
 
1566
        except AssertionError:
 
1567
            raise AssertionError(tohex(bin))
 
1568
 
 
1569
    def testUnpackRequest0(self):
 
1570
        args, remain = request.UngrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1571
        try:
 
1572
            assert len(remain) == 0
 
1573
        except AssertionError:
 
1574
            raise AssertionError(tohex(remain))
 
1575
        try:
 
1576
            assert args == self.req_args_0
 
1577
        except AssertionError:
 
1578
            raise AssertionError(args)
 
1579
 
 
1580
 
 
1581
class TestGrabButton(unittest.TestCase):
 
1582
    def setUp(self):
 
1583
        self.req_args_0 = {
 
1584
            'owner_events': 1,
 
1585
            'grab_window': 526402184,
 
1586
            'confine_to': 1843948635,
 
1587
            'event_mask': 16279,
 
1588
            'pointer_mode': 1,
 
1589
            'modifiers': 15589,
 
1590
            'button': 208,
 
1591
            'keyboard_mode': 1,
 
1592
            'cursor': 1070323643,
 
1593
            }
 
1594
        self.req_bin_0 = '\x1c\x01\x00\x06' '\x1f\x60\x42\x88' \
 
1595
            '\x3f\x97\x01\x01' '\x6d\xe8\x6c\x5b' \
 
1596
            '\x3f\xcb\xd7\xbb' '\xd0\x00\x3c\xe5'
 
1597
 
 
1598
 
 
1599
    def testPackRequest0(self):
 
1600
        bin = apply(request.GrabButton._request.to_binary, (), self.req_args_0)
 
1601
        try:
 
1602
            assert bin == self.req_bin_0
 
1603
        except AssertionError:
 
1604
            raise AssertionError(tohex(bin))
 
1605
 
 
1606
    def testUnpackRequest0(self):
 
1607
        args, remain = request.GrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1608
        try:
 
1609
            assert len(remain) == 0
 
1610
        except AssertionError:
 
1611
            raise AssertionError(tohex(remain))
 
1612
        try:
 
1613
            assert args == self.req_args_0
 
1614
        except AssertionError:
 
1615
            raise AssertionError(args)
 
1616
 
 
1617
 
 
1618
class TestUngrabButton(unittest.TestCase):
 
1619
    def setUp(self):
 
1620
        self.req_args_0 = {
 
1621
            'grab_window': 795414150,
 
1622
            'button': 240,
 
1623
            'modifiers': 51717,
 
1624
            }
 
1625
        self.req_bin_0 = '\x1d\xf0\x00\x03' '\x2f\x69\x0e\x86' \
 
1626
            '\xca\x05\x00\x00'
 
1627
 
 
1628
 
 
1629
    def testPackRequest0(self):
 
1630
        bin = apply(request.UngrabButton._request.to_binary, (), self.req_args_0)
 
1631
        try:
 
1632
            assert bin == self.req_bin_0
 
1633
        except AssertionError:
 
1634
            raise AssertionError(tohex(bin))
 
1635
 
 
1636
    def testUnpackRequest0(self):
 
1637
        args, remain = request.UngrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1638
        try:
 
1639
            assert len(remain) == 0
 
1640
        except AssertionError:
 
1641
            raise AssertionError(tohex(remain))
 
1642
        try:
 
1643
            assert args == self.req_args_0
 
1644
        except AssertionError:
 
1645
            raise AssertionError(args)
 
1646
 
 
1647
 
 
1648
class TestChangeActivePointerGrab(unittest.TestCase):
 
1649
    def setUp(self):
 
1650
        self.req_args_0 = {
 
1651
            'time': 891337572,
 
1652
            'event_mask': 23423,
 
1653
            'cursor': 1696594928,
 
1654
            }
 
1655
        self.req_bin_0 = '\x1e\x00\x00\x04' '\x65\x1f\xfb\xf0' \
 
1656
            '\x35\x20\xbb\x64' '\x5b\x7f\x00\x00'
 
1657
 
 
1658
 
 
1659
    def testPackRequest0(self):
 
1660
        bin = apply(request.ChangeActivePointerGrab._request.to_binary, (), self.req_args_0)
 
1661
        try:
 
1662
            assert bin == self.req_bin_0
 
1663
        except AssertionError:
 
1664
            raise AssertionError(tohex(bin))
 
1665
 
 
1666
    def testUnpackRequest0(self):
 
1667
        args, remain = request.ChangeActivePointerGrab._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1668
        try:
 
1669
            assert len(remain) == 0
 
1670
        except AssertionError:
 
1671
            raise AssertionError(tohex(remain))
 
1672
        try:
 
1673
            assert args == self.req_args_0
 
1674
        except AssertionError:
 
1675
            raise AssertionError(args)
 
1676
 
 
1677
 
 
1678
class TestGrabKeyboard(unittest.TestCase):
 
1679
    def setUp(self):
 
1680
        self.req_args_0 = {
 
1681
            'owner_events': 0,
 
1682
            'grab_window': 76132199,
 
1683
            'time': 1562605785,
 
1684
            'pointer_mode': 1,
 
1685
            'keyboard_mode': 1,
 
1686
            }
 
1687
        self.req_bin_0 = '\x1f\x00\x00\x04' '\x04\x89\xaf\x67' \
 
1688
            '\x5d\x23\x78\xd9' '\x01\x01\x00\x00'
 
1689
 
 
1690
        self.reply_args_0 = {
 
1691
            'sequence_number': 9648,
 
1692
            'status': 129,
 
1693
            }
 
1694
        self.reply_bin_0 = '\x01\x81\x25\xb0' '\x00\x00\x00\x00' \
 
1695
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1696
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1697
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
1698
 
 
1699
 
 
1700
    def testPackRequest0(self):
 
1701
        bin = apply(request.GrabKeyboard._request.to_binary, (), self.req_args_0)
 
1702
        try:
 
1703
            assert bin == self.req_bin_0
 
1704
        except AssertionError:
 
1705
            raise AssertionError(tohex(bin))
 
1706
 
 
1707
    def testUnpackRequest0(self):
 
1708
        args, remain = request.GrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1709
        try:
 
1710
            assert len(remain) == 0
 
1711
        except AssertionError:
 
1712
            raise AssertionError(tohex(remain))
 
1713
        try:
 
1714
            assert args == self.req_args_0
 
1715
        except AssertionError:
 
1716
            raise AssertionError(args)
 
1717
 
 
1718
    def testPackReply0(self):
 
1719
        bin = apply(request.GrabKeyboard._reply.to_binary, (), self.reply_args_0)
 
1720
        try:
 
1721
            assert bin == self.reply_bin_0
 
1722
        except AssertionError:
 
1723
            raise AssertionError(tohex(bin))
 
1724
 
 
1725
    def testUnpackReply0(self):
 
1726
        args, remain = request.GrabKeyboard._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
1727
        try:
 
1728
            assert len(remain) == 0
 
1729
        except AssertionError:
 
1730
            raise AssertionError(tohex(remain))
 
1731
        try:
 
1732
            assert args == self.reply_args_0
 
1733
        except AssertionError:
 
1734
            raise AssertionError(args)
 
1735
 
 
1736
 
 
1737
class TestUngrabKeyboard(unittest.TestCase):
 
1738
    def setUp(self):
 
1739
        self.req_args_0 = {
 
1740
            'time': 1352311886,
 
1741
            }
 
1742
        self.req_bin_0 = '\x20\x00\x00\x02' '\x50\x9a\xa4\x4e'
 
1743
 
 
1744
 
 
1745
    def testPackRequest0(self):
 
1746
        bin = apply(request.UngrabKeyboard._request.to_binary, (), self.req_args_0)
 
1747
        try:
 
1748
            assert bin == self.req_bin_0
 
1749
        except AssertionError:
 
1750
            raise AssertionError(tohex(bin))
 
1751
 
 
1752
    def testUnpackRequest0(self):
 
1753
        args, remain = request.UngrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1754
        try:
 
1755
            assert len(remain) == 0
 
1756
        except AssertionError:
 
1757
            raise AssertionError(tohex(remain))
 
1758
        try:
 
1759
            assert args == self.req_args_0
 
1760
        except AssertionError:
 
1761
            raise AssertionError(args)
 
1762
 
 
1763
 
 
1764
class TestGrabKey(unittest.TestCase):
 
1765
    def setUp(self):
 
1766
        self.req_args_0 = {
 
1767
            'owner_events': 1,
 
1768
            'grab_window': 1467490800,
 
1769
            'pointer_mode': 0,
 
1770
            'keyboard_mode': 0,
 
1771
            'modifiers': 28819,
 
1772
            'key': 193,
 
1773
            }
 
1774
        self.req_bin_0 = '\x21\x01\x00\x04' '\x57\x78\x21\xf0' \
 
1775
            '\x70\x93\xc1\x00' '\x00\x00\x00\x00'
 
1776
 
 
1777
 
 
1778
    def testPackRequest0(self):
 
1779
        bin = apply(request.GrabKey._request.to_binary, (), self.req_args_0)
 
1780
        try:
 
1781
            assert bin == self.req_bin_0
 
1782
        except AssertionError:
 
1783
            raise AssertionError(tohex(bin))
 
1784
 
 
1785
    def testUnpackRequest0(self):
 
1786
        args, remain = request.GrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1787
        try:
 
1788
            assert len(remain) == 0
 
1789
        except AssertionError:
 
1790
            raise AssertionError(tohex(remain))
 
1791
        try:
 
1792
            assert args == self.req_args_0
 
1793
        except AssertionError:
 
1794
            raise AssertionError(args)
 
1795
 
 
1796
 
 
1797
class TestUngrabKey(unittest.TestCase):
 
1798
    def setUp(self):
 
1799
        self.req_args_0 = {
 
1800
            'grab_window': 769929659,
 
1801
            'key': 215,
 
1802
            'modifiers': 60588,
 
1803
            }
 
1804
        self.req_bin_0 = '\x22\xd7\x00\x03' '\x2d\xe4\x31\xbb' \
 
1805
            '\xec\xac\x00\x00'
 
1806
 
 
1807
 
 
1808
    def testPackRequest0(self):
 
1809
        bin = apply(request.UngrabKey._request.to_binary, (), self.req_args_0)
 
1810
        try:
 
1811
            assert bin == self.req_bin_0
 
1812
        except AssertionError:
 
1813
            raise AssertionError(tohex(bin))
 
1814
 
 
1815
    def testUnpackRequest0(self):
 
1816
        args, remain = request.UngrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1817
        try:
 
1818
            assert len(remain) == 0
 
1819
        except AssertionError:
 
1820
            raise AssertionError(tohex(remain))
 
1821
        try:
 
1822
            assert args == self.req_args_0
 
1823
        except AssertionError:
 
1824
            raise AssertionError(args)
 
1825
 
 
1826
 
 
1827
class TestAllowEvents(unittest.TestCase):
 
1828
    def setUp(self):
 
1829
        self.req_args_0 = {
 
1830
            'time': 342147129,
 
1831
            'mode': 1,
 
1832
            }
 
1833
        self.req_bin_0 = '\x23\x01\x00\x02' '\x14\x64\xc0\x39'
 
1834
 
 
1835
 
 
1836
    def testPackRequest0(self):
 
1837
        bin = apply(request.AllowEvents._request.to_binary, (), self.req_args_0)
 
1838
        try:
 
1839
            assert bin == self.req_bin_0
 
1840
        except AssertionError:
 
1841
            raise AssertionError(tohex(bin))
 
1842
 
 
1843
    def testUnpackRequest0(self):
 
1844
        args, remain = request.AllowEvents._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1845
        try:
 
1846
            assert len(remain) == 0
 
1847
        except AssertionError:
 
1848
            raise AssertionError(tohex(remain))
 
1849
        try:
 
1850
            assert args == self.req_args_0
 
1851
        except AssertionError:
 
1852
            raise AssertionError(args)
 
1853
 
 
1854
 
 
1855
class TestGrabServer(unittest.TestCase):
 
1856
    def setUp(self):
 
1857
        self.req_args_0 = {
 
1858
            }
 
1859
        self.req_bin_0 = '\x24\x00\x00\x01'
 
1860
 
 
1861
 
 
1862
    def testPackRequest0(self):
 
1863
        bin = apply(request.GrabServer._request.to_binary, (), self.req_args_0)
 
1864
        try:
 
1865
            assert bin == self.req_bin_0
 
1866
        except AssertionError:
 
1867
            raise AssertionError(tohex(bin))
 
1868
 
 
1869
    def testUnpackRequest0(self):
 
1870
        args, remain = request.GrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1871
        try:
 
1872
            assert len(remain) == 0
 
1873
        except AssertionError:
 
1874
            raise AssertionError(tohex(remain))
 
1875
        try:
 
1876
            assert args == self.req_args_0
 
1877
        except AssertionError:
 
1878
            raise AssertionError(args)
 
1879
 
 
1880
 
 
1881
class TestUngrabServer(unittest.TestCase):
 
1882
    def setUp(self):
 
1883
        self.req_args_0 = {
 
1884
            }
 
1885
        self.req_bin_0 = '\x25\x00\x00\x01'
 
1886
 
 
1887
 
 
1888
    def testPackRequest0(self):
 
1889
        bin = apply(request.UngrabServer._request.to_binary, (), self.req_args_0)
 
1890
        try:
 
1891
            assert bin == self.req_bin_0
 
1892
        except AssertionError:
 
1893
            raise AssertionError(tohex(bin))
 
1894
 
 
1895
    def testUnpackRequest0(self):
 
1896
        args, remain = request.UngrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1897
        try:
 
1898
            assert len(remain) == 0
 
1899
        except AssertionError:
 
1900
            raise AssertionError(tohex(remain))
 
1901
        try:
 
1902
            assert args == self.req_args_0
 
1903
        except AssertionError:
 
1904
            raise AssertionError(args)
 
1905
 
 
1906
 
 
1907
class TestQueryPointer(unittest.TestCase):
 
1908
    def setUp(self):
 
1909
        self.req_args_0 = {
 
1910
            'window': 561336799,
 
1911
            }
 
1912
        self.req_bin_0 = '\x26\x00\x00\x02' '\x21\x75\x51\xdf'
 
1913
 
 
1914
        self.reply_args_0 = {
 
1915
            'win_y': -25733,
 
1916
            'same_screen': 0,
 
1917
            'sequence_number': 41448,
 
1918
            'root': 1599238998,
 
1919
            'root_x': -4185,
 
1920
            'root_y': -6112,
 
1921
            'mask': 35955,
 
1922
            'child': 1075058918,
 
1923
            'win_x': -18858,
 
1924
            }
 
1925
        self.reply_bin_0 = '\x01\x00\xa1\xe8' '\x00\x00\x00\x00' \
 
1926
            '\x5f\x52\x73\x56' '\x40\x14\x18\xe6' \
 
1927
            '\xef\xa7\xe8\x20' '\xb6\x56\x9b\x7b' \
 
1928
            '\x8c\x73\x00\x00' '\x00\x00\x00\x00'
 
1929
 
 
1930
 
 
1931
    def testPackRequest0(self):
 
1932
        bin = apply(request.QueryPointer._request.to_binary, (), self.req_args_0)
 
1933
        try:
 
1934
            assert bin == self.req_bin_0
 
1935
        except AssertionError:
 
1936
            raise AssertionError(tohex(bin))
 
1937
 
 
1938
    def testUnpackRequest0(self):
 
1939
        args, remain = request.QueryPointer._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
1940
        try:
 
1941
            assert len(remain) == 0
 
1942
        except AssertionError:
 
1943
            raise AssertionError(tohex(remain))
 
1944
        try:
 
1945
            assert args == self.req_args_0
 
1946
        except AssertionError:
 
1947
            raise AssertionError(args)
 
1948
 
 
1949
    def testPackReply0(self):
 
1950
        bin = apply(request.QueryPointer._reply.to_binary, (), self.reply_args_0)
 
1951
        try:
 
1952
            assert bin == self.reply_bin_0
 
1953
        except AssertionError:
 
1954
            raise AssertionError(tohex(bin))
 
1955
 
 
1956
    def testUnpackReply0(self):
 
1957
        args, remain = request.QueryPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
1958
        try:
 
1959
            assert len(remain) == 0
 
1960
        except AssertionError:
 
1961
            raise AssertionError(tohex(remain))
 
1962
        try:
 
1963
            assert args == self.reply_args_0
 
1964
        except AssertionError:
 
1965
            raise AssertionError(args)
 
1966
 
 
1967
 
 
1968
class TestGetMotionEvents(unittest.TestCase):
 
1969
    def setUp(self):
 
1970
        self.req_args_0 = {
 
1971
            'window': 843681780,
 
1972
            'start': 1520150500,
 
1973
            'stop': 11115313,
 
1974
            }
 
1975
        self.req_bin_0 = '\x27\x00\x00\x04' '\x32\x49\x8f\xf4' \
 
1976
            '\x5a\x9b\xa7\xe4' '\x00\xa9\x9b\x31'
 
1977
 
 
1978
        self.reply_args_0 = {
 
1979
            'sequence_number': 52222,
 
1980
            'events': [{'time': 2107444516, 'x': -649, 'y': -11631}, {'time': 1827536960, 'x': -18061, 'y': -2301}, {'time': 554175146, 'x': -32111, 'y': -13522}, {'time': 608168588, 'x': -5963, 'y': -24618}, {'time': 590416221, 'x': -3325, 'y': -19656}],
 
1981
            }
 
1982
        self.reply_bin_0 = '\x01\x00\xcb\xfe' '\x00\x00\x00\x0a' \
 
1983
            '\x00\x00\x00\x05' '\x00\x00\x00\x00' \
 
1984
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1985
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
1986
            '\x7d\x9d\x0d\x24' '\xfd\x77\xd2\x91' \
 
1987
            '\x6c\xee\x00\x40' '\xb9\x73\xf7\x03' \
 
1988
            '\x21\x08\x0a\xaa' '\x82\x91\xcb\x2e' \
 
1989
            '\x24\x3f\xea\x8c' '\xe8\xb5\x9f\xd6' \
 
1990
            '\x23\x31\x09\x5d' '\xf3\x03\xb3\x38'
 
1991
 
 
1992
 
 
1993
    def testPackRequest0(self):
 
1994
        bin = apply(request.GetMotionEvents._request.to_binary, (), self.req_args_0)
 
1995
        try:
 
1996
            assert bin == self.req_bin_0
 
1997
        except AssertionError:
 
1998
            raise AssertionError(tohex(bin))
 
1999
 
 
2000
    def testUnpackRequest0(self):
 
2001
        args, remain = request.GetMotionEvents._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2002
        try:
 
2003
            assert len(remain) == 0
 
2004
        except AssertionError:
 
2005
            raise AssertionError(tohex(remain))
 
2006
        try:
 
2007
            assert args == self.req_args_0
 
2008
        except AssertionError:
 
2009
            raise AssertionError(args)
 
2010
 
 
2011
    def testPackReply0(self):
 
2012
        bin = apply(request.GetMotionEvents._reply.to_binary, (), self.reply_args_0)
 
2013
        try:
 
2014
            assert bin == self.reply_bin_0
 
2015
        except AssertionError:
 
2016
            raise AssertionError(tohex(bin))
 
2017
 
 
2018
    def testUnpackReply0(self):
 
2019
        args, remain = request.GetMotionEvents._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
2020
        try:
 
2021
            assert len(remain) == 0
 
2022
        except AssertionError:
 
2023
            raise AssertionError(tohex(remain))
 
2024
        try:
 
2025
            assert args == self.reply_args_0
 
2026
        except AssertionError:
 
2027
            raise AssertionError(args)
 
2028
 
 
2029
 
 
2030
class TestTranslateCoords(unittest.TestCase):
 
2031
    def setUp(self):
 
2032
        self.req_args_0 = {
 
2033
            'src_y': -27247,
 
2034
            'src_x': -25331,
 
2035
            'src_wid': 257619448,
 
2036
            'dst_wid': 1238981863,
 
2037
            }
 
2038
        self.req_bin_0 = '\x28\x00\x00\x04' '\x0f\x5a\xf5\xf8' \
 
2039
            '\x49\xd9\x5c\xe7' '\x9d\x0d\x95\x91'
 
2040
 
 
2041
        self.reply_args_0 = {
 
2042
            'child': 2050350678,
 
2043
            'same_screen': 1,
 
2044
            'sequence_number': 38657,
 
2045
            'x': -18096,
 
2046
            'y': -5252,
 
2047
            }
 
2048
        self.reply_bin_0 = '\x01\x01\x97\x01' '\x00\x00\x00\x00' \
 
2049
            '\x7a\x35\xde\x56' '\xb9\x50\xeb\x7c' \
 
2050
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
2051
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
2052
 
 
2053
 
 
2054
    def testPackRequest0(self):
 
2055
        bin = apply(request.TranslateCoords._request.to_binary, (), self.req_args_0)
 
2056
        try:
 
2057
            assert bin == self.req_bin_0
 
2058
        except AssertionError:
 
2059
            raise AssertionError(tohex(bin))
 
2060
 
 
2061
    def testUnpackRequest0(self):
 
2062
        args, remain = request.TranslateCoords._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2063
        try:
 
2064
            assert len(remain) == 0
 
2065
        except AssertionError:
 
2066
            raise AssertionError(tohex(remain))
 
2067
        try:
 
2068
            assert args == self.req_args_0
 
2069
        except AssertionError:
 
2070
            raise AssertionError(args)
 
2071
 
 
2072
    def testPackReply0(self):
 
2073
        bin = apply(request.TranslateCoords._reply.to_binary, (), self.reply_args_0)
 
2074
        try:
 
2075
            assert bin == self.reply_bin_0
 
2076
        except AssertionError:
 
2077
            raise AssertionError(tohex(bin))
 
2078
 
 
2079
    def testUnpackReply0(self):
 
2080
        args, remain = request.TranslateCoords._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
2081
        try:
 
2082
            assert len(remain) == 0
 
2083
        except AssertionError:
 
2084
            raise AssertionError(tohex(remain))
 
2085
        try:
 
2086
            assert args == self.reply_args_0
 
2087
        except AssertionError:
 
2088
            raise AssertionError(args)
 
2089
 
 
2090
 
 
2091
class TestWarpPointer(unittest.TestCase):
 
2092
    def setUp(self):
 
2093
        self.req_args_0 = {
 
2094
            'src_height': 56634,
 
2095
            'src_window': 1335081711,
 
2096
            'dst_window': 675547124,
 
2097
            'src_width': 21809,
 
2098
            'src_y': -26071,
 
2099
            'src_x': -27119,
 
2100
            'dst_x': -30516,
 
2101
            'dst_y': -24204,
 
2102
            }
 
2103
        self.req_bin_0 = '\x29\x00\x00\x06' '\x4f\x93\xba\xef' \
 
2104
            '\x28\x44\x07\xf4' '\x96\x11\x9a\x29' \
 
2105
            '\x55\x31\xdd\x3a' '\x88\xcc\xa1\x74'
 
2106
 
 
2107
 
 
2108
    def testPackRequest0(self):
 
2109
        bin = apply(request.WarpPointer._request.to_binary, (), self.req_args_0)
 
2110
        try:
 
2111
            assert bin == self.req_bin_0
 
2112
        except AssertionError:
 
2113
            raise AssertionError(tohex(bin))
 
2114
 
 
2115
    def testUnpackRequest0(self):
 
2116
        args, remain = request.WarpPointer._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2117
        try:
 
2118
            assert len(remain) == 0
 
2119
        except AssertionError:
 
2120
            raise AssertionError(tohex(remain))
 
2121
        try:
 
2122
            assert args == self.req_args_0
 
2123
        except AssertionError:
 
2124
            raise AssertionError(args)
 
2125
 
 
2126
 
 
2127
class TestSetInputFocus(unittest.TestCase):
 
2128
    def setUp(self):
 
2129
        self.req_args_0 = {
 
2130
            'revert_to': 1,
 
2131
            'time': 1079702500,
 
2132
            'focus': 1026400247,
 
2133
            }
 
2134
        self.req_bin_0 = '\x2a\x01\x00\x03' '\x3d\x2d\x9f\xf7' \
 
2135
            '\x40\x5a\xf3\xe4'
 
2136
 
 
2137
 
 
2138
    def testPackRequest0(self):
 
2139
        bin = apply(request.SetInputFocus._request.to_binary, (), self.req_args_0)
 
2140
        try:
 
2141
            assert bin == self.req_bin_0
 
2142
        except AssertionError:
 
2143
            raise AssertionError(tohex(bin))
 
2144
 
 
2145
    def testUnpackRequest0(self):
 
2146
        args, remain = request.SetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2147
        try:
 
2148
            assert len(remain) == 0
 
2149
        except AssertionError:
 
2150
            raise AssertionError(tohex(remain))
 
2151
        try:
 
2152
            assert args == self.req_args_0
 
2153
        except AssertionError:
 
2154
            raise AssertionError(args)
 
2155
 
 
2156
 
 
2157
class TestGetInputFocus(unittest.TestCase):
 
2158
    def setUp(self):
 
2159
        self.req_args_0 = {
 
2160
            }
 
2161
        self.req_bin_0 = '\x2b\x00\x00\x01'
 
2162
 
 
2163
        self.reply_args_0 = {
 
2164
            'revert_to': 152,
 
2165
            'sequence_number': 16002,
 
2166
            'focus': 2024022965,
 
2167
            }
 
2168
        self.reply_bin_0 = '\x01\x98\x3e\x82' '\x00\x00\x00\x00' \
 
2169
            '\x78\xa4\x23\xb5' '\x00\x00\x00\x00' \
 
2170
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
2171
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
2172
 
 
2173
 
 
2174
    def testPackRequest0(self):
 
2175
        bin = apply(request.GetInputFocus._request.to_binary, (), self.req_args_0)
 
2176
        try:
 
2177
            assert bin == self.req_bin_0
 
2178
        except AssertionError:
 
2179
            raise AssertionError(tohex(bin))
 
2180
 
 
2181
    def testUnpackRequest0(self):
 
2182
        args, remain = request.GetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2183
        try:
 
2184
            assert len(remain) == 0
 
2185
        except AssertionError:
 
2186
            raise AssertionError(tohex(remain))
 
2187
        try:
 
2188
            assert args == self.req_args_0
 
2189
        except AssertionError:
 
2190
            raise AssertionError(args)
 
2191
 
 
2192
    def testPackReply0(self):
 
2193
        bin = apply(request.GetInputFocus._reply.to_binary, (), self.reply_args_0)
 
2194
        try:
 
2195
            assert bin == self.reply_bin_0
 
2196
        except AssertionError:
 
2197
            raise AssertionError(tohex(bin))
 
2198
 
 
2199
    def testUnpackReply0(self):
 
2200
        args, remain = request.GetInputFocus._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
2201
        try:
 
2202
            assert len(remain) == 0
 
2203
        except AssertionError:
 
2204
            raise AssertionError(tohex(remain))
 
2205
        try:
 
2206
            assert args == self.reply_args_0
 
2207
        except AssertionError:
 
2208
            raise AssertionError(args)
 
2209
 
 
2210
 
 
2211
class TestQueryKeymap(unittest.TestCase):
 
2212
    def setUp(self):
 
2213
        self.req_args_0 = {
 
2214
            }
 
2215
        self.req_bin_0 = '\x2c\x00\x00\x01'
 
2216
 
 
2217
        self.reply_args_0 = {
 
2218
            'sequence_number': 16233,
 
2219
            'map': [186, 167, 191, 213, 241, 231, 234, 175, 154, 169, 132, 146, 215, 191, 196, 212, 158, 156, 177, 233, 220, 192, 130, 226, 181, 233, 238, 141, 129, 215, 245, 215],
 
2220
            }
 
2221
        self.reply_bin_0 = '\x01\x00\x3f\x69' '\x00\x00\x00\x02' \
 
2222
            '\xba\xa7\xbf\xd5' '\xf1\xe7\xea\xaf' \
 
2223
            '\x9a\xa9\x84\x92' '\xd7\xbf\xc4\xd4' \
 
2224
            '\x9e\x9c\xb1\xe9' '\xdc\xc0\x82\xe2' \
 
2225
            '\xb5\xe9\xee\x8d' '\x81\xd7\xf5\xd7'
 
2226
 
 
2227
 
 
2228
    def testPackRequest0(self):
 
2229
        bin = apply(request.QueryKeymap._request.to_binary, (), self.req_args_0)
 
2230
        try:
 
2231
            assert bin == self.req_bin_0
 
2232
        except AssertionError:
 
2233
            raise AssertionError(tohex(bin))
 
2234
 
 
2235
    def testUnpackRequest0(self):
 
2236
        args, remain = request.QueryKeymap._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2237
        try:
 
2238
            assert len(remain) == 0
 
2239
        except AssertionError:
 
2240
            raise AssertionError(tohex(remain))
 
2241
        try:
 
2242
            assert args == self.req_args_0
 
2243
        except AssertionError:
 
2244
            raise AssertionError(args)
 
2245
 
 
2246
    def testPackReply0(self):
 
2247
        bin = apply(request.QueryKeymap._reply.to_binary, (), self.reply_args_0)
 
2248
        try:
 
2249
            assert bin == self.reply_bin_0
 
2250
        except AssertionError:
 
2251
            raise AssertionError(tohex(bin))
 
2252
 
 
2253
    def testUnpackReply0(self):
 
2254
        args, remain = request.QueryKeymap._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
2255
        try:
 
2256
            assert len(remain) == 0
 
2257
        except AssertionError:
 
2258
            raise AssertionError(tohex(remain))
 
2259
        try:
 
2260
            assert args == self.reply_args_0
 
2261
        except AssertionError:
 
2262
            raise AssertionError(args)
 
2263
 
 
2264
 
 
2265
class TestOpenFont(unittest.TestCase):
 
2266
    def setUp(self):
 
2267
        self.req_args_0 = {
 
2268
            'fid': 1728036313,
 
2269
            'name': 'foofont',
 
2270
            }
 
2271
        self.req_bin_0 = '\x2d\x00\x00\x05' '\x66\xff\xbd\xd9' \
 
2272
            '\x00\x07\x00\x00' '\x66\x6f\x6f\x66' \
 
2273
            '\x6f\x6e\x74\x00'
 
2274
 
 
2275
 
 
2276
    def testPackRequest0(self):
 
2277
        bin = apply(request.OpenFont._request.to_binary, (), self.req_args_0)
 
2278
        try:
 
2279
            assert bin == self.req_bin_0
 
2280
        except AssertionError:
 
2281
            raise AssertionError(tohex(bin))
 
2282
 
 
2283
    def testUnpackRequest0(self):
 
2284
        args, remain = request.OpenFont._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2285
        try:
 
2286
            assert len(remain) == 0
 
2287
        except AssertionError:
 
2288
            raise AssertionError(tohex(remain))
 
2289
        try:
 
2290
            assert args == self.req_args_0
 
2291
        except AssertionError:
 
2292
            raise AssertionError(args)
 
2293
 
 
2294
 
 
2295
class TestCloseFont(unittest.TestCase):
 
2296
    def setUp(self):
 
2297
        self.req_args_0 = {
 
2298
            'font': 1139770507,
 
2299
            }
 
2300
        self.req_bin_0 = '\x2e\x00\x00\x02' '\x43\xef\x84\x8b'
 
2301
 
 
2302
 
 
2303
    def testPackRequest0(self):
 
2304
        bin = apply(request.CloseFont._request.to_binary, (), self.req_args_0)
 
2305
        try:
 
2306
            assert bin == self.req_bin_0
 
2307
        except AssertionError:
 
2308
            raise AssertionError(tohex(bin))
 
2309
 
 
2310
    def testUnpackRequest0(self):
 
2311
        args, remain = request.CloseFont._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2312
        try:
 
2313
            assert len(remain) == 0
 
2314
        except AssertionError:
 
2315
            raise AssertionError(tohex(remain))
 
2316
        try:
 
2317
            assert args == self.req_args_0
 
2318
        except AssertionError:
 
2319
            raise AssertionError(args)
 
2320
 
 
2321
 
 
2322
class TestQueryFont(unittest.TestCase):
 
2323
    def setUp(self):
 
2324
        self.req_args_0 = {
 
2325
            'font': 1867659050,
 
2326
            }
 
2327
        self.req_bin_0 = '\x2f\x00\x00\x02' '\x6f\x52\x37\x2a'
 
2328
 
 
2329
        self.reply_args_0 = {
 
2330
            'sequence_number': 8877,
 
2331
            'properties': [{'value': 2110348825, 'name': 1450586355}],
 
2332
            'min_byte1': 190,
 
2333
            'max_byte1': 168,
 
2334
            'char_infos': [{'descent': -331, 'ascent': -14454, 'character_width': -28521, 'left_side_bearing': -4521, 'right_side_bearing': -9875, 'attributes': 55191}, {'descent': -18739, 'ascent': -6278, 'character_width': -4532, 'left_side_bearing': -20397, 'right_side_bearing': -25187, 'attributes': 29476}, {'descent': -18381, 'ascent': -2378, 'character_width': -21855, 'left_side_bearing': -20068, 'right_side_bearing': -906, 'attributes': 34385}],
 
2335
            'max_char_or_byte2': 2516,
 
2336
            'default_char': 8994,
 
2337
            'min_char_or_byte2': 49360,
 
2338
            'draw_direction': 143,
 
2339
            'min_bounds': {'descent': -29813, 'ascent': -27033, 'character_width': -5286, 'left_side_bearing': -20740, 'right_side_bearing': -21698, 'attributes': 11392},
 
2340
            'all_chars_exist': 1,
 
2341
            'font_ascent': -15646,
 
2342
            'font_descent': -23067,
 
2343
            'max_bounds': {'descent': -24292, 'ascent': -26972, 'character_width': -19286, 'left_side_bearing': -16363, 'right_side_bearing': -3149, 'attributes': 35968},
 
2344
            }
 
2345
        self.reply_bin_0 = '\x01\x00\x22\xad' '\x00\x00\x00\x12' \
 
2346
            '\xae\xfc\xab\x3e' '\xeb\x5a\x96\x67' \
 
2347
            '\x8b\x8b\x2c\x80' '\x00\x00\x00\x00' \
 
2348
            '\xc0\x15\xf3\xb3' '\xb4\xaa\x96\xa4' \
 
2349
            '\xa1\x1c\x8c\x80' '\x00\x00\x00\x00' \
 
2350
            '\xc0\xd0\x09\xd4' '\x23\x22\x00\x01' \
 
2351
            '\x8f\xbe\xa8\x01' '\xc2\xe2\xa5\xe5' \
 
2352
            '\x00\x00\x00\x03' '\x56\x76\x30\xf3' \
 
2353
            '\x7d\xc9\x5e\x19' '\xee\x57\xd9\x6d' \
 
2354
            '\x90\x97\xc7\x8a' '\xfe\xb5\xd7\x97' \
 
2355
            '\xb0\x53\x9d\x9d' '\xee\x4c\xe7\x7a' \
 
2356
            '\xb6\xcd\x73\x24' '\xb1\x9c\xfc\x76' \
 
2357
            '\xaa\xa1\xf6\xb6' '\xb8\x33\x86\x51'
 
2358
 
 
2359
 
 
2360
    def testPackRequest0(self):
 
2361
        bin = apply(request.QueryFont._request.to_binary, (), self.req_args_0)
 
2362
        try:
 
2363
            assert bin == self.req_bin_0
 
2364
        except AssertionError:
 
2365
            raise AssertionError(tohex(bin))
 
2366
 
 
2367
    def testUnpackRequest0(self):
 
2368
        args, remain = request.QueryFont._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2369
        try:
 
2370
            assert len(remain) == 0
 
2371
        except AssertionError:
 
2372
            raise AssertionError(tohex(remain))
 
2373
        try:
 
2374
            assert args == self.req_args_0
 
2375
        except AssertionError:
 
2376
            raise AssertionError(args)
 
2377
 
 
2378
    def testPackReply0(self):
 
2379
        bin = apply(request.QueryFont._reply.to_binary, (), self.reply_args_0)
 
2380
        try:
 
2381
            assert bin == self.reply_bin_0
 
2382
        except AssertionError:
 
2383
            raise AssertionError(tohex(bin))
 
2384
 
 
2385
    def testUnpackReply0(self):
 
2386
        args, remain = request.QueryFont._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
2387
        try:
 
2388
            assert len(remain) == 0
 
2389
        except AssertionError:
 
2390
            raise AssertionError(tohex(remain))
 
2391
        try:
 
2392
            assert args == self.reply_args_0
 
2393
        except AssertionError:
 
2394
            raise AssertionError(args)
 
2395
 
 
2396
 
 
2397
class TestQueryTextExtents(unittest.TestCase):
 
2398
    def setUp(self):
 
2399
        self.req_args_0 = {
 
2400
            'font': 1562125736,
 
2401
            'string': (102, 111, 111),
 
2402
            }
 
2403
        self.req_bin_0 = '\x30\x01\x00\x04' '\x5d\x1c\x25\xa8' \
 
2404
            '\x00\x66\x00\x6f' '\x00\x6f\x00\x00'
 
2405
 
 
2406
        self.reply_args_0 = {
 
2407
            'overall_width': -1378352414,
 
2408
            'draw_direction': 219,
 
2409
            'sequence_number': 6791,
 
2410
            'font_ascent': -16915,
 
2411
            'overall_ascent': -22910,
 
2412
            'overall_descent': -1795,
 
2413
            'overall_right': -530284310,
 
2414
            'overall_left': -1046976699,
 
2415
            'font_descent': -14179,
 
2416
            }
 
2417
        self.reply_bin_0 = '\x01\xdb\x1a\x87' '\x00\x00\x00\x00' \
 
2418
            '\xbd\xed\xc8\x9d' '\xa6\x82\xf8\xfd' \
 
2419
            '\xad\xd8\x02\xe2' '\xc1\x98\x67\x45' \
 
2420
            '\xe0\x64\x80\xea' '\x00\x00\x00\x00'
 
2421
 
 
2422
 
 
2423
    def testPackRequest0(self):
 
2424
        bin = apply(request.QueryTextExtents._request.to_binary, (), self.req_args_0)
 
2425
        try:
 
2426
            assert bin == self.req_bin_0
 
2427
        except AssertionError:
 
2428
            raise AssertionError(tohex(bin))
 
2429
 
 
2430
    def testUnpackRequest0(self):
 
2431
        args, remain = request.QueryTextExtents._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2432
        try:
 
2433
            assert len(remain) == 0
 
2434
        except AssertionError:
 
2435
            raise AssertionError(tohex(remain))
 
2436
        try:
 
2437
            assert args == self.req_args_0
 
2438
        except AssertionError:
 
2439
            raise AssertionError(args)
 
2440
 
 
2441
    def testPackReply0(self):
 
2442
        bin = apply(request.QueryTextExtents._reply.to_binary, (), self.reply_args_0)
 
2443
        try:
 
2444
            assert bin == self.reply_bin_0
 
2445
        except AssertionError:
 
2446
            raise AssertionError(tohex(bin))
 
2447
 
 
2448
    def testUnpackReply0(self):
 
2449
        args, remain = request.QueryTextExtents._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
2450
        try:
 
2451
            assert len(remain) == 0
 
2452
        except AssertionError:
 
2453
            raise AssertionError(tohex(remain))
 
2454
        try:
 
2455
            assert args == self.reply_args_0
 
2456
        except AssertionError:
 
2457
            raise AssertionError(args)
 
2458
 
 
2459
 
 
2460
class TestListFonts(unittest.TestCase):
 
2461
    def setUp(self):
 
2462
        self.req_args_0 = {
 
2463
            'max_names': 53961,
 
2464
            'pattern': 'bhazr',
 
2465
            }
 
2466
        self.req_bin_0 = '\x31\x00\x00\x04' '\xd2\xc9\x00\x05' \
 
2467
            '\x62\x68\x61\x7a' '\x72\x00\x00\x00'
 
2468
 
 
2469
        self.reply_args_0 = {
 
2470
            'fonts': ['fie', 'fuzzy', 'foozooom'],
 
2471
            'sequence_number': 38267,
 
2472
            }
 
2473
        self.reply_bin_0 = '\x01\x00\x95\x7b' '\x00\x00\x00\x05' \
 
2474
            '\x00\x03\x00\x00' '\x00\x00\x00\x00' \
 
2475
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
2476
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
2477
            '\x03\x66\x69\x65' '\x05\x66\x75\x7a' \
 
2478
            '\x7a\x79\x08\x66' '\x6f\x6f\x7a\x6f' \
 
2479
            '\x6f\x6f\x6d\x00'
 
2480
 
 
2481
 
 
2482
    def testPackRequest0(self):
 
2483
        bin = apply(request.ListFonts._request.to_binary, (), self.req_args_0)
 
2484
        try:
 
2485
            assert bin == self.req_bin_0
 
2486
        except AssertionError:
 
2487
            raise AssertionError(tohex(bin))
 
2488
 
 
2489
    def testUnpackRequest0(self):
 
2490
        args, remain = request.ListFonts._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2491
        try:
 
2492
            assert len(remain) == 0
 
2493
        except AssertionError:
 
2494
            raise AssertionError(tohex(remain))
 
2495
        try:
 
2496
            assert args == self.req_args_0
 
2497
        except AssertionError:
 
2498
            raise AssertionError(args)
 
2499
 
 
2500
    def testPackReply0(self):
 
2501
        bin = apply(request.ListFonts._reply.to_binary, (), self.reply_args_0)
 
2502
        try:
 
2503
            assert bin == self.reply_bin_0
 
2504
        except AssertionError:
 
2505
            raise AssertionError(tohex(bin))
 
2506
 
 
2507
    def testUnpackReply0(self):
 
2508
        args, remain = request.ListFonts._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
2509
        try:
 
2510
            assert len(remain) == 0
 
2511
        except AssertionError:
 
2512
            raise AssertionError(tohex(remain))
 
2513
        try:
 
2514
            assert args == self.reply_args_0
 
2515
        except AssertionError:
 
2516
            raise AssertionError(args)
 
2517
 
 
2518
 
 
2519
class TestListFontsWithInfo(unittest.TestCase):
 
2520
    def setUp(self):
 
2521
        self.req_args_0 = {
 
2522
            'max_names': 46571,
 
2523
            'pattern': 'bhazr2',
 
2524
            }
 
2525
        self.req_bin_0 = '\x32\x00\x00\x04' '\xb5\xeb\x00\x06' \
 
2526
            '\x62\x68\x61\x7a' '\x72\x32\x00\x00'
 
2527
 
 
2528
        self.reply_args_0 = {
 
2529
            'sequence_number': 20014,
 
2530
            'properties': [{'value': 2110430409, 'name': 435956656}],
 
2531
            'min_byte1': 214,
 
2532
            'max_byte1': 217,
 
2533
            'max_char_or_byte2': 2479,
 
2534
            'default_char': 17041,
 
2535
            'min_char_or_byte2': 26638,
 
2536
            'draw_direction': 192,
 
2537
            'replies_hint': 1985190562,
 
2538
            'min_bounds': {'descent': -27837, 'ascent': -14775, 'character_width': -13026, 'left_side_bearing': -29767, 'right_side_bearing': -31908, 'attributes': 2465},
 
2539
            'all_chars_exist': 0,
 
2540
            'name': 'fontfont',
 
2541
            'font_ascent': -30550,
 
2542
            'font_descent': -28978,
 
2543
            'max_bounds': {'descent': -20692, 'ascent': -6999, 'character_width': -15180, 'left_side_bearing': -7789, 'right_side_bearing': -5339, 'attributes': 1068},
 
2544
            }
 
2545
        self.reply_bin_0 = '\x01\x08\x4e\x2e' '\x00\x00\x00\x0b' \
 
2546
            '\x8b\xb9\x83\x5c' '\xcd\x1e\xc6\x49' \
 
2547
            '\x93\x43\x09\xa1' '\x00\x00\x00\x00' \
 
2548
            '\xe1\x93\xeb\x25' '\xc4\xb4\xe4\xa9' \
 
2549
            '\xaf\x2c\x04\x2c' '\x00\x00\x00\x00' \
 
2550
            '\x68\x0e\x09\xaf' '\x42\x91\x00\x01' \
 
2551
            '\xc0\xd6\xd9\x00' '\x88\xaa\x8e\xce' \
 
2552
            '\x76\x53\x9a\xa2' '\x19\xfc\x2b\xb0' \
 
2553
            '\x7d\xca\x9c\xc9' '\x66\x6f\x6e\x74' \
 
2554
            '\x66\x6f\x6e\x74'
 
2555
 
 
2556
 
 
2557
    def testPackRequest0(self):
 
2558
        bin = apply(request.ListFontsWithInfo._request.to_binary, (), self.req_args_0)
 
2559
        try:
 
2560
            assert bin == self.req_bin_0
 
2561
        except AssertionError:
 
2562
            raise AssertionError(tohex(bin))
 
2563
 
 
2564
    def testUnpackRequest0(self):
 
2565
        args, remain = request.ListFontsWithInfo._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2566
        try:
 
2567
            assert len(remain) == 0
 
2568
        except AssertionError:
 
2569
            raise AssertionError(tohex(remain))
 
2570
        try:
 
2571
            assert args == self.req_args_0
 
2572
        except AssertionError:
 
2573
            raise AssertionError(args)
 
2574
 
 
2575
    def testPackReply0(self):
 
2576
        bin = apply(request.ListFontsWithInfo._reply.to_binary, (), self.reply_args_0)
 
2577
        try:
 
2578
            assert bin == self.reply_bin_0
 
2579
        except AssertionError:
 
2580
            raise AssertionError(tohex(bin))
 
2581
 
 
2582
    def testUnpackReply0(self):
 
2583
        args, remain = request.ListFontsWithInfo._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
2584
        try:
 
2585
            assert len(remain) == 0
 
2586
        except AssertionError:
 
2587
            raise AssertionError(tohex(remain))
 
2588
        try:
 
2589
            assert args == self.reply_args_0
 
2590
        except AssertionError:
 
2591
            raise AssertionError(args)
 
2592
 
 
2593
 
 
2594
class TestSetFontPath(unittest.TestCase):
 
2595
    def setUp(self):
 
2596
        self.req_args_0 = {
 
2597
            'path': ['foo', 'bar', 'gazonk'],
 
2598
            }
 
2599
        self.req_bin_0 = '\x33\x00\x00\x06' '\x00\x03\x00\x00' \
 
2600
            '\x03\x66\x6f\x6f' '\x03\x62\x61\x72' \
 
2601
            '\x06\x67\x61\x7a' '\x6f\x6e\x6b\x00'
 
2602
 
 
2603
        self.req_args_1 = {
 
2604
            'path': [],
 
2605
            }
 
2606
        self.req_bin_1 = '\x33\x00\x00\x02' '\x00\x00\x00\x00'
 
2607
 
 
2608
 
 
2609
    def testPackRequest0(self):
 
2610
        bin = apply(request.SetFontPath._request.to_binary, (), self.req_args_0)
 
2611
        try:
 
2612
            assert bin == self.req_bin_0
 
2613
        except AssertionError:
 
2614
            raise AssertionError(tohex(bin))
 
2615
 
 
2616
    def testUnpackRequest0(self):
 
2617
        args, remain = request.SetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2618
        try:
 
2619
            assert len(remain) == 0
 
2620
        except AssertionError:
 
2621
            raise AssertionError(tohex(remain))
 
2622
        try:
 
2623
            assert args == self.req_args_0
 
2624
        except AssertionError:
 
2625
            raise AssertionError(args)
 
2626
 
 
2627
    def testPackRequest1(self):
 
2628
        bin = apply(request.SetFontPath._request.to_binary, (), self.req_args_1)
 
2629
        try:
 
2630
            assert bin == self.req_bin_1
 
2631
        except AssertionError:
 
2632
            raise AssertionError(tohex(bin))
 
2633
 
 
2634
    def testUnpackRequest1(self):
 
2635
        args, remain = request.SetFontPath._request.parse_binary(self.req_bin_1, dummy_display, 1)
 
2636
        try:
 
2637
            assert len(remain) == 0
 
2638
        except AssertionError:
 
2639
            raise AssertionError(tohex(remain))
 
2640
        try:
 
2641
            assert args == self.req_args_1
 
2642
        except AssertionError:
 
2643
            raise AssertionError(args)
 
2644
 
 
2645
 
 
2646
class TestGetFontPath(unittest.TestCase):
 
2647
    def setUp(self):
 
2648
        self.req_args_0 = {
 
2649
            }
 
2650
        self.req_bin_0 = '\x34\x00\x00\x01'
 
2651
 
 
2652
        self.reply_args_0 = {
 
2653
            'sequence_number': 21510,
 
2654
            'paths': ['path1', 'path2232'],
 
2655
            }
 
2656
        self.reply_bin_0 = '\x01\x00\x54\x06' '\x00\x00\x00\x04' \
 
2657
            '\x00\x02\x00\x00' '\x00\x00\x00\x00' \
 
2658
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
2659
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
2660
            '\x05\x70\x61\x74' '\x68\x31\x08\x70' \
 
2661
            '\x61\x74\x68\x32' '\x32\x33\x32\x00'
 
2662
 
 
2663
        self.reply_args_1 = {
 
2664
            'sequence_number': 62463,
 
2665
            'paths': [],
 
2666
            }
 
2667
        self.reply_bin_1 = '\x01\x00\xf3\xff' '\x00\x00\x00\x00' \
 
2668
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
2669
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
2670
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
2671
 
 
2672
 
 
2673
    def testPackRequest0(self):
 
2674
        bin = apply(request.GetFontPath._request.to_binary, (), self.req_args_0)
 
2675
        try:
 
2676
            assert bin == self.req_bin_0
 
2677
        except AssertionError:
 
2678
            raise AssertionError(tohex(bin))
 
2679
 
 
2680
    def testUnpackRequest0(self):
 
2681
        args, remain = request.GetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2682
        try:
 
2683
            assert len(remain) == 0
 
2684
        except AssertionError:
 
2685
            raise AssertionError(tohex(remain))
 
2686
        try:
 
2687
            assert args == self.req_args_0
 
2688
        except AssertionError:
 
2689
            raise AssertionError(args)
 
2690
 
 
2691
    def testPackReply0(self):
 
2692
        bin = apply(request.GetFontPath._reply.to_binary, (), self.reply_args_0)
 
2693
        try:
 
2694
            assert bin == self.reply_bin_0
 
2695
        except AssertionError:
 
2696
            raise AssertionError(tohex(bin))
 
2697
 
 
2698
    def testUnpackReply0(self):
 
2699
        args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
2700
        try:
 
2701
            assert len(remain) == 0
 
2702
        except AssertionError:
 
2703
            raise AssertionError(tohex(remain))
 
2704
        try:
 
2705
            assert args == self.reply_args_0
 
2706
        except AssertionError:
 
2707
            raise AssertionError(args)
 
2708
 
 
2709
    def testPackReply1(self):
 
2710
        bin = apply(request.GetFontPath._reply.to_binary, (), self.reply_args_1)
 
2711
        try:
 
2712
            assert bin == self.reply_bin_1
 
2713
        except AssertionError:
 
2714
            raise AssertionError(tohex(bin))
 
2715
 
 
2716
    def testUnpackReply1(self):
 
2717
        args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_1, dummy_display, 1)
 
2718
        try:
 
2719
            assert len(remain) == 0
 
2720
        except AssertionError:
 
2721
            raise AssertionError(tohex(remain))
 
2722
        try:
 
2723
            assert args == self.reply_args_1
 
2724
        except AssertionError:
 
2725
            raise AssertionError(args)
 
2726
 
 
2727
 
 
2728
class TestCreatePixmap(unittest.TestCase):
 
2729
    def setUp(self):
 
2730
        self.req_args_0 = {
 
2731
            'height': 65515,
 
2732
            'drawable': 162261202,
 
2733
            'pid': 926490960,
 
2734
            'depth': 145,
 
2735
            'width': 5641,
 
2736
            }
 
2737
        self.req_bin_0 = '\x35\x91\x00\x04' '\x37\x39\x21\x50' \
 
2738
            '\x09\xab\xe8\xd2' '\x16\x09\xff\xeb'
 
2739
 
 
2740
 
 
2741
    def testPackRequest0(self):
 
2742
        bin = apply(request.CreatePixmap._request.to_binary, (), self.req_args_0)
 
2743
        try:
 
2744
            assert bin == self.req_bin_0
 
2745
        except AssertionError:
 
2746
            raise AssertionError(tohex(bin))
 
2747
 
 
2748
    def testUnpackRequest0(self):
 
2749
        args, remain = request.CreatePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2750
        try:
 
2751
            assert len(remain) == 0
 
2752
        except AssertionError:
 
2753
            raise AssertionError(tohex(remain))
 
2754
        try:
 
2755
            assert args == self.req_args_0
 
2756
        except AssertionError:
 
2757
            raise AssertionError(args)
 
2758
 
 
2759
 
 
2760
class TestFreePixmap(unittest.TestCase):
 
2761
    def setUp(self):
 
2762
        self.req_args_0 = {
 
2763
            'pixmap': 213012851,
 
2764
            }
 
2765
        self.req_bin_0 = '\x36\x00\x00\x02' '\x0c\xb2\x51\x73'
 
2766
 
 
2767
 
 
2768
    def testPackRequest0(self):
 
2769
        bin = apply(request.FreePixmap._request.to_binary, (), self.req_args_0)
 
2770
        try:
 
2771
            assert bin == self.req_bin_0
 
2772
        except AssertionError:
 
2773
            raise AssertionError(tohex(bin))
 
2774
 
 
2775
    def testUnpackRequest0(self):
 
2776
        args, remain = request.FreePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2777
        try:
 
2778
            assert len(remain) == 0
 
2779
        except AssertionError:
 
2780
            raise AssertionError(tohex(remain))
 
2781
        try:
 
2782
            assert args == self.req_args_0
 
2783
        except AssertionError:
 
2784
            raise AssertionError(args)
 
2785
 
 
2786
 
 
2787
class TestCreateGC(unittest.TestCase):
 
2788
    def setUp(self):
 
2789
        self.req_args_0 = {
 
2790
            'cid': 1060658282,
 
2791
            'drawable': 456876463,
 
2792
            'attrs': {'dashes': 183, 'fill_rule': 0, 'clip_mask': 620422624, 'plane_mask': 1797423280, 'line_style': 1, 'tile': 77620460, 'arc_mode': 0, 'clip_y_origin': -7419, 'dash_offset': 62459, 'line_width': 50494, 'background': 44336037, 'clip_x_origin': -32045, 'join_style': 2, 'graphics_exposures': 0, 'font': 95118395, 'tile_stipple_y_origin': -17619, 'stipple': 631657813, 'fill_style': 0, 'cap_style': 0, 'subwindow_mode': 0, 'tile_stipple_x_origin': -12494, 'foreground': 2096879871, 'function': 10},
 
2793
            }
 
2794
        self.req_bin_0 = '\x37\x00\x00\x1b' '\x3f\x38\x5c\x6a' \
 
2795
            '\x1b\x3b\x61\xaf' '\x00\x7f\xff\xff' \
 
2796
            '\x0a\x00\x00\x00' '\x6b\x22\x80\xb0' \
 
2797
            '\x7c\xfb\xd8\xff' '\x02\xa4\x83\xa5' \
 
2798
            '\xc5\x3e\x00\x00' '\x01\x00\x00\x00' \
 
2799
            '\x00\x00\x00\x00' '\x02\x00\x00\x00' \
 
2800
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
2801
            '\x04\xa0\x64\xec' '\x25\xa6\x55\x55' \
 
2802
            '\xcf\x32\x00\x00' '\xbb\x2d\x00\x00' \
 
2803
            '\x05\xab\x64\x3b' '\x00\x00\x00\x00' \
 
2804
            '\x00\x00\x00\x00' '\x82\xd3\x00\x00' \
 
2805
            '\xe3\x05\x00\x00' '\x24\xfa\xe5\xe0' \
 
2806
            '\xf3\xfb\x00\x00' '\xb7\x00\x00\x00' \
 
2807
            '\x00\x00\x00\x00'
 
2808
 
 
2809
 
 
2810
    def testPackRequest0(self):
 
2811
        bin = apply(request.CreateGC._request.to_binary, (), self.req_args_0)
 
2812
        try:
 
2813
            assert bin == self.req_bin_0
 
2814
        except AssertionError:
 
2815
            raise AssertionError(tohex(bin))
 
2816
 
 
2817
    def testUnpackRequest0(self):
 
2818
        args, remain = request.CreateGC._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2819
        try:
 
2820
            assert len(remain) == 0
 
2821
        except AssertionError:
 
2822
            raise AssertionError(tohex(remain))
 
2823
        try:
 
2824
            assert args == self.req_args_0
 
2825
        except AssertionError:
 
2826
            raise AssertionError(args)
 
2827
 
 
2828
 
 
2829
class TestChangeGC(unittest.TestCase):
 
2830
    def setUp(self):
 
2831
        self.req_args_0 = {
 
2832
            'attrs': {'dashes': 249, 'fill_rule': 1, 'clip_mask': 496525721, 'plane_mask': 1467281901, 'line_style': 2, 'tile': 1713935374, 'arc_mode': 0, 'clip_y_origin': -24572, 'dash_offset': 46636, 'line_width': 61036, 'background': 1598773587, 'clip_x_origin': -19725, 'join_style': 1, 'graphics_exposures': 0, 'font': 429323306, 'tile_stipple_y_origin': -11767, 'stipple': 1365263649, 'fill_style': 2, 'cap_style': 1, 'subwindow_mode': 1, 'tile_stipple_x_origin': -23501, 'foreground': 1272378077, 'function': 11},
 
2833
            'gc': 518903558,
 
2834
            }
 
2835
        self.req_bin_0 = '\x38\x00\x00\x1a' '\x1e\xed\xd7\x06' \
 
2836
            '\x00\x7f\xff\xff' '\x0b\x00\x00\x00' \
 
2837
            '\x57\x74\xf1\xed' '\x4b\xd6\xf2\xdd' \
 
2838
            '\x5f\x4b\x59\x53' '\xee\x6c\x00\x00' \
 
2839
            '\x02\x00\x00\x00' '\x01\x00\x00\x00' \
 
2840
            '\x01\x00\x00\x00' '\x02\x00\x00\x00' \
 
2841
            '\x01\x00\x00\x00' '\x66\x28\x94\x0e' \
 
2842
            '\x51\x60\x45\x21' '\xa4\x33\x00\x00' \
 
2843
            '\xd2\x09\x00\x00' '\x19\x96\xf4\x2a' \
 
2844
            '\x01\x00\x00\x00' '\x00\x00\x00\x00' \
 
2845
            '\xb2\xf3\x00\x00' '\xa0\x04\x00\x00' \
 
2846
            '\x1d\x98\x61\x99' '\xb6\x2c\x00\x00' \
 
2847
            '\xf9\x00\x00\x00' '\x00\x00\x00\x00'
 
2848
 
 
2849
 
 
2850
    def testPackRequest0(self):
 
2851
        bin = apply(request.ChangeGC._request.to_binary, (), self.req_args_0)
 
2852
        try:
 
2853
            assert bin == self.req_bin_0
 
2854
        except AssertionError:
 
2855
            raise AssertionError(tohex(bin))
 
2856
 
 
2857
    def testUnpackRequest0(self):
 
2858
        args, remain = request.ChangeGC._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2859
        try:
 
2860
            assert len(remain) == 0
 
2861
        except AssertionError:
 
2862
            raise AssertionError(tohex(remain))
 
2863
        try:
 
2864
            assert args == self.req_args_0
 
2865
        except AssertionError:
 
2866
            raise AssertionError(args)
 
2867
 
 
2868
 
 
2869
class TestCopyGC(unittest.TestCase):
 
2870
    def setUp(self):
 
2871
        self.req_args_0 = {
 
2872
            'mask': 1039948946,
 
2873
            'src_gc': 1958847367,
 
2874
            'dst_gc': 1311353896,
 
2875
            }
 
2876
        self.req_bin_0 = '\x39\x00\x00\x04' '\x74\xc1\xa3\x87' \
 
2877
            '\x4e\x29\xac\x28' '\x3d\xfc\x5c\x92'
 
2878
 
 
2879
 
 
2880
    def testPackRequest0(self):
 
2881
        bin = apply(request.CopyGC._request.to_binary, (), self.req_args_0)
 
2882
        try:
 
2883
            assert bin == self.req_bin_0
 
2884
        except AssertionError:
 
2885
            raise AssertionError(tohex(bin))
 
2886
 
 
2887
    def testUnpackRequest0(self):
 
2888
        args, remain = request.CopyGC._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2889
        try:
 
2890
            assert len(remain) == 0
 
2891
        except AssertionError:
 
2892
            raise AssertionError(tohex(remain))
 
2893
        try:
 
2894
            assert args == self.req_args_0
 
2895
        except AssertionError:
 
2896
            raise AssertionError(args)
 
2897
 
 
2898
 
 
2899
class TestSetDashes(unittest.TestCase):
 
2900
    def setUp(self):
 
2901
        self.req_args_0 = {
 
2902
            'dashes': [169, 241, 158, 238, 173, 159, 182, 139, 139],
 
2903
            'dash_offset': 51693,
 
2904
            'gc': 1639787502,
 
2905
            }
 
2906
        self.req_bin_0 = '\x3a\x00\x00\x06' '\x61\xbd\x2b\xee' \
 
2907
            '\xc9\xed\x00\x09' '\xa9\xf1\x9e\xee' \
 
2908
            '\xad\x9f\xb6\x8b' '\x8b\x00\x00\x00'
 
2909
 
 
2910
 
 
2911
    def testPackRequest0(self):
 
2912
        bin = apply(request.SetDashes._request.to_binary, (), self.req_args_0)
 
2913
        try:
 
2914
            assert bin == self.req_bin_0
 
2915
        except AssertionError:
 
2916
            raise AssertionError(tohex(bin))
 
2917
 
 
2918
    def testUnpackRequest0(self):
 
2919
        args, remain = request.SetDashes._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2920
        try:
 
2921
            assert len(remain) == 0
 
2922
        except AssertionError:
 
2923
            raise AssertionError(tohex(remain))
 
2924
        try:
 
2925
            assert args == self.req_args_0
 
2926
        except AssertionError:
 
2927
            raise AssertionError(args)
 
2928
 
 
2929
 
 
2930
class TestSetClipRectangles(unittest.TestCase):
 
2931
    def setUp(self):
 
2932
        self.req_args_0 = {
 
2933
            'rectangles': [{'height': 59391, 'x': -15430, 'width': 46673, 'y': -3009}, {'height': 9883, 'x': -14046, 'width': 7782, 'y': -24857}],
 
2934
            'gc': 1105675380,
 
2935
            'x_origin': -22760,
 
2936
            'y_origin': -16557,
 
2937
            'ordering': 3,
 
2938
            }
 
2939
        self.req_bin_0 = '\x3b\x03\x00\x07' '\x41\xe7\x44\x74' \
 
2940
            '\xa7\x18\xbf\x53' '\xc3\xba\xf4\x3f' \
 
2941
            '\xb6\x51\xe7\xff' '\xc9\x22\x9e\xe7' \
 
2942
            '\x1e\x66\x26\x9b'
 
2943
 
 
2944
        self.req_args_1 = {
 
2945
            'rectangles': [],
 
2946
            'gc': 291514811,
 
2947
            'x_origin': -29867,
 
2948
            'y_origin': -10293,
 
2949
            'ordering': 0,
 
2950
            }
 
2951
        self.req_bin_1 = '\x3b\x00\x00\x03' '\x11\x60\x29\xbb' \
 
2952
            '\x8b\x55\xd7\xcb'
 
2953
 
 
2954
 
 
2955
    def testPackRequest0(self):
 
2956
        bin = apply(request.SetClipRectangles._request.to_binary, (), self.req_args_0)
 
2957
        try:
 
2958
            assert bin == self.req_bin_0
 
2959
        except AssertionError:
 
2960
            raise AssertionError(tohex(bin))
 
2961
 
 
2962
    def testUnpackRequest0(self):
 
2963
        args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
2964
        try:
 
2965
            assert len(remain) == 0
 
2966
        except AssertionError:
 
2967
            raise AssertionError(tohex(remain))
 
2968
        try:
 
2969
            assert args == self.req_args_0
 
2970
        except AssertionError:
 
2971
            raise AssertionError(args)
 
2972
 
 
2973
    def testPackRequest1(self):
 
2974
        bin = apply(request.SetClipRectangles._request.to_binary, (), self.req_args_1)
 
2975
        try:
 
2976
            assert bin == self.req_bin_1
 
2977
        except AssertionError:
 
2978
            raise AssertionError(tohex(bin))
 
2979
 
 
2980
    def testUnpackRequest1(self):
 
2981
        args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_1, dummy_display, 1)
 
2982
        try:
 
2983
            assert len(remain) == 0
 
2984
        except AssertionError:
 
2985
            raise AssertionError(tohex(remain))
 
2986
        try:
 
2987
            assert args == self.req_args_1
 
2988
        except AssertionError:
 
2989
            raise AssertionError(args)
 
2990
 
 
2991
 
 
2992
class TestFreeGC(unittest.TestCase):
 
2993
    def setUp(self):
 
2994
        self.req_args_0 = {
 
2995
            'gc': 371787524,
 
2996
            }
 
2997
        self.req_bin_0 = '\x3c\x00\x00\x02' '\x16\x29\x07\x04'
 
2998
 
 
2999
 
 
3000
    def testPackRequest0(self):
 
3001
        bin = apply(request.FreeGC._request.to_binary, (), self.req_args_0)
 
3002
        try:
 
3003
            assert bin == self.req_bin_0
 
3004
        except AssertionError:
 
3005
            raise AssertionError(tohex(bin))
 
3006
 
 
3007
    def testUnpackRequest0(self):
 
3008
        args, remain = request.FreeGC._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3009
        try:
 
3010
            assert len(remain) == 0
 
3011
        except AssertionError:
 
3012
            raise AssertionError(tohex(remain))
 
3013
        try:
 
3014
            assert args == self.req_args_0
 
3015
        except AssertionError:
 
3016
            raise AssertionError(args)
 
3017
 
 
3018
 
 
3019
class TestClearArea(unittest.TestCase):
 
3020
    def setUp(self):
 
3021
        self.req_args_0 = {
 
3022
            'exposures': 0,
 
3023
            'height': 53776,
 
3024
            'width': 63821,
 
3025
            'window': 1253992673,
 
3026
            'x': -1843,
 
3027
            'y': -32148,
 
3028
            }
 
3029
        self.req_bin_0 = '\x3d\x00\x00\x04' '\x4a\xbe\x68\xe1' \
 
3030
            '\xf8\xcd\x82\x6c' '\xf9\x4d\xd2\x10'
 
3031
 
 
3032
 
 
3033
    def testPackRequest0(self):
 
3034
        bin = apply(request.ClearArea._request.to_binary, (), self.req_args_0)
 
3035
        try:
 
3036
            assert bin == self.req_bin_0
 
3037
        except AssertionError:
 
3038
            raise AssertionError(tohex(bin))
 
3039
 
 
3040
    def testUnpackRequest0(self):
 
3041
        args, remain = request.ClearArea._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3042
        try:
 
3043
            assert len(remain) == 0
 
3044
        except AssertionError:
 
3045
            raise AssertionError(tohex(remain))
 
3046
        try:
 
3047
            assert args == self.req_args_0
 
3048
        except AssertionError:
 
3049
            raise AssertionError(args)
 
3050
 
 
3051
 
 
3052
class TestCopyArea(unittest.TestCase):
 
3053
    def setUp(self):
 
3054
        self.req_args_0 = {
 
3055
            'src_drawable': 321720617,
 
3056
            'dst_drawable': 252019697,
 
3057
            'src_y': -8372,
 
3058
            'src_x': -25544,
 
3059
            'gc': 126071392,
 
3060
            'width': 49414,
 
3061
            'height': 61502,
 
3062
            'dst_x': -19068,
 
3063
            'dst_y': -4602,
 
3064
            }
 
3065
        self.req_bin_0 = '\x3e\x00\x00\x07' '\x13\x2d\x11\x29' \
 
3066
            '\x0f\x05\x83\xf1' '\x07\x83\xb2\x60' \
 
3067
            '\x9c\x38\xdf\x4c' '\xb5\x84\xee\x06' \
 
3068
            '\xc1\x06\xf0\x3e'
 
3069
 
 
3070
 
 
3071
    def testPackRequest0(self):
 
3072
        bin = apply(request.CopyArea._request.to_binary, (), self.req_args_0)
 
3073
        try:
 
3074
            assert bin == self.req_bin_0
 
3075
        except AssertionError:
 
3076
            raise AssertionError(tohex(bin))
 
3077
 
 
3078
    def testUnpackRequest0(self):
 
3079
        args, remain = request.CopyArea._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3080
        try:
 
3081
            assert len(remain) == 0
 
3082
        except AssertionError:
 
3083
            raise AssertionError(tohex(remain))
 
3084
        try:
 
3085
            assert args == self.req_args_0
 
3086
        except AssertionError:
 
3087
            raise AssertionError(args)
 
3088
 
 
3089
 
 
3090
class TestCopyPlane(unittest.TestCase):
 
3091
    def setUp(self):
 
3092
        self.req_args_0 = {
 
3093
            'src_drawable': 1988650265,
 
3094
            'bit_plane': 2052065832,
 
3095
            'dst_drawable': 2120887972,
 
3096
            'src_y': -22401,
 
3097
            'src_x': -4542,
 
3098
            'gc': 1266180573,
 
3099
            'width': 41241,
 
3100
            'height': 33787,
 
3101
            'dst_x': -24940,
 
3102
            'dst_y': -13009,
 
3103
            }
 
3104
        self.req_bin_0 = '\x3f\x00\x00\x08' '\x76\x88\x65\x19' \
 
3105
            '\x7e\x6a\x2e\xa4' '\x4b\x78\x61\xdd' \
 
3106
            '\xee\x42\xa8\x7f' '\x9e\x94\xcd\x2f' \
 
3107
            '\xa1\x19\x83\xfb' '\x7a\x50\x0a\x28'
 
3108
 
 
3109
 
 
3110
    def testPackRequest0(self):
 
3111
        bin = apply(request.CopyPlane._request.to_binary, (), self.req_args_0)
 
3112
        try:
 
3113
            assert bin == self.req_bin_0
 
3114
        except AssertionError:
 
3115
            raise AssertionError(tohex(bin))
 
3116
 
 
3117
    def testUnpackRequest0(self):
 
3118
        args, remain = request.CopyPlane._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3119
        try:
 
3120
            assert len(remain) == 0
 
3121
        except AssertionError:
 
3122
            raise AssertionError(tohex(remain))
 
3123
        try:
 
3124
            assert args == self.req_args_0
 
3125
        except AssertionError:
 
3126
            raise AssertionError(args)
 
3127
 
 
3128
 
 
3129
class TestPolyPoint(unittest.TestCase):
 
3130
    def setUp(self):
 
3131
        self.req_args_0 = {
 
3132
            'gc': 206266633,
 
3133
            'points': [{'x': -22449, 'y': -16714}, {'x': -16465, 'y': -12850}, {'x': -19616, 'y': -13131}],
 
3134
            'drawable': 1008674,
 
3135
            'coord_mode': 1,
 
3136
            }
 
3137
        self.req_bin_0 = '\x40\x01\x00\x06' '\x00\x0f\x64\x22' \
 
3138
            '\x0c\x4b\x61\x09' '\xa8\x4f\xbe\xb6' \
 
3139
            '\xbf\xaf\xcd\xce' '\xb3\x60\xcc\xb5'
 
3140
 
 
3141
 
 
3142
    def testPackRequest0(self):
 
3143
        bin = apply(request.PolyPoint._request.to_binary, (), self.req_args_0)
 
3144
        try:
 
3145
            assert bin == self.req_bin_0
 
3146
        except AssertionError:
 
3147
            raise AssertionError(tohex(bin))
 
3148
 
 
3149
    def testUnpackRequest0(self):
 
3150
        args, remain = request.PolyPoint._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3151
        try:
 
3152
            assert len(remain) == 0
 
3153
        except AssertionError:
 
3154
            raise AssertionError(tohex(remain))
 
3155
        try:
 
3156
            assert args == self.req_args_0
 
3157
        except AssertionError:
 
3158
            raise AssertionError(args)
 
3159
 
 
3160
 
 
3161
class TestPolyLine(unittest.TestCase):
 
3162
    def setUp(self):
 
3163
        self.req_args_0 = {
 
3164
            'gc': 1355594189,
 
3165
            'points': [{'x': -11743, 'y': -18781}, {'x': -21373, 'y': -22722}, {'x': -17579, 'y': -13699}, {'x': -26545, 'y': -19353}, {'x': -11779, 'y': -26488}],
 
3166
            'drawable': 1668889192,
 
3167
            'coord_mode': 1,
 
3168
            }
 
3169
        self.req_bin_0 = '\x41\x01\x00\x08' '\x63\x79\x3a\x68' \
 
3170
            '\x50\xcc\xb9\xcd' '\xd2\x21\xb6\xa3' \
 
3171
            '\xac\x83\xa7\x3e' '\xbb\x55\xca\x7d' \
 
3172
            '\x98\x4f\xb4\x67' '\xd1\xfd\x98\x88'
 
3173
 
 
3174
 
 
3175
    def testPackRequest0(self):
 
3176
        bin = apply(request.PolyLine._request.to_binary, (), self.req_args_0)
 
3177
        try:
 
3178
            assert bin == self.req_bin_0
 
3179
        except AssertionError:
 
3180
            raise AssertionError(tohex(bin))
 
3181
 
 
3182
    def testUnpackRequest0(self):
 
3183
        args, remain = request.PolyLine._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3184
        try:
 
3185
            assert len(remain) == 0
 
3186
        except AssertionError:
 
3187
            raise AssertionError(tohex(remain))
 
3188
        try:
 
3189
            assert args == self.req_args_0
 
3190
        except AssertionError:
 
3191
            raise AssertionError(args)
 
3192
 
 
3193
 
 
3194
class TestPolySegment(unittest.TestCase):
 
3195
    def setUp(self):
 
3196
        self.req_args_0 = {
 
3197
            'segments': [{'y1': -24252, 'y2': -22523, 'x1': -12610, 'x2': -25770}],
 
3198
            'drawable': 146511635,
 
3199
            'gc': 53385255,
 
3200
            }
 
3201
        self.req_bin_0 = '\x42\x00\x00\x05' '\x08\xbb\x97\x13' \
 
3202
            '\x03\x2e\x98\x27' '\xce\xbe\xa1\x44' \
 
3203
            '\x9b\x56\xa8\x05'
 
3204
 
 
3205
 
 
3206
    def testPackRequest0(self):
 
3207
        bin = apply(request.PolySegment._request.to_binary, (), self.req_args_0)
 
3208
        try:
 
3209
            assert bin == self.req_bin_0
 
3210
        except AssertionError:
 
3211
            raise AssertionError(tohex(bin))
 
3212
 
 
3213
    def testUnpackRequest0(self):
 
3214
        args, remain = request.PolySegment._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3215
        try:
 
3216
            assert len(remain) == 0
 
3217
        except AssertionError:
 
3218
            raise AssertionError(tohex(remain))
 
3219
        try:
 
3220
            assert args == self.req_args_0
 
3221
        except AssertionError:
 
3222
            raise AssertionError(args)
 
3223
 
 
3224
 
 
3225
class TestPolyRectangle(unittest.TestCase):
 
3226
    def setUp(self):
 
3227
        self.req_args_0 = {
 
3228
            'drawable': 1927481661,
 
3229
            'gc': 410140275,
 
3230
            'rectangles': [{'height': 63567, 'x': -16992, 'width': 11122, 'y': -21320}, {'height': 34652, 'x': -18051, 'width': 59622, 'y': -30426}, {'height': 45646, 'x': -1111, 'width': 46231, 'y': -25261}],
 
3231
            }
 
3232
        self.req_bin_0 = '\x43\x00\x00\x09' '\x72\xe3\x09\x3d' \
 
3233
            '\x18\x72\x3e\x73' '\xbd\xa0\xac\xb8' \
 
3234
            '\x2b\x72\xf8\x4f' '\xb9\x7d\x89\x26' \
 
3235
            '\xe8\xe6\x87\x5c' '\xfb\xa9\x9d\x53' \
 
3236
            '\xb4\x97\xb2\x4e'
 
3237
 
 
3238
 
 
3239
    def testPackRequest0(self):
 
3240
        bin = apply(request.PolyRectangle._request.to_binary, (), self.req_args_0)
 
3241
        try:
 
3242
            assert bin == self.req_bin_0
 
3243
        except AssertionError:
 
3244
            raise AssertionError(tohex(bin))
 
3245
 
 
3246
    def testUnpackRequest0(self):
 
3247
        args, remain = request.PolyRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3248
        try:
 
3249
            assert len(remain) == 0
 
3250
        except AssertionError:
 
3251
            raise AssertionError(tohex(remain))
 
3252
        try:
 
3253
            assert args == self.req_args_0
 
3254
        except AssertionError:
 
3255
            raise AssertionError(args)
 
3256
 
 
3257
 
 
3258
class TestPolyArc(unittest.TestCase):
 
3259
    def setUp(self):
 
3260
        self.req_args_0 = {
 
3261
            'arcs': [{'height': 37549, 'angle1': -16979, 'x': -4943, 'angle2': -25650, 'width': 65448, 'y': -9205}, {'height': 9322, 'angle1': -20781, 'x': -13865, 'angle2': -8498, 'width': 62173, 'y': -22862}, {'height': 63266, 'angle1': -1231, 'x': -12693, 'angle2': -809, 'width': 63732, 'y': -7550}],
 
3262
            'drawable': 718777148,
 
3263
            'gc': 1127021391,
 
3264
            }
 
3265
        self.req_bin_0 = '\x44\x00\x00\x0c' '\x2a\xd7\xab\x3c' \
 
3266
            '\x43\x2c\xfb\x4f' '\xec\xb1\xdc\x0b' \
 
3267
            '\xff\xa8\x92\xad' '\xbd\xad\x9b\xce' \
 
3268
            '\xc9\xd7\xa6\xb2' '\xf2\xdd\x24\x6a' \
 
3269
            '\xae\xd3\xde\xce' '\xce\x6b\xe2\x82' \
 
3270
            '\xf8\xf4\xf7\x22' '\xfb\x31\xfc\xd7'
 
3271
 
 
3272
 
 
3273
    def testPackRequest0(self):
 
3274
        bin = apply(request.PolyArc._request.to_binary, (), self.req_args_0)
 
3275
        try:
 
3276
            assert bin == self.req_bin_0
 
3277
        except AssertionError:
 
3278
            raise AssertionError(tohex(bin))
 
3279
 
 
3280
    def testUnpackRequest0(self):
 
3281
        args, remain = request.PolyArc._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3282
        try:
 
3283
            assert len(remain) == 0
 
3284
        except AssertionError:
 
3285
            raise AssertionError(tohex(remain))
 
3286
        try:
 
3287
            assert args == self.req_args_0
 
3288
        except AssertionError:
 
3289
            raise AssertionError(args)
 
3290
 
 
3291
 
 
3292
class TestFillPoly(unittest.TestCase):
 
3293
    def setUp(self):
 
3294
        self.req_args_0 = {
 
3295
            'shape': 1,
 
3296
            'gc': 1070496026,
 
3297
            'points': [{'x': -18749, 'y': -19415}, {'x': -8904, 'y': -26948}, {'x': -13336, 'y': -9462}],
 
3298
            'drawable': 1326525185,
 
3299
            'coord_mode': 0,
 
3300
            }
 
3301
        self.req_bin_0 = '\x45\x00\x00\x07' '\x4f\x11\x2b\x01' \
 
3302
            '\x3f\xce\x79\x1a' '\x01\x00\x00\x00' \
 
3303
            '\xb6\xc3\xb4\x29' '\xdd\x38\x96\xbc' \
 
3304
            '\xcb\xe8\xdb\x0a'
 
3305
 
 
3306
 
 
3307
    def testPackRequest0(self):
 
3308
        bin = apply(request.FillPoly._request.to_binary, (), self.req_args_0)
 
3309
        try:
 
3310
            assert bin == self.req_bin_0
 
3311
        except AssertionError:
 
3312
            raise AssertionError(tohex(bin))
 
3313
 
 
3314
    def testUnpackRequest0(self):
 
3315
        args, remain = request.FillPoly._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3316
        try:
 
3317
            assert len(remain) == 0
 
3318
        except AssertionError:
 
3319
            raise AssertionError(tohex(remain))
 
3320
        try:
 
3321
            assert args == self.req_args_0
 
3322
        except AssertionError:
 
3323
            raise AssertionError(args)
 
3324
 
 
3325
 
 
3326
class TestPolyFillRectangle(unittest.TestCase):
 
3327
    def setUp(self):
 
3328
        self.req_args_0 = {
 
3329
            'drawable': 1708671692,
 
3330
            'gc': 1965498255,
 
3331
            'rectangles': [{'height': 36920, 'x': -2965, 'width': 26437, 'y': -3568}, {'height': 44383, 'x': -18327, 'width': 37730, 'y': -26752}],
 
3332
            }
 
3333
        self.req_bin_0 = '\x46\x00\x00\x07' '\x65\xd8\x42\xcc' \
 
3334
            '\x75\x27\x1f\x8f' '\xf4\x6b\xf2\x10' \
 
3335
            '\x67\x45\x90\x38' '\xb8\x69\x97\x80' \
 
3336
            '\x93\x62\xad\x5f'
 
3337
 
 
3338
 
 
3339
    def testPackRequest0(self):
 
3340
        bin = apply(request.PolyFillRectangle._request.to_binary, (), self.req_args_0)
 
3341
        try:
 
3342
            assert bin == self.req_bin_0
 
3343
        except AssertionError:
 
3344
            raise AssertionError(tohex(bin))
 
3345
 
 
3346
    def testUnpackRequest0(self):
 
3347
        args, remain = request.PolyFillRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3348
        try:
 
3349
            assert len(remain) == 0
 
3350
        except AssertionError:
 
3351
            raise AssertionError(tohex(remain))
 
3352
        try:
 
3353
            assert args == self.req_args_0
 
3354
        except AssertionError:
 
3355
            raise AssertionError(args)
 
3356
 
 
3357
 
 
3358
class TestPolyFillArc(unittest.TestCase):
 
3359
    def setUp(self):
 
3360
        self.req_args_0 = {
 
3361
            'arcs': [{'height': 64114, 'angle1': -28360, 'x': -10754, 'angle2': -6712, 'width': 53819, 'y': -19555}],
 
3362
            'drawable': 2083870696,
 
3363
            'gc': 414470877,
 
3364
            }
 
3365
        self.req_bin_0 = '\x47\x00\x00\x06' '\x7c\x35\x57\xe8' \
 
3366
            '\x18\xb4\x52\xdd' '\xd5\xfe\xb3\x9d' \
 
3367
            '\xd2\x3b\xfa\x72' '\x91\x38\xe5\xc8'
 
3368
 
 
3369
 
 
3370
    def testPackRequest0(self):
 
3371
        bin = apply(request.PolyFillArc._request.to_binary, (), self.req_args_0)
 
3372
        try:
 
3373
            assert bin == self.req_bin_0
 
3374
        except AssertionError:
 
3375
            raise AssertionError(tohex(bin))
 
3376
 
 
3377
    def testUnpackRequest0(self):
 
3378
        args, remain = request.PolyFillArc._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3379
        try:
 
3380
            assert len(remain) == 0
 
3381
        except AssertionError:
 
3382
            raise AssertionError(tohex(remain))
 
3383
        try:
 
3384
            assert args == self.req_args_0
 
3385
        except AssertionError:
 
3386
            raise AssertionError(args)
 
3387
 
 
3388
 
 
3389
class TestPutImage(unittest.TestCase):
 
3390
    def setUp(self):
 
3391
        self.req_args_0 = {
 
3392
            'height': 9883,
 
3393
            'data': 'bit map data',
 
3394
            'drawable': 1534678783,
 
3395
            'left_pad': 147,
 
3396
            'format': 1,
 
3397
            'dst_x': -3284,
 
3398
            'gc': 209913475,
 
3399
            'depth': 173,
 
3400
            'width': 62850,
 
3401
            'dst_y': -30693,
 
3402
            }
 
3403
        self.req_bin_0 = '\x48\x01\x00\x09' '\x5b\x79\x56\xff' \
 
3404
            '\x0c\x83\x06\x83' '\xf5\x82\x26\x9b' \
 
3405
            '\xf3\x2c\x88\x1b' '\x93\xad\x00\x00' \
 
3406
            '\x62\x69\x74\x20' '\x6d\x61\x70\x20' \
 
3407
            '\x64\x61\x74\x61'
 
3408
 
 
3409
 
 
3410
    def testPackRequest0(self):
 
3411
        bin = apply(request.PutImage._request.to_binary, (), self.req_args_0)
 
3412
        try:
 
3413
            assert bin == self.req_bin_0
 
3414
        except AssertionError:
 
3415
            raise AssertionError(tohex(bin))
 
3416
 
 
3417
    def testUnpackRequest0(self):
 
3418
        args, remain = request.PutImage._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3419
        try:
 
3420
            assert len(remain) == 0
 
3421
        except AssertionError:
 
3422
            raise AssertionError(tohex(remain))
 
3423
        try:
 
3424
            assert args == self.req_args_0
 
3425
        except AssertionError:
 
3426
            raise AssertionError(args)
 
3427
 
 
3428
 
 
3429
class TestGetImage(unittest.TestCase):
 
3430
    def setUp(self):
 
3431
        self.req_args_0 = {
 
3432
            'height': 42657,
 
3433
            'plane_mask': 1756278272,
 
3434
            'drawable': 1329487747,
 
3435
            'x': -27672,
 
3436
            'y': -30859,
 
3437
            'format': 1,
 
3438
            'width': 58993,
 
3439
            }
 
3440
        self.req_bin_0 = '\x49\x01\x00\x05' '\x4f\x3e\x5f\x83' \
 
3441
            '\x93\xe8\x87\x75' '\xe6\x71\xa6\xa1' \
 
3442
            '\x68\xae\xae\x00'
 
3443
 
 
3444
        self.reply_args_0 = {
 
3445
            'sequence_number': 54997,
 
3446
            'data': 'this is real ly imag e b-map',
 
3447
            'visual': 1108632607,
 
3448
            'depth': 181,
 
3449
            }
 
3450
        self.reply_bin_0 = '\x01\xb5\xd6\xd5' '\x00\x00\x00\x07' \
 
3451
            '\x42\x14\x64\x1f' '\x00\x00\x00\x00' \
 
3452
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
3453
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
3454
            '\x74\x68\x69\x73' '\x20\x69\x73\x20' \
 
3455
            '\x72\x65\x61\x6c' '\x20\x6c\x79\x20' \
 
3456
            '\x69\x6d\x61\x67' '\x20\x65\x20\x62' \
 
3457
            '\x2d\x6d\x61\x70'
 
3458
 
 
3459
 
 
3460
    def testPackRequest0(self):
 
3461
        bin = apply(request.GetImage._request.to_binary, (), self.req_args_0)
 
3462
        try:
 
3463
            assert bin == self.req_bin_0
 
3464
        except AssertionError:
 
3465
            raise AssertionError(tohex(bin))
 
3466
 
 
3467
    def testUnpackRequest0(self):
 
3468
        args, remain = request.GetImage._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3469
        try:
 
3470
            assert len(remain) == 0
 
3471
        except AssertionError:
 
3472
            raise AssertionError(tohex(remain))
 
3473
        try:
 
3474
            assert args == self.req_args_0
 
3475
        except AssertionError:
 
3476
            raise AssertionError(args)
 
3477
 
 
3478
    def testPackReply0(self):
 
3479
        bin = apply(request.GetImage._reply.to_binary, (), self.reply_args_0)
 
3480
        try:
 
3481
            assert bin == self.reply_bin_0
 
3482
        except AssertionError:
 
3483
            raise AssertionError(tohex(bin))
 
3484
 
 
3485
    def testUnpackReply0(self):
 
3486
        args, remain = request.GetImage._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
3487
        try:
 
3488
            assert len(remain) == 0
 
3489
        except AssertionError:
 
3490
            raise AssertionError(tohex(remain))
 
3491
        try:
 
3492
            assert args == self.reply_args_0
 
3493
        except AssertionError:
 
3494
            raise AssertionError(args)
 
3495
 
 
3496
 
 
3497
class TestPolyText8(unittest.TestCase):
 
3498
    def setUp(self):
 
3499
        self.req_args_0 = {
 
3500
            'gc': 1481564777,
 
3501
            'x': -13548,
 
3502
            'drawable': 1550998666,
 
3503
            'items': [{'delta': 2, 'string': 'zoo'}, 16909060, {'delta': 0, 'string': 'ie'}],
 
3504
            'y': -8902,
 
3505
            }
 
3506
        self.req_bin_0 = '\x4a\x00\x00\x08' '\x5c\x72\x5c\x8a' \
 
3507
            '\x58\x4e\xe2\x69' '\xcb\x14\xdd\x3a' \
 
3508
            '\x03\x02\x7a\x6f' '\x6f\xff\x01\x02' \
 
3509
            '\x03\x04\x02\x00' '\x69\x65\x00\x00'
 
3510
 
 
3511
 
 
3512
    def testPackRequest0(self):
 
3513
        bin = apply(request.PolyText8._request.to_binary, (), self.req_args_0)
 
3514
        try:
 
3515
            assert bin == self.req_bin_0
 
3516
        except AssertionError:
 
3517
            raise AssertionError(tohex(bin))
 
3518
 
 
3519
    def testUnpackRequest0(self):
 
3520
        args, remain = request.PolyText8._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3521
        try:
 
3522
            assert len(remain) == 0
 
3523
        except AssertionError:
 
3524
            raise AssertionError(tohex(remain))
 
3525
        try:
 
3526
            assert args == self.req_args_0
 
3527
        except AssertionError:
 
3528
            raise AssertionError(args)
 
3529
 
 
3530
 
 
3531
class TestPolyText16(unittest.TestCase):
 
3532
    def setUp(self):
 
3533
        self.req_args_0 = {
 
3534
            'gc': 400697368,
 
3535
            'x': -31614,
 
3536
            'drawable': 1591407092,
 
3537
            'items': [{'delta': 2, 'string': (4131, 18)}, 16909060],
 
3538
            'y': -2741,
 
3539
            }
 
3540
        self.req_bin_0 = '\x4b\x00\x00\x07' '\x5e\xda\xf1\xf4' \
 
3541
            '\x17\xe2\x28\x18' '\x84\x82\xf5\x4b' \
 
3542
            '\x02\x02\x10\x23' '\x00\x12\xff\x01' \
 
3543
            '\x02\x03\x04\x00'
 
3544
 
 
3545
 
 
3546
    def testPackRequest0(self):
 
3547
        bin = apply(request.PolyText16._request.to_binary, (), self.req_args_0)
 
3548
        try:
 
3549
            assert bin == self.req_bin_0
 
3550
        except AssertionError:
 
3551
            raise AssertionError(tohex(bin))
 
3552
 
 
3553
    def testUnpackRequest0(self):
 
3554
        args, remain = request.PolyText16._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3555
        try:
 
3556
            assert len(remain) == 0
 
3557
        except AssertionError:
 
3558
            raise AssertionError(tohex(remain))
 
3559
        try:
 
3560
            assert args == self.req_args_0
 
3561
        except AssertionError:
 
3562
            raise AssertionError(args)
 
3563
 
 
3564
 
 
3565
class TestImageText8(unittest.TestCase):
 
3566
    def setUp(self):
 
3567
        self.req_args_0 = {
 
3568
            'string': 'showme',
 
3569
            'gc': 1393590305,
 
3570
            'drawable': 1823595869,
 
3571
            'x': -16077,
 
3572
            'y': -4873,
 
3573
            }
 
3574
        self.req_bin_0 = '\x4c\x06\x00\x06' '\x6c\xb1\xdd\x5d' \
 
3575
            '\x53\x10\x80\x21' '\xc1\x33\xec\xf7' \
 
3576
            '\x73\x68\x6f\x77' '\x6d\x65\x00\x00'
 
3577
 
 
3578
 
 
3579
    def testPackRequest0(self):
 
3580
        bin = apply(request.ImageText8._request.to_binary, (), self.req_args_0)
 
3581
        try:
 
3582
            assert bin == self.req_bin_0
 
3583
        except AssertionError:
 
3584
            raise AssertionError(tohex(bin))
 
3585
 
 
3586
    def testUnpackRequest0(self):
 
3587
        args, remain = request.ImageText8._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3588
        try:
 
3589
            assert len(remain) == 0
 
3590
        except AssertionError:
 
3591
            raise AssertionError(tohex(remain))
 
3592
        try:
 
3593
            assert args == self.req_args_0
 
3594
        except AssertionError:
 
3595
            raise AssertionError(args)
 
3596
 
 
3597
 
 
3598
class TestImageText16(unittest.TestCase):
 
3599
    def setUp(self):
 
3600
        self.req_args_0 = {
 
3601
            'string': (115, 104, 111, 119, 109, 111, 114, 101),
 
3602
            'gc': 1702299870,
 
3603
            'drawable': 33607184,
 
3604
            'x': -21343,
 
3605
            'y': -24237,
 
3606
            }
 
3607
        self.req_bin_0 = '\x4d\x08\x00\x08' '\x02\x00\xce\x10' \
 
3608
            '\x65\x77\x08\xde' '\xac\xa1\xa1\x53' \
 
3609
            '\x00\x73\x00\x68' '\x00\x6f\x00\x77' \
 
3610
            '\x00\x6d\x00\x6f' '\x00\x72\x00\x65'
 
3611
 
 
3612
 
 
3613
    def testPackRequest0(self):
 
3614
        bin = apply(request.ImageText16._request.to_binary, (), self.req_args_0)
 
3615
        try:
 
3616
            assert bin == self.req_bin_0
 
3617
        except AssertionError:
 
3618
            raise AssertionError(tohex(bin))
 
3619
 
 
3620
    def testUnpackRequest0(self):
 
3621
        args, remain = request.ImageText16._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3622
        try:
 
3623
            assert len(remain) == 0
 
3624
        except AssertionError:
 
3625
            raise AssertionError(tohex(remain))
 
3626
        try:
 
3627
            assert args == self.req_args_0
 
3628
        except AssertionError:
 
3629
            raise AssertionError(args)
 
3630
 
 
3631
 
 
3632
class TestCreateColormap(unittest.TestCase):
 
3633
    def setUp(self):
 
3634
        self.req_args_0 = {
 
3635
            'mid': 157536683,
 
3636
            'alloc': 0,
 
3637
            'visual': 813982403,
 
3638
            'window': 698475631,
 
3639
            }
 
3640
        self.req_bin_0 = '\x4e\x00\x00\x04' '\x09\x63\xd1\xab' \
 
3641
            '\x29\xa1\xe4\x6f' '\x30\x84\x62\xc3'
 
3642
 
 
3643
 
 
3644
    def testPackRequest0(self):
 
3645
        bin = apply(request.CreateColormap._request.to_binary, (), self.req_args_0)
 
3646
        try:
 
3647
            assert bin == self.req_bin_0
 
3648
        except AssertionError:
 
3649
            raise AssertionError(tohex(bin))
 
3650
 
 
3651
    def testUnpackRequest0(self):
 
3652
        args, remain = request.CreateColormap._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3653
        try:
 
3654
            assert len(remain) == 0
 
3655
        except AssertionError:
 
3656
            raise AssertionError(tohex(remain))
 
3657
        try:
 
3658
            assert args == self.req_args_0
 
3659
        except AssertionError:
 
3660
            raise AssertionError(args)
 
3661
 
 
3662
 
 
3663
class TestFreeColormap(unittest.TestCase):
 
3664
    def setUp(self):
 
3665
        self.req_args_0 = {
 
3666
            'cmap': 1296514923,
 
3667
            }
 
3668
        self.req_bin_0 = '\x4f\x00\x00\x02' '\x4d\x47\x3f\x6b'
 
3669
 
 
3670
 
 
3671
    def testPackRequest0(self):
 
3672
        bin = apply(request.FreeColormap._request.to_binary, (), self.req_args_0)
 
3673
        try:
 
3674
            assert bin == self.req_bin_0
 
3675
        except AssertionError:
 
3676
            raise AssertionError(tohex(bin))
 
3677
 
 
3678
    def testUnpackRequest0(self):
 
3679
        args, remain = request.FreeColormap._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3680
        try:
 
3681
            assert len(remain) == 0
 
3682
        except AssertionError:
 
3683
            raise AssertionError(tohex(remain))
 
3684
        try:
 
3685
            assert args == self.req_args_0
 
3686
        except AssertionError:
 
3687
            raise AssertionError(args)
 
3688
 
 
3689
 
 
3690
class TestCopyColormapAndFree(unittest.TestCase):
 
3691
    def setUp(self):
 
3692
        self.req_args_0 = {
 
3693
            'src_cmap': 1049336329,
 
3694
            'mid': 1237242690,
 
3695
            }
 
3696
        self.req_bin_0 = '\x50\x00\x00\x03' '\x49\xbe\xd3\x42' \
 
3697
            '\x3e\x8b\x9a\x09'
 
3698
 
 
3699
 
 
3700
    def testPackRequest0(self):
 
3701
        bin = apply(request.CopyColormapAndFree._request.to_binary, (), self.req_args_0)
 
3702
        try:
 
3703
            assert bin == self.req_bin_0
 
3704
        except AssertionError:
 
3705
            raise AssertionError(tohex(bin))
 
3706
 
 
3707
    def testUnpackRequest0(self):
 
3708
        args, remain = request.CopyColormapAndFree._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3709
        try:
 
3710
            assert len(remain) == 0
 
3711
        except AssertionError:
 
3712
            raise AssertionError(tohex(remain))
 
3713
        try:
 
3714
            assert args == self.req_args_0
 
3715
        except AssertionError:
 
3716
            raise AssertionError(args)
 
3717
 
 
3718
 
 
3719
class TestInstallColormap(unittest.TestCase):
 
3720
    def setUp(self):
 
3721
        self.req_args_0 = {
 
3722
            'cmap': 1539075582,
 
3723
            }
 
3724
        self.req_bin_0 = '\x51\x00\x00\x02' '\x5b\xbc\x6d\xfe'
 
3725
 
 
3726
 
 
3727
    def testPackRequest0(self):
 
3728
        bin = apply(request.InstallColormap._request.to_binary, (), self.req_args_0)
 
3729
        try:
 
3730
            assert bin == self.req_bin_0
 
3731
        except AssertionError:
 
3732
            raise AssertionError(tohex(bin))
 
3733
 
 
3734
    def testUnpackRequest0(self):
 
3735
        args, remain = request.InstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3736
        try:
 
3737
            assert len(remain) == 0
 
3738
        except AssertionError:
 
3739
            raise AssertionError(tohex(remain))
 
3740
        try:
 
3741
            assert args == self.req_args_0
 
3742
        except AssertionError:
 
3743
            raise AssertionError(args)
 
3744
 
 
3745
 
 
3746
class TestUninstallColormap(unittest.TestCase):
 
3747
    def setUp(self):
 
3748
        self.req_args_0 = {
 
3749
            'cmap': 959493342,
 
3750
            }
 
3751
        self.req_bin_0 = '\x52\x00\x00\x02' '\x39\x30\xb4\xde'
 
3752
 
 
3753
 
 
3754
    def testPackRequest0(self):
 
3755
        bin = apply(request.UninstallColormap._request.to_binary, (), self.req_args_0)
 
3756
        try:
 
3757
            assert bin == self.req_bin_0
 
3758
        except AssertionError:
 
3759
            raise AssertionError(tohex(bin))
 
3760
 
 
3761
    def testUnpackRequest0(self):
 
3762
        args, remain = request.UninstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3763
        try:
 
3764
            assert len(remain) == 0
 
3765
        except AssertionError:
 
3766
            raise AssertionError(tohex(remain))
 
3767
        try:
 
3768
            assert args == self.req_args_0
 
3769
        except AssertionError:
 
3770
            raise AssertionError(args)
 
3771
 
 
3772
 
 
3773
class TestListInstalledColormaps(unittest.TestCase):
 
3774
    def setUp(self):
 
3775
        self.req_args_0 = {
 
3776
            'window': 1517864638,
 
3777
            }
 
3778
        self.req_bin_0 = '\x53\x00\x00\x02' '\x5a\x78\xc6\xbe'
 
3779
 
 
3780
        self.reply_args_0 = {
 
3781
            'cmaps': [2146327722, 1361260227],
 
3782
            'sequence_number': 61652,
 
3783
            }
 
3784
        self.reply_bin_0 = '\x01\x00\xf0\xd4' '\x00\x00\x00\x02' \
 
3785
            '\x00\x02\x00\x00' '\x00\x00\x00\x00' \
 
3786
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
3787
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
3788
            '\x7f\xee\x5c\xaa' '\x51\x23\x2e\xc3'
 
3789
 
 
3790
 
 
3791
    def testPackRequest0(self):
 
3792
        bin = apply(request.ListInstalledColormaps._request.to_binary, (), self.req_args_0)
 
3793
        try:
 
3794
            assert bin == self.req_bin_0
 
3795
        except AssertionError:
 
3796
            raise AssertionError(tohex(bin))
 
3797
 
 
3798
    def testUnpackRequest0(self):
 
3799
        args, remain = request.ListInstalledColormaps._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3800
        try:
 
3801
            assert len(remain) == 0
 
3802
        except AssertionError:
 
3803
            raise AssertionError(tohex(remain))
 
3804
        try:
 
3805
            assert args == self.req_args_0
 
3806
        except AssertionError:
 
3807
            raise AssertionError(args)
 
3808
 
 
3809
    def testPackReply0(self):
 
3810
        bin = apply(request.ListInstalledColormaps._reply.to_binary, (), self.reply_args_0)
 
3811
        try:
 
3812
            assert bin == self.reply_bin_0
 
3813
        except AssertionError:
 
3814
            raise AssertionError(tohex(bin))
 
3815
 
 
3816
    def testUnpackReply0(self):
 
3817
        args, remain = request.ListInstalledColormaps._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
3818
        try:
 
3819
            assert len(remain) == 0
 
3820
        except AssertionError:
 
3821
            raise AssertionError(tohex(remain))
 
3822
        try:
 
3823
            assert args == self.reply_args_0
 
3824
        except AssertionError:
 
3825
            raise AssertionError(args)
 
3826
 
 
3827
 
 
3828
class TestAllocColor(unittest.TestCase):
 
3829
    def setUp(self):
 
3830
        self.req_args_0 = {
 
3831
            'red': 39725,
 
3832
            'green': 49854,
 
3833
            'cmap': 523356125,
 
3834
            'blue': 49580,
 
3835
            }
 
3836
        self.req_bin_0 = '\x54\x00\x00\x04' '\x1f\x31\xc7\xdd' \
 
3837
            '\x9b\x2d\xc2\xbe' '\xc1\xac\x00\x00'
 
3838
 
 
3839
        self.reply_args_0 = {
 
3840
            'sequence_number': 10904,
 
3841
            'red': 43784,
 
3842
            'green': 3170,
 
3843
            'pixel': 1067923656,
 
3844
            'blue': 14525,
 
3845
            }
 
3846
        self.reply_bin_0 = '\x01\x00\x2a\x98' '\x00\x00\x00\x00' \
 
3847
            '\xab\x08\x0c\x62' '\x38\xbd\x00\x00' \
 
3848
            '\x3f\xa7\x38\xc8' '\x00\x00\x00\x00' \
 
3849
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
3850
 
 
3851
 
 
3852
    def testPackRequest0(self):
 
3853
        bin = apply(request.AllocColor._request.to_binary, (), self.req_args_0)
 
3854
        try:
 
3855
            assert bin == self.req_bin_0
 
3856
        except AssertionError:
 
3857
            raise AssertionError(tohex(bin))
 
3858
 
 
3859
    def testUnpackRequest0(self):
 
3860
        args, remain = request.AllocColor._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3861
        try:
 
3862
            assert len(remain) == 0
 
3863
        except AssertionError:
 
3864
            raise AssertionError(tohex(remain))
 
3865
        try:
 
3866
            assert args == self.req_args_0
 
3867
        except AssertionError:
 
3868
            raise AssertionError(args)
 
3869
 
 
3870
    def testPackReply0(self):
 
3871
        bin = apply(request.AllocColor._reply.to_binary, (), self.reply_args_0)
 
3872
        try:
 
3873
            assert bin == self.reply_bin_0
 
3874
        except AssertionError:
 
3875
            raise AssertionError(tohex(bin))
 
3876
 
 
3877
    def testUnpackReply0(self):
 
3878
        args, remain = request.AllocColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
3879
        try:
 
3880
            assert len(remain) == 0
 
3881
        except AssertionError:
 
3882
            raise AssertionError(tohex(remain))
 
3883
        try:
 
3884
            assert args == self.reply_args_0
 
3885
        except AssertionError:
 
3886
            raise AssertionError(args)
 
3887
 
 
3888
 
 
3889
class TestAllocNamedColor(unittest.TestCase):
 
3890
    def setUp(self):
 
3891
        self.req_args_0 = {
 
3892
            'cmap': 128217824,
 
3893
            'name': 'octarin',
 
3894
            }
 
3895
        self.req_bin_0 = '\x55\x00\x00\x05' '\x07\xa4\x72\xe0' \
 
3896
            '\x00\x07\x00\x00' '\x6f\x63\x74\x61' \
 
3897
            '\x72\x69\x6e\x00'
 
3898
 
 
3899
        self.reply_args_0 = {
 
3900
            'sequence_number': 19971,
 
3901
            'pixel': 1324239222,
 
3902
            'screen_green': 50499,
 
3903
            'screen_red': 33379,
 
3904
            'exact_green': 29067,
 
3905
            'exact_blue': 58811,
 
3906
            'screen_blue': 43109,
 
3907
            'exact_red': 64213,
 
3908
            }
 
3909
        self.reply_bin_0 = '\x01\x00\x4e\x03' '\x00\x00\x00\x00' \
 
3910
            '\x4e\xee\x49\x76' '\xfa\xd5\x71\x8b' \
 
3911
            '\xe5\xbb\x82\x63' '\xc5\x43\xa8\x65' \
 
3912
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
3913
 
 
3914
 
 
3915
    def testPackRequest0(self):
 
3916
        bin = apply(request.AllocNamedColor._request.to_binary, (), self.req_args_0)
 
3917
        try:
 
3918
            assert bin == self.req_bin_0
 
3919
        except AssertionError:
 
3920
            raise AssertionError(tohex(bin))
 
3921
 
 
3922
    def testUnpackRequest0(self):
 
3923
        args, remain = request.AllocNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
3924
        try:
 
3925
            assert len(remain) == 0
 
3926
        except AssertionError:
 
3927
            raise AssertionError(tohex(remain))
 
3928
        try:
 
3929
            assert args == self.req_args_0
 
3930
        except AssertionError:
 
3931
            raise AssertionError(args)
 
3932
 
 
3933
    def testPackReply0(self):
 
3934
        bin = apply(request.AllocNamedColor._reply.to_binary, (), self.reply_args_0)
 
3935
        try:
 
3936
            assert bin == self.reply_bin_0
 
3937
        except AssertionError:
 
3938
            raise AssertionError(tohex(bin))
 
3939
 
 
3940
    def testUnpackReply0(self):
 
3941
        args, remain = request.AllocNamedColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
3942
        try:
 
3943
            assert len(remain) == 0
 
3944
        except AssertionError:
 
3945
            raise AssertionError(tohex(remain))
 
3946
        try:
 
3947
            assert args == self.reply_args_0
 
3948
        except AssertionError:
 
3949
            raise AssertionError(args)
 
3950
 
 
3951
 
 
3952
class TestAllocColorCells(unittest.TestCase):
 
3953
    def setUp(self):
 
3954
        self.req_args_0 = {
 
3955
            'planes': 32867,
 
3956
            'colors': 58698,
 
3957
            'cmap': 675372338,
 
3958
            'contiguous': 1,
 
3959
            }
 
3960
        self.req_bin_0 = '\x56\x01\x00\x03' '\x28\x41\x5d\x32' \
 
3961
            '\xe5\x4a\x80\x63'
 
3962
 
 
3963
        self.reply_args_0 = {
 
3964
            'masks': [733927381, 1023311668, 595898647],
 
3965
            'pixels': [693075497, 1294879029, 1478712895, 1781963728, 1442185575, 1654003869, 787619123, 1049825849, 1773935772, 1689075922, 1626562257, 177731275, 661046122, 1970509470, 1918486395, 688539096, 41044851],
 
3966
            'sequence_number': 54025,
 
3967
            }
 
3968
        self.reply_bin_0 = '\x01\x00\xd3\x09' '\x00\x00\x00\x14' \
 
3969
            '\x00\x11\x00\x03' '\x00\x00\x00\x00' \
 
3970
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
3971
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
3972
            '\x29\x4f\x7e\x29' '\x4d\x2e\x49\x35' \
 
3973
            '\x58\x23\x5e\x3f' '\x6a\x36\x9b\xd0' \
 
3974
            '\x55\xf6\x01\x67' '\x62\x96\x18\x9d' \
 
3975
            '\x2e\xf2\x1d\x33' '\x3e\x93\x12\x39' \
 
3976
            '\x69\xbc\x1c\x9c' '\x64\xad\x40\xd2' \
 
3977
            '\x60\xf3\x5e\xd1' '\x0a\x97\xf6\xcb' \
 
3978
            '\x27\x66\xc3\x6a' '\x75\x73\x96\x9e' \
 
3979
            '\x72\x59\xc7\x7b' '\x29\x0a\x45\xd8' \
 
3980
            '\x02\x72\x4b\x73' '\x2b\xbe\xd7\xd5' \
 
3981
            '\x3c\xfe\x7f\x34' '\x23\x84\xb1\x17'
 
3982
 
 
3983
        self.reply_args_1 = {
 
3984
            'masks': [],
 
3985
            'pixels': [],
 
3986
            'sequence_number': 6273,
 
3987
            }
 
3988
        self.reply_bin_1 = '\x01\x00\x18\x81' '\x00\x00\x00\x00' \
 
3989
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
3990
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
3991
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
3992
 
 
3993
 
 
3994
    def testPackRequest0(self):
 
3995
        bin = apply(request.AllocColorCells._request.to_binary, (), self.req_args_0)
 
3996
        try:
 
3997
            assert bin == self.req_bin_0
 
3998
        except AssertionError:
 
3999
            raise AssertionError(tohex(bin))
 
4000
 
 
4001
    def testUnpackRequest0(self):
 
4002
        args, remain = request.AllocColorCells._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4003
        try:
 
4004
            assert len(remain) == 0
 
4005
        except AssertionError:
 
4006
            raise AssertionError(tohex(remain))
 
4007
        try:
 
4008
            assert args == self.req_args_0
 
4009
        except AssertionError:
 
4010
            raise AssertionError(args)
 
4011
 
 
4012
    def testPackReply0(self):
 
4013
        bin = apply(request.AllocColorCells._reply.to_binary, (), self.reply_args_0)
 
4014
        try:
 
4015
            assert bin == self.reply_bin_0
 
4016
        except AssertionError:
 
4017
            raise AssertionError(tohex(bin))
 
4018
 
 
4019
    def testUnpackReply0(self):
 
4020
        args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
4021
        try:
 
4022
            assert len(remain) == 0
 
4023
        except AssertionError:
 
4024
            raise AssertionError(tohex(remain))
 
4025
        try:
 
4026
            assert args == self.reply_args_0
 
4027
        except AssertionError:
 
4028
            raise AssertionError(args)
 
4029
 
 
4030
    def testPackReply1(self):
 
4031
        bin = apply(request.AllocColorCells._reply.to_binary, (), self.reply_args_1)
 
4032
        try:
 
4033
            assert bin == self.reply_bin_1
 
4034
        except AssertionError:
 
4035
            raise AssertionError(tohex(bin))
 
4036
 
 
4037
    def testUnpackReply1(self):
 
4038
        args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_1, dummy_display, 1)
 
4039
        try:
 
4040
            assert len(remain) == 0
 
4041
        except AssertionError:
 
4042
            raise AssertionError(tohex(remain))
 
4043
        try:
 
4044
            assert args == self.reply_args_1
 
4045
        except AssertionError:
 
4046
            raise AssertionError(args)
 
4047
 
 
4048
 
 
4049
class TestAllocColorPlanes(unittest.TestCase):
 
4050
    def setUp(self):
 
4051
        self.req_args_0 = {
 
4052
            'red': 22876,
 
4053
            'colors': 58275,
 
4054
            'green': 9425,
 
4055
            'cmap': 308019811,
 
4056
            'contiguous': 0,
 
4057
            'blue': 23880,
 
4058
            }
 
4059
        self.req_bin_0 = '\x57\x00\x00\x04' '\x12\x5c\x02\x63' \
 
4060
            '\xe3\xa3\x59\x5c' '\x24\xd1\x5d\x48'
 
4061
 
 
4062
        self.reply_args_0 = {
 
4063
            'green_mask': 265888391,
 
4064
            'sequence_number': 36175,
 
4065
            'pixels': [491961865, 1301906366, 1604705021, 1418751120],
 
4066
            'blue_mask': 44676180,
 
4067
            'red_mask': 734623206,
 
4068
            }
 
4069
        self.reply_bin_0 = '\x01\x00\x8d\x4f' '\x00\x00\x00\x04' \
 
4070
            '\x00\x04\x00\x00' '\x2b\xc9\x75\xe6' \
 
4071
            '\x0f\xd9\x22\x87' '\x02\xa9\xb4\x54' \
 
4072
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4073
            '\x1d\x52\xbe\x09' '\x4d\x99\x83\xbe' \
 
4074
            '\x5f\xa5\xda\xfd' '\x54\x90\x6c\x90'
 
4075
 
 
4076
 
 
4077
    def testPackRequest0(self):
 
4078
        bin = apply(request.AllocColorPlanes._request.to_binary, (), self.req_args_0)
 
4079
        try:
 
4080
            assert bin == self.req_bin_0
 
4081
        except AssertionError:
 
4082
            raise AssertionError(tohex(bin))
 
4083
 
 
4084
    def testUnpackRequest0(self):
 
4085
        args, remain = request.AllocColorPlanes._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4086
        try:
 
4087
            assert len(remain) == 0
 
4088
        except AssertionError:
 
4089
            raise AssertionError(tohex(remain))
 
4090
        try:
 
4091
            assert args == self.req_args_0
 
4092
        except AssertionError:
 
4093
            raise AssertionError(args)
 
4094
 
 
4095
    def testPackReply0(self):
 
4096
        bin = apply(request.AllocColorPlanes._reply.to_binary, (), self.reply_args_0)
 
4097
        try:
 
4098
            assert bin == self.reply_bin_0
 
4099
        except AssertionError:
 
4100
            raise AssertionError(tohex(bin))
 
4101
 
 
4102
    def testUnpackReply0(self):
 
4103
        args, remain = request.AllocColorPlanes._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
4104
        try:
 
4105
            assert len(remain) == 0
 
4106
        except AssertionError:
 
4107
            raise AssertionError(tohex(remain))
 
4108
        try:
 
4109
            assert args == self.reply_args_0
 
4110
        except AssertionError:
 
4111
            raise AssertionError(args)
 
4112
 
 
4113
 
 
4114
class TestFreeColors(unittest.TestCase):
 
4115
    def setUp(self):
 
4116
        self.req_args_0 = {
 
4117
            'cmap': 727008216,
 
4118
            'pixels': [61281082, 398475082, 1660604639, 1516738417, 1211104329, 105034864, 884930615, 902914796, 288637231, 2097165249, 1171127263, 1027274519, 806213035, 1485898709, 542709465, 169067149, 1230881159],
 
4119
            'plane_mask': 1204733200,
 
4120
            }
 
4121
        self.req_bin_0 = '\x58\x00\x00\x14' '\x2b\x55\x43\xd8' \
 
4122
            '\x47\xce\xc5\x10' '\x03\xa7\x13\x3a' \
 
4123
            '\x17\xc0\x3f\x4a' '\x62\xfa\xd0\xdf' \
 
4124
            '\x5a\x67\x97\x71' '\x48\x2f\xfc\x49' \
 
4125
            '\x06\x42\xb4\x70' '\x34\xbe\xf8\x37' \
 
4126
            '\x35\xd1\x62\xec' '\x11\x34\x41\x2f' \
 
4127
            '\x7d\x00\x33\xc1' '\x45\xcd\xfb\xdf' \
 
4128
            '\x3d\x3a\xf7\x17' '\x30\x0d\xd5\xab' \
 
4129
            '\x58\x91\x03\xd5' '\x20\x59\x16\xd9' \
 
4130
            '\x0a\x13\xc2\x8d' '\x49\x5d\xc1\x87'
 
4131
 
 
4132
 
 
4133
    def testPackRequest0(self):
 
4134
        bin = apply(request.FreeColors._request.to_binary, (), self.req_args_0)
 
4135
        try:
 
4136
            assert bin == self.req_bin_0
 
4137
        except AssertionError:
 
4138
            raise AssertionError(tohex(bin))
 
4139
 
 
4140
    def testUnpackRequest0(self):
 
4141
        args, remain = request.FreeColors._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4142
        try:
 
4143
            assert len(remain) == 0
 
4144
        except AssertionError:
 
4145
            raise AssertionError(tohex(remain))
 
4146
        try:
 
4147
            assert args == self.req_args_0
 
4148
        except AssertionError:
 
4149
            raise AssertionError(args)
 
4150
 
 
4151
 
 
4152
class TestStoreColors(unittest.TestCase):
 
4153
    def setUp(self):
 
4154
        self.req_args_0 = {
 
4155
            'cmap': 501035281,
 
4156
            'items': [{'red': 27925, 'pixel': 1094971765, 'green': 3673, 'flags': 189, 'blue': 31593}, {'red': 41633, 'pixel': 1330003189, 'green': 56186, 'flags': 178, 'blue': 30263}, {'red': 36007, 'pixel': 1813524037, 'green': 29697, 'flags': 224, 'blue': 14071}, {'red': 45716, 'pixel': 1987610486, 'green': 55405, 'flags': 200, 'blue': 35734}],
 
4157
            }
 
4158
        self.req_bin_0 = '\x59\x00\x00\x0e' '\x1d\xdd\x31\x11' \
 
4159
            '\x41\x43\xf1\x75' '\x6d\x15\x0e\x59' \
 
4160
            '\x7b\x69\xbd\x00' '\x4f\x46\x3c\xf5' \
 
4161
            '\xa2\xa1\xdb\x7a' '\x76\x37\xb2\x00' \
 
4162
            '\x6c\x18\x2e\x45' '\x8c\xa7\x74\x01' \
 
4163
            '\x36\xf7\xe0\x00' '\x76\x78\x87\x76' \
 
4164
            '\xb2\x94\xd8\x6d' '\x8b\x96\xc8\x00'
 
4165
 
 
4166
 
 
4167
    def testPackRequest0(self):
 
4168
        bin = apply(request.StoreColors._request.to_binary, (), self.req_args_0)
 
4169
        try:
 
4170
            assert bin == self.req_bin_0
 
4171
        except AssertionError:
 
4172
            raise AssertionError(tohex(bin))
 
4173
 
 
4174
    def testUnpackRequest0(self):
 
4175
        args, remain = request.StoreColors._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4176
        try:
 
4177
            assert len(remain) == 0
 
4178
        except AssertionError:
 
4179
            raise AssertionError(tohex(remain))
 
4180
        try:
 
4181
            assert args == self.req_args_0
 
4182
        except AssertionError:
 
4183
            raise AssertionError(args)
 
4184
 
 
4185
 
 
4186
class TestStoreNamedColor(unittest.TestCase):
 
4187
    def setUp(self):
 
4188
        self.req_args_0 = {
 
4189
            'name': 'blue',
 
4190
            'flags': 186,
 
4191
            'cmap': 2061119590,
 
4192
            'pixel': 1846011298,
 
4193
            }
 
4194
        self.req_bin_0 = '\x5a\xba\x00\x05' '\x7a\xda\x30\x66' \
 
4195
            '\x6e\x07\xe5\xa2' '\x00\x04\x00\x00' \
 
4196
            '\x62\x6c\x75\x65'
 
4197
 
 
4198
 
 
4199
    def testPackRequest0(self):
 
4200
        bin = apply(request.StoreNamedColor._request.to_binary, (), self.req_args_0)
 
4201
        try:
 
4202
            assert bin == self.req_bin_0
 
4203
        except AssertionError:
 
4204
            raise AssertionError(tohex(bin))
 
4205
 
 
4206
    def testUnpackRequest0(self):
 
4207
        args, remain = request.StoreNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4208
        try:
 
4209
            assert len(remain) == 0
 
4210
        except AssertionError:
 
4211
            raise AssertionError(tohex(remain))
 
4212
        try:
 
4213
            assert args == self.req_args_0
 
4214
        except AssertionError:
 
4215
            raise AssertionError(args)
 
4216
 
 
4217
 
 
4218
class TestQueryColors(unittest.TestCase):
 
4219
    def setUp(self):
 
4220
        self.req_args_0 = {
 
4221
            'cmap': 596369797,
 
4222
            'pixels': [1018587496, 1553480933, 952694607, 341816269, 306591348, 1178729919, 173027853, 875811363],
 
4223
            }
 
4224
        self.req_bin_0 = '\x5b\x00\x00\x0a' '\x23\x8b\xe1\x85' \
 
4225
            '\x3c\xb6\x69\x68' '\x5c\x98\x3c\xe5' \
 
4226
            '\x38\xc8\xf7\x4f' '\x14\x5f\xb3\xcd' \
 
4227
            '\x12\x46\x36\x74' '\x46\x41\xfd\xbf' \
 
4228
            '\x0a\x50\x32\x0d' '\x34\x33\xd2\x23'
 
4229
 
 
4230
        self.reply_args_0 = {
 
4231
            'colors': [{'red': 6715, 'blue': 40144, 'green': 56664}, {'red': 5799, 'blue': 22078, 'green': 35523}, {'red': 60111, 'blue': 58654, 'green': 25206}, {'red': 7433, 'blue': 60908, 'green': 14468}, {'red': 31213, 'blue': 9298, 'green': 27481}],
 
4232
            'sequence_number': 60323,
 
4233
            }
 
4234
        self.reply_bin_0 = '\x01\x00\xeb\xa3' '\x00\x00\x00\x0a' \
 
4235
            '\x00\x05\x00\x00' '\x00\x00\x00\x00' \
 
4236
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4237
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4238
            '\x1a\x3b\xdd\x58' '\x9c\xd0\x00\x00' \
 
4239
            '\x16\xa7\x8a\xc3' '\x56\x3e\x00\x00' \
 
4240
            '\xea\xcf\x62\x76' '\xe5\x1e\x00\x00' \
 
4241
            '\x1d\x09\x38\x84' '\xed\xec\x00\x00' \
 
4242
            '\x79\xed\x6b\x59' '\x24\x52\x00\x00'
 
4243
 
 
4244
        self.req_args_1 = {
 
4245
            'cmap': 79317049,
 
4246
            'pixels': [],
 
4247
            }
 
4248
        self.req_bin_1 = '\x5b\x00\x00\x02' '\x04\xba\x48\x39'
 
4249
 
 
4250
 
 
4251
    def testPackRequest0(self):
 
4252
        bin = apply(request.QueryColors._request.to_binary, (), self.req_args_0)
 
4253
        try:
 
4254
            assert bin == self.req_bin_0
 
4255
        except AssertionError:
 
4256
            raise AssertionError(tohex(bin))
 
4257
 
 
4258
    def testUnpackRequest0(self):
 
4259
        args, remain = request.QueryColors._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4260
        try:
 
4261
            assert len(remain) == 0
 
4262
        except AssertionError:
 
4263
            raise AssertionError(tohex(remain))
 
4264
        try:
 
4265
            assert args == self.req_args_0
 
4266
        except AssertionError:
 
4267
            raise AssertionError(args)
 
4268
 
 
4269
    def testPackRequest1(self):
 
4270
        bin = apply(request.QueryColors._request.to_binary, (), self.req_args_1)
 
4271
        try:
 
4272
            assert bin == self.req_bin_1
 
4273
        except AssertionError:
 
4274
            raise AssertionError(tohex(bin))
 
4275
 
 
4276
    def testUnpackRequest1(self):
 
4277
        args, remain = request.QueryColors._request.parse_binary(self.req_bin_1, dummy_display, 1)
 
4278
        try:
 
4279
            assert len(remain) == 0
 
4280
        except AssertionError:
 
4281
            raise AssertionError(tohex(remain))
 
4282
        try:
 
4283
            assert args == self.req_args_1
 
4284
        except AssertionError:
 
4285
            raise AssertionError(args)
 
4286
 
 
4287
    def testPackReply0(self):
 
4288
        bin = apply(request.QueryColors._reply.to_binary, (), self.reply_args_0)
 
4289
        try:
 
4290
            assert bin == self.reply_bin_0
 
4291
        except AssertionError:
 
4292
            raise AssertionError(tohex(bin))
 
4293
 
 
4294
    def testUnpackReply0(self):
 
4295
        args, remain = request.QueryColors._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
4296
        try:
 
4297
            assert len(remain) == 0
 
4298
        except AssertionError:
 
4299
            raise AssertionError(tohex(remain))
 
4300
        try:
 
4301
            assert args == self.reply_args_0
 
4302
        except AssertionError:
 
4303
            raise AssertionError(args)
 
4304
 
 
4305
 
 
4306
class TestLookupColor(unittest.TestCase):
 
4307
    def setUp(self):
 
4308
        self.req_args_0 = {
 
4309
            'cmap': 789574750,
 
4310
            'name': 'octarin',
 
4311
            }
 
4312
        self.req_bin_0 = '\x5c\x00\x00\x05' '\x2f\x0f\xf4\x5e' \
 
4313
            '\x00\x07\x00\x00' '\x6f\x63\x74\x61' \
 
4314
            '\x72\x69\x6e\x00'
 
4315
 
 
4316
        self.reply_args_0 = {
 
4317
            'sequence_number': 21040,
 
4318
            'screen_green': 65314,
 
4319
            'screen_red': 51033,
 
4320
            'exact_green': 59546,
 
4321
            'exact_blue': 61512,
 
4322
            'screen_blue': 29893,
 
4323
            'exact_red': 41875,
 
4324
            }
 
4325
        self.reply_bin_0 = '\x01\x00\x52\x30' '\x00\x00\x00\x00' \
 
4326
            '\xa3\x93\xe8\x9a' '\xf0\x48\xc7\x59' \
 
4327
            '\xff\x22\x74\xc5' '\x00\x00\x00\x00' \
 
4328
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
4329
 
 
4330
 
 
4331
    def testPackRequest0(self):
 
4332
        bin = apply(request.LookupColor._request.to_binary, (), self.req_args_0)
 
4333
        try:
 
4334
            assert bin == self.req_bin_0
 
4335
        except AssertionError:
 
4336
            raise AssertionError(tohex(bin))
 
4337
 
 
4338
    def testUnpackRequest0(self):
 
4339
        args, remain = request.LookupColor._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4340
        try:
 
4341
            assert len(remain) == 0
 
4342
        except AssertionError:
 
4343
            raise AssertionError(tohex(remain))
 
4344
        try:
 
4345
            assert args == self.req_args_0
 
4346
        except AssertionError:
 
4347
            raise AssertionError(args)
 
4348
 
 
4349
    def testPackReply0(self):
 
4350
        bin = apply(request.LookupColor._reply.to_binary, (), self.reply_args_0)
 
4351
        try:
 
4352
            assert bin == self.reply_bin_0
 
4353
        except AssertionError:
 
4354
            raise AssertionError(tohex(bin))
 
4355
 
 
4356
    def testUnpackReply0(self):
 
4357
        args, remain = request.LookupColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
4358
        try:
 
4359
            assert len(remain) == 0
 
4360
        except AssertionError:
 
4361
            raise AssertionError(tohex(remain))
 
4362
        try:
 
4363
            assert args == self.reply_args_0
 
4364
        except AssertionError:
 
4365
            raise AssertionError(args)
 
4366
 
 
4367
 
 
4368
class TestCreateCursor(unittest.TestCase):
 
4369
    def setUp(self):
 
4370
        self.req_args_0 = {
 
4371
            'x': 14199,
 
4372
            'fore_red': 65323,
 
4373
            'back_green': 5090,
 
4374
            'mask': 420188900,
 
4375
            'back_blue': 49879,
 
4376
            'y': 32780,
 
4377
            'cid': 2022028217,
 
4378
            'fore_blue': 63540,
 
4379
            'fore_green': 43028,
 
4380
            'back_red': 31899,
 
4381
            'source': 794739749,
 
4382
            }
 
4383
        self.req_bin_0 = '\x5d\x00\x00\x08' '\x78\x85\xb3\xb9' \
 
4384
            '\x2f\x5e\xc4\x25' '\x19\x0b\x92\xe4' \
 
4385
            '\xff\x2b\xa8\x14' '\xf8\x34\x7c\x9b' \
 
4386
            '\x13\xe2\xc2\xd7' '\x37\x77\x80\x0c'
 
4387
 
 
4388
 
 
4389
    def testPackRequest0(self):
 
4390
        bin = apply(request.CreateCursor._request.to_binary, (), self.req_args_0)
 
4391
        try:
 
4392
            assert bin == self.req_bin_0
 
4393
        except AssertionError:
 
4394
            raise AssertionError(tohex(bin))
 
4395
 
 
4396
    def testUnpackRequest0(self):
 
4397
        args, remain = request.CreateCursor._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4398
        try:
 
4399
            assert len(remain) == 0
 
4400
        except AssertionError:
 
4401
            raise AssertionError(tohex(remain))
 
4402
        try:
 
4403
            assert args == self.req_args_0
 
4404
        except AssertionError:
 
4405
            raise AssertionError(args)
 
4406
 
 
4407
 
 
4408
class TestCreateGlyphCursor(unittest.TestCase):
 
4409
    def setUp(self):
 
4410
        self.req_args_0 = {
 
4411
            'fore_red': 56306,
 
4412
            'source_char': 7568,
 
4413
            'mask': 2018599719,
 
4414
            'back_blue': 6500,
 
4415
            'cid': 1999539964,
 
4416
            'mask_char': 46124,
 
4417
            'fore_blue': 30793,
 
4418
            'fore_green': 16989,
 
4419
            'back_red': 64484,
 
4420
            'source': 1412345132,
 
4421
            'back_green': 52966,
 
4422
            }
 
4423
        self.req_bin_0 = '\x5e\x00\x00\x08' '\x77\x2e\x8e\xfc' \
 
4424
            '\x54\x2e\xad\x2c' '\x78\x51\x63\x27' \
 
4425
            '\x1d\x90\xb4\x2c' '\xdb\xf2\x42\x5d' \
 
4426
            '\x78\x49\xfb\xe4' '\xce\xe6\x19\x64'
 
4427
 
 
4428
 
 
4429
    def testPackRequest0(self):
 
4430
        bin = apply(request.CreateGlyphCursor._request.to_binary, (), self.req_args_0)
 
4431
        try:
 
4432
            assert bin == self.req_bin_0
 
4433
        except AssertionError:
 
4434
            raise AssertionError(tohex(bin))
 
4435
 
 
4436
    def testUnpackRequest0(self):
 
4437
        args, remain = request.CreateGlyphCursor._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4438
        try:
 
4439
            assert len(remain) == 0
 
4440
        except AssertionError:
 
4441
            raise AssertionError(tohex(remain))
 
4442
        try:
 
4443
            assert args == self.req_args_0
 
4444
        except AssertionError:
 
4445
            raise AssertionError(args)
 
4446
 
 
4447
 
 
4448
class TestFreeCursor(unittest.TestCase):
 
4449
    def setUp(self):
 
4450
        self.req_args_0 = {
 
4451
            'cursor': 553262138,
 
4452
            }
 
4453
        self.req_bin_0 = '\x5f\x00\x00\x02' '\x20\xfa\x1c\x3a'
 
4454
 
 
4455
 
 
4456
    def testPackRequest0(self):
 
4457
        bin = apply(request.FreeCursor._request.to_binary, (), self.req_args_0)
 
4458
        try:
 
4459
            assert bin == self.req_bin_0
 
4460
        except AssertionError:
 
4461
            raise AssertionError(tohex(bin))
 
4462
 
 
4463
    def testUnpackRequest0(self):
 
4464
        args, remain = request.FreeCursor._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4465
        try:
 
4466
            assert len(remain) == 0
 
4467
        except AssertionError:
 
4468
            raise AssertionError(tohex(remain))
 
4469
        try:
 
4470
            assert args == self.req_args_0
 
4471
        except AssertionError:
 
4472
            raise AssertionError(args)
 
4473
 
 
4474
 
 
4475
class TestRecolorCursor(unittest.TestCase):
 
4476
    def setUp(self):
 
4477
        self.req_args_0 = {
 
4478
            'fore_red': 44718,
 
4479
            'fore_green': 33104,
 
4480
            'back_blue': 49533,
 
4481
            'back_green': 12163,
 
4482
            'fore_blue': 17246,
 
4483
            'back_red': 64013,
 
4484
            'cursor': 295995276,
 
4485
            }
 
4486
        self.req_bin_0 = '\x60\x00\x00\x05' '\x11\xa4\x87\x8c' \
 
4487
            '\xae\xae\x81\x50' '\x43\x5e\xfa\x0d' \
 
4488
            '\x2f\x83\xc1\x7d'
 
4489
 
 
4490
 
 
4491
    def testPackRequest0(self):
 
4492
        bin = apply(request.RecolorCursor._request.to_binary, (), self.req_args_0)
 
4493
        try:
 
4494
            assert bin == self.req_bin_0
 
4495
        except AssertionError:
 
4496
            raise AssertionError(tohex(bin))
 
4497
 
 
4498
    def testUnpackRequest0(self):
 
4499
        args, remain = request.RecolorCursor._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4500
        try:
 
4501
            assert len(remain) == 0
 
4502
        except AssertionError:
 
4503
            raise AssertionError(tohex(remain))
 
4504
        try:
 
4505
            assert args == self.req_args_0
 
4506
        except AssertionError:
 
4507
            raise AssertionError(args)
 
4508
 
 
4509
 
 
4510
class TestQueryBestSize(unittest.TestCase):
 
4511
    def setUp(self):
 
4512
        self.req_args_0 = {
 
4513
            'height': 34743,
 
4514
            'drawable': 503496990,
 
4515
            'item_class': 1,
 
4516
            'width': 27916,
 
4517
            }
 
4518
        self.req_bin_0 = '\x61\x01\x00\x03' '\x1e\x02\xc1\x1e' \
 
4519
            '\x6d\x0c\x87\xb7'
 
4520
 
 
4521
        self.reply_args_0 = {
 
4522
            'height': 60728,
 
4523
            'sequence_number': 34070,
 
4524
            'width': 35970,
 
4525
            }
 
4526
        self.reply_bin_0 = '\x01\x00\x85\x16' '\x00\x00\x00\x00' \
 
4527
            '\x8c\x82\xed\x38' '\x00\x00\x00\x00' \
 
4528
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4529
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
4530
 
 
4531
 
 
4532
    def testPackRequest0(self):
 
4533
        bin = apply(request.QueryBestSize._request.to_binary, (), self.req_args_0)
 
4534
        try:
 
4535
            assert bin == self.req_bin_0
 
4536
        except AssertionError:
 
4537
            raise AssertionError(tohex(bin))
 
4538
 
 
4539
    def testUnpackRequest0(self):
 
4540
        args, remain = request.QueryBestSize._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4541
        try:
 
4542
            assert len(remain) == 0
 
4543
        except AssertionError:
 
4544
            raise AssertionError(tohex(remain))
 
4545
        try:
 
4546
            assert args == self.req_args_0
 
4547
        except AssertionError:
 
4548
            raise AssertionError(args)
 
4549
 
 
4550
    def testPackReply0(self):
 
4551
        bin = apply(request.QueryBestSize._reply.to_binary, (), self.reply_args_0)
 
4552
        try:
 
4553
            assert bin == self.reply_bin_0
 
4554
        except AssertionError:
 
4555
            raise AssertionError(tohex(bin))
 
4556
 
 
4557
    def testUnpackReply0(self):
 
4558
        args, remain = request.QueryBestSize._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
4559
        try:
 
4560
            assert len(remain) == 0
 
4561
        except AssertionError:
 
4562
            raise AssertionError(tohex(remain))
 
4563
        try:
 
4564
            assert args == self.reply_args_0
 
4565
        except AssertionError:
 
4566
            raise AssertionError(args)
 
4567
 
 
4568
 
 
4569
class TestQueryExtension(unittest.TestCase):
 
4570
    def setUp(self):
 
4571
        self.req_args_0 = {
 
4572
            'name': 'XTRA',
 
4573
            }
 
4574
        self.req_bin_0 = '\x62\x00\x00\x03' '\x00\x04\x00\x00' \
 
4575
            '\x58\x54\x52\x41'
 
4576
 
 
4577
        self.reply_args_0 = {
 
4578
            'sequence_number': 39952,
 
4579
            'major_opcode': 195,
 
4580
            'first_error': 150,
 
4581
            'present': 1,
 
4582
            'first_event': 202,
 
4583
            }
 
4584
        self.reply_bin_0 = '\x01\x00\x9c\x10' '\x00\x00\x00\x00' \
 
4585
            '\x01\xc3\xca\x96' '\x00\x00\x00\x00' \
 
4586
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4587
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
4588
 
 
4589
 
 
4590
    def testPackRequest0(self):
 
4591
        bin = apply(request.QueryExtension._request.to_binary, (), self.req_args_0)
 
4592
        try:
 
4593
            assert bin == self.req_bin_0
 
4594
        except AssertionError:
 
4595
            raise AssertionError(tohex(bin))
 
4596
 
 
4597
    def testUnpackRequest0(self):
 
4598
        args, remain = request.QueryExtension._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4599
        try:
 
4600
            assert len(remain) == 0
 
4601
        except AssertionError:
 
4602
            raise AssertionError(tohex(remain))
 
4603
        try:
 
4604
            assert args == self.req_args_0
 
4605
        except AssertionError:
 
4606
            raise AssertionError(args)
 
4607
 
 
4608
    def testPackReply0(self):
 
4609
        bin = apply(request.QueryExtension._reply.to_binary, (), self.reply_args_0)
 
4610
        try:
 
4611
            assert bin == self.reply_bin_0
 
4612
        except AssertionError:
 
4613
            raise AssertionError(tohex(bin))
 
4614
 
 
4615
    def testUnpackReply0(self):
 
4616
        args, remain = request.QueryExtension._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
4617
        try:
 
4618
            assert len(remain) == 0
 
4619
        except AssertionError:
 
4620
            raise AssertionError(tohex(remain))
 
4621
        try:
 
4622
            assert args == self.reply_args_0
 
4623
        except AssertionError:
 
4624
            raise AssertionError(args)
 
4625
 
 
4626
 
 
4627
class TestListExtensions(unittest.TestCase):
 
4628
    def setUp(self):
 
4629
        self.req_args_0 = {
 
4630
            }
 
4631
        self.req_bin_0 = '\x63\x00\x00\x01'
 
4632
 
 
4633
        self.reply_args_0 = {
 
4634
            'sequence_number': 20200,
 
4635
            'names': ['XTRA', 'XTRA-II'],
 
4636
            }
 
4637
        self.reply_bin_0 = '\x01\x02\x4e\xe8' '\x00\x00\x00\x04' \
 
4638
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4639
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4640
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4641
            '\x04\x58\x54\x52' '\x41\x07\x58\x54' \
 
4642
            '\x52\x41\x2d\x49' '\x49\x00\x00\x00'
 
4643
 
 
4644
 
 
4645
    def testPackRequest0(self):
 
4646
        bin = apply(request.ListExtensions._request.to_binary, (), self.req_args_0)
 
4647
        try:
 
4648
            assert bin == self.req_bin_0
 
4649
        except AssertionError:
 
4650
            raise AssertionError(tohex(bin))
 
4651
 
 
4652
    def testUnpackRequest0(self):
 
4653
        args, remain = request.ListExtensions._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4654
        try:
 
4655
            assert len(remain) == 0
 
4656
        except AssertionError:
 
4657
            raise AssertionError(tohex(remain))
 
4658
        try:
 
4659
            assert args == self.req_args_0
 
4660
        except AssertionError:
 
4661
            raise AssertionError(args)
 
4662
 
 
4663
    def testPackReply0(self):
 
4664
        bin = apply(request.ListExtensions._reply.to_binary, (), self.reply_args_0)
 
4665
        try:
 
4666
            assert bin == self.reply_bin_0
 
4667
        except AssertionError:
 
4668
            raise AssertionError(tohex(bin))
 
4669
 
 
4670
    def testUnpackReply0(self):
 
4671
        args, remain = request.ListExtensions._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
4672
        try:
 
4673
            assert len(remain) == 0
 
4674
        except AssertionError:
 
4675
            raise AssertionError(tohex(remain))
 
4676
        try:
 
4677
            assert args == self.reply_args_0
 
4678
        except AssertionError:
 
4679
            raise AssertionError(args)
 
4680
 
 
4681
 
 
4682
class TestChangeKeyboardMapping(unittest.TestCase):
 
4683
    def setUp(self):
 
4684
        self.req_args_0 = {
 
4685
            'keysyms': [[707837223, 99294840, 1205405602], [67157514, 879853050, 2059131033], [1139736188, 578113249, 1525786315], [1335349176, 246731334, 277761436], [1386594542, 1676932187, 1862777168], [535892916, 342718655, 195574000], [5712156, 1820472637, 848853860], [1123197289, 1664064022, 94999154], [380150420, 402902535, 1061375041], [510686316, 502245882, 422893644], [1423643601, 194077695, 403885178], [1571826296, 529249772, 623556591], [720045879, 37553034, 955963792], [513407882, 861125615, 219940695], [184890179, 472466494, 1649347894], [1679171989, 1991748404, 1674460475], [1762342934, 276695222, 1941684480], [886658026, 1860690072, 577030090], [227169721, 1390318675, 321524615], [2144591365, 545119116, 404205206]],
 
4686
            'first_keycode': 250,
 
4687
            }
 
4688
        self.req_bin_0 = '\x64\x14\x00\x3e' '\xfa\x03\x00\x00' \
 
4689
            '\x2a\x30\xbd\x27' '\x05\xeb\x1e\x78' \
 
4690
            '\x47\xd9\x07\xa2' '\x04\x00\xbe\x0a' \
 
4691
            '\x34\x71\x7d\xfa' '\x7a\xbb\xd8\x99' \
 
4692
            '\x43\xee\xfe\x7c' '\x22\x75\x4e\xe1' \
 
4693
            '\x5a\xf1\xa6\xcb' '\x4f\x97\xcf\xb8' \
 
4694
            '\x0e\xb4\xd2\x46' '\x10\x8e\x4d\x9c' \
 
4695
            '\x52\xa5\xc0\xee' '\x63\xf3\xf4\x5b' \
 
4696
            '\x6f\x07\xb9\x50' '\x1f\xf1\x13\xb4' \
 
4697
            '\x14\x6d\x78\xbf' '\x0b\xa8\x38\xf0' \
 
4698
            '\x00\x57\x29\x1c' '\x6c\x82\x35\x3d' \
 
4699
            '\x32\x98\x7b\x64' '\x42\xf2\xa1\x69' \
 
4700
            '\x63\x2f\x9a\x16' '\x05\xa9\x92\x72' \
 
4701
            '\x16\xa8\xa2\x94' '\x18\x03\xce\x07' \
 
4702
            '\x3f\x43\x4c\x41' '\x1e\x70\x74\x6c' \
 
4703
            '\x1d\xef\xa9\xfa' '\x19\x34\xd8\x4c' \
 
4704
            '\x54\xdb\x13\xd1' '\x0b\x91\x63\xff' \
 
4705
            '\x18\x12\xcc\x7a' '\x5d\xb0\x2a\x78' \
 
4706
            '\x1f\x8b\xb5\xec' '\x25\x2a\xb7\xef' \
 
4707
            '\x2a\xeb\x07\x37' '\x02\x3d\x03\x8a' \
 
4708
            '\x38\xfa\xd9\x90' '\x1e\x99\xfb\x8a' \
 
4709
            '\x33\x53\xbb\xef' '\x0d\x1c\x07\x57' \
 
4710
            '\x0b\x05\x33\x43' '\x1c\x29\x44\x3e' \
 
4711
            '\x62\x4f\x0d\x36' '\x64\x16\x21\x95' \
 
4712
            '\x76\xb7\xab\x34' '\x63\xce\x3d\x3b' \
 
4713
            '\x69\x0b\x38\x16' '\x10\x7e\x08\xb6' \
 
4714
            '\x73\xbb\xc1\x00' '\x34\xd9\x53\xea' \
 
4715
            '\x6e\xe7\xe0\x98' '\x22\x64\xc7\xca' \
 
4716
            '\x0d\x8a\x55\xb9' '\x52\xde\x94\x53' \
 
4717
            '\x13\x2a\x13\x87' '\x7f\xd3\xde\x05' \
 
4718
            '\x20\x7d\xdb\x8c' '\x18\x17\xae\x96'
 
4719
 
 
4720
 
 
4721
    def testPackRequest0(self):
 
4722
        bin = apply(request.ChangeKeyboardMapping._request.to_binary, (), self.req_args_0)
 
4723
        try:
 
4724
            assert bin == self.req_bin_0
 
4725
        except AssertionError:
 
4726
            raise AssertionError(tohex(bin))
 
4727
 
 
4728
    def testUnpackRequest0(self):
 
4729
        args, remain = request.ChangeKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4730
        try:
 
4731
            assert len(remain) == 0
 
4732
        except AssertionError:
 
4733
            raise AssertionError(tohex(remain))
 
4734
        try:
 
4735
            assert args == self.req_args_0
 
4736
        except AssertionError:
 
4737
            raise AssertionError(args)
 
4738
 
 
4739
 
 
4740
class TestGetKeyboardMapping(unittest.TestCase):
 
4741
    def setUp(self):
 
4742
        self.req_args_0 = {
 
4743
            'count': 131,
 
4744
            'first_keycode': 206,
 
4745
            }
 
4746
        self.req_bin_0 = '\x65\x00\x00\x02' '\xce\x83\x00\x00'
 
4747
 
 
4748
        self.reply_args_0 = {
 
4749
            'keysyms': [[1550369014, 1683205347, 1879538861], [452613596, 1132022246, 357271408], [528724632, 2118423140, 640580111], [1981239140, 195173082, 497130901], [2001675011, 809172000, 1577756130], [739794769, 1774524806, 787951551], [1784021539, 1998872082, 1747812414], [396316053, 1525431160, 1808906812], [1676662850, 1222579650, 1205117622], [396026453, 1956747483, 1762026309], [1222502216, 1488139702, 1799119214], [1504675136, 1414564657, 419659384], [1934768917, 2095924224, 590955729], [582168798, 383228141, 1552516537], [1482483262, 1041896520, 1047041873], [1932705867, 292473490, 226147737], [780322016, 1965031752, 1481062205], [89811542, 1313413666, 686267194], [237776128, 1310737228, 792176733], [849034415, 1592538831, 837355505]],
 
4750
            'sequence_number': 61409,
 
4751
            }
 
4752
        self.reply_bin_0 = '\x01\x03\xef\xe1' '\x00\x00\x00\x3c' \
 
4753
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4754
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4755
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4756
            '\x5c\x68\xc0\xf6' '\x64\x53\xac\xe3' \
 
4757
            '\x70\x07\x7c\xad' '\x1a\xfa\x55\xdc' \
 
4758
            '\x43\x79\x49\xe6' '\x15\x4b\x87\x70' \
 
4759
            '\x1f\x83\xb2\x98' '\x7e\x44\x92\x64' \
 
4760
            '\x26\x2e\x7a\x0f' '\x76\x17\x4f\x64' \
 
4761
            '\x0b\xa2\x1a\xda' '\x1d\xa1\x9d\x95' \
 
4762
            '\x77\x4f\x23\x03' '\x30\x3a\xfc\x20' \
 
4763
            '\x5e\x0a\xa5\xe2' '\x2c\x18\x5f\x51' \
 
4764
            '\x69\xc5\x19\x86' '\x2e\xf7\x2f\xbf' \
 
4765
            '\x6a\x56\x02\x23' '\x77\x24\x5e\x12' \
 
4766
            '\x68\x2d\x80\x3e' '\x17\x9f\x4d\x95' \
 
4767
            '\x5a\xec\x3b\x78' '\x6b\xd1\xba\x3c' \
 
4768
            '\x63\xef\xd8\x42' '\x48\xdf\x15\xc2' \
 
4769
            '\x47\xd4\xa2\xb6' '\x17\x9a\xe2\x55' \
 
4770
            '\x74\xa1\x98\xdb' '\x69\x06\x63\x45' \
 
4771
            '\x48\xdd\xe7\x48' '\x58\xb3\x35\xb6' \
 
4772
            '\x6b\x3c\x61\x6e' '\x59\xaf\x85\x40' \
 
4773
            '\x54\x50\x8b\x31' '\x19\x03\x7e\x78' \
 
4774
            '\x73\x52\x3b\x15' '\x7c\xed\x44\x00' \
 
4775
            '\x23\x39\x44\xd1' '\x22\xb3\x30\xde' \
 
4776
            '\x16\xd7\x98\xed' '\x5c\x89\x85\xb9' \
 
4777
            '\x58\x5c\xe6\x3e' '\x3e\x1a\x14\x48' \
 
4778
            '\x3e\x68\x97\x51' '\x73\x32\xc0\x4b' \
 
4779
            '\x11\x6e\xca\x92' '\x0d\x7a\xbd\x99' \
 
4780
            '\x2e\x82\xc4\xe0' '\x75\x20\x01\x48' \
 
4781
            '\x58\x47\x37\x3d' '\x05\x5a\x6a\x56' \
 
4782
            '\x4e\x49\x1a\x22' '\x28\xe7\x9b\x3a' \
 
4783
            '\x0e\x2c\x2d\x00' '\x4e\x20\x43\x4c' \
 
4784
            '\x2f\x37\xa8\x5d' '\x32\x9b\x3c\xaf' \
 
4785
            '\x5e\xec\x36\xcf' '\x31\xe9\x07\xf1'
 
4786
 
 
4787
 
 
4788
    def testPackRequest0(self):
 
4789
        bin = apply(request.GetKeyboardMapping._request.to_binary, (), self.req_args_0)
 
4790
        try:
 
4791
            assert bin == self.req_bin_0
 
4792
        except AssertionError:
 
4793
            raise AssertionError(tohex(bin))
 
4794
 
 
4795
    def testUnpackRequest0(self):
 
4796
        args, remain = request.GetKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4797
        try:
 
4798
            assert len(remain) == 0
 
4799
        except AssertionError:
 
4800
            raise AssertionError(tohex(remain))
 
4801
        try:
 
4802
            assert args == self.req_args_0
 
4803
        except AssertionError:
 
4804
            raise AssertionError(args)
 
4805
 
 
4806
    def testPackReply0(self):
 
4807
        bin = apply(request.GetKeyboardMapping._reply.to_binary, (), self.reply_args_0)
 
4808
        try:
 
4809
            assert bin == self.reply_bin_0
 
4810
        except AssertionError:
 
4811
            raise AssertionError(tohex(bin))
 
4812
 
 
4813
    def testUnpackReply0(self):
 
4814
        args, remain = request.GetKeyboardMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
4815
        try:
 
4816
            assert len(remain) == 0
 
4817
        except AssertionError:
 
4818
            raise AssertionError(tohex(remain))
 
4819
        try:
 
4820
            assert args == self.reply_args_0
 
4821
        except AssertionError:
 
4822
            raise AssertionError(args)
 
4823
 
 
4824
 
 
4825
class TestChangeKeyboardControl(unittest.TestCase):
 
4826
    def setUp(self):
 
4827
        self.req_args_0 = {
 
4828
            'attrs': {'key_click_percent': -35, 'bell_percent': -53, 'led_mode': 1, 'bell_pitch': -17390, 'auto_repeat_mode': 2, 'bell_duration': -30281, 'key': 235, 'led': 192},
 
4829
            }
 
4830
        self.req_bin_0 = '\x66\x00\x00\x0a' '\x00\x00\x00\xff' \
 
4831
            '\xdd\x00\x00\x00' '\xcb\x00\x00\x00' \
 
4832
            '\xbc\x12\x00\x00' '\x89\xb7\x00\x00' \
 
4833
            '\xc0\x00\x00\x00' '\x01\x00\x00\x00' \
 
4834
            '\xeb\x00\x00\x00' '\x02\x00\x00\x00'
 
4835
 
 
4836
 
 
4837
    def testPackRequest0(self):
 
4838
        bin = apply(request.ChangeKeyboardControl._request.to_binary, (), self.req_args_0)
 
4839
        try:
 
4840
            assert bin == self.req_bin_0
 
4841
        except AssertionError:
 
4842
            raise AssertionError(tohex(bin))
 
4843
 
 
4844
    def testUnpackRequest0(self):
 
4845
        args, remain = request.ChangeKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4846
        try:
 
4847
            assert len(remain) == 0
 
4848
        except AssertionError:
 
4849
            raise AssertionError(tohex(remain))
 
4850
        try:
 
4851
            assert args == self.req_args_0
 
4852
        except AssertionError:
 
4853
            raise AssertionError(args)
 
4854
 
 
4855
 
 
4856
class TestGetKeyboardControl(unittest.TestCase):
 
4857
    def setUp(self):
 
4858
        self.req_args_0 = {
 
4859
            }
 
4860
        self.req_bin_0 = '\x67\x00\x00\x01'
 
4861
 
 
4862
        self.reply_args_0 = {
 
4863
            'key_click_percent': 206,
 
4864
            'sequence_number': 30149,
 
4865
            'bell_percent': 251,
 
4866
            'bell_pitch': 13779,
 
4867
            'auto_repeats': [217, 171, 167, 167, 243, 163, 129, 239, 168, 153, 225, 199, 189, 155, 228, 149, 148, 237, 139, 150, 211, 133, 135, 250, 191, 166, 146, 212, 239, 183, 214, 250],
 
4868
            'global_auto_repeat': 0,
 
4869
            'led_mask': 438224369,
 
4870
            'bell_duration': 20235,
 
4871
            }
 
4872
        self.reply_bin_0 = '\x01\x00\x75\xc5' '\x00\x00\x00\x05' \
 
4873
            '\x1a\x1e\xc5\xf1' '\xce\xfb\x35\xd3' \
 
4874
            '\x4f\x0b\x00\x00' '\xd9\xab\xa7\xa7' \
 
4875
            '\xf3\xa3\x81\xef' '\xa8\x99\xe1\xc7' \
 
4876
            '\xbd\x9b\xe4\x95' '\x94\xed\x8b\x96' \
 
4877
            '\xd3\x85\x87\xfa' '\xbf\xa6\x92\xd4' \
 
4878
            '\xef\xb7\xd6\xfa'
 
4879
 
 
4880
 
 
4881
    def testPackRequest0(self):
 
4882
        bin = apply(request.GetKeyboardControl._request.to_binary, (), self.req_args_0)
 
4883
        try:
 
4884
            assert bin == self.req_bin_0
 
4885
        except AssertionError:
 
4886
            raise AssertionError(tohex(bin))
 
4887
 
 
4888
    def testUnpackRequest0(self):
 
4889
        args, remain = request.GetKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4890
        try:
 
4891
            assert len(remain) == 0
 
4892
        except AssertionError:
 
4893
            raise AssertionError(tohex(remain))
 
4894
        try:
 
4895
            assert args == self.req_args_0
 
4896
        except AssertionError:
 
4897
            raise AssertionError(args)
 
4898
 
 
4899
    def testPackReply0(self):
 
4900
        bin = apply(request.GetKeyboardControl._reply.to_binary, (), self.reply_args_0)
 
4901
        try:
 
4902
            assert bin == self.reply_bin_0
 
4903
        except AssertionError:
 
4904
            raise AssertionError(tohex(bin))
 
4905
 
 
4906
    def testUnpackReply0(self):
 
4907
        args, remain = request.GetKeyboardControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
4908
        try:
 
4909
            assert len(remain) == 0
 
4910
        except AssertionError:
 
4911
            raise AssertionError(tohex(remain))
 
4912
        try:
 
4913
            assert args == self.reply_args_0
 
4914
        except AssertionError:
 
4915
            raise AssertionError(args)
 
4916
 
 
4917
 
 
4918
class TestBell(unittest.TestCase):
 
4919
    def setUp(self):
 
4920
        self.req_args_0 = {
 
4921
            'percent': -19,
 
4922
            }
 
4923
        self.req_bin_0 = '\x68\xed\x00\x01'
 
4924
 
 
4925
 
 
4926
    def testPackRequest0(self):
 
4927
        bin = apply(request.Bell._request.to_binary, (), self.req_args_0)
 
4928
        try:
 
4929
            assert bin == self.req_bin_0
 
4930
        except AssertionError:
 
4931
            raise AssertionError(tohex(bin))
 
4932
 
 
4933
    def testUnpackRequest0(self):
 
4934
        args, remain = request.Bell._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4935
        try:
 
4936
            assert len(remain) == 0
 
4937
        except AssertionError:
 
4938
            raise AssertionError(tohex(remain))
 
4939
        try:
 
4940
            assert args == self.req_args_0
 
4941
        except AssertionError:
 
4942
            raise AssertionError(args)
 
4943
 
 
4944
 
 
4945
class TestChangePointerControl(unittest.TestCase):
 
4946
    def setUp(self):
 
4947
        self.req_args_0 = {
 
4948
            'accel_denum': -32484,
 
4949
            'accel_num': -9346,
 
4950
            'do_accel': 0,
 
4951
            'do_thresh': 0,
 
4952
            'threshold': -8309,
 
4953
            }
 
4954
        self.req_bin_0 = '\x69\x00\x00\x03' '\xdb\x7e\x81\x1c' \
 
4955
            '\xdf\x8b\x00\x00'
 
4956
 
 
4957
 
 
4958
    def testPackRequest0(self):
 
4959
        bin = apply(request.ChangePointerControl._request.to_binary, (), self.req_args_0)
 
4960
        try:
 
4961
            assert bin == self.req_bin_0
 
4962
        except AssertionError:
 
4963
            raise AssertionError(tohex(bin))
 
4964
 
 
4965
    def testUnpackRequest0(self):
 
4966
        args, remain = request.ChangePointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
4967
        try:
 
4968
            assert len(remain) == 0
 
4969
        except AssertionError:
 
4970
            raise AssertionError(tohex(remain))
 
4971
        try:
 
4972
            assert args == self.req_args_0
 
4973
        except AssertionError:
 
4974
            raise AssertionError(args)
 
4975
 
 
4976
 
 
4977
class TestGetPointerControl(unittest.TestCase):
 
4978
    def setUp(self):
 
4979
        self.req_args_0 = {
 
4980
            }
 
4981
        self.req_bin_0 = '\x6a\x00\x00\x01'
 
4982
 
 
4983
        self.reply_args_0 = {
 
4984
            'accel_denom': 63793,
 
4985
            'sequence_number': 59946,
 
4986
            'threshold': 46060,
 
4987
            'accel_num': 53419,
 
4988
            }
 
4989
        self.reply_bin_0 = '\x01\x00\xea\x2a' '\x00\x00\x00\x00' \
 
4990
            '\xd0\xab\xf9\x31' '\xb3\xec\x00\x00' \
 
4991
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
4992
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
4993
 
 
4994
 
 
4995
    def testPackRequest0(self):
 
4996
        bin = apply(request.GetPointerControl._request.to_binary, (), self.req_args_0)
 
4997
        try:
 
4998
            assert bin == self.req_bin_0
 
4999
        except AssertionError:
 
5000
            raise AssertionError(tohex(bin))
 
5001
 
 
5002
    def testUnpackRequest0(self):
 
5003
        args, remain = request.GetPointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5004
        try:
 
5005
            assert len(remain) == 0
 
5006
        except AssertionError:
 
5007
            raise AssertionError(tohex(remain))
 
5008
        try:
 
5009
            assert args == self.req_args_0
 
5010
        except AssertionError:
 
5011
            raise AssertionError(args)
 
5012
 
 
5013
    def testPackReply0(self):
 
5014
        bin = apply(request.GetPointerControl._reply.to_binary, (), self.reply_args_0)
 
5015
        try:
 
5016
            assert bin == self.reply_bin_0
 
5017
        except AssertionError:
 
5018
            raise AssertionError(tohex(bin))
 
5019
 
 
5020
    def testUnpackReply0(self):
 
5021
        args, remain = request.GetPointerControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
5022
        try:
 
5023
            assert len(remain) == 0
 
5024
        except AssertionError:
 
5025
            raise AssertionError(tohex(remain))
 
5026
        try:
 
5027
            assert args == self.reply_args_0
 
5028
        except AssertionError:
 
5029
            raise AssertionError(args)
 
5030
 
 
5031
 
 
5032
class TestSetScreenSaver(unittest.TestCase):
 
5033
    def setUp(self):
 
5034
        self.req_args_0 = {
 
5035
            'allow_exposures': 0,
 
5036
            'timeout': -12675,
 
5037
            'interval': -12318,
 
5038
            'prefer_blank': 2,
 
5039
            }
 
5040
        self.req_bin_0 = '\x6b\x00\x00\x03' '\xce\x7d\xcf\xe2' \
 
5041
            '\x02\x00\x00\x00'
 
5042
 
 
5043
 
 
5044
    def testPackRequest0(self):
 
5045
        bin = apply(request.SetScreenSaver._request.to_binary, (), self.req_args_0)
 
5046
        try:
 
5047
            assert bin == self.req_bin_0
 
5048
        except AssertionError:
 
5049
            raise AssertionError(tohex(bin))
 
5050
 
 
5051
    def testUnpackRequest0(self):
 
5052
        args, remain = request.SetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5053
        try:
 
5054
            assert len(remain) == 0
 
5055
        except AssertionError:
 
5056
            raise AssertionError(tohex(remain))
 
5057
        try:
 
5058
            assert args == self.req_args_0
 
5059
        except AssertionError:
 
5060
            raise AssertionError(args)
 
5061
 
 
5062
 
 
5063
class TestGetScreenSaver(unittest.TestCase):
 
5064
    def setUp(self):
 
5065
        self.req_args_0 = {
 
5066
            }
 
5067
        self.req_bin_0 = '\x6c\x00\x00\x01'
 
5068
 
 
5069
        self.reply_args_0 = {
 
5070
            'allow_exposures': 1,
 
5071
            'timeout': 1865,
 
5072
            'sequence_number': 14674,
 
5073
            'prefer_blanking': 1,
 
5074
            'interval': 60559,
 
5075
            }
 
5076
        self.reply_bin_0 = '\x01\x00\x39\x52' '\x00\x00\x00\x00' \
 
5077
            '\x07\x49\xec\x8f' '\x01\x01\x00\x00' \
 
5078
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5079
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
5080
 
 
5081
 
 
5082
    def testPackRequest0(self):
 
5083
        bin = apply(request.GetScreenSaver._request.to_binary, (), self.req_args_0)
 
5084
        try:
 
5085
            assert bin == self.req_bin_0
 
5086
        except AssertionError:
 
5087
            raise AssertionError(tohex(bin))
 
5088
 
 
5089
    def testUnpackRequest0(self):
 
5090
        args, remain = request.GetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5091
        try:
 
5092
            assert len(remain) == 0
 
5093
        except AssertionError:
 
5094
            raise AssertionError(tohex(remain))
 
5095
        try:
 
5096
            assert args == self.req_args_0
 
5097
        except AssertionError:
 
5098
            raise AssertionError(args)
 
5099
 
 
5100
    def testPackReply0(self):
 
5101
        bin = apply(request.GetScreenSaver._reply.to_binary, (), self.reply_args_0)
 
5102
        try:
 
5103
            assert bin == self.reply_bin_0
 
5104
        except AssertionError:
 
5105
            raise AssertionError(tohex(bin))
 
5106
 
 
5107
    def testUnpackReply0(self):
 
5108
        args, remain = request.GetScreenSaver._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
5109
        try:
 
5110
            assert len(remain) == 0
 
5111
        except AssertionError:
 
5112
            raise AssertionError(tohex(remain))
 
5113
        try:
 
5114
            assert args == self.reply_args_0
 
5115
        except AssertionError:
 
5116
            raise AssertionError(args)
 
5117
 
 
5118
 
 
5119
class TestChangeHosts(unittest.TestCase):
 
5120
    def setUp(self):
 
5121
        self.req_args_0 = {
 
5122
            'host': [188, 226, 135, 199],
 
5123
            'mode': 1,
 
5124
            'host_family': 1,
 
5125
            }
 
5126
        self.req_bin_0 = '\x6d\x01\x00\x03' '\x01\x00\x00\x04' \
 
5127
            '\xbc\xe2\x87\xc7'
 
5128
 
 
5129
 
 
5130
    def testPackRequest0(self):
 
5131
        bin = apply(request.ChangeHosts._request.to_binary, (), self.req_args_0)
 
5132
        try:
 
5133
            assert bin == self.req_bin_0
 
5134
        except AssertionError:
 
5135
            raise AssertionError(tohex(bin))
 
5136
 
 
5137
    def testUnpackRequest0(self):
 
5138
        args, remain = request.ChangeHosts._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5139
        try:
 
5140
            assert len(remain) == 0
 
5141
        except AssertionError:
 
5142
            raise AssertionError(tohex(remain))
 
5143
        try:
 
5144
            assert args == self.req_args_0
 
5145
        except AssertionError:
 
5146
            raise AssertionError(args)
 
5147
 
 
5148
 
 
5149
class TestListHosts(unittest.TestCase):
 
5150
    def setUp(self):
 
5151
        self.req_args_0 = {
 
5152
            }
 
5153
        self.req_bin_0 = '\x6e\x00\x00\x01'
 
5154
 
 
5155
        self.reply_args_0 = {
 
5156
            'sequence_number': 31662,
 
5157
            'mode': 1,
 
5158
            'hosts': [{'family': 0, 'name': [34, 23, 178, 12]}, {'family': 0, 'name': [130, 236, 254, 15]}],
 
5159
            }
 
5160
        self.reply_bin_0 = '\x01\x01\x7b\xae' '\x00\x00\x00\x04' \
 
5161
            '\x00\x02\x00\x00' '\x00\x00\x00\x00' \
 
5162
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5163
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5164
            '\x00\x00\x00\x04' '\x22\x17\xb2\x0c' \
 
5165
            '\x00\x00\x00\x04' '\x82\xec\xfe\x0f'
 
5166
 
 
5167
 
 
5168
    def testPackRequest0(self):
 
5169
        bin = apply(request.ListHosts._request.to_binary, (), self.req_args_0)
 
5170
        try:
 
5171
            assert bin == self.req_bin_0
 
5172
        except AssertionError:
 
5173
            raise AssertionError(tohex(bin))
 
5174
 
 
5175
    def testUnpackRequest0(self):
 
5176
        args, remain = request.ListHosts._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5177
        try:
 
5178
            assert len(remain) == 0
 
5179
        except AssertionError:
 
5180
            raise AssertionError(tohex(remain))
 
5181
        try:
 
5182
            assert args == self.req_args_0
 
5183
        except AssertionError:
 
5184
            raise AssertionError(args)
 
5185
 
 
5186
    def testPackReply0(self):
 
5187
        bin = apply(request.ListHosts._reply.to_binary, (), self.reply_args_0)
 
5188
        try:
 
5189
            assert bin == self.reply_bin_0
 
5190
        except AssertionError:
 
5191
            raise AssertionError(tohex(bin))
 
5192
 
 
5193
    def testUnpackReply0(self):
 
5194
        args, remain = request.ListHosts._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
5195
        try:
 
5196
            assert len(remain) == 0
 
5197
        except AssertionError:
 
5198
            raise AssertionError(tohex(remain))
 
5199
        try:
 
5200
            assert args == self.reply_args_0
 
5201
        except AssertionError:
 
5202
            raise AssertionError(args)
 
5203
 
 
5204
 
 
5205
class TestSetAccessControl(unittest.TestCase):
 
5206
    def setUp(self):
 
5207
        self.req_args_0 = {
 
5208
            'mode': 0,
 
5209
            }
 
5210
        self.req_bin_0 = '\x6f\x00\x00\x01'
 
5211
 
 
5212
 
 
5213
    def testPackRequest0(self):
 
5214
        bin = apply(request.SetAccessControl._request.to_binary, (), self.req_args_0)
 
5215
        try:
 
5216
            assert bin == self.req_bin_0
 
5217
        except AssertionError:
 
5218
            raise AssertionError(tohex(bin))
 
5219
 
 
5220
    def testUnpackRequest0(self):
 
5221
        args, remain = request.SetAccessControl._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5222
        try:
 
5223
            assert len(remain) == 0
 
5224
        except AssertionError:
 
5225
            raise AssertionError(tohex(remain))
 
5226
        try:
 
5227
            assert args == self.req_args_0
 
5228
        except AssertionError:
 
5229
            raise AssertionError(args)
 
5230
 
 
5231
 
 
5232
class TestSetCloseDownMode(unittest.TestCase):
 
5233
    def setUp(self):
 
5234
        self.req_args_0 = {
 
5235
            'mode': 0,
 
5236
            }
 
5237
        self.req_bin_0 = '\x70\x00\x00\x01'
 
5238
 
 
5239
 
 
5240
    def testPackRequest0(self):
 
5241
        bin = apply(request.SetCloseDownMode._request.to_binary, (), self.req_args_0)
 
5242
        try:
 
5243
            assert bin == self.req_bin_0
 
5244
        except AssertionError:
 
5245
            raise AssertionError(tohex(bin))
 
5246
 
 
5247
    def testUnpackRequest0(self):
 
5248
        args, remain = request.SetCloseDownMode._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5249
        try:
 
5250
            assert len(remain) == 0
 
5251
        except AssertionError:
 
5252
            raise AssertionError(tohex(remain))
 
5253
        try:
 
5254
            assert args == self.req_args_0
 
5255
        except AssertionError:
 
5256
            raise AssertionError(args)
 
5257
 
 
5258
 
 
5259
class TestKillClient(unittest.TestCase):
 
5260
    def setUp(self):
 
5261
        self.req_args_0 = {
 
5262
            'resource': 1679944210,
 
5263
            }
 
5264
        self.req_bin_0 = '\x71\x00\x00\x02' '\x64\x21\xea\x12'
 
5265
 
 
5266
 
 
5267
    def testPackRequest0(self):
 
5268
        bin = apply(request.KillClient._request.to_binary, (), self.req_args_0)
 
5269
        try:
 
5270
            assert bin == self.req_bin_0
 
5271
        except AssertionError:
 
5272
            raise AssertionError(tohex(bin))
 
5273
 
 
5274
    def testUnpackRequest0(self):
 
5275
        args, remain = request.KillClient._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5276
        try:
 
5277
            assert len(remain) == 0
 
5278
        except AssertionError:
 
5279
            raise AssertionError(tohex(remain))
 
5280
        try:
 
5281
            assert args == self.req_args_0
 
5282
        except AssertionError:
 
5283
            raise AssertionError(args)
 
5284
 
 
5285
 
 
5286
class TestRotateProperties(unittest.TestCase):
 
5287
    def setUp(self):
 
5288
        self.req_args_0 = {
 
5289
            'delta': -27095,
 
5290
            'window': 109899869,
 
5291
            'properties': [1758270592, 1474783027, 1362037883, 19212066, 1095428186, 1435857629, 337040311, 1202859364, 1426187239, 725785004, 1722986690, 435243112],
 
5292
            }
 
5293
        self.req_bin_0 = '\x72\x00\x00\x0f' '\x06\x8c\xf0\x5d' \
 
5294
            '\x00\x0c\x96\x29' '\x68\xcd\x14\x80' \
 
5295
            '\x57\xe7\x67\x33' '\x51\x2f\x0c\x7b' \
 
5296
            '\x01\x25\x27\x22' '\x41\x4a\xe8\x5a' \
 
5297
            '\x55\x95\x72\xdd' '\x14\x16\xd3\xb7' \
 
5298
            '\x47\xb2\x2d\x64' '\x55\x01\xe3\xe7' \
 
5299
            '\x2b\x42\x99\xac' '\x66\xb2\xb0\xc2' \
 
5300
            '\x19\xf1\x48\x68'
 
5301
 
 
5302
 
 
5303
    def testPackRequest0(self):
 
5304
        bin = apply(request.RotateProperties._request.to_binary, (), self.req_args_0)
 
5305
        try:
 
5306
            assert bin == self.req_bin_0
 
5307
        except AssertionError:
 
5308
            raise AssertionError(tohex(bin))
 
5309
 
 
5310
    def testUnpackRequest0(self):
 
5311
        args, remain = request.RotateProperties._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5312
        try:
 
5313
            assert len(remain) == 0
 
5314
        except AssertionError:
 
5315
            raise AssertionError(tohex(remain))
 
5316
        try:
 
5317
            assert args == self.req_args_0
 
5318
        except AssertionError:
 
5319
            raise AssertionError(args)
 
5320
 
 
5321
 
 
5322
class TestForceScreenSaver(unittest.TestCase):
 
5323
    def setUp(self):
 
5324
        self.req_args_0 = {
 
5325
            'mode': 1,
 
5326
            }
 
5327
        self.req_bin_0 = '\x73\x01\x00\x01'
 
5328
 
 
5329
 
 
5330
    def testPackRequest0(self):
 
5331
        bin = apply(request.ForceScreenSaver._request.to_binary, (), self.req_args_0)
 
5332
        try:
 
5333
            assert bin == self.req_bin_0
 
5334
        except AssertionError:
 
5335
            raise AssertionError(tohex(bin))
 
5336
 
 
5337
    def testUnpackRequest0(self):
 
5338
        args, remain = request.ForceScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5339
        try:
 
5340
            assert len(remain) == 0
 
5341
        except AssertionError:
 
5342
            raise AssertionError(tohex(remain))
 
5343
        try:
 
5344
            assert args == self.req_args_0
 
5345
        except AssertionError:
 
5346
            raise AssertionError(args)
 
5347
 
 
5348
 
 
5349
class TestSetPointerMapping(unittest.TestCase):
 
5350
    def setUp(self):
 
5351
        self.req_args_0 = {
 
5352
            'map': [218, 142, 195, 250, 194],
 
5353
            }
 
5354
        self.req_bin_0 = '\x74\x05\x00\x03' '\xda\x8e\xc3\xfa' \
 
5355
            '\xc2\x00\x00\x00'
 
5356
 
 
5357
        self.reply_args_0 = {
 
5358
            'sequence_number': 11995,
 
5359
            'status': 187,
 
5360
            }
 
5361
        self.reply_bin_0 = '\x01\xbb\x2e\xdb' '\x00\x00\x00\x00' \
 
5362
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5363
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5364
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
5365
 
 
5366
 
 
5367
    def testPackRequest0(self):
 
5368
        bin = apply(request.SetPointerMapping._request.to_binary, (), self.req_args_0)
 
5369
        try:
 
5370
            assert bin == self.req_bin_0
 
5371
        except AssertionError:
 
5372
            raise AssertionError(tohex(bin))
 
5373
 
 
5374
    def testUnpackRequest0(self):
 
5375
        args, remain = request.SetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5376
        try:
 
5377
            assert len(remain) == 0
 
5378
        except AssertionError:
 
5379
            raise AssertionError(tohex(remain))
 
5380
        try:
 
5381
            assert args == self.req_args_0
 
5382
        except AssertionError:
 
5383
            raise AssertionError(args)
 
5384
 
 
5385
    def testPackReply0(self):
 
5386
        bin = apply(request.SetPointerMapping._reply.to_binary, (), self.reply_args_0)
 
5387
        try:
 
5388
            assert bin == self.reply_bin_0
 
5389
        except AssertionError:
 
5390
            raise AssertionError(tohex(bin))
 
5391
 
 
5392
    def testUnpackReply0(self):
 
5393
        args, remain = request.SetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
5394
        try:
 
5395
            assert len(remain) == 0
 
5396
        except AssertionError:
 
5397
            raise AssertionError(tohex(remain))
 
5398
        try:
 
5399
            assert args == self.reply_args_0
 
5400
        except AssertionError:
 
5401
            raise AssertionError(args)
 
5402
 
 
5403
 
 
5404
class TestGetPointerMapping(unittest.TestCase):
 
5405
    def setUp(self):
 
5406
        self.req_args_0 = {
 
5407
            }
 
5408
        self.req_bin_0 = '\x75\x00\x00\x01'
 
5409
 
 
5410
        self.reply_args_0 = {
 
5411
            'sequence_number': 35825,
 
5412
            'map': [165, 233, 136, 197, 230],
 
5413
            }
 
5414
        self.reply_bin_0 = '\x01\x05\x8b\xf1' '\x00\x00\x00\x02' \
 
5415
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5416
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5417
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5418
            '\xa5\xe9\x88\xc5' '\xe6\x00\x00\x00'
 
5419
 
 
5420
 
 
5421
    def testPackRequest0(self):
 
5422
        bin = apply(request.GetPointerMapping._request.to_binary, (), self.req_args_0)
 
5423
        try:
 
5424
            assert bin == self.req_bin_0
 
5425
        except AssertionError:
 
5426
            raise AssertionError(tohex(bin))
 
5427
 
 
5428
    def testUnpackRequest0(self):
 
5429
        args, remain = request.GetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5430
        try:
 
5431
            assert len(remain) == 0
 
5432
        except AssertionError:
 
5433
            raise AssertionError(tohex(remain))
 
5434
        try:
 
5435
            assert args == self.req_args_0
 
5436
        except AssertionError:
 
5437
            raise AssertionError(args)
 
5438
 
 
5439
    def testPackReply0(self):
 
5440
        bin = apply(request.GetPointerMapping._reply.to_binary, (), self.reply_args_0)
 
5441
        try:
 
5442
            assert bin == self.reply_bin_0
 
5443
        except AssertionError:
 
5444
            raise AssertionError(tohex(bin))
 
5445
 
 
5446
    def testUnpackReply0(self):
 
5447
        args, remain = request.GetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
5448
        try:
 
5449
            assert len(remain) == 0
 
5450
        except AssertionError:
 
5451
            raise AssertionError(tohex(remain))
 
5452
        try:
 
5453
            assert args == self.reply_args_0
 
5454
        except AssertionError:
 
5455
            raise AssertionError(args)
 
5456
 
 
5457
 
 
5458
class TestSetModifierMapping(unittest.TestCase):
 
5459
    def setUp(self):
 
5460
        self.req_args_0 = {
 
5461
            'keycodes': [[72, 169], [161, 154], [26, 10], [108, 187], [110, 198], [225, 88], [33, 66], [189, 147]],
 
5462
            }
 
5463
        self.req_bin_0 = '\x76\x02\x00\x05' '\x48\xa9\xa1\x9a' \
 
5464
            '\x1a\x0a\x6c\xbb' '\x6e\xc6\xe1\x58' \
 
5465
            '\x21\x42\xbd\x93'
 
5466
 
 
5467
        self.reply_args_0 = {
 
5468
            'sequence_number': 44526,
 
5469
            'status': 188,
 
5470
            }
 
5471
        self.reply_bin_0 = '\x01\xbc\xad\xee' '\x00\x00\x00\x00' \
 
5472
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5473
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5474
            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
 
5475
 
 
5476
 
 
5477
    def testPackRequest0(self):
 
5478
        bin = apply(request.SetModifierMapping._request.to_binary, (), self.req_args_0)
 
5479
        try:
 
5480
            assert bin == self.req_bin_0
 
5481
        except AssertionError:
 
5482
            raise AssertionError(tohex(bin))
 
5483
 
 
5484
    def testUnpackRequest0(self):
 
5485
        args, remain = request.SetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5486
        try:
 
5487
            assert len(remain) == 0
 
5488
        except AssertionError:
 
5489
            raise AssertionError(tohex(remain))
 
5490
        try:
 
5491
            assert args == self.req_args_0
 
5492
        except AssertionError:
 
5493
            raise AssertionError(args)
 
5494
 
 
5495
    def testPackReply0(self):
 
5496
        bin = apply(request.SetModifierMapping._reply.to_binary, (), self.reply_args_0)
 
5497
        try:
 
5498
            assert bin == self.reply_bin_0
 
5499
        except AssertionError:
 
5500
            raise AssertionError(tohex(bin))
 
5501
 
 
5502
    def testUnpackReply0(self):
 
5503
        args, remain = request.SetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
5504
        try:
 
5505
            assert len(remain) == 0
 
5506
        except AssertionError:
 
5507
            raise AssertionError(tohex(remain))
 
5508
        try:
 
5509
            assert args == self.reply_args_0
 
5510
        except AssertionError:
 
5511
            raise AssertionError(args)
 
5512
 
 
5513
 
 
5514
class TestGetModifierMapping(unittest.TestCase):
 
5515
    def setUp(self):
 
5516
        self.req_args_0 = {
 
5517
            }
 
5518
        self.req_bin_0 = '\x77\x00\x00\x01'
 
5519
 
 
5520
        self.reply_args_0 = {
 
5521
            'sequence_number': 58377,
 
5522
            'keycodes': [[3, 183], [213, 173], [9, 97], [35, 60], [249, 78], [175, 62], [237, 11], [26, 119]],
 
5523
            }
 
5524
        self.reply_bin_0 = '\x01\x02\xe4\x09' '\x00\x00\x00\x04' \
 
5525
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5526
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5527
            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
 
5528
            '\x03\xb7\xd5\xad' '\x09\x61\x23\x3c' \
 
5529
            '\xf9\x4e\xaf\x3e' '\xed\x0b\x1a\x77'
 
5530
 
 
5531
 
 
5532
    def testPackRequest0(self):
 
5533
        bin = apply(request.GetModifierMapping._request.to_binary, (), self.req_args_0)
 
5534
        try:
 
5535
            assert bin == self.req_bin_0
 
5536
        except AssertionError:
 
5537
            raise AssertionError(tohex(bin))
 
5538
 
 
5539
    def testUnpackRequest0(self):
 
5540
        args, remain = request.GetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5541
        try:
 
5542
            assert len(remain) == 0
 
5543
        except AssertionError:
 
5544
            raise AssertionError(tohex(remain))
 
5545
        try:
 
5546
            assert args == self.req_args_0
 
5547
        except AssertionError:
 
5548
            raise AssertionError(args)
 
5549
 
 
5550
    def testPackReply0(self):
 
5551
        bin = apply(request.GetModifierMapping._reply.to_binary, (), self.reply_args_0)
 
5552
        try:
 
5553
            assert bin == self.reply_bin_0
 
5554
        except AssertionError:
 
5555
            raise AssertionError(tohex(bin))
 
5556
 
 
5557
    def testUnpackReply0(self):
 
5558
        args, remain = request.GetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1)
 
5559
        try:
 
5560
            assert len(remain) == 0
 
5561
        except AssertionError:
 
5562
            raise AssertionError(tohex(remain))
 
5563
        try:
 
5564
            assert args == self.reply_args_0
 
5565
        except AssertionError:
 
5566
            raise AssertionError(args)
 
5567
 
 
5568
 
 
5569
class TestNoOperation(unittest.TestCase):
 
5570
    def setUp(self):
 
5571
        self.req_args_0 = {
 
5572
            }
 
5573
        self.req_bin_0 = '\x7f\x00\x00\x01'
 
5574
 
 
5575
 
 
5576
    def testPackRequest0(self):
 
5577
        bin = apply(request.NoOperation._request.to_binary, (), self.req_args_0)
 
5578
        try:
 
5579
            assert bin == self.req_bin_0
 
5580
        except AssertionError:
 
5581
            raise AssertionError(tohex(bin))
 
5582
 
 
5583
    def testUnpackRequest0(self):
 
5584
        args, remain = request.NoOperation._request.parse_binary(self.req_bin_0, dummy_display, 1)
 
5585
        try:
 
5586
            assert len(remain) == 0
 
5587
        except AssertionError:
 
5588
            raise AssertionError(tohex(remain))
 
5589
        try:
 
5590
            assert args == self.req_args_0
 
5591
        except AssertionError:
 
5592
            raise AssertionError(args)
 
5593
 
 
5594
 
 
5595
if __name__ == "__main__":
 
5596
    check_endian()
 
5597
    unittest.main()