]> git.sur5r.net Git - i3/i3/blob - testcases/t/10-dock.t
tests: add test for dock client + restart
[i3/i3] / testcases / t / 10-dock.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test;
5 use X11::XCB qw(:all);
6 use Time::HiRes qw(sleep);
7 use List::Util qw(first);
8
9 BEGIN {
10     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
11 }
12
13 my $x = X11::XCB::Connection->new;
14 my $i3 = i3("/tmp/nestedcons");
15
16 #####################################################################
17 # verify that there is no dock window yet
18 #####################################################################
19
20 # Children of all dockareas
21 my @docked = get_dock_clients;
22 is(@docked, 0, 'no dock clients yet');
23
24 #####################################################################
25 # Create a dock window and see if it gets managed
26 #####################################################################
27
28 my $screens = $x->screens;
29
30 # Get the primary screen
31 my $primary = first { $_->primary } @{$screens};
32
33 # TODO: focus the primary screen before
34
35 my $window = $x->root->create_child(
36     class => WINDOW_CLASS_INPUT_OUTPUT,
37     rect => [ 0, 0, 30, 30],
38     background_color => '#FF0000',
39     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
40 );
41
42 $window->map;
43
44 sleep 0.25;
45
46 my $rect = $window->rect;
47 is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
48 is($rect->height, 30, 'height is unchanged');
49
50 #####################################################################
51 # check that we can find it in the layout tree at the expected position
52 #####################################################################
53
54 @docked = get_dock_clients;
55 is(@docked, 1, 'one dock client found');
56
57 # verify the position/size
58 my $docknode = $docked[0];
59
60 is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
61 is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
62 is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
63 is($docknode->{rect}->{height}, 30, 'dock node has unchanged height');
64
65 #####################################################################
66 # regression test: transient dock client
67 #####################################################################
68
69 my $fwindow = $x->root->create_child(
70     class => WINDOW_CLASS_INPUT_OUTPUT,
71     rect => [ 0, 0, 30, 30],
72     background_color => '#FF0000',
73     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
74 );
75
76 $fwindow->transient_for($window);
77 $fwindow->map;
78
79 sleep 0.25;
80
81 does_i3_live;
82
83 done_testing;