]> git.sur5r.net Git - i3/i3/blob - testcases/t/141-resize.t
testcases: let i3test.pm export $x, adapt testcases
[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
6 my $tmp = fresh_workspace;
7
8 cmd 'split v';
9
10 my $top = open_window($x);
11 my $bottom = open_window($x);
12
13 sync_with_i3($x);
14
15 diag("top = " . $top->id . ", bottom = " . $bottom->id);
16
17 is($x->input_focus, $bottom->id, 'Bottom window focused');
18
19 ############################################################
20 # resize
21 ############################################################
22
23 cmd 'resize grow up 10 px or 25 ppt';
24
25 my ($nodes, $focus) = get_ws_content($tmp);
26
27 is($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
28 is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
29
30
31 ############################################################
32 # split and check if the 'percent' factor is still correct
33 ############################################################
34
35 cmd 'split h';
36
37 ($nodes, $focus) = get_ws_content($tmp);
38
39 is($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
40 is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
41
42 ############################################################
43 # checks that resizing within stacked/tabbed cons works
44 ############################################################
45
46 $tmp = fresh_workspace;
47
48 cmd 'split v';
49
50 $top = open_window($x);
51 $bottom = open_window($x);
52
53 cmd 'split h';
54 cmd 'layout stacked';
55
56 ($nodes, $focus) = get_ws_content($tmp);
57 is($nodes->[0]->{percent}, 0.5, 'top window got 50%');
58 is($nodes->[1]->{percent}, 0.5, 'bottom window got 50%');
59
60 cmd 'resize grow up 10 px or 25 ppt';
61
62 ($nodes, $focus) = get_ws_content($tmp);
63 is($nodes->[0]->{percent}, 0.25, 'top window got 25%');
64 is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
65
66 ############################################################
67 # checks that resizing floating windows works
68 ############################################################
69
70 $tmp = fresh_workspace;
71
72 $top = open_window($x);
73
74 cmd 'floating enable';
75
76 my @content = @{get_ws($tmp)->{floating_nodes}};
77 cmp_ok(@content, '==', 1, 'one floating node on this ws');
78
79 # up
80 my $oldrect = $content[0]->{rect};
81
82 cmd 'resize grow up 10 px or 25 ppt';
83
84 @content = @{get_ws($tmp)->{floating_nodes}};
85 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
86 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 10, 'y exactly 10 px smaller');
87 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
88 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
89 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 10, 'height exactly 10 px higher');
90 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
91
92 # up, but with a different amount of px
93 $oldrect = $content[0]->{rect};
94
95 cmd 'resize grow up 12 px or 25 ppt';
96
97 @content = @{get_ws($tmp)->{floating_nodes}};
98 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
99 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 12, 'y exactly 10 px smaller');
100 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
101 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
102 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 12, 'height exactly 10 px higher');
103 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
104
105 # left
106 $oldrect = $content[0]->{rect};
107
108 cmd 'resize grow left 10 px or 25 ppt';
109
110 @content = @{get_ws($tmp)->{floating_nodes}};
111 cmp_ok($content[0]->{rect}->{x}, '<', $oldrect->{x}, 'x smaller than before');
112 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
113
114 # right
115 $oldrect = $content[0]->{rect};
116
117 cmd 'resize grow right 10 px or 25 ppt';
118
119 @content = @{get_ws($tmp)->{floating_nodes}};
120 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
121 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
122 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
123 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height}, 'height the same as before');
124
125 # down
126 $oldrect = $content[0]->{rect};
127
128 cmd 'resize grow down 10 px or 25 ppt';
129
130 @content = @{get_ws($tmp)->{floating_nodes}};
131 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
132 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
133 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
134 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width the same as before');
135
136 done_testing;