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 ############################################################
44 ############################################################
46 my $tmp = fresh_workspace;
50 my $top = open_window;
51 my $bottom = open_window;
53 diag("top = " . $top->id . ", bottom = " . $bottom->id);
55 is($x->input_focus, $bottom->id, 'Bottom window focused');
57 cmd 'resize set 0 ppt 75 ppt';
59 my ($nodes, $focus) = get_ws_content($tmp);
61 cmp_float($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
62 cmp_float($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
65 ############################################################
66 # resize horizontally and vertically
67 ############################################################
69 my $tmp = fresh_workspace;
72 my $left = open_window;
73 my $top_right = open_window;
75 my $bottom_right = open_window;
77 diag("left = " . $left->id . ", top-right = " . $top_right->id . ", bottom-right = " . $bottom_right->id);
79 is($x->input_focus, $bottom_right->id, 'Bottom-right window focused');
81 cmd 'resize set 75 ppt 75 ppt';
83 my ($nodes, $focus) = get_ws_content($tmp);
85 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
86 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
87 cmp_float($nodes->[1]->{nodes}->[0]->{percent}, 0.25, 'top-right window got 25%');
88 cmp_float($nodes->[1]->{nodes}->[1]->{percent}, 0.75, 'bottom-right window got 75%');
91 ############################################################
92 # resize from inside a tabbed container
93 ############################################################
95 my $tmp = fresh_workspace;
99 my $left = open_window;
100 my $right1 = open_window;
105 my $right2 = open_window;
107 diag("left = " . $left->id . ", right1 = " . $right1->id . ", right2 = " . $right2->id);
109 is($x->input_focus, $right2->id, '2nd right window focused');
111 cmd 'resize set 75 ppt 0 ppt';
113 my ($nodes, $focus) = get_ws_content($tmp);
115 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
116 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
119 ############################################################
120 # resize from inside a stacked container
121 ############################################################
123 my $tmp = fresh_workspace;
127 my $left = open_window;
128 my $right1 = open_window;
131 cmd 'layout stacked';
133 my $right2 = open_window;
135 diag("left = " . $left->id . ", right1 = " . $right1->id . ", right2 = " . $right2->id);
137 is($x->input_focus, $right2->id, '2nd right window focused');
139 cmd 'resize set 75 ppt 0 ppt';
141 my ($nodes, $focus) = get_ws_content($tmp);
143 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
144 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');