2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Tests the floating_{minimum,maximum}_size config options.
19 # Note that the minimum floating window size is already verified in
23 use i3test i3_autostart => 0;
25 ################################################################################
26 # 1: check floating_minimum_size (with non-default limits)
27 ################################################################################
31 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
33 # Test with different dimensions than the i3 default.
34 floating_minimum_size 60 x 40
37 my $pid = launch_with_config($config);
39 my $window = open_floating_window(rect => [ 0, 0, 20, 20 ]);
40 my $rect = $window->rect;
42 is($rect->{width}, 60, 'width = 60');
43 is($rect->{height}, 40, 'height = 40');
45 exit_gracefully($pid);
47 ################################################################################
48 # 2: check floating_minimum_size with -1 (unlimited)
49 ################################################################################
53 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
55 floating_minimum_size -1 x -1
58 $pid = launch_with_config($config);
61 $window = open_floating_window(rect => [ 0, 0, 50, 40 ]);
62 $rect = $window->rect;
64 is($rect->{width}, 50, 'width = 50');
65 is($rect->{height}, 40, 'height = 40');
67 exit_gracefully($pid);
69 ################################################################################
70 # 3: check floating_maximum_size
71 ################################################################################
75 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
77 # Test with different dimensions than the i3 default.
78 floating_maximum_size 100 x 100
81 $pid = launch_with_config($config);
83 $window = open_floating_window(rect => [ 0, 0, 150, 150 ]);
84 $rect = $window->rect;
86 is($rect->{width}, 100, 'width = 100');
87 is($rect->{height}, 100, 'height = 100');
89 exit_gracefully($pid);
91 # Test that the feature works at all (without explicit configuration) by
92 # opening a window which is bigger than the testsuite screen (1280x1024).
96 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
99 $pid = launch_with_config($config);
101 $window = open_floating_window(rect => [ 0, 0, 2048, 2048 ]);
102 $rect = $window->rect;
104 cmp_ok($rect->{width}, '<', 2048, 'width < 2048');
105 cmp_ok($rect->{height}, '<', 2048, 'height < 2048');
107 exit_gracefully($pid);
109 ################################################################################
110 # 4: check floating_maximum_size
111 ################################################################################
114 # i3 config file (v4)
115 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
117 # Test with different dimensions than the i3 default.
118 floating_maximum_size -1 x -1
121 $pid = launch_with_config($config);
123 $window = open_floating_window(rect => [ 0, 0, 2048, 2048 ]);
124 $rect = $window->rect;
126 is($rect->{width}, 2048, 'width = 2048');
127 is($rect->{height}, 2048, 'height = 2048');
129 exit_gracefully($pid);
131 ################################################################################
132 # 5: check floating_minimum_size with cmd_resize
133 ################################################################################
136 # i3 config file (v4)
137 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
139 # Test with different dimensions than the i3 default.
140 floating_minimum_size 60 x 50
143 $pid = launch_with_config($config);
145 $window = open_floating_window(rect => [ 0, 0, 100, 100 ]);
147 cmd 'resize shrink height 80px or 80ppt';
148 cmd 'resize shrink width 80px or 80ppt';
150 $rect = $window->rect;
151 is($rect->{width}, 60, 'width = 60');
152 is($rect->{height}, 50, 'height = 50');
154 exit_gracefully($pid);
156 ################################################################################
157 # 6: check floating_maximum_size with cmd_resize
158 ################################################################################
161 # i3 config file (v4)
162 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
164 # Test with different dimensions than the i3 default.
165 floating_maximum_size 100 x 100
168 $pid = launch_with_config($config);
170 $window = open_floating_window(rect => [ 200, 200, 50, 50 ]);
172 cmd 'resize grow height 100px or 100ppt';
173 cmd 'resize grow width 100px or 100ppt';
175 $rect = $window->rect;
176 is($rect->{width}, 100, 'width = 100');
177 is($rect->{height}, 100, 'height = 100');
179 my $old_x = $rect->{x};
180 my $old_y = $rect->{y};
181 cmd 'resize grow up 10px or 10ppt';
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');
187 exit_gracefully($pid);