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);
33 for (my $i = $#windows; $i >= 0; $i--) {
34 cmd '[id=' . $windows[$i]->id . '] focus';
41 is($x->input_focus, $windows[0]->id, $msg . ': window 0 focused');
42 foreach my $i (1 .. $#windows) {
43 kill_and_confirm_focus($windows[$i]->id, "$msg: window $i focused");
49 #####################################################################
50 # Open 5 windows, focus them in a custom order and then change to
51 # tabbed layout. The focus order should be preserved.
52 #####################################################################
56 $windows[3] = open_window;
57 $windows[1] = open_window;
58 $windows[0] = open_window;
59 $windows[2] = open_window;
60 $windows[4] = open_window;
64 confirm_focus('tabbed');
66 #####################################################################
67 # Same as above but with stacked.
68 #####################################################################
72 $windows[3] = open_window;
73 $windows[1] = open_window;
74 $windows[0] = open_window;
75 $windows[2] = open_window;
76 $windows[4] = open_window;
80 confirm_focus('stacked');
82 #####################################################################
83 # Open 4 windows horizontally, move the last one down. The focus
84 # order should be preserved.
85 #####################################################################
88 $windows[3] = open_window;
89 $windows[2] = open_window;
90 $windows[1] = open_window;
91 $windows[0] = open_window;
94 confirm_focus('split-h + move');
96 #####################################################################
97 # Same as above but with a vertical split.
98 #####################################################################
101 $windows[3] = open_window;
103 $windows[2] = open_window;
104 $windows[1] = open_window;
105 $windows[0] = open_window;
108 confirm_focus('split-v + move');
110 ######################################################################
111 # Test that moving an unfocused container maintains the correct focus
113 # Layout: H [ A V1 [ B C D ] ]
114 ######################################################################
117 $windows[3] = open_window;
118 $windows[2] = open_window;
120 $windows[1] = open_window;
121 $windows[0] = open_window;
123 cmd '[id=' . $windows[3]->id . '] move right';
124 confirm_focus('split-v + unfocused move');
126 ######################################################################
127 # Test that moving an unfocused container from inside a split
128 # container to another workspace doesn't focus sibling.
129 ######################################################################
131 $ws = fresh_workspace;
132 $windows[0] = open_window;
133 $windows[1] = open_window;
138 cmd '[id=' . $windows[0]->id . '] focus';
139 cmd '[con_mark=a] move to workspace ' . get_unused_workspace;
141 is(@{get_ws_content($ws)}, 2, 'Sanity check: marked window moved');
142 confirm_focus('Move unfocused window from split container');