]> git.sur5r.net Git - i3/i3/blob - testcases/t/189-floating-constraints.t
6b082bfdcb1bab61bbe2a108fd8bc9e47ccb3272
[i3/i3] / testcases / t / 189-floating-constraints.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Tests the floating_{minimum,maximum}_size config options.
18 #
19 # Note that the minimum floating window size is already verified in
20 # t/005-floating.t.
21 #
22
23 use i3test i3_autostart => 0;
24
25 ################################################################################
26 # 1: check floating_minimum_size (with non-default limits)
27 ################################################################################
28
29 my $config = <<EOT;
30 # i3 config file (v4)
31 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
32
33 # Test with different dimensions than the i3 default.
34 floating_minimum_size 60 x 40
35 EOT
36
37 my $pid = launch_with_config($config);
38
39 my $window = open_floating_window(rect => [ 0, 0, 20, 20 ]);
40 my $rect = $window->rect;
41
42 is($rect->{width}, 60, 'width = 60');
43 is($rect->{height}, 40, 'height = 40');
44
45 exit_gracefully($pid);
46
47 ################################################################################
48 # 2: check floating_minimum_size with -1 (unlimited)
49 ################################################################################
50
51 $config = <<EOT;
52 # i3 config file (v4)
53 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
54
55 floating_minimum_size -1 x -1
56 EOT
57
58 $pid = launch_with_config($config);
59
60 cmd 'nop MEH';
61 $window = open_floating_window(rect => [ 0, 0, 50, 40 ]);
62 $rect = $window->rect;
63
64 is($rect->{width}, 50, 'width = 50');
65 is($rect->{height}, 40, 'height = 40');
66
67 exit_gracefully($pid);
68
69 ################################################################################
70 # 3: check floating_maximum_size
71 ################################################################################
72
73 $config = <<EOT;
74 # i3 config file (v4)
75 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
76
77 # Test with different dimensions than the i3 default.
78 floating_maximum_size 100 x 100
79 EOT
80
81 $pid = launch_with_config($config);
82
83 $window = open_floating_window(rect => [ 0, 0, 150, 150 ]);
84 $rect = $window->rect;
85
86 is($rect->{width}, 100, 'width = 100');
87 is($rect->{height}, 100, 'height = 100');
88
89 exit_gracefully($pid);
90
91 # Test that the feature works at all (without explicit configuration) by
92 # opening a window which is bigger than the testsuite screen (1280x1024).
93
94 $config = <<EOT;
95 # i3 config file (v4)
96 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
97 EOT
98
99 $pid = launch_with_config($config);
100
101 $window = open_floating_window(rect => [ 0, 0, 2048, 2048 ]);
102 $rect = $window->rect;
103
104 cmp_ok($rect->{width}, '<', 2048, 'width < 2048');
105 cmp_ok($rect->{height}, '<', 2048, 'height < 2048');
106
107 exit_gracefully($pid);
108
109 ################################################################################
110 # 4: check floating_maximum_size
111 ################################################################################
112
113 $config = <<EOT;
114 # i3 config file (v4)
115 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
116
117 # Test with different dimensions than the i3 default.
118 floating_maximum_size -1 x -1
119 EOT
120
121 $pid = launch_with_config($config);
122
123 $window = open_floating_window(rect => [ 0, 0, 2048, 2048 ]);
124 $rect = $window->rect;
125
126 is($rect->{width}, 2048, 'width = 2048');
127 is($rect->{height}, 2048, 'height = 2048');
128
129 exit_gracefully($pid);
130
131 ################################################################################
132 # 5: check floating_minimum_size with cmd_resize
133 ################################################################################
134
135 $config = <<EOT;
136 # i3 config file (v4)
137 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
138
139 # Test with different dimensions than the i3 default.
140 floating_minimum_size 60 x 50
141 EOT
142
143 $pid = launch_with_config($config);
144
145 $window = open_floating_window(rect => [ 0, 0, 100, 100 ]);
146 cmd 'border none';
147 cmd 'resize shrink height 80px or 80ppt';
148 cmd 'resize shrink width 80px or 80ppt';
149 sync_with_i3;
150 $rect = $window->rect;
151 is($rect->{width}, 60, 'width = 60');
152 is($rect->{height}, 50, 'height = 50');
153
154 exit_gracefully($pid);
155
156 ################################################################################
157 # 6: check floating_maximum_size with cmd_resize
158 ################################################################################
159
160 $config = <<EOT;
161 # i3 config file (v4)
162 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
163
164 # Test with different dimensions than the i3 default.
165 floating_maximum_size 100 x 100
166 EOT
167
168 $pid = launch_with_config($config);
169
170 $window = open_floating_window(rect => [ 200, 200, 50, 50 ]);
171 cmd 'border none';
172 cmd 'resize grow height 100px or 100ppt';
173 cmd 'resize grow width 100px or 100ppt';
174 sync_with_i3;
175 $rect = $window->rect;
176 is($rect->{width}, 100, 'width = 100');
177 is($rect->{height}, 100, 'height = 100');
178
179 my $old_x = $rect->{x};
180 my $old_y = $rect->{y};
181 cmd 'resize grow up 10px or 10ppt';
182 sync_with_i3;
183 $rect = $window->rect;
184 is($rect->{x}, $old_x, 'window did not move when trying to resize');
185 is($rect->{y}, $old_y, 'window did not move when trying to resize');
186
187 exit_gracefully($pid);
188
189 ################################################################################
190 # 7: check floating_maximum_size with cmd_size
191 ################################################################################
192
193 $config = <<EOT;
194 # i3 config file (v4)
195 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
196
197 # Test with different dimensions than the i3 default.
198 floating_minimum_size 80 x 70
199 floating_maximum_size 100 x 90
200 EOT
201
202 $pid = launch_with_config($config);
203
204 $window = open_floating_window(rect => [ 0, 0, 90, 80 ]);
205 cmd 'border none';
206
207 cmd 'resize set 101 91';
208 sync_with_i3;
209 $rect = $window->rect;
210 is($rect->{width}, 100, 'width did not exceed maximum width');
211 is($rect->{height}, 90, 'height did not exceed maximum height');
212
213 cmd 'resize set 79 69';
214 sync_with_i3;
215 $rect = $window->rect;
216 is($rect->{width}, 80, 'width did not exceed minimum width');
217 is($rect->{height}, 70, 'height did not exceed minimum height');
218
219 exit_gracefully($pid);
220
221 done_testing;