]> git.sur5r.net Git - i3/i3/blob - testcases/t/112-floating-resize.t
Merge branch 'fix-fullscreen-enternotify'
[i3/i3] / testcases / t / 112-floating-resize.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test;
5 use X11::XCB qw(:all);
6
7 BEGIN {
8     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
9 }
10
11 my $x = X11::XCB::Connection->new;
12
13 fresh_workspace;
14
15 #####################################################################
16 # Create a floating window and see if resizing works
17 #####################################################################
18
19 my $window = open_floating_window($x);
20
21 # See if configurerequests cause window movements (they should not)
22 my ($a, $t) = $window->rect;
23 $window->rect(X11::XCB::Rect->new(x => $a->x, y => $a->y, width => $a->width, height => $a->height));
24
25 sync_with_i3($x);
26
27 my ($na, $nt) = $window->rect;
28 is_deeply($na, $a, 'Rects are equal after configurerequest');
29
30 sub test_resize {
31     $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 100, height => 100));
32
33     sync_with_i3($x);
34
35     my ($absolute, $top) = $window->rect;
36
37     # Make sure the width/height are different from what we’re gonna test, so
38     # that the test will work.
39     isnt($absolute->width, 300, 'width != 300');
40     isnt($absolute->height, 500, 'height != 500');
41
42     $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 300, height => 500));
43
44     sync_with_i3($x);
45
46     ($absolute, $top) = $window->rect;
47
48     is($absolute->width, 300, 'width = 300');
49     is($absolute->height, 500, 'height = 500');
50 }
51
52 # Test with default border
53 test_resize;
54
55 # Test borderless
56 cmd 'border none';
57
58 test_resize;
59
60 # Test with 1-px-border
61 cmd 'border 1pixel';
62
63 test_resize;
64
65 ################################################################################
66 # Check if we can position a floating window out of bounds. The XDummy screen
67 # is 1280x1024, so x=2864, y=893 is out of bounds.
68 ################################################################################
69
70 ($a, $t) = $window->rect;
71 $window->rect(X11::XCB::Rect->new(
72     x => 2864,
73     y => 893,
74     width => $a->width,
75     height => $a->height));
76
77 sync_with_i3;
78
79 ($a, $t) = $window->rect;
80 cmp_ok($a->x, '<', 1280, 'X not moved out of bounds');
81 cmp_ok($a->y, '<', 1024, 'Y not moved out of bounds');
82
83 done_testing;