2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Verifies that one can bind on numpad keys in different numlock states.
19 # Bug still in: 4.12-78-g85bb324
20 use i3test i3_autostart => 0;
22 use ExtUtils::PkgConfig;
25 skip "libxcb-xkb too old (need >= 1.11)", 1 unless
26 ExtUtils::PkgConfig->atleast_version('xcb-xkb', '1.11');
30 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
32 # Same key, different numlock states.
33 bindsym Mod2+KP_1 nop KP_1
34 bindsym KP_End nop KP_End
36 # Binding which should work with numlock and without.
39 # Binding which should work with numlock and without, see issue #2418.
40 bindsym Escape nop Escape
42 # Binding which should work with numlock and without, see issue #2418.
43 bindsym Shift+Escape nop Shift+Escape
45 # Binding which should work with numlock and without, see issue #2418.
46 bindsym Mod1+Shift+q nop Mod1+Shift+q
49 my $pid = launch_with_config($config);
51 start_binding_capture;
53 is(listen_for_binding(
55 xtest_key_press(87); # KP_End
56 xtest_key_release(87); # KP_End
60 'triggered the "KP_End" keybinding');
62 is(listen_for_binding(
64 xtest_key_press(77); # enable Num_Lock
65 xtest_key_release(77); # enable Num_Lock
66 xtest_key_press(87); # KP_1
67 xtest_key_release(87); # KP_1
68 xtest_key_press(77); # disable Num_Lock
69 xtest_key_release(77); # disable Num_Lock
73 'triggered the "KP_1" keybinding');
75 is(listen_for_binding(
77 xtest_key_press(133); # Super_L
78 xtest_key_press(38); # a
79 xtest_key_release(38); # a
80 xtest_key_release(133); # Super_L
84 'triggered the "a" keybinding');
86 is(listen_for_binding(
88 xtest_key_press(77); # enable Num_Lock
89 xtest_key_release(77); # enable Num_Lock
90 xtest_key_press(133); # Super_L
91 xtest_key_press(38); # a
92 xtest_key_release(38); # a
93 xtest_key_release(133); # Super_L
94 xtest_key_press(77); # disable Num_Lock
95 xtest_key_release(77); # disable Num_Lock
99 'triggered the "a" keybinding');
101 is(listen_for_binding(
103 xtest_key_press(9); # Escape
104 xtest_key_release(9); # Escape
108 'triggered the "Escape" keybinding');
110 is(listen_for_binding(
112 xtest_key_press(77); # enable Num_Lock
113 xtest_key_release(77); # enable Num_Lock
114 xtest_key_press(9); # Escape
115 xtest_key_release(9); # Escape
116 xtest_key_press(77); # disable Num_Lock
117 xtest_key_release(77); # disable Num_Lock
121 'triggered the "Escape" keybinding');
123 is(listen_for_binding(
125 xtest_key_press(50); # Shift_L
126 xtest_key_press(9); # Escape
127 xtest_key_release(9); # Escape
128 xtest_key_release(50); # Shift_L
132 'triggered the "Escape" keybinding');
134 is(listen_for_binding(
136 xtest_key_press(77); # enable Num_Lock
137 xtest_key_release(77); # enable Num_Lock
138 xtest_key_press(50); # Shift_L
139 xtest_key_press(9); # Escape
140 xtest_key_release(9); # Escape
141 xtest_key_release(50); # Shift_L
142 xtest_key_press(77); # disable Num_Lock
143 xtest_key_release(77); # disable Num_Lock
147 'triggered the "Escape" keybinding');
149 is(listen_for_binding(
151 xtest_key_press(50); # Shift_L
152 xtest_key_press(64); # Alt_L
153 xtest_key_press(24); # q
154 xtest_key_release(24); # q
155 xtest_key_release(64); # Alt_L
156 xtest_key_release(50); # Shift_L
160 'triggered the "Mod1+Shift+q" keybinding');
163 is(listen_for_binding(
165 xtest_key_press(77); # enable Num_Lock
166 xtest_key_release(77); # enable Num_Lock
167 xtest_key_press(50); # Shift_L
168 xtest_key_press(64); # Alt_L
169 xtest_key_press(24); # q
170 xtest_key_release(24); # q
171 xtest_key_release(64); # Alt_L
172 xtest_key_release(50); # Shift_L
173 xtest_key_press(77); # disable Num_Lock
174 xtest_key_release(77); # disable Num_Lock
178 'triggered the "Mod1+Shift+q" keybinding');
181 is(scalar @i3test::XTEST::binding_events, 10, 'Received exactly 10 binding events');
183 exit_gracefully($pid);
185 ################################################################################
186 # Verify the binding is only triggered for KP_End, not KP_1
187 ################################################################################
190 # i3 config file (v4)
191 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
193 bindsym KP_End nop KP_End
196 $pid = launch_with_config($config);
198 start_binding_capture;
200 is(listen_for_binding(
202 xtest_key_press(87); # KP_End
203 xtest_key_release(87); # KP_End
207 'triggered the "KP_End" keybinding');
209 is(listen_for_binding(
211 xtest_key_press(77); # enable Num_Lock
212 xtest_key_release(77); # enable Num_Lock
213 xtest_key_press(87); # KP_1
214 xtest_key_release(87); # KP_1
215 xtest_key_press(77); # disable Num_Lock
216 xtest_key_release(77); # disable Num_Lock
220 'Did not trigger the KP_End keybinding with KP_1');
222 # TODO: This test does not verify that i3 does _NOT_ grab keycode 87 with Mod2.
225 is(scalar @i3test::XTEST::binding_events, 11, 'Received exactly 11 binding events');
227 exit_gracefully($pid);