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

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

Merge "Make sure TAPL waits for Launcher activity to stop each time it stops" into main

parents 379b5b04 dd33b64a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -411,6 +411,8 @@ public class Launcher extends StatefulActivity<LauncherState>
    private final SettingsCache.OnChangeListener mNaturalScrollingChangedListener =
            enabled -> mIsNaturalScrollingEnabled = enabled;

    private int mActivityStopCount; // Used only by tests

    public static Launcher getLauncher(Context context) {
        return fromContext(context);
    }
@@ -1052,10 +1054,18 @@ public class Launcher extends StatefulActivity<LauncherState>
        mAppWidgetHolder.setActivityStarted(false);
        NotificationListener.removeNotificationsChangedListener(getPopupDataProvider());
        FloatingIconView.resetIconLoadResult();
        ++mActivityStopCount;
        AccessibilityManagerCompat.sendTestProtocolEventToTest(
                this, LAUNCHER_ACTIVITY_STOPPED_MESSAGE);
    }

    /** Return activity stop count and reset it. Used only by tests. */
    public int getAndResetActivityStopCount() {
        final int activityStopCount = mActivityStopCount;
        mActivityStopCount = 0;
        return activityStopCount;
    }

    @Override
    protected void onStart() {
        TraceHelper.INSTANCE.beginSection(ON_START_EVT);
+10 −0
Original line number Diff line number Diff line
@@ -214,6 +214,16 @@ public class TestInformationHandler implements ResourceBasedOverride {
                                .forceAllowRotationForTesting(Boolean.parseBoolean(arg)));
                return response;

            case TestProtocol.REQUEST_GET_AND_RESET_ACTIVITY_STOP_COUNT: {
                final Bundle bundle = getLauncherUIProperty(Bundle::putInt,
                        launcher -> launcher.getAndResetActivityStopCount());
                if (bundle != null) return bundle;

                // If Launcher activity wasn't created, 'it' was stopped 0 times.
                response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, 0);
                return response;
            }

            case TestProtocol.REQUEST_WORKSPACE_CELL_LAYOUT_SIZE:
                return getLauncherUIProperty(Bundle::putIntArray, launcher -> {
                    final Workspace<?> workspace = launcher.getWorkspace();
+3 −0
Original line number Diff line number Diff line
@@ -178,6 +178,9 @@ public final class TestProtocol {
    public static final String REQUEST_UNSTASH_BUBBLE_BAR_IF_STASHED =
            "unstash-bubble-bar-if-stashed";

    public static final String REQUEST_GET_AND_RESET_ACTIVITY_STOP_COUNT =
            "get-and-reset-activity-stops";

    /** Logs {@link Log#d(String, String)} if {@link #sDebugTracing} is true. */
    public static void testLogD(String tag, String message) {
        if (!sDebugTracing) {
+3 −0
Original line number Diff line number Diff line
@@ -599,6 +599,9 @@ public abstract class AbstractLauncherUiTest {
        Wait.atMost("Launcher activity didn't stop",
                () -> !launcherInstrumentation.isLauncherActivityStarted(),
                DEFAULT_ACTIVITY_TIMEOUT, launcherInstrumentation);

        // Reset activity stop count.
        launcherInstrumentation.getAndResetActivityStopCount();
    }

    public static ActivityInfo resolveSystemAppInfo(String category) {
+5 −1
Original line number Diff line number Diff line
@@ -44,11 +44,15 @@ public class TestIsolationRule implements TestRule {
        return new Statement() {
            @Override
            public void evaluate() throws Throwable {
                // Reset activity stop count.
                mLauncher.getAndResetActivityStopCount();

                base.evaluate();
                // Make sure that Launcher workspace looks correct.

                // Make sure that Launcher workspace looks correct.
                UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).pressHome();
                AbstractLauncherUiTest.checkDetectedLeaks(mLauncher, mRequireOneActiveActivity);
                mLauncher.assertNoUnexpectedStops();
            }
        };
    }
Loading