From 6d44d95aa2c9dba4275afd2ccea98f189efd0ba4 Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Fri, 3 Dec 2021 18:59:02 +0100 Subject: [PATCH] Make replaceLayers less flaky This is done by checking for a splash screen layer before app layer becomes visible Test: atest FlickerTest:OpenAppTransition#appLayerReplacesLauncher Bug: 208623073 Change-Id: I2c1a84ddde363facce645d08bd09b66e69d16586 --- .../android/server/wm/flicker/CommonAssertions.kt | 15 ++++++++++++--- .../server/wm/flicker/launch/OpenAppTransition.kt | 2 +- 2 files changed, 13 insertions(+), 4 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 64cb790d324ba..aec80ac9d7b66 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt @@ -143,17 +143,26 @@ fun FlickerTestParameter.statusBarLayerRotatesScales() { * @param newLayer Layer that should be visible at the end * @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. + * If true then we will allow for a splashscreen to be shown before the layer is shown, + * otherwise we won't and the layer must appear immediately. */ fun FlickerTestParameter.replacesLayer( originalLayer: FlickerComponentName, newLayer: FlickerComponentName, - ignoreSnapshot: Boolean = false + ignoreSnapshot: Boolean = false, + ignoreSplashscreen: Boolean = true ) { assertLayers { val assertion = this.isVisible(originalLayer) - if (ignoreSnapshot) { + if (ignoreSnapshot || ignoreSplashscreen) { assertion.then() - .isVisible(FlickerComponentName.SNAPSHOT, isOptional = true) + } + if (ignoreSnapshot) { + assertion.isVisible(FlickerComponentName.SNAPSHOT, isOptional = true) + } + if (ignoreSplashscreen) { + assertion.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 b104b970766f3..62e3fa6196791 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,7 @@ 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) + testSpec.replacesLayer(LAUNCHER_COMPONENT, testApp.component, ignoreSnapshot = true) } /**