]> git.sur5r.net Git - i3/i3/blob - testcases/t/141-resize.t
Merge branch 'fix-var-tabs'
[i3/i3] / testcases / t / 141-resize.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # Tests resizing tiling containers
4 use i3test;
5 use X11::XCB qw(:all);
6
7 BEGIN {
8     use_ok('X11::XCB::Window');
9 }
10
11 my $x = X11::XCB::Connection->new;
12
13 my $tmp = fresh_workspace;
14
15 cmd 'split v';
16
17 my $top = open_window($x);
18 my $bottom = open_window($x);
19
20 sync_with_i3($x);
21
22 diag("top = " . $top->id . ", bottom = " . $bottom->id);
23
24 is($x->input_focus, $bottom->id, 'Bottom window focused');
25
26 ############################################################
27 # resize
28 ############################################################
29
30 cmd 'resize grow up 10 px or 25 ppt';
31
32 my ($nodes, $focus) = get_ws_content($tmp);
33
34 is($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
35 is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
36
37
38 ############################################################
39 # split and check if the 'percent' factor is still correct
40 ############################################################
41
42 cmd 'split h';
43
44 ($nodes, $focus) = get_ws_content($tmp);
45
46 is($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
47 is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
48
49 ############################################################
50 # checks that resizing within stacked/tabbed cons works
51 ############################################################
52
53 $tmp = fresh_workspace;
54
55 cmd 'split v';
56
57 $top = open_window($x);
58 $bottom = open_window($x);
59
60 cmd 'split h';
61 cmd 'layout stacked';
62
63 ($nodes, $focus) = get_ws_content($tmp);
64 is($nodes->[0]->{percent}, 0.5, 'top window got 50%');
65 is($nodes->[1]->{percent}, 0.5, 'bottom window got 50%');
66
67 cmd 'resize grow up 10 px or 25 ppt';
68
69 ($nodes, $focus) = get_ws_content($tmp);
70 is($nodes->[0]->{percent}, 0.25, 'top window got 25%');
71 is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
72
73 ############################################################
74 # Checks that resizing in the parent's parent's orientation works.
75 # Take for example a horizontal workspace with one window on the left side and
76 # a v-split container with two windows on the right side. Focus is on the
77 # bottom right window, use 'resize left'.
78 ############################################################
79
80 $tmp = fresh_workspace;
81
82 my $left = open_window;
83 my $right = open_window;
84
85 cmd 'split v';
86
87 $top = open_window;
88 $bottom = open_window;
89
90 ($nodes, $focus) = get_ws_content($tmp);
91 is($nodes->[0]->{percent}, 0.5, 'left window got 50%');
92 is($nodes->[1]->{percent}, 0.5, 'right window got 50%');
93
94 cmd 'resize grow left 10 px or 25 ppt';
95
96 ($nodes, $focus) = get_ws_content($tmp);
97 is($nodes->[0]->{percent}, 0.25, 'left window got 25%');
98 is($nodes->[1]->{percent}, 0.75, 'right window got 75%');
99
100 ############################################################
101 # checks that resizing floating windows works
102 ############################################################
103
104 $tmp = fresh_workspace;
105
106 $top = open_window($x);
107
108 cmd 'floating enable';
109
110 my @content = @{get_ws($tmp)->{floating_nodes}};
111 cmp_ok(@content, '==', 1, 'one floating node on this ws');
112
113 # up
114 my $oldrect = $content[0]->{rect};
115
116 cmd 'resize grow up 10 px or 25 ppt';
117
118 @content = @{get_ws($tmp)->{floating_nodes}};
119 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
120 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 10, 'y exactly 10 px smaller');
121 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
122 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
123 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 10, 'height exactly 10 px higher');
124 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
125
126 # up, but with a different amount of px
127 $oldrect = $content[0]->{rect};
128
129 cmd 'resize grow up 12 px or 25 ppt';
130
131 @content = @{get_ws($tmp)->{floating_nodes}};
132 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
133 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 12, 'y exactly 10 px smaller');
134 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
135 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
136 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 12, 'height exactly 10 px higher');
137 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
138
139 # left
140 $oldrect = $content[0]->{rect};
141
142 cmd 'resize grow left 10 px or 25 ppt';
143
144 @content = @{get_ws($tmp)->{floating_nodes}};
145 cmp_ok($content[0]->{rect}->{x}, '<', $oldrect->{x}, 'x smaller than before');
146 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
147
148 # right
149 $oldrect = $content[0]->{rect};
150
151 cmd 'resize grow right 10 px or 25 ppt';
152
153 @content = @{get_ws($tmp)->{floating_nodes}};
154 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
155 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
156 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
157 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height}, 'height the same as before');
158
159 # down
160 $oldrect = $content[0]->{rect};
161
162 cmd 'resize grow down 10 px or 25 ppt';
163
164 @content = @{get_ws($tmp)->{floating_nodes}};
165 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
166 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
167 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
168 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width the same as before');
169
170 done_testing;