Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b188122 authored by Vadim Tryshev's avatar Vadim Tryshev Committed by Android (Google) Code Review
Browse files

Merge "Waiting for the setup wizard to go away" into main

parents a0c9db6d 0fe753af
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ public class FallbackRecentsTest {
    @Before
    public void setUp() {
        mLauncher.onTestStart();
        AbstractLauncherUiTest.waitForSetupWizardDismissal();
        AbstractLauncherUiTest.verifyKeyguardInvisible();
    }

+29 −1
Original line number Diff line number Diff line
@@ -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<Launcher, Boolean> condition, long timeout) {
        waitForSetupWizardDismissal();
        verifyKeyguardInvisible();
        if (!TestHelpers.isInLauncherProcess()) return;
        Wait.atMost(message, () -> getFromLauncher(condition), timeout, mLauncher);