]> git.sur5r.net Git - i3/i3/blob - testcases/t/53-floating-originalsize.t
b1dc6199f0ff030b45028704504bc5ffab9f88a0
[i3/i3] / testcases / t / 53-floating-originalsize.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Test if the requested width/height is set after making the window floating.
5 #
6 use X11::XCB qw(:all);
7 use i3test;
8
9 my $tmp = fresh_workspace;
10
11 my $x = X11::XCB::Connection->new;
12
13 # Create a floating window which is smaller than the minimum enforced size of i3
14 my $window = $x->root->create_child(
15     class => WINDOW_CLASS_INPUT_OUTPUT,
16     rect => [ 0, 0, 400, 150],
17     background_color => '#C0C0C0',
18     event_mask => [ 'structure_notify' ],
19 );
20
21 isa_ok($window, 'X11::XCB::Window');
22
23 $window->map;
24
25 wait_for_map $x;
26
27 my ($absolute, $top) = $window->rect;
28
29 ok($window->mapped, 'Window is mapped');
30 cmp_ok($absolute->{width}, '>', 400, 'i3 raised the width');
31 cmp_ok($absolute->{height}, '>', 150, 'i3 raised the height');
32
33 cmd 'floating toggle';
34 sync_with_i3($x);
35
36 ($absolute, $top) = $window->rect;
37
38 diag('new width: ' . $absolute->{width});
39 diag('new height: ' . $absolute->{height});
40
41 # we compare with a tolerance of ± 20 pixels for borders in each direction
42 # (overkill, but hey)
43 cmp_ok($absolute->{width}, '>', 400-20, 'width now > 380');
44 cmp_ok($absolute->{width}, '<', 400+20, 'width now < 420');
45 cmp_ok($absolute->{height}, '>', 150-20, 'height now > 130');
46 cmp_ok($absolute->{height}, '<', 150+20, 'height now < 170');
47
48 #cmp_ok($absolute->{width}, '>=', 75, 'i3 raised the width to 75');
49 #cmp_ok($absolute->{height}, '>=', 50, 'i3 raised the height to 50');
50
51 done_testing;