2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
18 use X11::XCB 'PROP_MODE_REPLACE';
19 use List::Util qw(first);
21 #####################################################################
22 # verify that there is no dock window yet
23 #####################################################################
25 # Children of all dockareas
26 my @docked = get_dock_clients;
27 is(@docked, 0, 'no dock clients yet');
29 #####################################################################
30 # Create a dock window and see if it gets managed
31 #####################################################################
33 my $screens = $x->screens;
35 # Get the primary screen
36 my $primary = first { $_->primary } @{$screens};
38 # TODO: focus the primary screen before
39 my $window = open_window({
40 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
43 my $rect = $window->rect;
44 is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
45 is($rect->height, 30, 'height is unchanged');
47 #####################################################################
48 # check that we can find it in the layout tree at the expected position
49 #####################################################################
51 @docked = get_dock_clients('top');
52 is(@docked, 1, 'one dock client found');
54 # verify the position/size
55 my $docknode = $docked[0];
57 is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
58 is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
59 is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
60 is($docknode->{rect}->{height}, 30, 'dock node has unchanged height');
62 #####################################################################
63 # check that re-configuring the height works
64 #####################################################################
66 $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 50, height => 40));
70 @docked = get_dock_clients('top');
71 is(@docked, 1, 'one dock client found');
73 # verify the position/size
74 $docknode = $docked[0];
76 is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
77 is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
78 is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
79 is($docknode->{rect}->{height}, 40, 'dock height changed');
83 wait_for_unmap $window;
85 @docked = get_dock_clients();
86 is(@docked, 0, 'no more dock clients');
88 #####################################################################
89 # check if it gets placed on bottom (by coordinates)
90 #####################################################################
92 $window = open_window({
93 rect => [ 0, 1000, 30, 30 ],
94 background_color => '#FF0000',
95 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
98 $rect = $window->rect;
99 is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
100 is($rect->height, 30, 'height is unchanged');
102 @docked = get_dock_clients('bottom');
103 is(@docked, 1, 'dock client on bottom');
107 wait_for_unmap $window;
109 @docked = get_dock_clients();
110 is(@docked, 0, 'no more dock clients');
112 #####################################################################
113 # check if it gets placed on bottom (by hint)
114 #####################################################################
116 $window = open_window({
118 rect => [ 0, 1000, 30, 30 ],
119 background_color => '#FF0000',
120 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
125 # Add a _NET_WM_STRUT_PARTIAL hint
126 my $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
127 my $atomtype = $x->atom(name => 'CARDINAL');
136 pack('L12', 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0, 0)
141 wait_for_map $window;
143 @docked = get_dock_clients('top');
144 is(@docked, 1, 'dock client on top');
146 # now change strut_partial to reserve space on the bottom and the dock should
147 # be moved to the bottom dock area
155 pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0)
159 @docked = get_dock_clients('bottom');
160 is(@docked, 1, 'dock client on bottom');
164 wait_for_unmap $window;
166 @docked = get_dock_clients();
167 is(@docked, 0, 'no more dock clients');
169 $window = open_window({
171 rect => [ 0, 1000, 30, 30 ],
172 background_color => '#FF0000',
173 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
178 # Add a _NET_WM_STRUT_PARTIAL hint
179 $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
180 $atomtype = $x->atom(name => 'CARDINAL');
189 pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 1280, 0, 0)
194 wait_for_map $window;
196 @docked = get_dock_clients('bottom');
197 is(@docked, 1, 'dock client on bottom');
202 #####################################################################
203 # regression test: transient dock client
204 #####################################################################
206 my $fwindow = open_window({
208 background_color => '#FF0000',
209 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
212 $fwindow->transient_for($window);
215 wait_for_map $fwindow;