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
48 # Binding which should work with numlock and without, see issue #2559.
52 my $pid = launch_with_config($config);
54 start_binding_capture;
56 is(listen_for_binding(
58 xtest_key_press(87); # KP_End
59 xtest_key_release(87); # KP_End
63 'triggered the "KP_End" keybinding');
65 is(listen_for_binding(
67 xtest_key_press(77); # enable Num_Lock
68 xtest_key_release(77); # enable Num_Lock
69 xtest_key_press(87); # KP_1
70 xtest_key_release(87); # KP_1
71 xtest_key_press(77); # disable Num_Lock
72 xtest_key_release(77); # disable Num_Lock
76 'triggered the "KP_1" keybinding');
78 is(listen_for_binding(
80 xtest_key_press(133); # Super_L
81 xtest_key_press(38); # a
82 xtest_key_release(38); # a
83 xtest_key_release(133); # Super_L
87 'triggered the "a" keybinding');
89 is(listen_for_binding(
91 xtest_key_press(77); # enable Num_Lock
92 xtest_key_release(77); # enable Num_Lock
93 xtest_key_press(133); # Super_L
94 xtest_key_press(38); # a
95 xtest_key_release(38); # a
96 xtest_key_release(133); # Super_L
97 xtest_key_press(77); # disable Num_Lock
98 xtest_key_release(77); # disable Num_Lock
102 'triggered the "a" keybinding');
104 is(listen_for_binding(
106 xtest_key_press(9); # Escape
107 xtest_key_release(9); # Escape
111 'triggered the "Escape" keybinding');
113 is(listen_for_binding(
115 xtest_key_press(77); # enable Num_Lock
116 xtest_key_release(77); # enable Num_Lock
117 xtest_key_press(9); # Escape
118 xtest_key_release(9); # Escape
119 xtest_key_press(77); # disable Num_Lock
120 xtest_key_release(77); # disable Num_Lock
124 'triggered the "Escape" keybinding');
126 is(listen_for_binding(
128 xtest_key_press(50); # Shift_L
129 xtest_key_press(9); # Escape
130 xtest_key_release(9); # Escape
131 xtest_key_release(50); # Shift_L
135 'triggered the "Escape" keybinding');
137 is(listen_for_binding(
139 xtest_key_press(77); # enable Num_Lock
140 xtest_key_release(77); # enable Num_Lock
141 xtest_key_press(50); # Shift_L
142 xtest_key_press(9); # Escape
143 xtest_key_release(9); # Escape
144 xtest_key_release(50); # Shift_L
145 xtest_key_press(77); # disable Num_Lock
146 xtest_key_release(77); # disable Num_Lock
150 'triggered the "Escape" keybinding');
152 is(listen_for_binding(
154 xtest_key_press(50); # Shift_L
155 xtest_key_press(64); # Alt_L
156 xtest_key_press(24); # q
157 xtest_key_release(24); # q
158 xtest_key_release(64); # Alt_L
159 xtest_key_release(50); # Shift_L
163 'triggered the "Mod1+Shift+q" keybinding');
165 is(listen_for_binding(
167 xtest_key_press(77); # enable Num_Lock
168 xtest_key_release(77); # enable Num_Lock
169 xtest_key_press(50); # Shift_L
170 xtest_key_press(64); # Alt_L
171 xtest_key_press(24); # q
172 xtest_key_release(24); # q
173 xtest_key_release(64); # Alt_L
174 xtest_key_release(50); # Shift_L
175 xtest_key_press(77); # disable Num_Lock
176 xtest_key_release(77); # disable Num_Lock
180 'triggered the "Mod1+Shift+q" keybinding');
182 is(listen_for_binding(
184 xtest_key_press(39); # s
185 xtest_key_release(39); # s
189 'triggered the "s" keybinding without Num_Lock');
191 is(listen_for_binding(
193 xtest_key_press(77); # enable Num_Lock
194 xtest_key_release(77); # enable Num_Lock
195 xtest_key_press(39); # s
196 xtest_key_release(39); # s
197 xtest_key_press(77); # disable Num_Lock
198 xtest_key_release(77); # disable Num_Lock
202 'triggered the "s" keybinding with Num_Lock');
205 is(scalar @i3test::XTEST::binding_events, 12, 'Received exactly 12 binding events');
207 exit_gracefully($pid);
209 ################################################################################
210 # Verify the binding is only triggered for KP_End, not KP_1
211 ################################################################################
214 # i3 config file (v4)
215 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
217 bindsym KP_End nop KP_End
218 bindcode 88 nop KP_Down
221 $pid = launch_with_config($config);
223 start_binding_capture;
225 is(listen_for_binding(
227 xtest_key_press(87); # KP_End
228 xtest_key_release(87); # KP_End
232 'triggered the "KP_End" keybinding');
234 is(listen_for_binding(
236 xtest_key_press(88); # KP_Down
237 xtest_key_release(88); # KP_Down
241 'triggered the "KP_Down" keybinding');
243 is(listen_for_binding(
245 xtest_key_press(77); # enable Num_Lock
246 xtest_key_release(77); # enable Num_Lock
247 xtest_key_press(87); # KP_1
248 xtest_key_release(87); # KP_1
249 xtest_key_press(77); # disable Num_Lock
250 xtest_key_release(77); # disable Num_Lock
254 'Did not trigger the KP_End keybinding with KP_1');
256 is(listen_for_binding(
258 xtest_key_press(77); # enable Num_Lock
259 xtest_key_release(77); # enable Num_Lock
260 xtest_key_press(88); # KP_2
261 xtest_key_release(88); # KP_2
262 xtest_key_press(77); # disable Num_Lock
263 xtest_key_release(77); # disable Num_Lock
267 'Did not trigger the KP_Down keybinding with KP_2');
269 # TODO: This test does not verify that i3 does _NOT_ grab keycode 87 with Mod2.
272 is(scalar @i3test::XTEST::binding_events, 14, 'Received exactly 14 binding events');
274 exit_gracefully($pid);