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

Commit 47d66ad8 authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

Support for running tests out of Launcher process

This CL doesn't turn it on yet.

Bug: 113056917
Test: TaplTests
Change-Id: I01007cb9ab330166cbb8a4c1fcd0cee0c60aeba5
parent 19e0e8ab
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -82,12 +82,17 @@ public abstract class AbstractLauncherUiTest {
    protected final LauncherInstrumentation mLauncher;
    protected Context mTargetContext;
    protected String mTargetPackage;
    protected final boolean mIsInLauncherProcess;

    private static final String TAG = "AbstractLauncherUiTest";

    protected AbstractLauncherUiTest() {
        mDevice = UiDevice.getInstance(getInstrumentation());
        mLauncher = new LauncherInstrumentation(getInstrumentation());
        final Instrumentation instrumentation = getInstrumentation();
        mDevice = UiDevice.getInstance(instrumentation);
        mLauncher = new LauncherInstrumentation(instrumentation);

        mIsInLauncherProcess = instrumentation.getTargetContext().getPackageName().equals(
                mDevice.getLauncherPackageName());
    }

    @Rule
@@ -261,6 +266,7 @@ public abstract class AbstractLauncherUiTest {
    }

    protected <T> T getFromLauncher(Function<Launcher, T> f) {
        if (!mIsInLauncherProcess) return null;
        return getOnUiThread(() -> f.apply(mActivityMonitor.getActivity()));
    }

@@ -287,6 +293,7 @@ public abstract class AbstractLauncherUiTest {
    // flakiness.
    protected boolean waitForLauncherCondition(
            Function<Launcher, Boolean> condition, long timeout) {
        if (!mIsInLauncherProcess) return true;
        return Wait.atMost(() -> getFromLauncher(condition), timeout);
    }