diff options
author | 2022-09-19 16:50:46 +0000 | |
---|---|---|
committer | 2022-09-19 16:50:46 +0000 | |
commit | 5c04ae0b840c021f5eee81d606227e079ed1ce47 (patch) | |
tree | 07a05f089b2da4a533be3084977d96290ed5ceaf | |
parent | e62ee60683e55120a1603ba74ba585b33da2abfa (diff) | |
parent | 6ae3883e86b6bdcee728905f4debd8b69c8d2b03 (diff) |
Merge "Update PiP region movement logic"
4 files changed, 93 insertions, 57 deletions
diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt index 06361f9ca4ab..53dd8b04afeb 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt @@ -24,3 +24,7 @@ val APP_PAIR_SPLIT_DIVIDER_COMPONENT = ComponentNameMatcher("", "AppPairSplitDiv val DOCKED_STACK_DIVIDER_COMPONENT = ComponentNameMatcher("", "DockedStackDivider#") val SPLIT_SCREEN_DIVIDER_COMPONENT = ComponentNameMatcher("", "StageCoordinatorSplitDivider#") val SPLIT_DECOR_MANAGER = ComponentNameMatcher("", "SplitDecorManager#") + +enum class Direction { + UP, DOWN, LEFT, RIGHT +} 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 412f56bd2d3d..746ce913c587 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 @@ -16,28 +16,30 @@ package com.android.wm.shell.flicker.pip +import android.platform.test.annotations.Presubmit +import android.platform.test.annotations.RequiresDevice import android.view.Surface -import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group3 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.traces.region.RegionSubject +import com.android.wm.shell.flicker.Direction import org.junit.FixMethodOrder +import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters import org.junit.runners.Parameterized /** - * Test Pip movement with Launcher shelf height change (decrease). + * Test Pip movement with Launcher shelf height change (increase). * - * To run this test: `atest WMShellFlickerTests:MovePipDownShelfHeightChangeTest` + * To run this test: `atest WMShellFlickerTests:MovePipUpShelfHeightChangeTest` * * Actions: * Launch [pipApp] in pip mode - * Launch [testApp] * Press home + * Launch [testApp] * Check if pip window moves down (visually) * * Notes: @@ -53,28 +55,41 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group3 -open class MovePipDownShelfHeightChangeTest( +class MovePipDownShelfHeightChangeTest( testSpec: FlickerTestParameter ) : MovePipShelfHeightTransition(testSpec) { +// @Before +// fun before() { +// Assume.assumeFalse(isShellTransitionsEnabled) +// } + /** * Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit - get() = buildTransition() { - setup { - testApp.launchViaIntent(wmHelper) - } - transitions { - tapl.pressHome() - } + get() = buildTransition { teardown { + tapl.pressHome() testApp.exit(wmHelper) } + transitions { + testApp.launchViaIntent(wmHelper) + } } - override fun assertRegionMovement(previous: RegionSubject, current: RegionSubject) { - current.isHigherOrEqual(previous.region) - } + /** + * Checks that the visible region of [pipApp] window always moves down during the animation. + */ + @Presubmit + @Test + fun pipWindowMovesDown() = pipWindowMoves(Direction.DOWN) + + /** + * Checks that the visible region of [pipApp] layer always moves down during the animation. + */ + @Presubmit + @Test + fun pipLayerMovesDown() = pipLayerMoves(Direction.DOWN) companion object { /** diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt index 9fb941e2a584..19bdca51f8af 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt @@ -19,6 +19,7 @@ package com.android.wm.shell.flicker.pip import android.platform.test.annotations.Presubmit import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.traces.region.RegionSubject +import com.android.wm.shell.flicker.Direction import com.android.wm.shell.flicker.helpers.FixedAppHelper import org.junit.Test @@ -31,11 +32,6 @@ abstract class MovePipShelfHeightTransition( protected val testApp = FixedAppHelper(instrumentation) /** - * Checks if the window movement direction is valid - */ - protected abstract fun assertRegionMovement(previous: RegionSubject, current: RegionSubject) - - /** * Checks [pipApp] window remains visible throughout the animation */ @Presubmit @@ -82,31 +78,46 @@ abstract class MovePipShelfHeightTransition( } /** - * Checks that the visible region of [pipApp] always moves in the correct direction + * Checks that the visible region of [pipApp] window always moves in the specified direction * during the animation. */ - @Presubmit - @Test - open fun pipWindowMoves() { + protected fun pipWindowMoves(direction: Direction) { testSpec.assertWm { - val pipWindowList = this.windowStates { pipApp.windowMatchesAnyOf(it) && it.isVisible } - pipWindowList.zipWithNext { previous, current -> - assertRegionMovement(previous.frame, current.frame) + val pipWindowFrameList = this.windowStates { + pipApp.windowMatchesAnyOf(it) && it.isVisible + }.map { it.frame } + when (direction) { + Direction.UP -> assertRegionMovementUp(pipWindowFrameList) + Direction.DOWN -> assertRegionMovementDown(pipWindowFrameList) + else -> error("Unhandled direction") } } } /** - * Checks that the visible region of [pipApp] always moves up during the animation + * Checks that the visible region of [pipApp] layer always moves in the specified direction + * during the animation. */ - @Presubmit - @Test - open fun pipLayerMoves() { + protected fun pipLayerMoves(direction: Direction) { testSpec.assertLayers { - val pipLayerList = this.layers { pipApp.layerMatchesAnyOf(it) && it.isVisible } - pipLayerList.zipWithNext { previous, current -> - assertRegionMovement(previous.visibleRegion, current.visibleRegion) + val pipLayerRegionList = this.layers { + pipApp.layerMatchesAnyOf(it) && it.isVisible + }.map { it.visibleRegion } + when (direction) { + Direction.UP -> assertRegionMovementUp(pipLayerRegionList) + Direction.DOWN -> assertRegionMovementDown(pipLayerRegionList) + else -> error("Unhandled direction") } } } + + private fun assertRegionMovementDown(regions: List<RegionSubject>) { + regions.zipWithNext { previous, current -> current.isLowerOrEqual(previous) } + regions.last().isLower(regions.first()) + } + + private fun assertRegionMovementUp(regions: List<RegionSubject>) { + regions.zipWithNext { previous, current -> current.isHigherOrEqual(previous.region) } + regions.last().isHigher(regions.first()) + } } 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 1f25e4f3a4bc..93e7d5ca45ad 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 @@ -16,31 +16,30 @@ package com.android.wm.shell.flicker.pip -import android.platform.test.annotations.RequiresDevice +import android.platform.test.annotations.Presubmit import android.view.Surface +import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group3 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled -import com.android.server.wm.flicker.traces.region.RegionSubject -import org.junit.Assume -import org.junit.Before +import com.android.wm.shell.flicker.Direction import org.junit.FixMethodOrder +import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters import org.junit.runners.Parameterized /** - * Test Pip movement with Launcher shelf height change (increase). + * Test Pip movement with Launcher shelf height change (decrease). * - * To run this test: `atest WMShellFlickerTests:MovePipUpShelfHeightChangeTest` + * To run this test: `atest WMShellFlickerTests:MovePipDownShelfHeightChangeTest` * * Actions: * Launch [pipApp] in pip mode - * Press home * Launch [testApp] + * Press home * Check if pip window moves up (visually) * * Notes: @@ -56,31 +55,38 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group3 -class MovePipUpShelfHeightChangeTest( +open class MovePipUpShelfHeightChangeTest( testSpec: FlickerTestParameter ) : MovePipShelfHeightTransition(testSpec) { - @Before - fun before() { - Assume.assumeFalse(isShellTransitionsEnabled) - } - /** * Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit - get() = buildTransition { - teardown { - tapl.pressHome() - testApp.exit(wmHelper) + get() = buildTransition() { + setup { + testApp.launchViaIntent(wmHelper) } transitions { - testApp.launchViaIntent(wmHelper) + tapl.pressHome() + } + teardown { + testApp.exit(wmHelper) } } - override fun assertRegionMovement(previous: RegionSubject, current: RegionSubject) { - current.isLowerOrEqual(previous.region) - } + /** + * Checks that the visible region of [pipApp] window always moves up during the animation. + */ + @Presubmit + @Test + fun pipWindowMovesUp() = pipWindowMoves(Direction.UP) + + /** + * Checks that the visible region of [pipApp] layer always moves up during the animation. + */ + @Presubmit + @Test + fun pipLayerMovesUp() = pipLayerMoves(Direction.UP) companion object { /** |