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 # Tests resizing tiling containers
20 ############################################################
22 ############################################################
24 my $tmp = fresh_workspace;
28 my $left = open_window;
29 my $right = open_window;
31 diag("left = " . $left->id . ", right = " . $right->id);
33 is($x->input_focus, $right->id, 'Right window focused');
35 cmd 'resize set 75 ppt 0 ppt';
37 my ($nodes, $focus) = get_ws_content($tmp);
39 cmp_float($nodes->[0]->{percent}, 0.25, 'left window got only 25%');
40 cmp_float($nodes->[1]->{percent}, 0.75, 'right window got 75%');
42 # Same but use the 'width' keyword.
43 cmd 'resize set width 80 ppt';
45 ($nodes, $focus) = get_ws_content($tmp);
47 cmp_float($nodes->[0]->{percent}, 0.20, 'left window got 20%');
48 cmp_float($nodes->[1]->{percent}, 0.80, 'right window got 80%');
51 cmd 'resize set width 200 px';
53 ($nodes, $focus) = get_ws_content($tmp);
55 cmp_float($nodes->[1]->{rect}->{width}, 200, 'right window got 200 px');
57 ############################################################
59 ############################################################
61 $tmp = fresh_workspace;
65 my $top = open_window;
66 my $bottom = open_window;
68 diag("top = " . $top->id . ", bottom = " . $bottom->id);
70 is($x->input_focus, $bottom->id, 'Bottom window focused');
72 cmd 'resize set 0 ppt 75 ppt';
74 ($nodes, $focus) = get_ws_content($tmp);
76 cmp_float($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
77 cmp_float($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
79 # Same but use the 'height' keyword.
80 cmd 'resize set height 80 ppt';
82 ($nodes, $focus) = get_ws_content($tmp);
84 cmp_float($nodes->[0]->{percent}, 0.20, 'top window got 20%');
85 cmp_float($nodes->[1]->{percent}, 0.80, 'bottom window got 80%');
88 cmd 'resize set height 200 px';
90 ($nodes, $focus) = get_ws_content($tmp);
92 cmp_float($nodes->[1]->{rect}->{height}, 200, 'bottom window got 200 px');
94 ############################################################
95 # resize horizontally and vertically
96 ############################################################
98 $tmp = fresh_workspace;
102 my $top_right = open_window;
104 my $bottom_right = open_window;
106 diag("left = " . $left->id . ", top-right = " . $top_right->id . ", bottom-right = " . $bottom_right->id);
108 is($x->input_focus, $bottom_right->id, 'Bottom-right window focused');
110 cmd 'resize set 75 ppt 75 ppt';
112 ($nodes, $focus) = get_ws_content($tmp);
114 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
115 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
116 cmp_float($nodes->[1]->{nodes}->[0]->{percent}, 0.25, 'top-right window got 25%');
117 cmp_float($nodes->[1]->{nodes}->[1]->{percent}, 0.75, 'bottom-right window got 75%');
120 cmd 'resize set 155 px 135 px';
122 ($nodes, $focus) = get_ws_content($tmp);
124 cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{width}, 155, 'bottom-right window got 155 px width');
125 cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{height}, 135, 'bottom-right window got 135 px height');
127 ############################################################
128 # resize from inside a tabbed container
129 ############################################################
131 $tmp = fresh_workspace;
136 my $right1 = open_window;
141 my $right2 = open_window;
143 diag("left = " . $left->id . ", right1 = " . $right1->id . ", right2 = " . $right2->id);
145 is($x->input_focus, $right2->id, '2nd right window focused');
147 cmd 'resize set 75 ppt 0 ppt';
149 ($nodes, $focus) = get_ws_content($tmp);
151 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
152 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
155 cmd 'resize set 155 px';
157 ($nodes, $focus) = get_ws_content($tmp);
159 cmp_float($nodes->[1]->{rect}->{width}, 155, 'right container got 155 px');
161 ############################################################
162 # resize from inside a stacked container
163 ############################################################
165 $tmp = fresh_workspace;
170 $right1 = open_window;
173 cmd 'layout stacked';
175 $right2 = open_window;
177 diag("left = " . $left->id . ", right1 = " . $right1->id . ", right2 = " . $right2->id);
179 is($x->input_focus, $right2->id, '2nd right window focused');
181 cmd 'resize set 75 ppt 0 ppt';
183 ($nodes, $focus) = get_ws_content($tmp);
185 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
186 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
189 cmd 'resize set 130 px';
191 ($nodes, $focus) = get_ws_content($tmp);
193 cmp_float($nodes->[1]->{rect}->{width}, 130, 'right container got 130 px');