From c2229b905a5ea2c7ce855ae833d348a485e89a1c Mon Sep 17 00:00:00 2001 From: Maik Fischer Date: Wed, 23 Nov 2011 12:57:13 +0100 Subject: [PATCH] testcases: replace sleep with sync_with_i3 where appropiate --- testcases/t/001-tile.t | 2 +- testcases/t/127-regress-floating-parent.t | 5 ++--- testcases/t/129-focus-after-close.t | 8 +++----- testcases/t/147-regress-floatingmove.t | 19 ++++++++++--------- testcases/t/148-regress-floatingmovews.t | 6 ++---- testcases/t/168-regress-fullscreen-restart.t | 4 ++-- 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/testcases/t/001-tile.t b/testcases/t/001-tile.t index 460cbd90..65af8d74 100644 --- a/testcases/t/001-tile.t +++ b/testcases/t/001-tile.t @@ -18,7 +18,7 @@ is_deeply($window->rect, $original_rect, "rect unmodified before mapping"); $window->map; -sleep(0.25); +sleep(0.5); my $new_rect = $window->rect; ok(!eq_hash($new_rect, $original_rect), "Window got repositioned"); diff --git a/testcases/t/127-regress-floating-parent.t b/testcases/t/127-regress-floating-parent.t index 52b8b9c0..c83c0809 100644 --- a/testcases/t/127-regress-floating-parent.t +++ b/testcases/t/127-regress-floating-parent.t @@ -16,8 +16,7 @@ cmd 'open'; my $floating = get_focused($tmp); diag("focused floating: " . get_focused($tmp)); cmd 'mode toggle'; -# TODO: eliminate this race conditition -sleep 1; +sync_with_i3; # kill old container cmd qq|[con_id="$old"] focus|; @@ -33,7 +32,7 @@ cmd 'kill'; cmd qq|[con_id="$floating"] focus|; is(get_focused($tmp), $floating, 'floating window focused'); -sleep 1; +sync_with_i3; cmd 'mode toggle'; does_i3_live; diff --git a/testcases/t/129-focus-after-close.t b/testcases/t/129-focus-after-close.t index 3913f4c6..5fc3786e 100644 --- a/testcases/t/129-focus-after-close.t +++ b/testcases/t/129-focus-after-close.t @@ -42,9 +42,8 @@ isnt(get_focused($tmp), $second, 'different container focused'); ############################################################## cmd 'kill'; -# TODO: this testcase sometimes has different outcomes when the -# sleep is missing. why? -sleep 0.25; +sync_with_i3; + ($nodes, $focus) = get_ws_content($tmp); is($nodes->[1]->{nodes}->[0]->{id}, $second, 'second container found'); ok($nodes->[1]->{nodes}->[0]->{focused}, 'second container focused'); @@ -103,8 +102,7 @@ my $win = open_window({ background_color => '#00ff00' }); cmd qq|[con_id="$middle"] focus|; $win->destroy; - -sleep 0.25; +sync_with_i3; is(get_focused($tmp), $middle, 'middle container focused'); diff --git a/testcases/t/147-regress-floatingmove.t b/testcases/t/147-regress-floatingmove.t index ed85b57b..5a2c87d3 100644 --- a/testcases/t/147-regress-floatingmove.t +++ b/testcases/t/147-regress-floatingmove.t @@ -6,6 +6,11 @@ # use i3test; +sub sync_cmd { + cmd @_; + sync_with_i3; +} + my $tmp = fresh_workspace; my $left = open_window; @@ -13,23 +18,19 @@ my $mid = open_window; my $right = open_window; # go to workspace level -cmd 'level up'; -sleep 0.25; +sync_cmd 'level up'; # make it floating -cmd 'mode toggle'; -sleep 0.25; +sync_cmd 'mode toggle'; # move the con outside the floating con -cmd 'move up'; -sleep 0.25; +sync_cmd 'move up'; does_i3_live; # move another con outside -cmd '[id="' . $mid->id . '"] focus'; -cmd 'move up'; -sleep 0.25; +sync_cmd '[id="' . $mid->id . '"] focus'; +sync_cmd 'move up'; does_i3_live; diff --git a/testcases/t/148-regress-floatingmovews.t b/testcases/t/148-regress-floatingmovews.t index 44d5a445..3d71b500 100644 --- a/testcases/t/148-regress-floatingmovews.t +++ b/testcases/t/148-regress-floatingmovews.t @@ -10,20 +10,18 @@ my $tmp = fresh_workspace; # open a tiling window on the first workspace open_window; -#sleep 0.25; my $first = get_focused($tmp); # on a different ws, open a floating window my $otmp = fresh_workspace; open_window; -#sleep 0.25; my $float = get_focused($otmp); cmd 'mode toggle'; -#sleep 0.25; +sync_with_i3; # move the floating con to first workspace cmd "move workspace $tmp"; -#sleep 0.25; +sync_with_i3; # switch to the first ws and check focus is(get_focused($tmp), $float, 'floating client correctly focused'); diff --git a/testcases/t/168-regress-fullscreen-restart.t b/testcases/t/168-regress-fullscreen-restart.t index 74d284db..27812565 100644 --- a/testcases/t/168-regress-fullscreen-restart.t +++ b/testcases/t/168-regress-fullscreen-restart.t @@ -11,10 +11,10 @@ open_window; open_window; cmd 'layout stacking'; -sleep 1; +sync_with_i3; cmd 'fullscreen'; -sleep 1; +sync_with_i3; cmd 'restart'; sleep 1;