Fix enter pip via UI tests
1. Improve existing assertions
2. Create new assertions, e.g.:
pip layer reduces
pip layer in bounds
3. Add documentation for test and assertions
Bug: 174238257
Test: atest WMShellFlickerTests:com.android.wm.shell.flicker.pip
Change-Id: Ib08aa3e2f4dfe5112cca181ffddd301469354f5e
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.wm.shell.flicker.pip
|
||||
|
||||
import android.platform.test.annotations.Postsubmit
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import android.view.Surface
|
||||
import androidx.test.filters.FlakyTest
|
||||
@@ -23,8 +24,10 @@ 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.LAUNCHER_COMPONENT
|
||||
import com.android.server.wm.flicker.annotation.Group3
|
||||
import com.android.server.wm.flicker.dsl.FlickerBuilder
|
||||
import com.android.server.wm.traces.parser.toLayerName
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -32,8 +35,21 @@ import org.junit.runners.MethodSorters
|
||||
import org.junit.runners.Parameterized
|
||||
|
||||
/**
|
||||
* Test Pip launch.
|
||||
* Test entering pip from an app by interacting with the app UI
|
||||
*
|
||||
* To run this test: `atest WMShellFlickerTests:EnterPipTest`
|
||||
*
|
||||
* Actions:
|
||||
* Launch an app in full screen
|
||||
* Press an "enter pip" button to put [pipApp] in pip mode
|
||||
*
|
||||
* Notes:
|
||||
* 1. Some default assertions (e.g., nav bar, status bar and screen covered)
|
||||
* are inherited [PipTransition]
|
||||
* 2. Part of the test setup occurs automatically via
|
||||
* [com.android.server.wm.flicker.TransitionRunnerWithRules],
|
||||
* including configuring navigation mode, initial orientation and ensuring no
|
||||
* apps are running before setup
|
||||
*/
|
||||
@RequiresDevice
|
||||
@RunWith(Parameterized::class)
|
||||
@@ -41,6 +57,9 @@ import org.junit.runners.Parameterized
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@Group3
|
||||
class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec) {
|
||||
/**
|
||||
* Defines the transition used to run the test
|
||||
*/
|
||||
override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
|
||||
get() = buildTransition(eachRun = true, stringExtras = emptyMap()) {
|
||||
transitions {
|
||||
@@ -49,6 +68,9 @@ class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks [pipApp] window remains visible throughout the animation
|
||||
*/
|
||||
@Presubmit
|
||||
@Test
|
||||
fun pipAppWindowAlwaysVisible() {
|
||||
@@ -57,6 +79,9 @@ class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks [pipApp] layer remains visible throughout the animation
|
||||
*/
|
||||
@Presubmit
|
||||
@Test
|
||||
fun pipAppLayerAlwaysVisible() {
|
||||
@@ -65,19 +90,89 @@ class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec) {
|
||||
}
|
||||
}
|
||||
|
||||
@FlakyTest
|
||||
/**
|
||||
* Checks that the pip app window remains inside the display bounds throughout the whole
|
||||
* animation
|
||||
*/
|
||||
@Postsubmit
|
||||
@Test
|
||||
fun pipWindowBecomesVisible() {
|
||||
fun pipWindowRemainInsideVisibleBounds() {
|
||||
testSpec.assertWm {
|
||||
invoke("pipWindowIsNotVisible") {
|
||||
verify("Has no pip window").that(it.wmState.hasPipWindow()).isTrue()
|
||||
}.then().invoke("pipWindowIsVisible") {
|
||||
verify("Has pip window").that(it.wmState.hasPipWindow()).isTrue()
|
||||
coversAtMost(displayBounds, pipApp.component)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the pip app layer remains inside the display bounds throughout the whole
|
||||
* animation
|
||||
*/
|
||||
@Postsubmit
|
||||
@Test
|
||||
fun pipLayerRemainInsideVisibleBounds() {
|
||||
testSpec.assertLayers {
|
||||
coversAtMost(displayBounds, pipApp.component)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the visible region of [pipApp] always reduces during the animation
|
||||
*/
|
||||
@Postsubmit
|
||||
@Test
|
||||
fun pipLayerReduces() {
|
||||
val layerName = pipApp.component.toLayerName()
|
||||
testSpec.assertLayers {
|
||||
val pipLayerList = this.layers { it.name.contains(layerName) && it.isVisible }
|
||||
pipLayerList.zipWithNext { previous, current ->
|
||||
current.visibleRegion.coversAtMost(previous.visibleRegion.region)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that [pipApp] window becomes pinned
|
||||
*/
|
||||
@Postsubmit
|
||||
@Test
|
||||
fun pipWindowBecomesPinned() {
|
||||
testSpec.assertWm {
|
||||
invoke("pipWindowIsNotPinned") { it.isNotPinned(pipApp.component) }
|
||||
.then()
|
||||
.invoke("pipWindowIsPinned") { it.isPinned(pipApp.component) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks [LAUNCHER_COMPONENT] layer remains visible throughout the animation
|
||||
*/
|
||||
@Postsubmit
|
||||
@Test
|
||||
fun launcherLayerBecomesVisible() {
|
||||
testSpec.assertLayers {
|
||||
isInvisible(LAUNCHER_COMPONENT)
|
||||
.then()
|
||||
.isVisible(LAUNCHER_COMPONENT)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the focus doesn't change during the animation
|
||||
*/
|
||||
@FlakyTest
|
||||
@Test
|
||||
fun focusDoesNotChange() {
|
||||
testSpec.assertEventLog {
|
||||
this.focusDoesNotChange()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Creates the test configurations.
|
||||
*
|
||||
* See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring
|
||||
* repetitions, screen orientation and navigation modes.
|
||||
*/
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
@JvmStatic
|
||||
fun getParams(): List<FlickerTestParameter> {
|
||||
|
||||
Reference in New Issue
Block a user