Update PiP region movement logic
We want the assertion to be stricter and ensure we actually assert that the region is moving and fail if it doesn't move. Test: atest FlickerTests WmShellFlickerTests Bug: 247464794 Change-Id: I81eba3a61f4e999fc46b3a567db39d1d9a4e469b
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
get() = buildTransition {
|
||||
teardown {
|
||||
tapl.pressHome()
|
||||
testApp.exit(wmHelper)
|
||||
}
|
||||
transitions {
|
||||
tapl.pressHome()
|
||||
}
|
||||
teardown {
|
||||
testApp.exit(wmHelper)
|
||||
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 {
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -30,11 +31,6 @@ abstract class MovePipShelfHeightTransition(
|
||||
) : PipTransition(testSpec) {
|
||||
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
|
||||
*/
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user