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 Time::HiRes qw(sleep);
use Cwd qw(abs_path);
use Scalar::Util qw(blessed);
use SocketActivation;
use v5.10;
@ -122,14 +123,22 @@ sub wait_for_event {
# thin wrapper around wait_for_event which waits for MAP_NOTIFY
# make sure to include 'structure_notify' in the windows event_mask attribute
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
# sync_with_i3 to make sure i3 also picked up and processed the UnmapNotify
# event.
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);
}
@ -163,7 +172,7 @@ sub open_window {
return $window if $dont_map;
$window->map;
wait_for_map($x);
wait_for_map($window);
# We sync with i3 here to make sure $x->input_focus is updated.
sync_with_i3($x);
return $window;

View File

@ -18,7 +18,7 @@ isa_ok($window, 'X11::XCB::Window');
$window->map;
wait_for_map $x;
wait_for_map $window;
my ($absolute, $top) = $window->rect;
@ -42,7 +42,7 @@ isa_ok($window, 'X11::XCB::Window');
$window->map;
wait_for_map $x;
wait_for_map $window;
($absolute, $top) = $window->rect;
@ -73,10 +73,11 @@ isa_ok($window, 'X11::XCB::Window');
$window->map;
wait_for_map $x;
wait_for_map $window;
cmd 'floating enable';
# XXX potentionally racy
($absolute, $top) = $window->rect;
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;
wait_for_map $x;
wait_for_map $window;
# open another container to make the window get only half of the screen
cmd 'open';
@ -95,7 +95,7 @@ is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
$window->fullscreen(1);
$window->map;
wait_for_map $x;
wait_for_map $window;
$new_rect = $window->rect;
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;
wait_for_unmap $x;
wait_for_unmap $window;
@docked = get_dock_clients();
is(@docked, 0, 'no more dock clients');
@ -91,7 +91,7 @@ is(@docked, 1, 'dock client on bottom');
$window->destroy;
wait_for_unmap $x;
wait_for_unmap $window;
@docked = get_dock_clients();
is(@docked, 0, 'no more dock clients');
@ -125,14 +125,14 @@ $x->change_property(
$window->map;
wait_for_map $x;
wait_for_map $window;
@docked = get_dock_clients('top');
is(@docked, 1, 'dock client on top');
$window->destroy;
wait_for_unmap $x;
wait_for_unmap $window;
@docked = get_dock_clients();
is(@docked, 0, 'no more dock clients');
@ -162,7 +162,7 @@ $x->change_property(
$window->map;
wait_for_map $x;
wait_for_map $window;
@docked = get_dock_clients('bottom');
is(@docked, 1, 'dock client on bottom');
@ -183,7 +183,7 @@ my $fwindow = open_window($x, {
$fwindow->transient_for($window);
$fwindow->map;
wait_for_map $x;
wait_for_map $fwindow;
does_i3_live;

View File

@ -21,7 +21,7 @@ is($x->input_focus, $window->id, 'floating window focused');
$window->unmap;
wait_for_unmap($x);
wait_for_unmap $window;
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->map;
ok(wait_for_map($x), 'child window mapped');
ok(wait_for_map($child), 'child window mapped');
my $cgeom;
($abs, $cgeom) = $child->rect;
@ -38,7 +38,7 @@ my $child2 = open_floating_window($x, {
$child2->client_leader($left);
$child2->map;
ok(wait_for_map($x), 'second child window mapped');
ok(wait_for_map($child2), 'second child window mapped');
($abs, $cgeom) = $child2->rect;
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->map;
ok(wait_for_map($x), 'transient window mapped');
ok(wait_for_map($fwindow), 'transient window mapped');
my ($absolute, $top) = $fwindow->rect;
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' });
$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
@ -75,7 +75,7 @@ my $child = open_window($x, { dont_map => 1, name => 'Child window' });
$child->client_leader($window);
$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");

View File

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

View File

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

View File

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

View File

@ -45,7 +45,7 @@ cmd 'floating enable';
# now kill the third one (it's floating). focus should stay unchanged
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');
@ -76,12 +76,12 @@ cmd 'floating enable';
# now kill the second one. focus should fall back to the third one, which is
# also floating
cmd 'kill';
wait_for_unmap($x);
wait_for_unmap($second);
is($x->input_focus, $third->id, 'third con focused');
cmd 'kill';
wait_for_unmap($x);
wait_for_unmap($third);
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
# also floating
cmd 'kill';
wait_for_unmap($x);
wait_for_unmap($second);
is($x->input_focus, $third->id, 'third con focused');
cmd 'kill';
wait_for_unmap($x);
wait_for_unmap($third);
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;
wait_for_unmap $x;
wait_for_unmap $window;
@docked = get_dock_clients;
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;
wait_for_unmap $x;
wait_for_unmap $window;
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->map;
wait_for_map $x;
wait_for_map $window;
my @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'normal', 'normal border');
$window->unmap;
wait_for_unmap $x;
wait_for_unmap $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes');
@ -78,14 +78,14 @@ sub set_wm_class {
set_wm_class($window->id, 'borderless', 'borderless');
$window->name('Borderless window');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border');
$window->unmap;
wait_for_unmap $x;
wait_for_unmap $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes');
@ -117,7 +117,7 @@ $window = $x->root->create_child(
$window->name('special title');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
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');
$window->unmap;
wait_for_unmap $x;
wait_for_unmap $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes');
@ -177,7 +177,7 @@ $window = $x->root->create_child(
$window->name('special mark title');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -224,14 +224,14 @@ $window->_create;
set_wm_class($window->id, 'borderless', 'borderless');
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border');
cmd 'kill';
wait_for_unmap $x;
wait_for_unmap $window;
$window->destroy;
# give i3 a chance to delete the window from its tree
@ -245,7 +245,7 @@ $window->_create;
set_wm_class($window->id, 'borderless', 'borderless');
$window->name('notthis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -280,7 +280,7 @@ $window->_create;
set_wm_class($window->id, 'bar', 'foo');
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -315,7 +315,7 @@ $window->_create;
set_wm_class($window->id, 'bar', 'foo');
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -352,7 +352,7 @@ $window->_create;
set_wm_class($window->id, 'bar', 'foo');
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -400,7 +400,7 @@ $x->change_property(
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 1, 'one node on this workspace now');
@ -437,7 +437,7 @@ $window->_create;
$window->name('usethis');
$window->map;
wait_for_map $x;
wait_for_map $window;
@content = @{get_ws_content($tmp)};
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');
$window->name('special window');
$window->map;
wait_for_map $x;
wait_for_map $window;
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');
$window->name('special window');
$window->map;
wait_for_map $x;
wait_for_map $window;
ok(@{get_ws_content($tmp)} == 0, 'still no containers');
ok("targetws" ~~ @{get_workspace_names()}, 'targetws exists');
@ -172,7 +172,7 @@ $window->_create;
set_wm_class($window->id, 'special', 'special');
$window->name('special window');
$window->map;
wait_for_map $x;
wait_for_map $window;
my $content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons');
@ -213,7 +213,7 @@ $window->_create;
set_wm_class($window->id, 'SPEcial', 'SPEcial');
$window->name('special window');
$window->map;
wait_for_map $x;
wait_for_map $window;
$content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons');
@ -263,7 +263,7 @@ $window->_create;
set_wm_class($window->id, 'special', 'special');
$window->name('special window');
$window->map;
wait_for_map $x;
wait_for_map $window;
$content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons');