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 # Verify that the corrent focus stack order is preserved after various
21 sub kill_and_confirm_focus {
26 is($x->input_focus, $focus, $msg);
32 for (my $i = $#windows; $i >= 0; $i--) {
33 cmd '[id=' . $windows[$i]->id . '] focus';
40 is($x->input_focus, $windows[0]->id, $msg . ': window 0 focused');
41 foreach my $i (1 .. $#windows) {
42 kill_and_confirm_focus($windows[$i]->id, "$msg: window $i focused");
48 #####################################################################
49 # Open 5 windows, focus them in a custom order and then change to
50 # tabbed layout. The focus order should be preserved.
51 #####################################################################
55 $windows[3] = open_window;
56 $windows[1] = open_window;
57 $windows[0] = open_window;
58 $windows[2] = open_window;
59 $windows[4] = open_window;
63 confirm_focus('tabbed');
65 #####################################################################
66 # Same as above but with stacked.
67 #####################################################################
71 $windows[3] = open_window;
72 $windows[1] = open_window;
73 $windows[0] = open_window;
74 $windows[2] = open_window;
75 $windows[4] = open_window;
79 confirm_focus('stacked');
81 #####################################################################
82 # Open 4 windows horizontally, move the last one down. The focus
83 # order should be preserved.
84 #####################################################################
87 $windows[3] = open_window;
88 $windows[2] = open_window;
89 $windows[1] = open_window;
90 $windows[0] = open_window;
93 confirm_focus('split-h + move');
95 #####################################################################
96 # Same as above but with a vertical split.
97 #####################################################################
100 $windows[3] = open_window;
102 $windows[2] = open_window;
103 $windows[1] = open_window;
104 $windows[0] = open_window;
107 confirm_focus('split-v + move');
109 ######################################################################
110 # Test that moving an unfocused container maintains the correct focus
112 # Layout: H [ A V1 [ B C D ] ]
113 ######################################################################
116 $windows[3] = open_window;
117 $windows[2] = open_window;
119 $windows[1] = open_window;
120 $windows[0] = open_window;
122 cmd '[id=' . $windows[3]->id . '] move right';
123 confirm_focus('split-v + unfocused move');