From d2c4d9322e5105088b98e88b51f048a0bd01006d Mon Sep 17 00:00:00 2001 From: Toshiki Kikuchi Date: Fri, 2 May 2025 20:48:59 +0900 Subject: [PATCH] Specify display ID for taskbar availability checks This CL adds a display ID to the query to check the availability of taskbar. On an external display, we always show the taskbar regardless of the launcher state, so the existing checks don't make sense on the external display. Flag: EXEMPT - test fix Fix: 408631713 Fix: 414092022 Test: atest WMShellFlickerTestsDesktopMode:com.android.wm.shell.flicker.OpenAppWithExternalDisplayConnected Change-Id: I0281a3cffd182e57ecf56e8fb5e4d28d6a4384c3 --- .../tapl/LauncherInstrumentation.java | 91 ++++++++++++++----- 1 file changed, 67 insertions(+), 24 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 714827bd5d..f2d23a4d47 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -956,9 +956,9 @@ public final class LauncherInstrumentation { waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID); if (isTaskbarShownOnHome()) { - waitForSystemLauncherObject(TASKBAR_RES_ID); + waitForSystemLauncherObject(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } else { - waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } return waitForLauncherObject(WORKSPACE_RES_ID); @@ -978,7 +978,7 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(WIDGETS_RES_ID); waitUntilSystemLauncherObjectGone(OVERVIEW_RES_ID); if (isTransientTaskbar()) { - waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID); @@ -993,9 +993,9 @@ public final class LauncherInstrumentation { if ((is3PLauncher() && isTablet() && !isTransientTaskbar()) || isTaskbarShownOnHome()) { - waitForSystemLauncherObject(TASKBAR_RES_ID); + waitForSystemLauncherObject(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } else { - waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } boolean splitSelectionActive = getTestInfo(REQUEST_GET_SPLIT_SELECTION_ACTIVE) @@ -1012,9 +1012,9 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(WORKSPACE_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); if (isTablet() && !is3PLauncher()) { - waitForSystemLauncherObject(TASKBAR_RES_ID); + waitForSystemLauncherObject(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } else { - waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID); @@ -1026,9 +1026,9 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(WORKSPACE_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); if (isTablet()) { - waitForSystemLauncherObject(TASKBAR_RES_ID); + waitForSystemLauncherObject(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } else { - waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } waitForSystemLauncherObject(SPLIT_PLACEHOLDER_RES_ID); @@ -1051,10 +1051,10 @@ public final class LauncherInstrumentation { // Only check that Persistent Taskbar is visible, since Transient Taskbar // may or may not be visible by design. if (!isTransientTaskbar()) { - waitForSystemLauncherObject(TASKBAR_RES_ID); + waitForSystemLauncherObject(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } } else { - waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID, taskbarPrimaryDisplayId); } return null; } @@ -1421,20 +1421,32 @@ public final class LauncherInstrumentation { return new LaunchedAppState(this); } + void waitUntilLauncherObjectGone(String resId, @Nullable Integer displayId) { + waitUntilGoneBySelector(getLauncherObjectSelector(resId, displayId)); + } + void waitUntilLauncherObjectGone(String resId) { - waitUntilGoneBySelector(getLauncherObjectSelector(resId)); + waitUntilLauncherObjectGone(resId, /* displayId= */ null); + } + + void waitUntilOverviewObjectGone(String resId, @Nullable Integer displayId) { + waitUntilGoneBySelector(getOverviewObjectSelector(resId, displayId)); } void waitUntilOverviewObjectGone(String resId) { - waitUntilGoneBySelector(getOverviewObjectSelector(resId)); + waitUntilOverviewObjectGone(resId, /* displayId= */ null); + } + + void waitUntilSystemLauncherObjectGone(String resId, @Nullable Integer displayId) { + if (is3PLauncher()) { + waitUntilOverviewObjectGone(resId, displayId); + } else { + waitUntilLauncherObjectGone(resId, displayId); + } } void waitUntilSystemLauncherObjectGone(String resId) { - if (is3PLauncher()) { - waitUntilOverviewObjectGone(resId); - } else { - waitUntilLauncherObjectGone(resId); - } + waitUntilSystemLauncherObjectGone(resId, /* displayId= */ null); } void waitUntilLauncherObjectGone(BySelector selector) { @@ -1618,20 +1630,35 @@ public final class LauncherInstrumentation { return By.copy(selector).pkg(getLauncherPackageName()); } + @NonNull + UiObject2 waitForOverviewObject(String resName, @Nullable Integer displayId) { + return waitForObjectBySelector(getOverviewObjectSelector(resName, displayId)); + } + @NonNull UiObject2 waitForOverviewObject(String resName) { - return waitForObjectBySelector(getOverviewObjectSelector(resName)); + return waitForOverviewObject(resName, /* displayId= */ null); + } + + @NonNull + UiObject2 waitForLauncherObject(String resName, @Nullable Integer displayId) { + return waitForObjectBySelector(getLauncherObjectSelector(resName, displayId)); } @NonNull UiObject2 waitForLauncherObject(String resName) { - return waitForObjectBySelector(getLauncherObjectSelector(resName)); + return waitForLauncherObject(resName, /* displayId= */ null); + } + + @NonNull + UiObject2 waitForSystemLauncherObject(String resName, @Nullable Integer displayId) { + return is3PLauncher() ? waitForOverviewObject(resName, displayId) + : waitForLauncherObject(resName, displayId); } @NonNull UiObject2 waitForSystemLauncherObject(String resName) { - return is3PLauncher() ? waitForOverviewObject(resName) - : waitForLauncherObject(resName); + return waitForSystemLauncherObject(resName, /* displayId= */null); } @NonNull @@ -1670,11 +1697,27 @@ public final class LauncherInstrumentation { } BySelector getLauncherObjectSelector(String resName) { - return By.res(getLauncherPackageName(), resName); + return getLauncherObjectSelector(resName, /* displayId= */ null); + } + + BySelector getLauncherObjectSelector(String resName, @Nullable Integer displayId) { + final BySelector selector = By.res(getLauncherPackageName(), resName); + if (displayId != null) { + selector.displayId(displayId); + } + return selector; } BySelector getOverviewObjectSelector(String resName) { - return By.res(getOverviewPackageName(), resName); + return getOverviewObjectSelector(resName, /* displayId= */ null); + } + + BySelector getOverviewObjectSelector(String resName, @Nullable Integer displayId) { + final BySelector selector = By.res(getOverviewPackageName(), resName); + if (displayId != null) { + selector.displayId(displayId); + } + return selector; } String getLauncherPackageName() {