This repository was archived by the owner on Jun 27, 2023. It is now read-only.
File tree 1 file changed +54
-0
lines changed
1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ import xcb , xcb .xproto
2
+ import struct
3
+ import libpry
4
+
5
+ # covers xcb.Response too, the base class to xcb.Event
6
+ # xcb.Union and xcb.List too, via xproto.ClientMessageEvent
7
+
8
+ class uEvent (libpry .AutoTree ):
9
+ def test_client_message_event (self ):
10
+ response_type = 33 # ClientMessageEvent
11
+ format = 32
12
+ sequence = 0
13
+ window = 1234
14
+ # hardcoded values for these atoms since it doesn't matter here
15
+ WM_PROTOCOLS = 268
16
+ WM_DELETE_WINDOW = 266
17
+
18
+ event_raw = struct .pack ('BBHII5I' ,
19
+ response_type ,
20
+ format ,
21
+ sequence ,
22
+ window ,
23
+ WM_PROTOCOLS ,
24
+ WM_DELETE_WINDOW ,
25
+ xcb .xproto .Time .CurrentTime ,
26
+ 0 ,
27
+ 0 ,
28
+ 0
29
+ )
30
+
31
+ xcb_event = xcb .Event (event_raw )
32
+
33
+ assert '' .join (list (xcb_event )) == event_raw
34
+ assert ord (xcb_event [0 ]) == response_type
35
+ assert xcb_event .response_type == response_type
36
+ assert xcb_event .sequence == 0
37
+
38
+ xproto_event = xcb .xproto .ClientMessageEvent (xcb_event )
39
+
40
+ assert xproto_event .format == format
41
+ assert xproto_event .window == window
42
+ assert xproto_event .type == WM_PROTOCOLS
43
+
44
+ fourbytes = struct .pack ('I' , WM_DELETE_WINDOW )
45
+
46
+ assert xproto_event .data [:4 ] == fourbytes
47
+ assert xproto_event .data .data8 [:4 ] == list (struct .unpack ('4B' , fourbytes ))
48
+ assert xproto_event .data .data16 [:2 ] == list (struct .unpack ('2H' , fourbytes ))
49
+ assert xproto_event .data .data32 [0 ] == WM_DELETE_WINDOW
50
+
51
+
52
+ tests = [
53
+ uEvent (),
54
+ ]
You can’t perform that action at this time.
0 commit comments