]> git.sur5r.net Git - i3/i3/blob - testcases/t/257-keypress-group1-fallback.t
tests: unflake t/257-keypress-group1-fallback.t (#2946)
[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 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://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 i3_autostart => 0;
23 use i3test::XTEST;
24 use ExtUtils::PkgConfig;
25
26 SKIP: {
27     skip "libxcb-xkb too old (need >= 1.11)", 1 unless
28         ExtUtils::PkgConfig->atleast_version('xcb-xkb', '1.11');
29     skip "setxkbmap not found", 1 if
30         system(q|setxkbmap -print >/dev/null|) != 0;
31
32 my $config = <<EOT;
33 # i3 config file (v4)
34 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
35
36 bindsym Print nop Print
37 bindsym Mod4+Return nop Mod4+Return
38 EOT
39
40 my $pid = launch_with_config($config);
41
42 start_binding_capture;
43
44 system(q|setxkbmap us,ru -option grp:alt_shift_toggle|);
45
46 is(listen_for_binding(
47     sub {
48         xtest_key_press(107);
49         xtest_key_release(107);
50     },
51     ),
52    'Print',
53    'triggered the "Print" keybinding');
54
55 is(listen_for_binding(
56     sub {
57         xtest_key_press(133); # Super_L
58         xtest_key_press(36); # Return
59         xtest_key_release(36); # Return
60         xtest_key_release(133); # Super_L
61     },
62     ),
63    'Mod4+Return',
64    'triggered the "Mod4+Return" keybinding');
65
66 # Switch keyboard group to russian.
67 set_xkb_group(1);
68
69 is(listen_for_binding(
70     sub {
71         xtest_key_press(107);
72         xtest_key_release(107);
73     },
74     ),
75    'Print',
76    'triggered the "Print" keybinding');
77
78 is(listen_for_binding(
79     sub {
80         xtest_key_press(133); # Super_L
81         xtest_key_press(36); # Return
82         xtest_key_release(36); # Return
83         xtest_key_release(133); # Super_L
84     },
85     ),
86    'Mod4+Return',
87    'triggered the "Mod4+Return" keybinding');
88
89 sync_with_i3;
90 is(scalar @i3test::XTEST::binding_events, 4, 'Received exactly 4 binding events');
91
92 # Disable the grp:alt_shift_toggle option, as we use Alt+Shift in other testcases.
93 system(q|setxkbmap us -option|);
94
95 exit_gracefully($pid);
96
97 }
98
99 done_testing;