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