From c3d132034372297dd67dbe330059bcadac7b7713 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Sun, 21 Jun 2020 00:40:18 +0200 Subject: [PATCH] tests/stacking: Avoid random failures in focus tests Some tests were not waiting for the test client to actually issue destroy commands before checking their effect on the window focus. Similarly when mutter is supposed to change the focus based on a delay by sending a WM_TAKE_FOCUS to the client, this also could fail without synchronization with the client before checking the result. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1325 --- ...no-input-parent-delayed-focus-default-cancelled.metatest | 4 +++- .../stacking/closed-transient-no-input-parent.metatest | 4 +++- ...no-input-parents-queued-default-focus-destroyed.metatest | 6 ++++-- .../stacking/closed-transient-no-input-parents.metatest | 4 +++- .../closed-transient-only-take-focus-parents.metatest | 2 ++ 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/tests/stacking/closed-transient-no-input-parent-delayed-focus-default-cancelled.metatest b/src/tests/stacking/closed-transient-no-input-parent-delayed-focus-default-cancelled.metatest index 0c7261fa7..75a17e4e5 100644 --- a/src/tests/stacking/closed-transient-no-input-parent-delayed-focus-default-cancelled.metatest +++ b/src/tests/stacking/closed-transient-no-input-parent-delayed-focus-default-cancelled.metatest @@ -20,7 +20,7 @@ assert_focused 1/3 assert_stacking 2/1 1/1 1/2 1/3 destroy 1/3 -dispatch +wait assert_focused none assert_stacking 2/1 1/1 1/2 @@ -32,5 +32,7 @@ assert_focused 2/1 assert_stacking 1/1 1/2 2/1 sleep 250 +wait + assert_focused 2/1 assert_stacking 1/1 1/2 2/1 diff --git a/src/tests/stacking/closed-transient-no-input-parent.metatest b/src/tests/stacking/closed-transient-no-input-parent.metatest index d0f3228d5..1fe00d7bf 100644 --- a/src/tests/stacking/closed-transient-no-input-parent.metatest +++ b/src/tests/stacking/closed-transient-no-input-parent.metatest @@ -20,11 +20,13 @@ assert_focused 1/3 assert_stacking 2/1 1/1 1/2 1/3 destroy 1/3 -dispatch +wait assert_focused none assert_stacking 2/1 1/1 1/2 sleep 150 +wait + assert_focused 1/1 assert_stacking 2/1 1/1 1/2 diff --git a/src/tests/stacking/closed-transient-no-input-parents-queued-default-focus-destroyed.metatest b/src/tests/stacking/closed-transient-no-input-parents-queued-default-focus-destroyed.metatest index 49ecc510f..213177133 100644 --- a/src/tests/stacking/closed-transient-no-input-parents-queued-default-focus-destroyed.metatest +++ b/src/tests/stacking/closed-transient-no-input-parents-queued-default-focus-destroyed.metatest @@ -30,14 +30,16 @@ assert_focused 1/5 assert_stacking 0/1 1/1 1/2 1/3 1/4 1/5 destroy 1/5 -dispatch +wait assert_focused none assert_stacking 0/1 1/1 1/2 1/3 1/4 destroy 1/2 -dispatch +wait sleep 450 +wait + assert_focused 1/1 assert_stacking 0/1 1/1 1/3 1/4 diff --git a/src/tests/stacking/closed-transient-no-input-parents.metatest b/src/tests/stacking/closed-transient-no-input-parents.metatest index ee9984192..dcba70eba 100644 --- a/src/tests/stacking/closed-transient-no-input-parents.metatest +++ b/src/tests/stacking/closed-transient-no-input-parents.metatest @@ -30,12 +30,14 @@ assert_focused 1/5 assert_stacking 0/1 1/1 1/2 1/3 1/4 1/5 destroy 1/5 -dispatch +wait assert_focused none assert_stacking 0/1 1/1 1/2 1/3 1/4 sleep 600 +wait + assert_focused 1/1 assert_stacking 0/1 1/1 1/2 1/3 1/4 diff --git a/src/tests/stacking/closed-transient-only-take-focus-parents.metatest b/src/tests/stacking/closed-transient-only-take-focus-parents.metatest index 8aa86700f..88bf7865c 100644 --- a/src/tests/stacking/closed-transient-only-take-focus-parents.metatest +++ b/src/tests/stacking/closed-transient-only-take-focus-parents.metatest @@ -30,5 +30,7 @@ assert_focused 1/2 assert_stacking 0/1 1/1 1/2 sleep 150 +wait + assert_focused 1/2 assert_stacking 0/1 1/1 1/2