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

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

Merge "Having longer period of waiting for Launcher restart only in Launcher test suites" into main

parents daca6d07 ebf08d8b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public class FallbackRecentsTest {
        Context context = instrumentation.getContext();
        mDevice = UiDevice.getInstance(instrumentation);
        mDevice.setOrientationNatural();
        mLauncher = new LauncherInstrumentation();
        mLauncher = AbstractLauncherUiTest.createLauncherInstrumentation();
        mLauncher.enableDebugTracing();
        // b/143488140
        //mLauncher.enableCheckEventsForSuccessfulGestures();
+2 −2
Original line number Diff line number Diff line
@@ -114,9 +114,9 @@ public abstract class AbstractLauncherUiTest {
    protected final LauncherInstrumentation mLauncher = createLauncherInstrumentation();

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

    protected Context mTargetContext;
+25 −4
Original line number Diff line number Diff line
@@ -215,15 +215,31 @@ public final class LauncherInstrumentation {
     * Constructs the root of TAPL hierarchy. You get all other objects from it.
     */
    public LauncherInstrumentation() {
        this(InstrumentationRegistry.getInstrumentation());
        this(InstrumentationRegistry.getInstrumentation(), false);
    }

    /**
     * Constructs the root of TAPL hierarchy. You get all other objects from it.
     * Deprecated: use the constructor without parameters instead.
     */
    public LauncherInstrumentation(boolean isLauncherTest) {
        this(InstrumentationRegistry.getInstrumentation(), isLauncherTest);
    }

    /**
     * Constructs the root of TAPL hierarchy. You get all other objects from it.
     * @deprecated use the constructor without Instrumentation parameter instead.
     */
    @Deprecated
    public LauncherInstrumentation(Instrumentation instrumentation) {
        this(instrumentation, false);
    }

    /**
     * Constructs the root of TAPL hierarchy. You get all other objects from it.
     * @deprecated use the constructor without Instrumentation parameter instead.
     */
    @Deprecated
    public LauncherInstrumentation(Instrumentation instrumentation, boolean isLauncherTest) {
        mInstrumentation = instrumentation;
        mDevice = UiDevice.getInstance(instrumentation);

@@ -272,12 +288,17 @@ public final class LauncherInstrumentation {
                            .replaceAll("\\s", "");
                    mDevice.executeShellCommand(
                            "pm enable --user " + userId + " " + cn.flattenToString());

                    // Wait for Launcher restart after enabling test provider.
                    for (int i = 0; i < 100; ++i) {
                    final int iterations = isLauncherTest ? 300 : 100;

                    for (int i = 0; i < iterations; ++i) {
                        final String currentPid = mDevice.executeShellCommand(launcherPidCommand)
                                .replaceAll("\\s", "");
                        if (!currentPid.isEmpty() && !currentPid.equals(initialPid)) break;
                        if (i == 99) fail("Launcher didn't restart after enabling test provider");
                        if (i == iterations - 1) {
                            fail("Launcher didn't restart after enabling test provider");
                        }
                        SystemClock.sleep(100);
                    }
                } catch (IOException e) {