]> git.sur5r.net Git - i3/i3/blob - testcases/t/525-i3bar-mouse-bindings.t
Merge pull request #2135 from Alexis211/colors
[i3/i3] / testcases / t / 525-i3bar-mouse-bindings.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 # Ensures that mouse bindings on the i3bar work correctly.
18 # Ticket: #1695
19 use i3test i3_autostart => 0;
20
21 my ($cv, $timer);
22 sub reset_test {
23     $cv = AE::cv;
24     $timer = AE::timer(1, 0, sub { $cv->send(0); });
25 }
26
27 my $config = <<EOT;
28 # i3 config file (v4)
29 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
30 focus_follows_mouse no
31
32 bar {
33     font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
34     position top
35
36     bindsym button1 focus left
37     bindsym button2 focus right
38     bindsym button3 focus left
39     bindsym button4 focus right
40     bindsym button5 focus left
41 }
42 EOT
43
44 SKIP: {
45     qx(command -v xdotool 2> /dev/null);
46     skip 'xdotool is required for this test', 1 if $?;
47
48     my $pid = launch_with_config($config);
49     my $i3 = i3(get_socket_path());
50     $i3->connect()->recv;
51     my $ws = fresh_workspace;
52
53     reset_test;
54     $i3->subscribe({
55         window => sub {
56             my ($event) = @_;
57             if ($event->{change} eq 'focus') {
58                 $cv->send($event->{container});
59             }
60         },
61     })->recv;
62
63     my $left = open_window;
64     my $right = open_window;
65     sync_with_i3;
66     my $con = $cv->recv;
67     is($con->{window}, $right->{id}, 'focus is initially on the right container');
68     reset_test;
69
70     qx(xdotool mousemove 3 3 click 1);
71     sync_with_i3;
72     $con = $cv->recv;
73     is($con->{window}, $left->{id}, 'button 1 moves focus left');
74     reset_test;
75
76     qx(xdotool mousemove 3 3 click 2);
77     sync_with_i3;
78     $con = $cv->recv;
79     is($con->{window}, $right->{id}, 'button 2 moves focus right');
80     reset_test;
81
82     qx(xdotool mousemove 3 3 click 3);
83     sync_with_i3;
84     $con = $cv->recv;
85     is($con->{window}, $left->{id}, 'button 3 moves focus left');
86     reset_test;
87
88     qx(xdotool mousemove 3 3 click 4);
89     sync_with_i3;
90     $con = $cv->recv;
91     is($con->{window}, $right->{id}, 'button 4 moves focus right');
92     reset_test;
93
94     qx(xdotool mousemove 3 3 click 5);
95     sync_with_i3;
96     $con = $cv->recv;
97     is($con->{window}, $left->{id}, 'button 5 moves focus left');
98     reset_test;
99
100     exit_gracefully($pid);
101
102 }
103
104 done_testing;