From: Maik Fischer Date: Mon, 21 Nov 2011 15:49:22 +0000 (+0100) Subject: testcases: fix race conditions in various tests X-Git-Tag: 4.2~233 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0f386a96;p=i3%2Fi3 testcases: fix race conditions in various tests --- diff --git a/testcases/t/135-floating-focus.t b/testcases/t/135-floating-focus.t index a1ab211e..b43f0f7f 100644 --- a/testcases/t/135-floating-focus.t +++ b/testcases/t/135-floating-focus.t @@ -49,8 +49,7 @@ cmd 'floating enable'; # now kill the third one (it's floating). focus should stay unchanged cmd '[id="' . $third->id . '"] kill'; -# TODO: wait for unmapnotify -sync_with_i3($x); +wait_for_unmap($x); is($x->input_focus, $second->id, 'second con still focused after killing third'); @@ -81,15 +80,12 @@ cmd 'floating enable'; # now kill the second one. focus should fall back to the third one, which is # also floating cmd 'kill'; - -# TODO: wait for unmapnotify -sync_with_i3($x); +wait_for_unmap($x); is($x->input_focus, $third->id, 'third con focused'); cmd 'kill'; -# TODO: wait for unmapnotify -sync_with_i3($x); +wait_for_unmap($x); is($x->input_focus, $first->id, 'first con focused after killing all floating cons'); @@ -122,15 +118,12 @@ sync_with_i3($x); # now kill the second one. focus should fall back to the third one, which is # also floating cmd 'kill'; - -# TODO: wait for unmapnotify -sync_with_i3($x); +wait_for_unmap($x); is($x->input_focus, $third->id, 'third con focused'); cmd 'kill'; -# TODO: wait for unmapnotify -sync_with_i3($x); +wait_for_unmap($x); is($x->input_focus, $first->id, 'first con focused after killing all floating cons'); diff --git a/testcases/t/144-regress-floating-resize.t b/testcases/t/144-regress-floating-resize.t index de33eeb3..44a67bc3 100644 --- a/testcases/t/144-regress-floating-resize.t +++ b/testcases/t/144-regress-floating-resize.t @@ -8,13 +8,17 @@ # use i3test; use List::Util qw(sum); +use X11::XCB::Connection; + +my $x = X11::XCB::Connection->new; my $tmp = fresh_workspace; cmd 'exec /usr/bin/urxvt'; -sleep 0.5; +wait_for_map $x; cmd 'exec /usr/bin/urxvt'; -sleep 0.5; +wait_for_map $x; + my ($nodes, $focus) = get_ws_content($tmp); my $old_sum = sum map { $_->{rect}->{width} } @{$nodes}; #cmd 'open'; @@ -22,12 +26,13 @@ cmd 'resize grow left 10 px or 25 ppt'; cmd 'split v'; #cmd 'open'; cmd 'exec /usr/bin/urxvt'; -sleep 0.5; +wait_for_map $x; + cmd 'mode toggle'; -sleep 0.5; -cmd 'kill'; +sync_with_i3 $x; -sleep 0.5; +cmd 'kill'; +wait_for_unmap $x; ($nodes, $focus) = get_ws_content($tmp); my $new_sum = sum map { $_->{rect}->{width} } @{$nodes}; diff --git a/testcases/t/165-for_window.t b/testcases/t/165-for_window.t index cc100132..6e921cef 100644 --- a/testcases/t/165-for_window.t +++ b/testcases/t/165-for_window.t @@ -237,6 +237,9 @@ cmd 'kill'; wait_for_unmap $x; $window->destroy; +# give i3 a chance to delete the window from its tree +sync_with_i3 $x; + @content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 0, 'no nodes on this workspace now'); diff --git a/testcases/t/170-force_focus_wrapping.t b/testcases/t/170-force_focus_wrapping.t index 8a990f23..48869c10 100644 --- a/testcases/t/170-force_focus_wrapping.t +++ b/testcases/t/170-force_focus_wrapping.t @@ -5,10 +5,20 @@ # Tests if the 'force_focus_wrapping' config directive works correctly. # use i3test; -use X11::XCB qw(:all); -use X11::XCB::Connection; -my $x = X11::XCB::Connection->new; +{ + package i3test::X11; + use parent 'X11::XCB::Connection'; + + sub input_focus { + my $self = shift; + i3test::sync_with_i3($self); + + return $self->SUPER::input_focus(@_); + } +} + +my $x = i3test::X11->new; ##################################################################### # 1: test the wrapping behaviour without force_focus_wrapping