From 007755f38fecd4c9df7804b2ea5389b16bfb2160 Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Wed, 8 Dec 2021 19:51:48 +0100 Subject: [PATCH] Make 90 degree app launch less flaky When apps are launched during a rotation there maybe a moment where the launcher is no longer visible and where the app also isn't visible. A Rotation Layer is shown instead to fill the gap. We now check for this layer. Test: atest FlickerLibTests:OpenAppColdTest#appLayerReplacesLauncher Bug: 209593837 Change-Id: Ic2810eed27f25398d4dc9748329729ea6213a9eb --- .../android/server/wm/flicker/CommonAssertions.kt | 15 +++++++++++---- .../server/wm/flicker/launch/OpenAppTransition.kt | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt index aec80ac9d7b66..75f1337b9388a 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt @@ -141,6 +141,10 @@ fun FlickerTestParameter.statusBarLayerRotatesScales() { * * @param originalLayer Layer that should be visible at the start * @param newLayer Layer that should be visible at the end + * @param ignoreEntriesWithRotationLayer If entries with a visible rotation layer should be ignored + * when checking the transition. If true we will not fail the assertion if a rotation layer is + * visible to fill the gap between the [originalLayer] being visible and the [newLayer] being + * visible. * @param ignoreSnapshot If the snapshot layer should be ignored during the transition * (useful mostly for app launch) * @param ignoreSplashscreen If the splashscreen layer should be ignored during the transition. @@ -150,20 +154,23 @@ fun FlickerTestParameter.statusBarLayerRotatesScales() { fun FlickerTestParameter.replacesLayer( originalLayer: FlickerComponentName, newLayer: FlickerComponentName, + ignoreEntriesWithRotationLayer: Boolean = false, ignoreSnapshot: Boolean = false, ignoreSplashscreen: Boolean = true ) { assertLayers { val assertion = this.isVisible(originalLayer) - if (ignoreSnapshot || ignoreSplashscreen) { - assertion.then() + + if (ignoreEntriesWithRotationLayer) { + assertion.then().isVisible(FlickerComponentName.ROTATION, isOptional = true) } if (ignoreSnapshot) { - assertion.isVisible(FlickerComponentName.SNAPSHOT, isOptional = true) + assertion.then().isVisible(FlickerComponentName.SNAPSHOT, isOptional = true) } if (ignoreSplashscreen) { - assertion.isSplashScreenVisibleFor(newLayer, isOptional = true) + assertion.then().isSplashScreenVisibleFor(newLayer, isOptional = true) } + assertion.then().isVisible(newLayer) } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt index 62e3fa6196791..b5c81bb39ed4c 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt @@ -166,7 +166,8 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) { * is replaced by [testApp], which remains visible until the end */ open fun appLayerReplacesLauncher() { - testSpec.replacesLayer(LAUNCHER_COMPONENT, testApp.component, ignoreSnapshot = true) + testSpec.replacesLayer(LAUNCHER_COMPONENT, testApp.component, + ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true) } /**