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 # Verifies that switching between the different layouts works as expected.
20 my $tmp = fresh_workspace;
27 my ($nodes, $focus) = get_ws_content($tmp);
28 is($nodes->[1]->{layout}, 'splitv', 'layout is splitv currently');
31 ($nodes, $focus) = get_ws_content($tmp);
32 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
35 ($nodes, $focus) = get_ws_content($tmp);
36 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
38 cmd 'layout toggle split';
39 ($nodes, $focus) = get_ws_content($tmp);
40 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv again');
42 cmd 'layout toggle split';
43 ($nodes, $focus) = get_ws_content($tmp);
44 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
46 cmd 'layout toggle split';
47 ($nodes, $focus) = get_ws_content($tmp);
48 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
50 cmd 'layout toggle split';
51 ($nodes, $focus) = get_ws_content($tmp);
52 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
55 ($nodes, $focus) = get_ws_content($tmp);
56 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
59 ($nodes, $focus) = get_ws_content($tmp);
60 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
63 ($nodes, $focus) = get_ws_content($tmp);
64 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
67 ($nodes, $focus) = get_ws_content($tmp);
68 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
70 cmd 'layout toggle all';
71 ($nodes, $focus) = get_ws_content($tmp);
72 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
74 cmd 'layout toggle all';
75 ($nodes, $focus) = get_ws_content($tmp);
76 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
78 cmd 'layout toggle all';
79 ($nodes, $focus) = get_ws_content($tmp);
80 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
82 cmd 'layout toggle all';
83 ($nodes, $focus) = get_ws_content($tmp);
84 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
86 cmd 'layout toggle all';
87 ($nodes, $focus) = get_ws_content($tmp);
88 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
90 cmd 'layout toggle all';
91 ($nodes, $focus) = get_ws_content($tmp);
92 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
94 cmd 'layout toggle all';
95 ($nodes, $focus) = get_ws_content($tmp);
96 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
98 cmd 'layout toggle splith splitv';
99 ($nodes, $focus) = get_ws_content($tmp);
100 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
102 cmd 'layout toggle splith splitv';
103 ($nodes, $focus) = get_ws_content($tmp);
104 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
106 cmd 'layout toggle stacked splitv tabbed';
107 ($nodes, $focus) = get_ws_content($tmp);
108 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
110 cmd 'layout toggle stacking splitv tabbed';
111 ($nodes, $focus) = get_ws_content($tmp);
112 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
114 cmd 'layout toggle stacking splitv tabbed';
115 ($nodes, $focus) = get_ws_content($tmp);
116 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
118 cmd 'layout toggle splitv i stacking tabbed';
119 ($nodes, $focus) = get_ws_content($tmp);
120 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
122 cmd 'layout toggle stacked';
123 ($nodes, $focus) = get_ws_content($tmp);
124 # this is correct if it does nothing
125 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
127 cmd 'layout toggle tabbed stacked';
128 ($nodes, $focus) = get_ws_content($tmp);
129 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
131 # obsoletes 'split' ;)
132 cmd 'layout toggle splith splitv';
133 ($nodes, $focus) = get_ws_content($tmp);
134 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
136 # nonsense but works expectedly
137 cmd 'layout toggle split split';
138 ($nodes, $focus) = get_ws_content($tmp);
139 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
141 cmd 'layout toggle split split';
142 ($nodes, $focus) = get_ws_content($tmp);
143 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
145 # testing with arbitrary length and garbage
146 cmd 'layout toggle stacking splith tabbed splitv stacking';
147 ($nodes, $focus) = get_ws_content($tmp);
148 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
150 cmd 'layout toggle stacking splith garbage tabbed splitv stacking';
151 ($nodes, $focus) = get_ws_content($tmp);
152 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
154 cmd 'layout toggle stacking splith garbage tabbed splitv stacking';
155 ($nodes, $focus) = get_ws_content($tmp);
156 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
158 cmd 'layout toggle splitv splith garbage splitv tabbed stacking splitv';
159 ($nodes, $focus) = get_ws_content($tmp);
160 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
162 cmd 'layout toggle splitv garbage tabbed';
163 ($nodes, $focus) = get_ws_content($tmp);
164 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');