]> git.sur5r.net Git - i3/i3/blob - testcases/t/257-keypress-group1-fallback.t
tests: replace http:// with https:// where appropriate
[i3/i3] / testcases / t / 257-keypress-group1-fallback.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Verifies that when using multiple keyboard layouts at the same time, bindings
18 # without a specified XKB group will work in all XKB groups.
19 # Ticket: #2062
20 # Bug still in: 4.11-103-gc8d51b4
21 # Bug introduced with commit 0e5180cae9e9295678e3f053042b559e82cb8c98
22 use i3test
23     i3_config => <<EOT;
24 # i3 config file (v4)
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
26
27 bindsym Print nop Print
28 bindsym Mod4+Return nop Mod4+Return
29 EOT
30 use i3test::XTEST;
31 use ExtUtils::PkgConfig;
32
33 SKIP: {
34     skip "libxcb-xkb too old (need >= 1.11)", 1 unless
35         ExtUtils::PkgConfig->atleast_version('xcb-xkb', '1.11');
36     skip "setxkbmap not found", 1 if
37         system(q|setxkbmap -print >/dev/null|) != 0;
38
39 start_binding_capture;
40
41 system(q|setxkbmap us,ru -option grp:alt_shift_toggle|);
42
43 is(listen_for_binding(
44     sub {
45         xtest_key_press(107);
46         xtest_key_release(107);
47     },
48     ),
49    'Print',
50    'triggered the "Print" keybinding');
51
52 is(listen_for_binding(
53     sub {
54         xtest_key_press(133); # Super_L
55         xtest_key_press(36); # Return
56         xtest_key_release(36); # Return
57         xtest_key_release(133); # Super_L
58     },
59     ),
60    'Mod4+Return',
61    'triggered the "Mod4+Return" keybinding');
62
63 # Switch keyboard group to russian.
64 set_xkb_group(1);
65
66 is(listen_for_binding(
67     sub {
68         xtest_key_press(107);
69         xtest_key_release(107);
70     },
71     ),
72    'Print',
73    'triggered the "Print" keybinding');
74
75 is(listen_for_binding(
76     sub {
77         xtest_key_press(133); # Super_L
78         xtest_key_press(36); # Return
79         xtest_key_release(36); # Return
80         xtest_key_release(133); # Super_L
81     },
82     ),
83    'Mod4+Return',
84    'triggered the "Mod4+Return" keybinding');
85
86 sync_with_i3;
87 is(scalar @i3test::XTEST::binding_events, 4, 'Received exactly 4 binding events');
88
89 # Disable the grp:alt_shift_toggle option, as we use Alt+Shift in other testcases.
90 system(q|setxkbmap us -option|);
91
92 }
93
94 done_testing;