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

Commit 1f8ff662 authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

Making killing setup wizard a permanent solution

It will be killed only in presubmit. In postsubmit, we want to be a true
e2e test exposed to all actual problems, including setup wizard that
doesn't go away.

Bug: 309471958
Test: presubmit
Flag: N/A
Change-Id: I2e877eade060e75e277eb3603d90b659207b5a47
parent d66d1149
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -162,7 +162,6 @@ public class FallbackRecentsTest {
    @Before
    @Before
    public void setUp() {
    public void setUp() {
        mLauncher.onTestStart();
        mLauncher.onTestStart();
        AbstractLauncherUiTest.waitForSetupWizardDismissal();
        AbstractLauncherUiTest.onTestStart();
        AbstractLauncherUiTest.onTestStart();
    }
    }


+12 −15
Original line number Original line Diff line number Diff line
@@ -105,12 +105,20 @@ public abstract class AbstractLauncherUiTest {
    private static boolean sDumpWasGenerated = false;
    private static boolean sDumpWasGenerated = false;
    private static boolean sActivityLeakReported = false;
    private static boolean sActivityLeakReported = false;
    private static boolean sSeenKeyguard = false;
    private static boolean sSeenKeyguard = false;
    private static boolean sFirstTimeWaitingForWizard = true;


    private static final String SYSTEMUI_PACKAGE = "com.android.systemui";
    private static final String SYSTEMUI_PACKAGE = "com.android.systemui";


    protected LooperExecutor mMainThreadExecutor = MAIN_EXECUTOR;
    protected LooperExecutor mMainThreadExecutor = MAIN_EXECUTOR;
    protected final UiDevice mDevice = getUiDevice();
    protected final UiDevice mDevice = getUiDevice();
    protected final LauncherInstrumentation mLauncher = new LauncherInstrumentation();
    protected final LauncherInstrumentation mLauncher = createLauncherInstrumentation();

    @NonNull
    private static LauncherInstrumentation createLauncherInstrumentation() {
        waitForSetupWizardDismissal(); // precondition for creating LauncherInstrumentation
        return new LauncherInstrumentation();
    }

    protected Context mTargetContext;
    protected Context mTargetContext;
    protected String mTargetPackage;
    protected String mTargetPackage;
    private int mLauncherPid;
    private int mLauncherPid;
@@ -249,8 +257,6 @@ public abstract class AbstractLauncherUiTest {
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        mLauncher.onTestStart();
        mLauncher.onTestStart();


        waitForSetupWizardDismissal();

        final String launcherPackageName = mDevice.getLauncherPackageName();
        final String launcherPackageName = mDevice.getLauncherPackageName();
        try {
        try {
            final Context context = InstrumentationRegistry.getContext();
            final Context context = InstrumentationRegistry.getContext();
@@ -286,6 +292,8 @@ public abstract class AbstractLauncherUiTest {


    /** Method that should be called when a test starts. */
    /** Method that should be called when a test starts. */
    public static void onTestStart() {
    public static void onTestStart() {
        waitForSetupWizardDismissal();

        if (TestStabilityRule.isPresubmit()) {
        if (TestStabilityRule.isPresubmit()) {
            aggressivelyUnlockSysUi();
            aggressivelyUnlockSysUi();
        } else {
        } else {
@@ -320,18 +328,8 @@ public abstract class AbstractLauncherUiTest {
        Log.d(TAG, "Keyguard is not visible");
        Log.d(TAG, "Keyguard is not visible");
    }
    }


    // b/309008042
    private static boolean sFirstTimeWaitingForWizard = true;

    // b/309008042
    static {
        waitForSetupWizardDismissal();
    }

    // b/309008042
    // TODO(309471958) Productize killing/dismissal of setup wizard.
    /** Waits for setup wizard to go away. */
    /** Waits for setup wizard to go away. */
    public static void waitForSetupWizardDismissal() {
    private static void waitForSetupWizardDismissal() {
        if (!TestStabilityRule.isPresubmit()) return;
        if (!TestStabilityRule.isPresubmit()) return;


        if (sFirstTimeWaitingForWizard) {
        if (sFirstTimeWaitingForWizard) {
@@ -464,7 +462,6 @@ public abstract class AbstractLauncherUiTest {
    // flakiness.
    // flakiness.
    protected void waitForLauncherCondition(
    protected void waitForLauncherCondition(
            String message, Function<Launcher, Boolean> condition, long timeout) {
            String message, Function<Launcher, Boolean> condition, long timeout) {
        waitForSetupWizardDismissal();
        verifyKeyguardInvisible();
        verifyKeyguardInvisible();
        if (!TestHelpers.isInLauncherProcess()) return;
        if (!TestHelpers.isInLauncherProcess()) return;
        Wait.atMost(message, () -> getFromLauncher(condition), timeout, mLauncher);
        Wait.atMost(message, () -> getFromLauncher(condition), timeout, mLauncher);