]> git.sur5r.net Git - i3/i3/blob - testcases/t/12-floating-resize.t
implement configure requests, adapt testcase
[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 tests => 15;
8 use X11::XCB qw(:all);
9 use Time::HiRes qw(sleep);
10
11 BEGIN {
12     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
13 }
14
15 my $x = X11::XCB::Connection->new;
16
17 my $i3 = i3("/tmp/nestedcons");
18 my $tmp = get_unused_workspace();
19 $i3->command("workspace $tmp")->recv;
20
21 #####################################################################
22 # Create a floating window and see if resizing works
23 #####################################################################
24
25 # Create a floating window
26 my $window = $x->root->create_child(
27     class => WINDOW_CLASS_INPUT_OUTPUT,
28     rect => [ 0, 0, 30, 30],
29     background_color => '#C0C0C0',
30     # replace the type with 'utility' as soon as the coercion works again in X11::XCB
31     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
32 );
33
34 isa_ok($window, 'X11::XCB::Window');
35
36 $window->map;
37 sleep 0.25;
38
39 # See if configurerequests cause window movements (they should not)
40 my ($a, $t) = $window->rect;
41 $window->rect(X11::XCB::Rect->new(x => $a->x, y => $a->y, width => $a->width, height => $a->height));
42
43 sleep 0.25;
44 my ($na, $nt) = $window->rect;
45 is_deeply($na, $a, 'Rects are equal after configurerequest');
46
47 sub test_resize {
48     $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 100, height => 100));
49
50     my ($absolute, $top) = $window->rect;
51
52     # Make sure the width/height are different from what we’re gonna test, so
53     # that the test will work.
54     isnt($absolute->width, 300, 'width != 300');
55     isnt($absolute->height, 500, 'height != 500');
56
57     $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 300, height => 500));
58     sleep 0.25;
59
60     ($absolute, $top) = $window->rect;
61
62     is($absolute->width, 300, 'width = 300');
63     is($absolute->height, 500, 'height = 500');
64 }
65
66 # Test with default border
67 test_resize;
68
69 # Test borderless
70 $i3->command('border none')->recv;
71
72 test_resize;
73
74 # Test with 1-px-border
75 $i3->command('border 1pixel')->recv;
76
77 test_resize;