mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
mLauncher.clickLauncherObject(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();
|
||||
|
||||
@@ -49,4 +49,9 @@ public final class TaskbarAppIcon extends AppIcon implements SplitscreenDragSour
|
||||
public Launchable getLaunchable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean launcherStopsAfterLaunch() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,4 +54,9 @@ public final class TaskbarAppIconMenuItem extends AppIconMenuItem implements Spl
|
||||
public Launchable getLaunchable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean launcherStopsAfterLaunch() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,4 +42,9 @@ public class TaskbarSearchWebSuggestion extends SearchWebSuggestion implements
|
||||
public Launchable getLaunchable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean launcherStopsAfterLaunch() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user