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

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

Waiting for Launcher activity to stop when starting a Launchable

This will help to ensure that Launcher state has settled before continuing the test.

Bug: 313926097
Flag: N/A
Test: presubmit
Change-Id: I8bed0225617a225c2dc9587a75d004b98395fe1f
parent dacb0765
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ import static com.android.launcher3.popup.SystemShortcut.INSTALL;
import static com.android.launcher3.popup.SystemShortcut.WIDGETS;
import static com.android.launcher3.states.RotationHelper.REQUEST_LOCK;
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
import static com.android.launcher3.testing.shared.TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.ItemInfoMatcher.forFolderMatch;
import static com.android.launcher3.util.SettingsCache.TOUCHPAD_NATURAL_SCROLLING;
@@ -1034,6 +1035,8 @@ public class Launcher extends StatefulActivity<LauncherState>
        mAppWidgetHolder.setActivityStarted(false);
        NotificationListener.removeNotificationsChangedListener(getPopupDataProvider());
        FloatingIconView.resetIconLoadResult();
        AccessibilityManagerCompat.sendTestProtocolEventToTest(
                this, LAUNCHER_ACTIVITY_STOPPED_MESSAGE);
    }

    @Override
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ public final class TestProtocol {
    public static final String DISMISS_ANIMATION_ENDS_MESSAGE = "TAPL_DISMISS_ANIMATION_ENDS";
    public static final String FOLDER_OPENED_MESSAGE = "TAPL_FOLDER_OPENED";
    public static final String SEARCH_RESULT_COMPLETE = "SEARCH_RESULT_COMPLETE";
    public static final String LAUNCHER_ACTIVITY_STOPPED_MESSAGE = "TAPL_LAUNCHER_ACTIVITY_STOPPED";
    public static final int NORMAL_STATE_ORDINAL = 0;
    public static final int SPRING_LOADED_STATE_ORDINAL = 1;
    public static final int OVERVIEW_STATE_ORDINAL = 2;
+15 −1
Original line number Diff line number Diff line
@@ -47,8 +47,14 @@ public abstract class Launchable {
        return mObject;
    }

    protected boolean launcherStopsAfterLaunch() {
        return true;
    }

    /**
     * Clicks the object to launch its app.
     * We are assuming non-translucent app launches because only such launches generate
     * LAUNCHER_ACTIVITY_STOPPED_MESSAGE.
     */
    public LaunchedAppState launch(String expectedPackageName) {
        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
@@ -58,7 +64,15 @@ public abstract class Launchable {
                        + mObject.getVisibleCenter() + " in "
                        + mLauncher.getVisibleBounds(mObject));

                if (launcherStopsAfterLaunch()) {
                    mLauncher.executeAndWaitForLauncherEvent(
                            () -> mLauncher.clickLauncherObject(mObject),
                            event -> TestProtocol.LAUNCHER_ACTIVITY_STOPPED_MESSAGE
                                    .equals(event.getClassName().toString()),
                            () -> "Launcher activity didn't stop", "clicking the launchable");
                } else {
                    mLauncher.clickLauncherObject(mObject);
                }

                try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("clicked")) {
                    expectActivityStartEvents();
+5 −0
Original line number Diff line number Diff line
@@ -49,4 +49,9 @@ public final class TaskbarAppIcon extends AppIcon implements SplitscreenDragSour
    public Launchable getLaunchable() {
        return this;
    }

    @Override
    protected boolean launcherStopsAfterLaunch() {
        return false;
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -54,4 +54,9 @@ public final class TaskbarAppIconMenuItem extends AppIconMenuItem implements Spl
    public Launchable getLaunchable() {
        return this;
    }

    @Override
    protected boolean launcherStopsAfterLaunch() {
        return false;
    }
}
Loading