From a60deee835bb8d236305770a74ca57aa969fd21a Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Mon, 3 Jan 2022 11:38:10 +0100 Subject: [PATCH] Wait "launch_second_activity" button to be gone When running on slow devices (e.g. cuttlefish), the animation may take some time to start. The previous checks would pass if the animation didn't start and this causes an exception on the flicker tests Test: atest FlickerTests Change-Id: I8de4410e1c169d90d69d9a440daa82ec005fe222 --- .../wm/flicker/helpers/TwoActivitiesAppHelper.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/TwoActivitiesAppHelper.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/TwoActivitiesAppHelper.kt index 59e8dc8260075..8fe00297139ab 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/TwoActivitiesAppHelper.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/TwoActivitiesAppHelper.kt @@ -37,16 +37,21 @@ class TwoActivitiesAppHelper @JvmOverloads constructor( .launcherStrategy ) : StandardAppHelper(instr, launcherName, component, launcherStrategy) { fun openSecondActivity(device: UiDevice, wmHelper: WindowManagerStateHelper) { - val button = device.wait( - Until.findObject(By.res(getPackage(), "launch_second_activity")), - FIND_TIMEOUT) + val launchActivityButton = By.res(getPackage(), LAUNCH_SECOND_ACTIVITY) + val button = device.wait(Until.findObject(launchActivityButton), FIND_TIMEOUT) require(button != null) { "Button not found, this usually happens when the device " + "was left in an unknown state (e.g. in split screen)" } button.click() + + device.wait(Until.gone(launchActivityButton), FIND_TIMEOUT) wmHelper.waitForAppTransitionIdle() wmHelper.waitForFullScreenApp(component) } + + companion object { + private const val LAUNCH_SECOND_ACTIVITY = "launch_second_activity" + } } \ No newline at end of file