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 # 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 skip "AnyEvent::I3 too old (need >= 0.16)", 1 if $AnyEvent::I3::VERSION < 0.16;
40 my $pid = launch_with_config($config);
42 my $i3 = i3(get_socket_path());
46 my $timer = AE::timer 0.5, 0, sub { $cv->send(0); };
54 qx(xdotool key $binding_symbol);
60 diag "Event:\n", Dumper($e);
63 'the binding event should emit when user input triggers an i3 binding event');
65 is($e->{change}, 'run',
66 'the `change` field should indicate this binding has run');
69 'the `binding` field should be a hash that contains information about the binding');
71 is($e->{binding}->{input_type}, 'keyboard',
72 'the input_type field should be the input type of the binding (keyboard or mouse)');
74 note 'the `mods` field should contain the symbols for the modifiers of the binding';
76 ok(grep(/$_/i, @{$e->{binding}->{mods}}), "`mods` contains the modifier $_");
79 is($e->{binding}->{command}, $command,
80 'the `command` field should contain the command the binding ran');
82 is($e->{binding}->{input_code}, 0,
83 'the input_code should be the specified code if the key was bound with bindcode, and otherwise zero');
85 exit_gracefully($pid);