]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/10-dock.t
Merge branch 'fix-i3bar-man'
[i3/i3] / testcases / t / 10-dock.t
index f53626a54a1496cf50bbf47f10c38f395c9676e4..3f0a5195a70737f4956cf9f3a75f57618864f8bf 100644 (file)
@@ -1,19 +1,24 @@
 #!perl
 # vim:ts=4:sw=4:expandtab
 
-use i3test tests => 2;
+use i3test;
 use X11::XCB qw(:all);
-use Time::HiRes qw(sleep);
 use List::Util qw(first);
 
 BEGIN {
     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
 }
 
-SKIP: {
-    skip "Dock clients not yet implemented", 1;
-
 my $x = X11::XCB::Connection->new;
+my $i3 = i3(get_socket_path());
+
+#####################################################################
+# verify that there is no dock window yet
+#####################################################################
+
+# Children of all dockareas
+my @docked = get_dock_clients;
+is(@docked, 0, 'no dock clients yet');
 
 #####################################################################
 # Create a dock window and see if it gets managed
@@ -30,7 +35,7 @@ my $window = $x->root->create_child(
     class => WINDOW_CLASS_INPUT_OUTPUT,
     rect => [ 0, 0, 30, 30],
     background_color => '#FF0000',
-    type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
+    window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
 );
 
 $window->map;
@@ -39,12 +44,161 @@ sleep 0.25;
 
 my $rect = $window->rect;
 is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
+is($rect->height, 30, 'height is unchanged');
+
+#####################################################################
+# check that we can find it in the layout tree at the expected position
+#####################################################################
+
+@docked = get_dock_clients('top');
+is(@docked, 1, 'one dock client found');
+
+# verify the position/size
+my $docknode = $docked[0];
+
+is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
+is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
+is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
+is($docknode->{rect}->{height}, 30, 'dock node has unchanged height');
+
+#####################################################################
+# check that re-configuring the height works
+#####################################################################
+
+$window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 50, height => 40));
+
+sleep 0.25;
+
+@docked = get_dock_clients('top');
+is(@docked, 1, 'one dock client found');
+
+# verify the position/size
+$docknode = $docked[0];
+
+is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
+is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
+is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
+is($docknode->{rect}->{height}, 40, 'dock height changed');
+
+$window->destroy;
+
+sleep 0.25;
+
+@docked = get_dock_clients();
+is(@docked, 0, 'no more dock clients');
+
+#####################################################################
+# check if it gets placed on bottom (by coordinates)
+#####################################################################
+
+$window = $x->root->create_child(
+    class => WINDOW_CLASS_INPUT_OUTPUT,
+    rect => [ 0, 1000, 30, 30],
+    background_color => '#FF0000',
+    window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
+);
+
+$window->map;
+
+sleep 0.25;
+
+my $rect = $window->rect;
+is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
+is($rect->height, 30, 'height is unchanged');
+
+@docked = get_dock_clients('bottom');
+is(@docked, 1, 'dock client on bottom');
+
+$window->destroy;
+
+sleep 0.25;
+
+@docked = get_dock_clients();
+is(@docked, 0, 'no more dock clients');
+
+#####################################################################
+# check if it gets placed on bottom (by hint)
+#####################################################################
+
+$window = $x->root->create_child(
+    class => WINDOW_CLASS_INPUT_OUTPUT,
+    rect => [ 0, 1000, 30, 30],
+    background_color => '#FF0000',
+    window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
+);
+
+$window->_create();
+
+# Add a _NET_WM_STRUT_PARTIAL hint
+my $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
+my $atomtype = $x->atom(name => 'CARDINAL');
+
+$x->change_property(
+    PROP_MODE_REPLACE,
+    $window->id,
+    $atomname->id,
+    $atomtype->id,
+    32,         # 32 bit integer
+    12,
+    pack('L12', 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0, 0)
+);
+
+$window->map;
+
+sleep 0.25;
+
+@docked = get_dock_clients('top');
+is(@docked, 1, 'dock client on top');
+
+$window->destroy;
+
+sleep 0.25;
+
+@docked = get_dock_clients();
+is(@docked, 0, 'no more dock clients');
+
+$window = $x->root->create_child(
+    class => WINDOW_CLASS_INPUT_OUTPUT,
+    rect => [ 0, 1000, 30, 30],
+    background_color => '#FF0000',
+    window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
+);
+
+$window->_create();
+
+# Add a _NET_WM_STRUT_PARTIAL hint
+my $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
+my $atomtype = $x->atom(name => 'CARDINAL');
+
+$x->change_property(
+    PROP_MODE_REPLACE,
+    $window->id,
+    $atomname->id,
+    $atomtype->id,
+    32,         # 32 bit integer
+    12,
+    pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 1280, 0, 0)
+);
+
+$window->map;
+
+sleep 0.25;
+
+@docked = get_dock_clients('bottom');
+is(@docked, 1, 'dock client on bottom');
+
+$window->destroy;
+
+
+#####################################################################
+# regression test: transient dock client
+#####################################################################
 
 my $fwindow = $x->root->create_child(
     class => WINDOW_CLASS_INPUT_OUTPUT,
     rect => [ 0, 0, 30, 30],
     background_color => '#FF0000',
-    type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
+    window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
 );
 
 $fwindow->transient_for($window);
@@ -52,6 +206,6 @@ $fwindow->map;
 
 sleep 0.25;
 
+does_i3_live;
 
-diag( "Testing i3, Perl $], $^X" );
-}
+done_testing;