From f3fbc935cdb4b56425d800d244ff674a5c871057 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 3 Nov 2021 11:42:01 -0700 Subject: [PATCH] Testing to see if using isInStableState is better condition vs getCurrentStableState Test: presubmit Bug: 202735477 Change-Id: I06c964cc92b7731e73628210688817e2d9cf1bac --- .../android/launcher3/ui/AbstractLauncherUiTest.java | 10 ++++++++-- .../src/com/android/launcher3/ui/WorkProfileTest.java | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 0ffbeeb95e..68df544728 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -345,13 +345,19 @@ public abstract class AbstractLauncherUiTest { } // Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call - // expecting - // the results of that gesture because the wait can hide flakeness. + // expecting the results of that gesture because the wait can hide flakeness. protected void waitForState(String message, Supplier state) { waitForLauncherCondition(message, launcher -> launcher.getStateManager().getCurrentStableState() == state.get()); } + // Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call + // expecting the results of that gesture because the wait can hide flakeness. + protected void waitForStableState(String message, Supplier state) { + waitForLauncherCondition(message, + launcher -> launcher.getStateManager().isInStableState(state.get())); + } + protected void waitForResumed(String message) { waitForLauncherCondition(message, launcher -> launcher.hasBeenResumed()); } diff --git a/tests/src/com/android/launcher3/ui/WorkProfileTest.java b/tests/src/com/android/launcher3/ui/WorkProfileTest.java index 27a23757d6..2087bfe8c6 100644 --- a/tests/src/com/android/launcher3/ui/WorkProfileTest.java +++ b/tests/src/com/android/launcher3/ui/WorkProfileTest.java @@ -91,9 +91,9 @@ public class WorkProfileTest extends AbstractLauncherUiTest { public void workTabExists() { mDevice.pressHome(); waitForLauncherCondition("Launcher didn't start", Objects::nonNull); - waitForState("Launcher internal state didn't switch to Normal", () -> NORMAL); + waitForStableState("Launcher internal state didn't switch to Normal", () -> NORMAL); executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS)); - waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS); + waitForStableState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS); waitForLauncherCondition("Personal tab is missing", launcher -> launcher.getAppsView().isPersonalTabVisible(), LauncherInstrumentation.WAIT_TIME_MS);