diff --git a/testcases/t/10-dock.t b/testcases/t/10-dock.t index dabb7bd8..aa93d8f3 100644 --- a/testcases/t/10-dock.t +++ b/testcases/t/10-dock.t @@ -17,16 +17,8 @@ my $i3 = i3("/tmp/nestedcons"); # verify that there is no dock window yet ##################################################################### -my $tree = $i3->get_tree->recv; -my @outputs = @{$tree->{nodes}}; # Children of all dockareas -my @docked; -for my $output (@outputs) { - @docked = (@docked, map { @{$_->{nodes}} } - grep { $_->{type} == 5 } - @{$output->{nodes}}); -} - +my @docked = get_dock_clients; is(@docked, 0, 'no dock clients yet'); ##################################################################### @@ -59,15 +51,7 @@ is($rect->height, 30, 'height is unchanged'); # check that we can find it in the layout tree at the expected position ##################################################################### -$tree = $i3->get_tree->recv; -@outputs = @{$tree->{nodes}}; -@docked; -for my $output (@outputs) { - @docked = (@docked, map { @{$_->{nodes}} } - grep { $_->{type} == 5 } - @{$output->{nodes}}); -} - +@docked = get_dock_clients; is(@docked, 1, 'one dock client found'); # verify the position/size diff --git a/testcases/t/50-regress-dock-restart.t b/testcases/t/50-regress-dock-restart.t new file mode 100644 index 00000000..a753abe2 --- /dev/null +++ b/testcases/t/50-regress-dock-restart.t @@ -0,0 +1,111 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Regression test for inplace restarting with dock clients +# +use X11::XCB qw(:all); +use Time::HiRes qw(sleep); +use i3test; + +BEGIN { + use_ok('X11::XCB::Window'); +} + +my $x = X11::XCB::Connection->new; +my $i3 = i3("/tmp/nestedcons"); + +my $tmp = get_unused_workspace; +cmd "workspace $tmp"; + +##################################################################### +# verify that there is no dock window yet +##################################################################### + +# Children of all dockareas +my @docked = get_dock_clients; + +is(@docked, 0, 'no dock clients yet'); + +# open a dock client + +my $window = $x->root->create_child( + class => WINDOW_CLASS_INPUT_OUTPUT, + rect => [ 0, 0, 30, 30], + background_color => '#FF0000', + window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), +); + +$window->map; + +sleep 0.25; + +##################################################################### +# check that we can find it in the layout tree at the expected position +##################################################################### + +@docked = get_dock_clients; +is(@docked, 1, 'one dock client found'); + +# verify the height +my $docknode = $docked[0]; + +is($docknode->{rect}->{height}, 30, 'dock node has unchanged height'); + +# perform an inplace-restart +cmd 'restart'; + +sleep 0.25; + +does_i3_live; + + +##################################################################### +# check that we can still find the dock client +##################################################################### + +@docked = get_dock_clients; +is(@docked, 1, 'one dock client found'); +$docknode = $docked[0]; + +is($docknode->{rect}->{height}, 30, 'dock node has unchanged height after restart'); + +$window->destroy; + +sleep 0.25; + +@docked = get_dock_clients; +is(@docked, 0, 'no dock clients found'); + +##################################################################### +# create a dock client with a 1px border +##################################################################### + +$window = $x->root->create_child( + class => WINDOW_CLASS_INPUT_OUTPUT, + border => 1, + rect => [ 0, 0, 30, 20], + background_color => '#00FF00', + window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), +); + +$window->map; + +sleep 0.25; + +@docked = get_dock_clients; +is(@docked, 1, 'one dock client found'); +$docknode = $docked[0]; + +is($docknode->{rect}->{height}, 20, 'dock node has unchanged height'); + +cmd 'restart'; +sleep 0.25; + +@docked = get_dock_clients; +is(@docked, 1, 'one dock client found'); +$docknode = $docked[0]; + +is($docknode->{rect}->{height}, 20, 'dock node has unchanged height'); + + +done_testing; diff --git a/testcases/t/lib/i3test.pm b/testcases/t/lib/i3test.pm index 7f6c0614..d03c9e3c 100644 --- a/testcases/t/lib/i3test.pm +++ b/testcases/t/lib/i3test.pm @@ -11,7 +11,7 @@ use List::Util qw(first); use v5.10; use Exporter (); -our @EXPORT = qw(get_workspace_names get_unused_workspace get_ws_content get_ws get_focused open_empty_con open_standard_window cmd does_i3_live); +our @EXPORT = qw(get_workspace_names get_unused_workspace get_ws_content get_ws get_focused open_empty_con open_standard_window get_dock_clients cmd does_i3_live); my $tester = Test::Builder->new(); @@ -129,6 +129,19 @@ sub get_focused { return $lf; } +sub get_dock_clients { + my $tree = i3("/tmp/nestedcons")->get_tree->recv; + my @outputs = @{$tree->{nodes}}; + # Children of all dockareas + my @docked; + for my $output (@outputs) { + @docked = (@docked, map { @{$_->{nodes}} } + grep { $_->{type} == 5 } + @{$output->{nodes}}); + } + return @docked; +} + sub cmd { i3("/tmp/nestedcons")->command(@_)->recv }