diff --git a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java index 16235e0117..12568ea85d 100644 --- a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java +++ b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java @@ -162,6 +162,7 @@ public class FallbackRecentsTest { @Before public void setUp() { mLauncher.onTestStart(); + AbstractLauncherUiTest.waitForSetupWizardDismissal(); AbstractLauncherUiTest.verifyKeyguardInvisible(); } diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index ed846edc28..ed3a76bba4 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -187,7 +187,7 @@ public abstract class AbstractLauncherUiTest { Utilities.enableRunningInTestHarnessForTests(); mLauncher.setSystemHealthSupplier(startTime -> TestCommandReceiver.callCommand( TestCommandReceiver.GET_SYSTEM_HEALTH_MESSAGE, startTime.toString()) - .getString("result")); + .getString("result")); mLauncher.setOnSettledStateAction( containerType -> executeOnLauncher( launcher -> @@ -248,6 +248,7 @@ public abstract class AbstractLauncherUiTest { public void setUp() throws Exception { mLauncher.onTestStart(); + waitForSetupWizardDismissal(); if (TestStabilityRule.isPresubmit()) { aggressivelyUnlockSysUi(); } else { @@ -308,6 +309,32 @@ public abstract class AbstractLauncherUiTest { Log.d(TAG, "Keyguard is not visible"); } + // b/309008042 + private static boolean sFirstTimeWaitingForWizard = true; + + static { + waitForSetupWizardDismissal(); + } + + /** Waits for setup wizard to go away. */ + public static void waitForSetupWizardDismissal() { + if (sFirstTimeWaitingForWizard && TestStabilityRule.isPresubmit()) { + try { + UiDevice.getInstance(getInstrumentation()).executeShellCommand( + "am force-stop com.google.android.setupwizard"); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + final boolean wizardDismissed = TestHelpers.wait( + Until.gone(By.pkg("com.google.android.setupwizard").depth(0)), + sFirstTimeWaitingForWizard ? 120000 : 0); + sFirstTimeWaitingForWizard = false; + Assert.assertTrue("Setup wizard is still visible", + wizardDismissed); + } + public static void verifyKeyguardInvisible() { final boolean keyguardAlreadyVisible = sSeenKeyguard; @@ -422,6 +449,7 @@ public abstract class AbstractLauncherUiTest { // flakiness. protected void waitForLauncherCondition( String message, Function condition, long timeout) { + waitForSetupWizardDismissal(); verifyKeyguardInvisible(); if (!TestHelpers.isInLauncherProcess()) return; Wait.atMost(message, () -> getFromLauncher(condition), timeout, mLauncher);