]> git.sur5r.net Git - i3/i3/blob - testcases/t/55-floating-split-size.t
Merge branch 'fix-focus-ipc'
[i3/i3] / testcases / t / 55-floating-split-size.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Test to see if i3 combines the geometry of all children in a split container
5 # when setting the split container to floating
6 #
7 use X11::XCB qw(:all);
8 use i3test;
9
10 BEGIN {
11     use_ok('X11::XCB::Window');
12 }
13
14 my $x = X11::XCB::Connection->new;
15 my $i3 = i3(get_socket_path());
16
17 my $tmp = fresh_workspace;
18
19 #####################################################################
20 # open a window with 200x80
21 #####################################################################
22
23 my $first = $x->root->create_child(
24     class => WINDOW_CLASS_INPUT_OUTPUT,
25     rect => [ 0, 0, 200, 80],
26     background_color => '#FF0000',
27 );
28
29 $first->map;
30
31 sleep 0.25;
32
33 #####################################################################
34 # Open a second window with 300x90
35 #####################################################################
36
37 my $second = $x->root->create_child(
38     class => WINDOW_CLASS_INPUT_OUTPUT,
39     rect => [ 0, 0, 300, 90],
40     background_color => '#00FF00',
41 );
42
43 $second->map;
44
45 sleep 0.25;
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;