]> git.sur5r.net Git - i3/i3/blob - testcases/t/12-floating-resize.t
Merge branch 'tree' into next
[i3/i3] / testcases / t / 12-floating-resize.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # Beware that this test uses workspace 9 to perform some tests (it expects
4 # the workspace to be empty).
5 # TODO: skip it by default?
6
7 use i3test;
8 use X11::XCB qw(:all);
9
10 BEGIN {
11     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
12 }
13
14 my $x = X11::XCB::Connection->new;
15
16 fresh_workspace;
17
18 #####################################################################
19 # Create a floating window and see if resizing works
20 #####################################################################
21
22 # Create a floating window
23 my $window = $x->root->create_child(
24     class => WINDOW_CLASS_INPUT_OUTPUT,
25     rect => [ 0, 0, 30, 30],
26     background_color => '#C0C0C0',
27     # replace the type with 'utility' as soon as the coercion works again in X11::XCB
28     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
29 );
30
31 isa_ok($window, 'X11::XCB::Window');
32
33 $window->map;
34 sleep 0.25;
35
36 # See if configurerequests cause window movements (they should not)
37 my ($a, $t) = $window->rect;
38 $window->rect(X11::XCB::Rect->new(x => $a->x, y => $a->y, width => $a->width, height => $a->height));
39
40 sleep 0.25;
41 my ($na, $nt) = $window->rect;
42 is_deeply($na, $a, 'Rects are equal after configurerequest');
43
44 sub test_resize {
45     $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 100, height => 100));
46
47     my ($absolute, $top) = $window->rect;
48
49     # Make sure the width/height are different from what we’re gonna test, so
50     # that the test will work.
51     isnt($absolute->width, 300, 'width != 300');
52     isnt($absolute->height, 500, 'height != 500');
53
54     $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 300, height => 500));
55     sleep 0.25;
56
57     ($absolute, $top) = $window->rect;
58
59     is($absolute->width, 300, 'width = 300');
60     is($absolute->height, 500, 'height = 500');
61 }
62
63 # Test with default border
64 test_resize;
65
66 # Test borderless
67 cmd 'border none';
68
69 test_resize;
70
71 # Test with 1-px-border
72 cmd 'border 1pixel';
73
74 test_resize;
75
76 done_testing;