From aa92126aa8bd7771b866f7414178c5e8ef2a1ecc Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Mon, 30 Aug 2021 12:26:09 -0700 Subject: [PATCH] Ensure dismiss button within closePipWindow This is to comply with ag/15351291 that the dismiss button is only available after the tap-to-reveal PiP menu animation is completed. Bug: 176822698 Test: atest WMShellFlickerTests:ExitPipWithDismissButtonTest Change-Id: Iae0eae56b0fb358e3d39454de59c8ba64e65ee7b --- .../com/android/wm/shell/flicker/helpers/PipAppHelper.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt index 1529f5bcd7e1a..7a17bb3c31074 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt @@ -129,7 +129,7 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper( } /** - * Expands the pip window and dismisses it by clicking on the X button. + * Taps the pip window and dismisses it by clicking on the X button. */ fun closePipWindow(wmHelper: WindowManagerStateHelper) { if (isTelevision) { @@ -137,9 +137,12 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper( } else { val windowRect = getWindowRect(wmHelper) uiDevice.click(windowRect.centerX(), windowRect.centerY()) - val exitPipObject = uiDevice.findObject(By.res(SYSTEMUI_PACKAGE, "dismiss")) + // search and interact with the dismiss button + val dismissSelector = By.res(SYSTEMUI_PACKAGE, "dismiss") + uiDevice.wait(Until.hasObject(dismissSelector), FIND_TIMEOUT) + val dismissPipObject = uiDevice.findObject(dismissSelector) ?: error("PIP window dismiss button not found") - val dismissButtonBounds = exitPipObject.visibleBounds + val dismissButtonBounds = dismissPipObject.visibleBounds uiDevice.click(dismissButtonBounds.centerX(), dismissButtonBounds.centerY()) }