]> git.sur5r.net Git - i3/i3/blob - testcases/t/192-layout.t
Merge "force_focus_wrapping" option into "focus_wrapping force"
[i3/i3] / testcases / t / 192-layout.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 # Verifies that switching between the different layouts works as expected.
18 use i3test;
19
20 my $tmp = fresh_workspace;
21
22 open_window;
23 open_window;
24 cmd 'split v';
25 open_window;
26
27 my ($nodes, $focus) = get_ws_content($tmp);
28 is($nodes->[1]->{layout}, 'splitv', 'layout is splitv currently');
29
30 cmd 'layout stacked';
31 ($nodes, $focus) = get_ws_content($tmp);
32 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
33
34 cmd 'layout tabbed';
35 ($nodes, $focus) = get_ws_content($tmp);
36 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
37
38 cmd 'layout toggle split';
39 ($nodes, $focus) = get_ws_content($tmp);
40 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv again');
41
42 cmd 'layout toggle split';
43 ($nodes, $focus) = get_ws_content($tmp);
44 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
45
46 cmd 'layout toggle split';
47 ($nodes, $focus) = get_ws_content($tmp);
48 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
49
50 cmd 'layout toggle split';
51 ($nodes, $focus) = get_ws_content($tmp);
52 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
53
54 cmd 'layout toggle';
55 ($nodes, $focus) = get_ws_content($tmp);
56 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
57
58 cmd 'layout toggle';
59 ($nodes, $focus) = get_ws_content($tmp);
60 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
61
62 cmd 'layout toggle';
63 ($nodes, $focus) = get_ws_content($tmp);
64 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
65
66 cmd 'layout toggle';
67 ($nodes, $focus) = get_ws_content($tmp);
68 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
69
70 cmd 'layout toggle all';
71 ($nodes, $focus) = get_ws_content($tmp);
72 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
73
74 cmd 'layout toggle all';
75 ($nodes, $focus) = get_ws_content($tmp);
76 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
77
78 cmd 'layout toggle all';
79 ($nodes, $focus) = get_ws_content($tmp);
80 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
81
82 cmd 'layout toggle all';
83 ($nodes, $focus) = get_ws_content($tmp);
84 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
85
86 cmd 'layout toggle all';
87 ($nodes, $focus) = get_ws_content($tmp);
88 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
89
90 cmd 'layout toggle all';
91 ($nodes, $focus) = get_ws_content($tmp);
92 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
93
94 cmd 'layout toggle all';
95 ($nodes, $focus) = get_ws_content($tmp);
96 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
97
98 cmd 'layout toggle splith splitv';
99 ($nodes, $focus) = get_ws_content($tmp);
100 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
101
102 cmd 'layout toggle splith splitv';
103 ($nodes, $focus) = get_ws_content($tmp);
104 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
105
106 cmd 'layout toggle stacked splitv tabbed';
107 ($nodes, $focus) = get_ws_content($tmp);
108 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
109
110 cmd 'layout toggle stacking splitv tabbed';
111 ($nodes, $focus) = get_ws_content($tmp);
112 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
113
114 cmd 'layout toggle stacking splitv tabbed';
115 ($nodes, $focus) = get_ws_content($tmp);
116 is($nodes->[1]->{layout}, 'splitv', 'layout now splitv');
117
118 cmd 'layout toggle splitv i stacking tabbed';
119 ($nodes, $focus) = get_ws_content($tmp);
120 is($nodes->[1]->{layout}, 'stacked', 'layout now stacked');
121
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');
126
127 cmd 'layout toggle tabbed stacked';
128 ($nodes, $focus) = get_ws_content($tmp);
129 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
130
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');
135
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');
140
141 cmd 'layout toggle split split';
142 ($nodes, $focus) = get_ws_content($tmp);
143 is($nodes->[1]->{layout}, 'splith', 'layout now splith');
144
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');
149
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');
153
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');
157
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');
161
162 cmd 'layout toggle splitv garbage    tabbed';
163 ($nodes, $focus) = get_ws_content($tmp);
164 is($nodes->[1]->{layout}, 'tabbed', 'layout now tabbed');
165
166 done_testing;