2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://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 # Tests the workspace_layout config option.
20 use i3test i3_autostart => 0;
22 #####################################################################
23 # 1: check that with an empty config, cons are place next to each
24 # other and no split containers are created
25 #####################################################################
29 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
32 my $pid = launch_with_config($config);
34 my $tmp = fresh_workspace;
36 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
38 my $first = open_window;
39 my $second = open_window;
41 is($x->input_focus, $second->id, 'second window focused');
42 my @content = @{get_ws_content($tmp)};
43 ok(@content == 2, 'two containers opened');
44 isnt($content[0]->{layout}, 'stacked', 'layout not stacked');
45 isnt($content[1]->{layout}, 'stacked', 'layout not stacked');
47 exit_gracefully($pid);
49 #####################################################################
50 # 2: set workspace_layout stacked, check that when opening two cons,
51 # they end up in a stacked con
52 #####################################################################
56 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
57 workspace_layout stacked
60 $pid = launch_with_config($config);
62 $tmp = fresh_workspace;
64 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
67 $second = open_window;
69 is($x->input_focus, $second->id, 'second window focused');
70 @content = @{get_ws_content($tmp)};
71 ok(@content == 1, 'one con at workspace level');
72 is($content[0]->{layout}, 'stacked', 'layout stacked');
74 #####################################################################
75 # 3: focus parent, open two new cons, check that they end up in a stacked
77 #####################################################################
80 my $right_top = open_window;
81 my $right_bot = open_window;
83 @content = @{get_ws_content($tmp)};
84 is(@content, 2, 'two cons at workspace level after focus parent');
85 is($content[0]->{layout}, 'stacked', 'layout stacked');
86 is($content[1]->{layout}, 'stacked', 'layout stacked');
88 #####################################################################
89 # 4: move one of the cons to the right, check that it will end up in
91 #####################################################################
95 @content = @{get_ws_content($tmp)};
96 is(@content, 3, 'three cons at workspace level after move');
97 is($content[0]->{layout}, 'stacked', 'layout stacked');
98 is($content[1]->{layout}, 'stacked', 'layout stacked');
99 is($content[2]->{layout}, 'stacked', 'layout stacked');
101 #####################################################################
102 # 5: move it to the left again, check that the stacked con is deleted
103 #####################################################################
107 @content = @{get_ws_content($tmp)};
108 is(@content, 2, 'two cons at workspace level after moving back');
109 is($content[0]->{layout}, 'stacked', 'layout stacked');
110 is($content[1]->{layout}, 'stacked', 'layout stacked');
112 #####################################################################
113 # 6: move it to a different workspace, check that it ends up in a
115 #####################################################################
117 my $otmp = get_unused_workspace;
119 cmd "move workspace $otmp";
121 @content = @{get_ws_content($tmp)};
122 is(@content, 2, 'still two cons on this workspace');
123 is($content[0]->{layout}, 'stacked', 'layout stacked');
124 is($content[1]->{layout}, 'stacked', 'layout stacked');
126 @content = @{get_ws_content($otmp)};
127 is(@content, 1, 'one con on target workspace');
128 is($content[0]->{layout}, 'stacked', 'layout stacked');
130 #####################################################################
131 # 7: toggle floating mode and check that we have a stacked con when
132 # re-inserting a floating container.
133 #####################################################################
135 $tmp = fresh_workspace;
137 $first = open_window;
138 cmd 'floating toggle';
139 cmd 'floating toggle';
141 $second = open_window;
143 is($x->input_focus, $second->id, 'second window focused');
144 @content = @{get_ws_content($tmp)};
145 ok(@content == 1, 'one con at workspace level');
146 is($content[0]->{layout}, 'stacked', 'layout stacked');
148 exit_gracefully($pid);