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