Merge "Waiting for Launcher to stop after quick-starting test apps" into main

This commit is contained in:
Vadim Tryshev
2023-12-01 18:47:33 +00:00
committed by Android (Google) Code Review
4 changed files with 23 additions and 0 deletions

View File

@@ -104,6 +104,15 @@ public class TestInformationHandler implements ResourceBasedOverride {
return getUIProperty(Bundle::putBoolean, t -> isLauncherInitialized(), () -> true);
}
case TestProtocol.REQUEST_IS_LAUNCHER_LAUNCHER_ACTIVITY_STARTED: {
final Bundle bundle = getLauncherUIProperty(Bundle::putBoolean, l -> l.isStarted());
if (bundle != null) return bundle;
// If Launcher activity wasn't created, it's not started.
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, false);
return response;
}
case TestProtocol.REQUEST_FREEZE_APP_LIST:
return getLauncherUIProperty(Bundle::putBoolean, l -> {
l.getAppsView().getAppsStore().enableDeferUpdates(DEFER_UPDATES_TEST);

View File

@@ -86,6 +86,8 @@ public final class TestProtocol {
public static final String REQUEST_ICON_HEIGHT =
"icon-height";
public static final String REQUEST_IS_LAUNCHER_INITIALIZED = "is-launcher-initialized";
public static final String REQUEST_IS_LAUNCHER_LAUNCHER_ACTIVITY_STARTED =
"is-launcher-activity-started";
public static final String REQUEST_FREEZE_APP_LIST = "freeze-app-list";
public static final String REQUEST_UNFREEZE_APP_LIST = "unfreeze-app-list";
public static final String REQUEST_ENABLE_MANUAL_TASKBAR_STASHING = "enable-taskbar-stashing";

View File

@@ -590,6 +590,12 @@ public abstract class AbstractLauncherUiTest {
getInstrumentation().getTargetContext().startActivity(intent);
assertTrue("App didn't start: " + selector,
TestHelpers.wait(Until.hasObject(selector), DEFAULT_UI_TIMEOUT));
// Wait for the Launcher to stop.
final LauncherInstrumentation launcherInstrumentation = new LauncherInstrumentation();
Wait.atMost("Launcher activity didn't stop",
() -> !launcherInstrumentation.isLauncherActivityStarted(),
DEFAULT_ACTIVITY_TIMEOUT, launcherInstrumentation);
}
public static ActivityInfo resolveSystemAppInfo(String category) {

View File

@@ -944,6 +944,12 @@ public final class LauncherInstrumentation {
fail("Launcher didn't initialize");
}
public boolean isLauncherActivityStarted() {
return getTestInfo(
TestProtocol.REQUEST_IS_LAUNCHER_LAUNCHER_ACTIVITY_STARTED).
getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
Parcelable executeAndWaitForLauncherEvent(Runnable command,
UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message,
String actionName) {