]> git.sur5r.net Git - i3/i3/blob - testcases/t/141-resize.t
tests: rename files (00x-*.t is basic stuff, >=100-*.t are tests using IPC)
[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 floating windows works
75 ############################################################
76
77 $tmp = fresh_workspace;
78
79 $top = open_window($x);
80
81 cmd 'floating enable';
82
83 my @content = @{get_ws($tmp)->{floating_nodes}};
84 cmp_ok(@content, '==', 1, 'one floating node on this ws');
85
86 # up
87 my $oldrect = $content[0]->{rect};
88
89 cmd 'resize grow up 10 px or 25 ppt';
90
91 @content = @{get_ws($tmp)->{floating_nodes}};
92 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
93 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 10, 'y exactly 10 px smaller');
94 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
95 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
96 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 10, 'height exactly 10 px higher');
97 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
98
99 # up, but with a different amount of px
100 $oldrect = $content[0]->{rect};
101
102 cmd 'resize grow up 12 px or 25 ppt';
103
104 @content = @{get_ws($tmp)->{floating_nodes}};
105 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
106 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 12, 'y exactly 10 px smaller');
107 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
108 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
109 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 12, 'height exactly 10 px higher');
110 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
111
112 # left
113 $oldrect = $content[0]->{rect};
114
115 cmd 'resize grow left 10 px or 25 ppt';
116
117 @content = @{get_ws($tmp)->{floating_nodes}};
118 cmp_ok($content[0]->{rect}->{x}, '<', $oldrect->{x}, 'x smaller than before');
119 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
120
121 # right
122 $oldrect = $content[0]->{rect};
123
124 cmd 'resize grow right 10 px or 25 ppt';
125
126 @content = @{get_ws($tmp)->{floating_nodes}};
127 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
128 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
129 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
130 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height}, 'height the same as before');
131
132 # down
133 $oldrect = $content[0]->{rect};
134
135 cmd 'resize grow down 10 px or 25 ppt';
136
137 @content = @{get_ws($tmp)->{floating_nodes}};
138 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
139 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
140 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
141 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width the same as before');
142
143 done_testing;