]> git.sur5r.net Git - i3/i3/blob - testcases/t/541-resize-set-tiling.t
659fcc679825d945e19dcf3024223de46327b837
[i3/i3] / testcases / t / 541-resize-set-tiling.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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 resizing tiling containers
18 use i3test;
19
20 ############################################################
21 # resize horizontally
22 ############################################################
23
24 my $tmp = fresh_workspace;
25
26 cmd 'split h';
27
28 my $left = open_window;
29 my $right = open_window;
30
31 diag("left = " . $left->id . ", right = " . $right->id);
32
33 is($x->input_focus, $right->id, 'Right window focused');
34
35 cmd 'resize set 75 ppt 0 ppt';
36
37 my ($nodes, $focus) = get_ws_content($tmp);
38
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%');
41
42 # Same but use the 'width' keyword.
43 cmd 'resize set width 80 ppt';
44
45 ($nodes, $focus) = get_ws_content($tmp);
46
47 cmp_float($nodes->[0]->{percent}, 0.20, 'left window got 20%');
48 cmp_float($nodes->[1]->{percent}, 0.80, 'right window got 80%');
49
50 ############################################################
51 # resize vertically
52 ############################################################
53
54 $tmp = fresh_workspace;
55
56 cmd 'split v';
57
58 my $top = open_window;
59 my $bottom = open_window;
60
61 diag("top = " . $top->id . ", bottom = " . $bottom->id);
62
63 is($x->input_focus, $bottom->id, 'Bottom window focused');
64
65 cmd 'resize set 0 ppt 75 ppt';
66
67 ($nodes, $focus) = get_ws_content($tmp);
68
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%');
71
72 # Same but use the 'height' keyword.
73 cmd 'resize set height 80 ppt';
74
75 ($nodes, $focus) = get_ws_content($tmp);
76
77 cmp_float($nodes->[0]->{percent}, 0.20, 'top window got 20%');
78 cmp_float($nodes->[1]->{percent}, 0.80, 'bottom window got 80%');
79
80 ############################################################
81 # resize horizontally and vertically
82 ############################################################
83
84 $tmp = fresh_workspace;
85
86 cmd 'split h';
87 $left = open_window;
88 my $top_right = open_window;
89 cmd 'split v';
90 my $bottom_right = open_window;
91
92 diag("left = " . $left->id . ", top-right = " . $top_right->id . ", bottom-right = " . $bottom_right->id);
93
94 is($x->input_focus, $bottom_right->id, 'Bottom-right window focused');
95
96 cmd 'resize set 75 ppt 75 ppt';
97
98 ($nodes, $focus) = get_ws_content($tmp);
99
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%');
104
105
106 ############################################################
107 # resize from inside a tabbed container
108 ############################################################
109
110 $tmp = fresh_workspace;
111
112 cmd 'split h';
113
114 $left = open_window;
115 my $right1 = open_window;
116
117 cmd 'split h';
118 cmd 'layout tabbed';
119
120 my $right2 = open_window;
121
122 diag("left = " . $left->id . ", right1 = " . $right1->id . ", right2 = " . $right2->id);
123
124 is($x->input_focus, $right2->id, '2nd right window focused');
125
126 cmd 'resize set 75 ppt 0 ppt';
127
128 ($nodes, $focus) = get_ws_content($tmp);
129
130 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
131 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
132
133
134 ############################################################
135 # resize from inside a stacked container
136 ############################################################
137
138 $tmp = fresh_workspace;
139
140 cmd 'split h';
141
142 $left = open_window;
143 $right1 = open_window;
144
145 cmd 'split h';
146 cmd 'layout stacked';
147
148 $right2 = open_window;
149
150 diag("left = " . $left->id . ", right1 = " . $right1->id . ", right2 = " . $right2->id);
151
152 is($x->input_focus, $right2->id, '2nd right window focused');
153
154 cmd 'resize set 75 ppt 0 ppt';
155
156 ($nodes, $focus) = get_ws_content($tmp);
157
158 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
159 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
160
161
162 done_testing;