]> git.sur5r.net Git - i3/i3/blob - testcases/t/12-floating-resize.t
Add testcase for resizing of floating windows
[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 => 16;
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
17 BEGIN {
18     use_ok('IO::Socket::UNIX') or BAIL_OUT('Cannot load IO::Socket::UNIX');
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 $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
25 isa_ok($sock, 'IO::Socket::UNIX');
26
27 # Switch to the nineth workspace
28 $sock->write(i3test::format_ipc_command("9"));
29
30 sleep 0.25;
31
32 #####################################################################
33 # Create a floating window and see if resizing works
34 #####################################################################
35
36 # Create a floating window
37 my $window = $x->root->create_child(
38     class => WINDOW_CLASS_INPUT_OUTPUT,
39     rect => [ 0, 0, 30, 30],
40     background_color => '#C0C0C0',
41     # replace the type with 'utility' as soon as the coercion works again in X11::XCB
42     type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
43 );
44
45 isa_ok($window, 'X11::XCB::Window');
46
47 $window->map;
48 sleep 0.25;
49
50
51 sub test_resize {
52     $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 100, height => 100));
53
54     my ($absolute, $top) = $window->rect;
55
56     # Make sure the width/height are different from what we’re gonna test, so
57     # that the test will work.
58     isnt($absolute->width, 300, 'width != 300');
59     isnt($absolute->height, 500, 'height != 500');
60
61     $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 300, height => 500));
62     sleep 0.25;
63
64     ($absolute, $top) = $window->rect;
65
66     is($absolute->width, 300, 'width = 300');
67     is($absolute->height, 500, 'height = 500');
68 }
69
70 # Test with default border
71 test_resize;
72
73 # Test borderless
74 $sock->write(i3test::format_ipc_command("bb"));
75 sleep 0.25;
76
77 test_resize;
78
79 # Test with 1-px-border
80 $sock->write(i3test::format_ipc_command("bp"));
81 sleep 0.25;
82
83 test_resize;