]> git.sur5r.net Git - i3/i3/blob - testcases/t/167-workspace_layout.t
Update debian/changelog
[i3/i3] / testcases / t / 167-workspace_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 # Tests the workspace_layout config option.
18 #
19
20 use i3test i3_autostart => 0;
21
22 #####################################################################
23 # 1: check that with an empty config, cons are place next to each
24 # other and no split containers are created
25 #####################################################################
26
27 my $config = <<EOT;
28 # i3 config file (v4)
29 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
30 EOT
31
32 my $pid = launch_with_config($config);
33
34 my $tmp = fresh_workspace;
35
36 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
37
38 my $first = open_window;
39 my $second = open_window;
40
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');
46
47 exit_gracefully($pid);
48
49 #####################################################################
50 # 2: set workspace_layout stacked, check that when opening two cons,
51 # they end up in a stacked con
52 #####################################################################
53
54 $config = <<EOT;
55 # i3 config file (v4)
56 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
57 workspace_layout stacked
58 EOT
59
60 $pid = launch_with_config($config);
61
62 $tmp = fresh_workspace;
63
64 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
65
66 $first = open_window;
67 $second = open_window;
68
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');
73
74 #####################################################################
75 # 3: focus parent, open two new cons, check that they end up in a stacked
76 # con
77 #####################################################################
78
79 cmd 'focus parent';
80 my $right_top = open_window;
81 my $right_bot = open_window;
82
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');
87
88 #####################################################################
89 # 4: move one of the cons to the right, check that it will end up in
90 # a stacked con
91 #####################################################################
92
93 cmd 'move right';
94
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');
100
101 #####################################################################
102 # 5: move it to the left again, check that the stacked con is deleted
103 #####################################################################
104
105 cmd 'move left';
106
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');
111
112 #####################################################################
113 # 6: move it to a different workspace, check that it ends up in a
114 # stacked con
115 #####################################################################
116
117 my $otmp = get_unused_workspace;
118
119 cmd "move workspace $otmp";
120
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');
125
126 @content = @{get_ws_content($otmp)};
127 is(@content, 1, 'one con on target workspace');
128 is($content[0]->{layout}, 'stacked', 'layout stacked');
129
130 #####################################################################
131 # 7: toggle floating mode and check that we have a stacked con when
132 # re-inserting a floating container.
133 #####################################################################
134
135 $tmp = fresh_workspace;
136
137 $first = open_window;
138 cmd 'floating toggle';
139 cmd 'floating toggle';
140
141 $second = open_window;
142
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');
147
148 exit_gracefully($pid);
149
150 done_testing;