]> git.sur5r.net Git - i3/i3/blob - testcases/t/541-resize-set-tiling.t
82267baf6c73d8c65c6b6644faef67f41150964c
[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 ############################################################
43 # resize vertically
44 ############################################################
45
46 my $tmp = fresh_workspace;
47
48 cmd 'split v';
49
50 my $top = open_window;
51 my $bottom = open_window;
52
53 diag("top = " . $top->id . ", bottom = " . $bottom->id);
54
55 is($x->input_focus, $bottom->id, 'Bottom window focused');
56
57 cmd 'resize set 0 ppt 75 ppt';
58
59 my ($nodes, $focus) = get_ws_content($tmp);
60
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%');
63
64
65 ############################################################
66 # resize horizontally and vertically
67 ############################################################
68
69 my $tmp = fresh_workspace;
70
71 cmd 'split h';
72 my $left = open_window;
73 my $top_right = open_window;
74 cmd 'split v';
75 my $bottom_right = open_window;
76
77 diag("left = " . $left->id . ", top-right = " . $top_right->id . ", bottom-right = " . $bottom_right->id);
78
79 is($x->input_focus, $bottom_right->id, 'Bottom-right window focused');
80
81 cmd 'resize set 75 ppt 75 ppt';
82
83 my ($nodes, $focus) = get_ws_content($tmp);
84
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%');
89
90
91 ############################################################
92 # resize from inside a tabbed container
93 ############################################################
94
95 my $tmp = fresh_workspace;
96
97 cmd 'split h';
98
99 my $left = open_window;
100 my $right1 = open_window;
101
102 cmd 'split h';
103 cmd 'layout tabbed';
104
105 my $right2 = open_window;
106
107 diag("left = " . $left->id . ", right1 = " . $right1->id . ", right2 = " . $right2->id);
108
109 is($x->input_focus, $right2->id, '2nd right window focused');
110
111 cmd 'resize set 75 ppt 0 ppt';
112
113 my ($nodes, $focus) = get_ws_content($tmp);
114
115 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
116 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
117
118
119 ############################################################
120 # resize from inside a stacked container
121 ############################################################
122
123 my $tmp = fresh_workspace;
124
125 cmd 'split h';
126
127 my $left = open_window;
128 my $right1 = open_window;
129
130 cmd 'split h';
131 cmd 'layout stacked';
132
133 my $right2 = open_window;
134
135 diag("left = " . $left->id . ", right1 = " . $right1->id . ", right2 = " . $right2->id);
136
137 is($x->input_focus, $right2->id, '2nd right window focused');
138
139 cmd 'resize set 75 ppt 0 ppt';
140
141 my ($nodes, $focus) = get_ws_content($tmp);
142
143 cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
144 cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
145
146
147 done_testing;