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%');
50 ############################################################
52 ############################################################
54 my $tmp = fresh_workspace;
58 my $top = open_window;
59 my $bottom = open_window;
61 diag("top = " . $top->id . ", bottom = " . $bottom->id);
63 is($x->input_focus, $bottom->id, 'Bottom window focused');
65 cmd 'resize set 0 ppt 75 ppt';
67 my ($nodes, $focus) = get_ws_content($tmp);
69 cmp_float($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
70 cmp_float($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
72 # Same but use the 'height' keyword.
73 cmd 'resize set height 80 ppt';
75 ($nodes, $focus) = get_ws_content($tmp);
77 cmp_float($nodes->[0]->{percent}, 0.20, 'top window got 20%');
78 cmp_float($nodes->[1]->{percent}, 0.80, 'bottom window got 80%');
80 ############################################################
81 # resize horizontally and vertically
82 ############################################################
84 my $tmp = fresh_workspace;
87 my $left = open_window;
88 my $top_right = open_window;
90 my $bottom_right = open_window;
92 diag("left = " . $left->id . ", top-right = " . $top_right->id . ", bottom-right = " . $bottom_right->id);
94 is($x->input_focus, $bottom_right->id, 'Bottom-right window focused');
96 cmd 'resize set 75 ppt 75 ppt';
98 my ($nodes, $focus) = get_ws_content($tmp);
100 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
101 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
102 cmp_float($nodes->[1]->{nodes}->[0]->{percent}, 0.25, 'top-right window got 25%');
103 cmp_float($nodes->[1]->{nodes}->[1]->{percent}, 0.75, 'bottom-right window got 75%');
106 ############################################################
107 # resize from inside a tabbed container
108 ############################################################
110 my $tmp = fresh_workspace;
114 my $left = open_window;
115 my $right1 = open_window;
120 my $right2 = open_window;
122 diag("left = " . $left->id . ", right1 = " . $right1->id . ", right2 = " . $right2->id);
124 is($x->input_focus, $right2->id, '2nd right window focused');
126 cmd 'resize set 75 ppt 0 ppt';
128 my ($nodes, $focus) = get_ws_content($tmp);
130 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
131 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
134 ############################################################
135 # resize from inside a stacked container
136 ############################################################
138 my $tmp = fresh_workspace;
142 my $left = open_window;
143 my $right1 = open_window;
146 cmd 'layout stacked';
148 my $right2 = open_window;
150 diag("left = " . $left->id . ", right1 = " . $right1->id . ", right2 = " . $right2->id);
152 is($x->input_focus, $right2->id, '2nd right window focused');
154 cmd 'resize set 75 ppt 0 ppt';
156 my ($nodes, $focus) = get_ws_content($tmp);
158 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
159 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');