2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://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 # Test that the binding event works properly
19 use i3test i3_autostart => 0;
23 my @mods = ('Shift', 'Ctrl');
24 my $binding_symbol = join("+", @mods) . "+$keysym";
28 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
30 bindsym $binding_symbol $command
34 qx(which xdotool 2> /dev/null);
36 skip 'xdotool is required to test the binding event. `[apt-get install|pacman -S] xdotool`', 1 if $?;
38 my $pid = launch_with_config($config);
40 my $cv = AnyEvent->condvar;
42 my @events = events_for(
44 # TODO: this is still flaky: we need to synchronize every X11
45 # connection with i3. Move to XTEST and synchronize that connection.
46 qx(xdotool key $binding_symbol);
50 is(scalar @events, 1, 'Received 1 event');
52 is($events[0]->{change}, 'run',
53 'the `change` field should indicate this binding has run');
55 ok($events[0]->{binding},
56 'the `binding` field should be a hash that contains information about the binding');
58 is($events[0]->{binding}->{input_type}, 'keyboard',
59 'the input_type field should be the input type of the binding (keyboard or mouse)');
61 note 'the `mods` field should contain the symbols for the modifiers of the binding';
63 ok(grep(/$_/i, @{$events[0]->{binding}->{mods}}), "`mods` contains the modifier $_");
66 is($events[0]->{binding}->{command}, $command,
67 'the `command` field should contain the command the binding ran');
69 is($events[0]->{binding}->{input_code}, 0,
70 'the input_code should be the specified code if the key was bound with bindcode, and otherwise zero');
72 exit_gracefully($pid);