]> git.sur5r.net Git - i3/i3/blob - testcases/t/41-resize.t
Initialize output (fixes compiler warning)
[i3/i3] / testcases / t / 41-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_standard_window($x);
18 sleep 0.25;
19 my $bottom = open_standard_window($x);
20 sleep 0.25;
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 floating windows works
51 ############################################################
52
53 $tmp = fresh_workspace;
54
55 $top = open_standard_window($x);
56 sleep 0.25;
57
58 cmd 'floating enable';
59
60 my @content = @{get_ws($tmp)->{floating_nodes}};
61 cmp_ok(@content, '==', 1, 'one floating node on this ws');
62
63 # up
64 my $oldrect = $content[0]->{rect};
65
66 cmd 'resize grow up 10 px or 25 ppt';
67
68 @content = @{get_ws($tmp)->{floating_nodes}};
69 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
70 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 10, 'y exactly 10 px smaller');
71 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
72 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
73 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 10, 'height exactly 10 px higher');
74 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
75
76 # up, but with a different amount of px
77 $oldrect = $content[0]->{rect};
78
79 cmd 'resize grow up 12 px or 25 ppt';
80
81 @content = @{get_ws($tmp)->{floating_nodes}};
82 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
83 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 12, 'y exactly 10 px smaller');
84 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
85 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
86 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 12, 'height exactly 10 px higher');
87 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
88
89 # left
90 $oldrect = $content[0]->{rect};
91
92 cmd 'resize grow left 10 px or 25 ppt';
93
94 @content = @{get_ws($tmp)->{floating_nodes}};
95 cmp_ok($content[0]->{rect}->{x}, '<', $oldrect->{x}, 'x smaller than before');
96 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
97
98 # right
99 $oldrect = $content[0]->{rect};
100
101 cmd 'resize grow right 10 px or 25 ppt';
102
103 @content = @{get_ws($tmp)->{floating_nodes}};
104 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
105 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
106 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
107 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height}, 'height the same as before');
108
109 # down
110 $oldrect = $content[0]->{rect};
111
112 cmd 'resize grow down 10 px or 25 ppt';
113
114 @content = @{get_ws($tmp)->{floating_nodes}};
115 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
116 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
117 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
118 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width the same as before');
119
120 done_testing;