]> git.sur5r.net Git - i3/i3/blob - testcases/t/189-floating-constraints.t
add boilerplate to all testcases with documentation references
[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 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://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 done_testing;