testcases: use $x in wait_for_(un)map change to wait_for_(un)map($win)

wait_for_unmap currently ignores its $window parameter, since
X11::XCB doesn't provide $event->{window} for unmap events yet.
This commit is contained in:
Maik Fischer 2011-11-21 23:44:20 +01:00 committed by Michael Stapelberg
parent 65471a6b18
commit da403b3667
14 changed files with 66 additions and 56 deletions

View File

@ -12,6 +12,7 @@ use EV;
use List::Util qw(first); use List::Util qw(first);
use Time::HiRes qw(sleep); use Time::HiRes qw(sleep);
use Cwd qw(abs_path); use Cwd qw(abs_path);
use Scalar::Util qw(blessed);
use SocketActivation; use SocketActivation;
use v5.10; use v5.10;
@ -122,14 +123,22 @@ sub wait_for_event {
# thin wrapper around wait_for_event which waits for MAP_NOTIFY # thin wrapper around wait_for_event which waits for MAP_NOTIFY
# make sure to include 'structure_notify' in the windows event_mask attribute # make sure to include 'structure_notify' in the windows event_mask attribute
sub wait_for_map { sub wait_for_map {
wait_for_event 2, sub { $_[0]->{response_type} == MAP_NOTIFY }; my ($win) = @_;
my $id = (blessed($win) && $win->isa('X11::XCB::Window')) ? $win->id : $win;
wait_for_event 2, sub {
$_[0]->{response_type} == MAP_NOTIFY and $_[0]->{window} == $id
};
} }
# Wrapper around wait_for_event which waits for UNMAP_NOTIFY. Also calls # Wrapper around wait_for_event which waits for UNMAP_NOTIFY. Also calls
# sync_with_i3 to make sure i3 also picked up and processed the UnmapNotify # sync_with_i3 to make sure i3 also picked up and processed the UnmapNotify
# event. # event.
sub wait_for_unmap { sub wait_for_unmap {
wait_for_event 2, sub { $_[0]->{response_type} == UNMAP_NOTIFY }; my ($win) = @_;
# my $id = (blessed($win) && $win->isa('X11::XCB::Window')) ? $win->id : $win;
wait_for_event 2, sub {
$_[0]->{response_type} == UNMAP_NOTIFY # and $_[0]->{window} == $id
};
sync_with_i3($x); sync_with_i3($x);
} }
@ -163,7 +172,7 @@ sub open_window {
return $window if $dont_map; return $window if $dont_map;
$window->map; $window->map;
wait_for_map($x); wait_for_map($window);
# We sync with i3 here to make sure $x->input_focus is updated. # We sync with i3 here to make sure $x->input_focus is updated.
sync_with_i3($x); sync_with_i3($x);
return $window; return $window;

View File

@ -18,7 +18,7 @@ isa_ok($window, 'X11::XCB::Window');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
my ($absolute, $top) = $window->rect; my ($absolute, $top) = $window->rect;
@ -42,7 +42,7 @@ isa_ok($window, 'X11::XCB::Window');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
($absolute, $top) = $window->rect; ($absolute, $top) = $window->rect;
@ -73,10 +73,11 @@ isa_ok($window, 'X11::XCB::Window');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
cmd 'floating enable'; cmd 'floating enable';
# XXX potentionally racy
($absolute, $top) = $window->rect; ($absolute, $top) = $window->rect;
cmp_ok($absolute->{width}, '==', 80, "i3 let the width at 80"); cmp_ok($absolute->{width}, '==', 80, "i3 let the width at 80");

View File

@ -45,7 +45,7 @@ is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
# open another container to make the window get only half of the screen # open another container to make the window get only half of the screen
cmd 'open'; cmd 'open';
@ -95,7 +95,7 @@ is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
$window->fullscreen(1); $window->fullscreen(1);
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
$new_rect = $window->rect; $new_rect = $window->rect;
ok(!eq_deeply($new_rect, $original_rect), "Window got repositioned after fullscreen"); ok(!eq_deeply($new_rect, $original_rect), "Window got repositioned after fullscreen");

View File

@ -67,7 +67,7 @@ is($docknode->{rect}->{height}, 40, 'dock height changed');
$window->destroy; $window->destroy;
wait_for_unmap $x; wait_for_unmap $window;
@docked = get_dock_clients(); @docked = get_dock_clients();
is(@docked, 0, 'no more dock clients'); is(@docked, 0, 'no more dock clients');
@ -91,7 +91,7 @@ is(@docked, 1, 'dock client on bottom');
$window->destroy; $window->destroy;
wait_for_unmap $x; wait_for_unmap $window;
@docked = get_dock_clients(); @docked = get_dock_clients();
is(@docked, 0, 'no more dock clients'); is(@docked, 0, 'no more dock clients');
@ -125,14 +125,14 @@ $x->change_property(
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@docked = get_dock_clients('top'); @docked = get_dock_clients('top');
is(@docked, 1, 'dock client on top'); is(@docked, 1, 'dock client on top');
$window->destroy; $window->destroy;
wait_for_unmap $x; wait_for_unmap $window;
@docked = get_dock_clients(); @docked = get_dock_clients();
is(@docked, 0, 'no more dock clients'); is(@docked, 0, 'no more dock clients');
@ -162,7 +162,7 @@ $x->change_property(
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@docked = get_dock_clients('bottom'); @docked = get_dock_clients('bottom');
is(@docked, 1, 'dock client on bottom'); is(@docked, 1, 'dock client on bottom');
@ -183,7 +183,7 @@ my $fwindow = open_window($x, {
$fwindow->transient_for($window); $fwindow->transient_for($window);
$fwindow->map; $fwindow->map;
wait_for_map $x; wait_for_map $fwindow;
does_i3_live; does_i3_live;

View File

@ -21,7 +21,7 @@ is($x->input_focus, $window->id, 'floating window focused');
$window->unmap; $window->unmap;
wait_for_unmap($x); wait_for_unmap $window;
is($x->input_focus, $focus, 'Focus correctly restored'); is($x->input_focus, $focus, 'Focus correctly restored');

View File

@ -25,7 +25,7 @@ my $child = open_floating_window($x, {
$child->client_leader($right); $child->client_leader($right);
$child->map; $child->map;
ok(wait_for_map($x), 'child window mapped'); ok(wait_for_map($child), 'child window mapped');
my $cgeom; my $cgeom;
($abs, $cgeom) = $child->rect; ($abs, $cgeom) = $child->rect;
@ -38,7 +38,7 @@ my $child2 = open_floating_window($x, {
$child2->client_leader($left); $child2->client_leader($left);
$child2->map; $child2->map;
ok(wait_for_map($x), 'second child window mapped'); ok(wait_for_map($child2), 'second child window mapped');
($abs, $cgeom) = $child2->rect; ($abs, $cgeom) = $child2->rect;
cmp_ok(($cgeom->x + $cgeom->width), '<', $rgeom->x, 'child above left window'); cmp_ok(($cgeom->x + $cgeom->width), '<', $rgeom->x, 'child above left window');
@ -48,7 +48,7 @@ my $fwindow = open_window($x, { dont_map => 1 });
$fwindow->transient_for($right); $fwindow->transient_for($right);
$fwindow->map; $fwindow->map;
ok(wait_for_map($x), 'transient window mapped'); ok(wait_for_map($fwindow), 'transient window mapped');
my ($absolute, $top) = $fwindow->rect; my ($absolute, $top) = $fwindow->rect;
ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)'); ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)');
@ -63,7 +63,7 @@ SKIP: {
my $window = open_window($x, { dont_map => 1, name => 'Parent window' }); my $window = open_window($x, { dont_map => 1, name => 'Parent window' });
$window->map; $window->map;
ok(wait_for_map($x), 'parent window mapped'); ok(wait_for_map($window), 'parent window mapped');
######################################################################### #########################################################################
# Switch to a different workspace and open a child window. It should be opened # Switch to a different workspace and open a child window. It should be opened
@ -75,7 +75,7 @@ my $child = open_window($x, { dont_map => 1, name => 'Child window' });
$child->client_leader($window); $child->client_leader($window);
$child->map; $child->map;
ok(wait_for_map($x), 'child window mapped'); ok(wait_for_map($child), 'child window mapped');
isnt($x->input_focus, $child->id, "Child window focused"); isnt($x->input_focus, $child->id, "Child window focused");

View File

@ -113,7 +113,7 @@ ok(defined($ws), "workspace 0: $tmp was created");
is($ws->{num}, 0, 'workspace number is 0'); is($ws->{num}, 0, 'workspace number is 0');
cmd "workspace aa: $tmp"; cmd "workspace aa: $tmp";
my $ws = get_ws("aa: $tmp"); $ws = get_ws("aa: $tmp");
ok(defined($ws), "workspace aa: $tmp was created"); ok(defined($ws), "workspace aa: $tmp was created");
is($ws->{num}, -1, 'workspace number is -1'); is($ws->{num}, -1, 'workspace number is -1');

View File

@ -34,7 +34,7 @@ cmd 'nop now killing the window';
my $id = $win->{id}; my $id = $win->{id};
cmd qq|[con_id="$id"] kill|; cmd qq|[con_id="$id"] kill|;
wait_for_unmap $x; wait_for_unmap $window;
cmd 'nop checking if its gone'; cmd 'nop checking if its gone';
$content = get_ws_content($tmp); $content = get_ws_content($tmp);
@ -80,7 +80,7 @@ $left->_create;
set_wm_class($left->id, 'special', 'special'); set_wm_class($left->id, 'special', 'special');
$left->name('left'); $left->name('left');
$left->map; $left->map;
ok(wait_for_map($x), 'left window mapped'); ok(wait_for_map($left), 'left window mapped');
my $right = $x->root->create_child( my $right = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT, class => WINDOW_CLASS_INPUT_OUTPUT,
@ -93,7 +93,7 @@ $right->_create;
set_wm_class($right->id, 'special', 'special'); set_wm_class($right->id, 'special', 'special');
$right->name('right'); $right->name('right');
$right->map; $right->map;
ok(wait_for_map($x), 'right window mapped'); ok(wait_for_map($right), 'right window mapped');
# two windows should be here # two windows should be here
$content = get_ws_content($tmp); $content = get_ws_content($tmp);
@ -123,7 +123,7 @@ $left->_create;
set_wm_class($left->id, 'special7', 'special7'); set_wm_class($left->id, 'special7', 'special7');
$left->name('left'); $left->name('left');
$left->map; $left->map;
ok(wait_for_map($x), 'left window mapped'); ok(wait_for_map($left), 'left window mapped');
# two windows should be here # two windows should be here
$content = get_ws_content($tmp); $content = get_ws_content($tmp);
@ -131,7 +131,7 @@ ok(@{$content} == 1, 'window opened');
cmd '[class="^special[0-9]$"] kill'; cmd '[class="^special[0-9]$"] kill';
wait_for_unmap $x; wait_for_unmap $left;
$content = get_ws_content($tmp); $content = get_ws_content($tmp);
is(@{$content}, 0, 'window killed'); is(@{$content}, 0, 'window killed');
@ -153,7 +153,7 @@ $left->_create;
set_wm_class($left->id, 'special7', 'special7'); set_wm_class($left->id, 'special7', 'special7');
$left->name('ä 3'); $left->name('ä 3');
$left->map; $left->map;
ok(wait_for_map($x), 'left window mapped'); ok(wait_for_map($left), 'left window mapped');
# two windows should be here # two windows should be here
$content = get_ws_content($tmp); $content = get_ws_content($tmp);
@ -161,7 +161,7 @@ ok(@{$content} == 1, 'window opened');
cmd '[title="^\w [3]$"] kill'; cmd '[title="^\w [3]$"] kill';
wait_for_unmap $x; wait_for_unmap $left;
$content = get_ws_content($tmp); $content = get_ws_content($tmp);
is(@{$content}, 0, 'window killed'); is(@{$content}, 0, 'window killed');

View File

@ -19,7 +19,7 @@ $aspect->max_num(600);
$aspect->max_den(300); $aspect->max_den(300);
$win->_create; $win->_create;
$win->map; $win->map;
wait_for_map $x; wait_for_map $win;
$win->hints->aspect($aspect); $win->hints->aspect($aspect);
$x->flush; $x->flush;

View File

@ -45,7 +45,7 @@ cmd 'floating enable';
# now kill the third one (it's floating). focus should stay unchanged # now kill the third one (it's floating). focus should stay unchanged
cmd '[id="' . $third->id . '"] kill'; cmd '[id="' . $third->id . '"] kill';
wait_for_unmap($x); wait_for_unmap($third);
is($x->input_focus, $second->id, 'second con still focused after killing third'); is($x->input_focus, $second->id, 'second con still focused after killing third');
@ -76,12 +76,12 @@ cmd 'floating enable';
# now kill the second one. focus should fall back to the third one, which is # now kill the second one. focus should fall back to the third one, which is
# also floating # also floating
cmd 'kill'; cmd 'kill';
wait_for_unmap($x); wait_for_unmap($second);
is($x->input_focus, $third->id, 'third con focused'); is($x->input_focus, $third->id, 'third con focused');
cmd 'kill'; cmd 'kill';
wait_for_unmap($x); wait_for_unmap($third);
is($x->input_focus, $first->id, 'first con focused after killing all floating cons'); is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
@ -114,12 +114,12 @@ sync_with_i3($x);
# now kill the second one. focus should fall back to the third one, which is # now kill the second one. focus should fall back to the third one, which is
# also floating # also floating
cmd 'kill'; cmd 'kill';
wait_for_unmap($x); wait_for_unmap($second);
is($x->input_focus, $third->id, 'third con focused'); is($x->input_focus, $third->id, 'third con focused');
cmd 'kill'; cmd 'kill';
wait_for_unmap($x); wait_for_unmap($third);
is($x->input_focus, $first->id, 'first con focused after killing all floating cons'); is($x->input_focus, $first->id, 'first con focused after killing all floating cons');

View File

@ -55,7 +55,7 @@ is($docknode->{rect}->{height}, 30, 'dock node has unchanged height after restar
$window->destroy; $window->destroy;
wait_for_unmap $x; wait_for_unmap $window;
@docked = get_dock_clients; @docked = get_dock_clients;
is(@docked, 0, 'no dock clients found'); is(@docked, 0, 'no dock clients found');

View File

@ -15,7 +15,7 @@ is($window->state, ICCCM_WM_STATE_NORMAL, 'WM_STATE normal');
$window->unmap; $window->unmap;
wait_for_unmap $x; wait_for_unmap $window;
is($window->state, ICCCM_WM_STATE_WITHDRAWN, 'WM_STATE withdrawn'); is($window->state, ICCCM_WM_STATE_WITHDRAWN, 'WM_STATE withdrawn');

View File

@ -34,14 +34,14 @@ my $window = $x->root->create_child(
$window->name('Border window'); $window->name('Border window');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
my @content = @{get_ws_content($tmp)}; my @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'normal', 'normal border'); is($content[0]->{border}, 'normal', 'normal border');
$window->unmap; $window->unmap;
wait_for_unmap $x; wait_for_unmap $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes'); cmp_ok(@content, '==', 0, 'no more nodes');
@ -78,14 +78,14 @@ sub set_wm_class {
set_wm_class($window->id, 'borderless', 'borderless'); set_wm_class($window->id, 'borderless', 'borderless');
$window->name('Borderless window'); $window->name('Borderless window');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border'); is($content[0]->{border}, 'none', 'no border');
$window->unmap; $window->unmap;
wait_for_unmap $x; wait_for_unmap $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes'); cmp_ok(@content, '==', 0, 'no more nodes');
@ -117,7 +117,7 @@ $window = $x->root->create_child(
$window->name('special title'); $window->name('special title');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -144,7 +144,7 @@ sync_with_i3 $x;
is($content[0]->{border}, 'normal', 'still normal border'); is($content[0]->{border}, 'normal', 'still normal border');
$window->unmap; $window->unmap;
wait_for_unmap $x; wait_for_unmap $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes'); cmp_ok(@content, '==', 0, 'no more nodes');
@ -177,7 +177,7 @@ $window = $x->root->create_child(
$window->name('special mark title'); $window->name('special mark title');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -224,14 +224,14 @@ $window->_create;
set_wm_class($window->id, 'borderless', 'borderless'); set_wm_class($window->id, 'borderless', 'borderless');
$window->name('usethis'); $window->name('usethis');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border'); is($content[0]->{border}, 'none', 'no border');
cmd 'kill'; cmd 'kill';
wait_for_unmap $x; wait_for_unmap $window;
$window->destroy; $window->destroy;
# give i3 a chance to delete the window from its tree # give i3 a chance to delete the window from its tree
@ -245,7 +245,7 @@ $window->_create;
set_wm_class($window->id, 'borderless', 'borderless'); set_wm_class($window->id, 'borderless', 'borderless');
$window->name('notthis'); $window->name('notthis');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -280,7 +280,7 @@ $window->_create;
set_wm_class($window->id, 'bar', 'foo'); set_wm_class($window->id, 'bar', 'foo');
$window->name('usethis'); $window->name('usethis');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -315,7 +315,7 @@ $window->_create;
set_wm_class($window->id, 'bar', 'foo'); set_wm_class($window->id, 'bar', 'foo');
$window->name('usethis'); $window->name('usethis');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -352,7 +352,7 @@ $window->_create;
set_wm_class($window->id, 'bar', 'foo'); set_wm_class($window->id, 'bar', 'foo');
$window->name('usethis'); $window->name('usethis');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -400,7 +400,7 @@ $x->change_property(
$window->name('usethis'); $window->name('usethis');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -437,7 +437,7 @@ $window->_create;
$window->name('usethis'); $window->name('usethis');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');

View File

@ -53,7 +53,7 @@ $window->_create;
set_wm_class($window->id, 'special', 'special'); set_wm_class($window->id, 'special', 'special');
$window->name('special window'); $window->name('special window');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
ok(@{get_ws_content($tmp)} == 1, 'special window got managed to current (random) workspace'); ok(@{get_ws_content($tmp)} == 1, 'special window got managed to current (random) workspace');
@ -91,7 +91,7 @@ $window->_create;
set_wm_class($window->id, 'special', 'special'); set_wm_class($window->id, 'special', 'special');
$window->name('special window'); $window->name('special window');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
ok(@{get_ws_content($tmp)} == 0, 'still no containers'); ok(@{get_ws_content($tmp)} == 0, 'still no containers');
ok("targetws" ~~ @{get_workspace_names()}, 'targetws exists'); ok("targetws" ~~ @{get_workspace_names()}, 'targetws exists');
@ -172,7 +172,7 @@ $window->_create;
set_wm_class($window->id, 'special', 'special'); set_wm_class($window->id, 'special', 'special');
$window->name('special window'); $window->name('special window');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
my $content = get_ws($tmp); my $content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons'); ok(@{$content->{nodes}} == 0, 'no tiling cons');
@ -213,7 +213,7 @@ $window->_create;
set_wm_class($window->id, 'SPEcial', 'SPEcial'); set_wm_class($window->id, 'SPEcial', 'SPEcial');
$window->name('special window'); $window->name('special window');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
$content = get_ws($tmp); $content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons'); ok(@{$content->{nodes}} == 0, 'no tiling cons');
@ -263,7 +263,7 @@ $window->_create;
set_wm_class($window->id, 'special', 'special'); set_wm_class($window->id, 'special', 'special');
$window->name('special window'); $window->name('special window');
$window->map; $window->map;
wait_for_map $x; wait_for_map $window;
$content = get_ws($tmp); $content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons'); ok(@{$content->{nodes}} == 0, 'no tiling cons');