From c35d359131457d75458d3174f28927044f0ef7af Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Mon, 19 Sep 2022 09:05:32 +0000 Subject: [PATCH] Fix PiP Flicker test transitions Ensures we don't have no-op transitions anymore. Another change makes it so we assert and fail if we have transitions we no entries to make sure we don't fail silenetly in these cases. Test: atest FlickerTests WmShellFlickerTests Bug: 247464790 Change-Id: Iaad739c4bb869c51c6deee582ae5ff9c81013ea2 --- .../wm/shell/flicker/pip/ExitPipTransition.kt | 2 +- .../pip/ExitPipViaExpandButtonClickTest.kt | 2 +- .../wm/shell/flicker/pip/ExitPipViaIntentTest.kt | 2 +- .../flicker/pip/ExpandPipOnDoubleClickTest.kt | 2 +- .../pip/MovePipDownShelfHeightChangeTest.kt | 8 +++++--- .../pip/MovePipUpShelfHeightChangeTest.kt | 2 +- .../wm/shell/flicker/pip/PipKeyboardTest.kt | 2 +- .../wm/shell/flicker/pip/PipRotationTest.kt | 2 +- .../wm/shell/flicker/pip/PipTransition.kt | 16 +--------------- 9 files changed, 13 insertions(+), 25 deletions(-) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt index 0f7d8a9510b35..39be89d2592b1 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt @@ -30,7 +30,7 @@ import org.junit.Test */ abstract class ExitPipTransition(testSpec: FlickerTestParameter) : PipTransition(testSpec) { override val transition: FlickerBuilder.() -> Unit - get() = buildTransition(eachRun = true) { + get() = buildTransition { setup { this.setRotation(testSpec.startRotation) } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaExpandButtonClickTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaExpandButtonClickTest.kt index 53450de5221d5..c2fd0d78f0d5b 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaExpandButtonClickTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaExpandButtonClickTest.kt @@ -62,7 +62,7 @@ class ExitPipViaExpandButtonClickTest( * Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit - get() = buildTransition(eachRun = true) { + get() = buildTransition { setup { // launch an app behind the pip one testApp.launchViaIntent(wmHelper) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt index 75018d1612673..0d75e02bd467a 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt @@ -62,7 +62,7 @@ class ExitPipViaIntentTest(testSpec: FlickerTestParameter) : ExitPipToAppTransit * Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit - get() = buildTransition(eachRun = true) { + get() = buildTransition { setup { // launch an app behind the pip one testApp.launchViaIntent(wmHelper) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt index 4d39ec53f18cd..513ce95042d00 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt @@ -56,7 +56,7 @@ import org.junit.runners.Parameterized @Group3 class ExpandPipOnDoubleClickTest(testSpec: FlickerTestParameter) : PipTransition(testSpec) { override val transition: FlickerBuilder.() -> Unit - get() = buildTransition(eachRun = true) { + get() = buildTransition { transitions { pipApp.doubleClickPipWindow(wmHelper) } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownShelfHeightChangeTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownShelfHeightChangeTest.kt index de8c0093bfc50..412f56bd2d3d3 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownShelfHeightChangeTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownShelfHeightChangeTest.kt @@ -60,14 +60,16 @@ open class MovePipDownShelfHeightChangeTest( * Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit - get() = buildTransition(eachRun = false) { - teardown { + get() = buildTransition() { + setup { testApp.launchViaIntent(wmHelper) - testApp.exit(wmHelper) } transitions { tapl.pressHome() } + teardown { + testApp.exit(wmHelper) + } } override fun assertRegionMovement(previous: RegionSubject, current: RegionSubject) { diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipUpShelfHeightChangeTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipUpShelfHeightChangeTest.kt index 3e08bfb247e65..1f25e4f3a4bc3 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipUpShelfHeightChangeTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipUpShelfHeightChangeTest.kt @@ -68,7 +68,7 @@ class MovePipUpShelfHeightChangeTest( * Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit - get() = buildTransition(eachRun = false) { + get() = buildTransition { teardown { tapl.pressHome() testApp.exit(wmHelper) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt index 27fc2ed23b83b..3d3b53de3dc8f 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt @@ -56,7 +56,7 @@ open class PipKeyboardTest(testSpec: FlickerTestParameter) : PipTransition(testS /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit - get() = buildTransition(eachRun = false) { + get() = buildTransition { setup { imeApp.launchViaIntent(wmHelper) setRotation(testSpec.startRotation) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt index fd5ff2933f8c9..f13698f1d04e9 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt @@ -72,7 +72,7 @@ open class PipRotationTest(testSpec: FlickerTestParameter) : PipTransition(testS } override val transition: FlickerBuilder.() -> Unit - get() = buildTransition(eachRun = false) { + get() = buildTransition { setup { fixedApp.launchViaIntent(wmHelper) setRotation(testSpec.startRotation) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt index faf6afc64c692..b67cf772358b0 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt @@ -65,7 +65,6 @@ abstract class PipTransition(testSpec: FlickerTestParameter) : BaseTest(testSpec */ @JvmOverloads protected open fun buildTransition( - eachRun: Boolean, stringExtras: Map = mapOf(Components.PipActivity.EXTRA_ENTER_PIP to "true"), extraSpec: FlickerBuilder.() -> Unit = {} ): FlickerBuilder.() -> Unit { @@ -73,25 +72,12 @@ abstract class PipTransition(testSpec: FlickerTestParameter) : BaseTest(testSpec setup { setRotation(Surface.ROTATION_0) removeAllTasksButHome() - - if (!eachRun) { - pipApp.launchViaIntentAndWaitForPip(wmHelper, stringExtras = stringExtras) - } - if (eachRun) { - pipApp.launchViaIntentAndWaitForPip(wmHelper, stringExtras = stringExtras) - } + pipApp.launchViaIntentAndWaitForPip(wmHelper, stringExtras = stringExtras) } teardown { setRotation(Surface.ROTATION_0) removeAllTasksButHome() pipApp.exit(wmHelper) - - if (eachRun) { - pipApp.exit(wmHelper) - } - if (!eachRun) { - pipApp.exit(wmHelper) - } } extraSpec(this)