]> git.sur5r.net Git - i3/i3/blob - testcases/t/04-floating.t
Add testcases for IPC and basic focus switching
[i3/i3] / testcases / t / 04-floating.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use Test::More tests => 9;
5 use Test::Deep;
6 use X11::XCB qw(:all);
7 use Data::Dumper;
8 use Time::HiRes qw(sleep);
9 use FindBin;
10 use lib "$FindBin::Bin/lib";
11 use i3test;
12
13 BEGIN {
14     use_ok('X11::XCB::Window');
15 }
16
17 X11::XCB::Connection->connect(':0');
18
19 # Create a floating window which is smaller than the minimum enforced size of i3
20 my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30);
21
22 my $window = X11::XCB::Window->new(
23     class => WINDOW_CLASS_INPUT_OUTPUT,
24     rect => $original_rect,
25     background_color => 12632256,
26     type => 'utility',
27 );
28
29 isa_ok($window, 'X11::XCB::Window');
30
31 $window->create;
32 $window->map;
33
34 sleep(0.25);
35
36 my ($absolute, $top) = $window->rect;
37
38 ok($absolute->{width} >= 75, "i3 raised the width to 75");
39 ok($absolute->{height} >= 50, "i3 raised the height to 50");
40
41 ok($absolute->{x} != 0 && $absolute->{y} != 0, "i3 did not map it to (0x0)");
42
43 $original_rect = X11::XCB::Rect->new(x => 1, y => 1, width => 80, height => 90);
44
45 $window = X11::XCB::Window->new(
46     class => WINDOW_CLASS_INPUT_OUTPUT,
47     rect => $original_rect,
48     background_color => 12632256,
49     type => 'utility',
50 );
51
52 isa_ok($window, 'X11::XCB::Window');
53
54 $window->create;
55 $window->map;
56
57 sleep(0.25);
58
59 ($absolute, $top) = $window->rect;
60
61 ok($absolute->{width} == 80, "i3 let the width at 80");
62 ok($absolute->{height} == 90, "i3 let the height at 90");
63
64 ok($top->{x} == 1 && $top->{y} == 1, "i3 mapped it to (1,1)");
65
66 diag( "Testing i3, Perl $], $^X" );