]> git.sur5r.net Git - i3/i3/blob - testcases/t/155-floating-split-size.t
tests: replace http:// with https:// where appropriate
[i3/i3] / testcases / t / 155-floating-split-size.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 # Test to see if i3 combines the geometry of all children in a split container
18 # when setting the split container to floating
19 #
20 use i3test;
21
22 my $tmp = fresh_workspace;
23
24 open_window;
25 cmd 'split v';
26
27 #####################################################################
28 # open a window with 200x80
29 #####################################################################
30
31 my $first = open_window({
32         rect => [ 0, 0, 200, 80],
33         background_color => '#FF0000',
34     });
35
36 cmd 'split h';
37
38 #####################################################################
39 # Open a second window with 300x90
40 #####################################################################
41
42 my $second = open_window({
43         rect => [ 0, 0, 300, 90],
44         background_color => '#00FF00',
45     });
46
47 #####################################################################
48 # Set the parent to floating
49 #####################################################################
50 cmd 'nop setting floating';
51 cmd 'focus parent';
52 cmd 'floating enable';
53
54 #####################################################################
55 # Get geometry of the first floating node (the split container)
56 #####################################################################
57
58 my @nodes = @{get_ws($tmp)->{floating_nodes}};
59 my $rect = $nodes[0]->{rect};
60
61 # we compare the width with ± 20 pixels for borders
62 cmp_ok($rect->{width}, '>', 500-20, 'width now > 480');
63 cmp_ok($rect->{width}, '<', 500+20, 'width now < 520');
64 # we compare the height with ± 40 pixels for decorations
65 cmp_ok($rect->{height}, '>', 90-40, 'width now > 50');
66 cmp_ok($rect->{height}, '<', 90+40, 'width now < 130');
67
68 done_testing;