]> git.sur5r.net Git - i3/i3/blob - testcases/t/297-scroll-tabbed.t
b535d0cd262a0839b6c219240133bfff8064d17f
[i3/i3] / testcases / t / 297-scroll-tabbed.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 # Tests if scrolling the tab bar on a tabbed container works and verifies that
18 # only one window is focused as a result.
19 # Ticket: #3215 (PR)
20 # Bug still in: 4.15-92-g666aa9e0
21 use i3test;
22 use i3test::XTEST;
23
24 sub scroll_down {
25     # button5 = scroll down
26     xtest_button_press(5, 3, 3);
27     xtest_button_release(5, 3, 3);
28     xtest_sync_with_i3;
29 }
30
31 sub scroll_up {
32     # button4 = scroll up
33     xtest_button_press(4, 3, 3);
34     xtest_button_release(4, 3, 3);
35     xtest_sync_with_i3;
36 }
37
38 # Decoration of top left window.
39 $x->root->warp_pointer(3, 3);
40
41 # H [ T [ H [ A B ] C D V [ E F ] ] G ]
42 # Inner horizontal split.
43 open_window;
44 cmd 'layout tabbed';
45 cmd 'splith';
46 my $first = open_window;
47 cmd 'focus parent';
48 # Simple tabs.
49 open_window;
50 my $second_last = open_window;
51 # V-Split container
52 open_window;
53 cmd 'splitv';
54 my $last = open_window;
55 # Second child of the outer horizontal split, next to the tabbed one.
56 my $outside = open_window;
57 cmd 'move right, move right';
58
59 cmd '[id=' . $first->id . '] focus';
60
61 # Scroll from first to last.
62 scroll_down;
63 scroll_down;
64 is($x->input_focus, $second_last->id, 'Sanity check: scrolling');
65 scroll_down;
66 is($x->input_focus, $last->id, 'Last window focused through scrolling');
67 scroll_down;
68 is($x->input_focus, $last->id, 'Scrolling again doesn\'t leave the tabbed container and doesn\'t focus the whole sibling');
69
70 # Scroll from last to first.
71 scroll_up;
72 is($x->input_focus, $second_last->id, 'Scrolling up works');
73 scroll_up;
74 scroll_up;
75 is($x->input_focus, $first->id, 'First window focused through scrolling');
76 scroll_up;
77 is($x->input_focus, $first->id, 'Scrolling again doesn\'t focus the whole sibling');
78
79 # Try scrolling with another window focused
80 cmd '[id=' . $outside->id . '] focus';
81 scroll_up;
82 is($x->input_focus, $first->id, 'Scrolling from outside the tabbed container works');
83
84 done_testing;