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