Split PipShelfHeightTest to check both movement up and down
1. Split test into shelf moves up and down
2. Simplify existing assertions (using region subject)
3. Add new assertions
pip layers moves up
pip layer in visible bounds
4. Add documentation for test and assertions
Bug: 196213706
Test: atest WMShellFlickerTests:com.android.wm.shell.flicker.pip
Change-Id: Ia9a0a1d272dbe968098934292b214f6b6d31ed83
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.wm.shell.flicker.pip
|
||||
|
||||
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.RegionSubject
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.MethodSorters
|
||||
import org.junit.runners.Parameterized
|
||||
|
||||
/**
|
||||
* Test Pip movement with Launcher shelf height change (decrease).
|
||||
*
|
||||
* To run this test: `atest WMShellFlickerTests:MovePipDownShelfHeightChangeTest`
|
||||
*
|
||||
* Actions:
|
||||
* Launch [pipApp] in pip mode
|
||||
* Launch [testApp]
|
||||
* Press home
|
||||
* Check if pip window moves down (visually)
|
||||
*
|
||||
* 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)
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@Group3
|
||||
class MovePipDownShelfHeightChangeTest(
|
||||
testSpec: FlickerTestParameter
|
||||
) : MovePipShelfHeightTransition(testSpec) {
|
||||
/**
|
||||
* Defines the transition used to run the test
|
||||
*/
|
||||
override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
|
||||
get() = buildTransition(eachRun = false) {
|
||||
teardown {
|
||||
eachRun {
|
||||
testApp.launchViaIntent(wmHelper)
|
||||
}
|
||||
test {
|
||||
testApp.exit(wmHelper)
|
||||
}
|
||||
}
|
||||
transitions {
|
||||
taplInstrumentation.pressHome()
|
||||
}
|
||||
}
|
||||
|
||||
override fun assertRegionMovement(previous: RegionSubject, current: RegionSubject) {
|
||||
current.isHigherOrEqual(previous.region)
|
||||
}
|
||||
|
||||
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> {
|
||||
return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests(
|
||||
supportedRotations = listOf(Surface.ROTATION_0), repetitions = 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.wm.shell.flicker.pip
|
||||
|
||||
import android.platform.test.annotations.Postsubmit
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import com.android.launcher3.tapl.LauncherInstrumentation
|
||||
import com.android.server.wm.flicker.FlickerTestParameter
|
||||
import com.android.server.wm.flicker.traces.RegionSubject
|
||||
import com.android.server.wm.traces.parser.toLayerName
|
||||
import com.android.server.wm.traces.parser.toWindowName
|
||||
import com.android.wm.shell.flicker.helpers.FixedAppHelper
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Base class for pip tests with Launcher shelf height change
|
||||
*/
|
||||
abstract class MovePipShelfHeightTransition(
|
||||
testSpec: FlickerTestParameter
|
||||
) : PipTransition(testSpec) {
|
||||
protected val taplInstrumentation = LauncherInstrumentation()
|
||||
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
|
||||
*/
|
||||
@Postsubmit
|
||||
@Test
|
||||
open fun pipWindowIsAlwaysVisible() {
|
||||
testSpec.assertWm {
|
||||
isAppWindowVisible(pipApp.component)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks [pipApp] layer remains visible throughout the animation
|
||||
*/
|
||||
@Postsubmit
|
||||
@Test
|
||||
open fun pipLayerIsAlwaysVisible() {
|
||||
testSpec.assertLayers {
|
||||
isVisible(pipApp.component)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the pip app window remains inside the display bounds throughout the whole
|
||||
* animation
|
||||
*/
|
||||
@Postsubmit
|
||||
@Test
|
||||
open fun pipWindowRemainInsideVisibleBounds() {
|
||||
testSpec.assertWm {
|
||||
coversAtMost(displayBounds, pipApp.component)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the pip app layer remains inside the display bounds throughout the whole
|
||||
* animation
|
||||
*/
|
||||
@Postsubmit
|
||||
@Test
|
||||
open fun pipLayerRemainInsideVisibleBounds() {
|
||||
testSpec.assertLayers {
|
||||
coversAtMost(displayBounds, pipApp.component)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the visible region of [pipApp] always moves in the correct direction
|
||||
* during the animation.
|
||||
*/
|
||||
@Presubmit
|
||||
@Test
|
||||
open fun pipWindowMoves() {
|
||||
val windowName = pipApp.component.toWindowName()
|
||||
testSpec.assertWm {
|
||||
val pipWindowList = this.windowStates { it.name.contains(windowName) && it.isVisible }
|
||||
pipWindowList.zipWithNext { previous, current ->
|
||||
assertRegionMovement(previous.frame, current.frame)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the visible region of [pipApp] always moves up during the animation
|
||||
*/
|
||||
@Presubmit
|
||||
@Test
|
||||
open fun pipLayerMoves() {
|
||||
val layerName = pipApp.component.toLayerName()
|
||||
testSpec.assertLayers {
|
||||
val pipLayerList = this.layers { it.name.contains(layerName) && it.isVisible }
|
||||
pipLayerList.zipWithNext { previous, current ->
|
||||
assertRegionMovement(previous.visibleRegion, current.visibleRegion)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,36 +16,49 @@
|
||||
|
||||
package com.android.wm.shell.flicker.pip
|
||||
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import android.view.Surface
|
||||
import androidx.test.filters.RequiresDevice
|
||||
import com.android.launcher3.tapl.LauncherInstrumentation
|
||||
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.wm.shell.flicker.helpers.FixedAppHelper
|
||||
import com.google.common.truth.Truth
|
||||
import com.android.server.wm.flicker.traces.RegionSubject
|
||||
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.
|
||||
* To run this test: `atest WMShellFlickerTests:PipShelfHeightTest`
|
||||
* Test Pip movement with Launcher shelf height change (increase).
|
||||
*
|
||||
* To run this test: `atest WMShellFlickerTests:MovePipUpShelfHeightChangeTest`
|
||||
*
|
||||
* Actions:
|
||||
* Launch [pipApp] in pip mode
|
||||
* Press home
|
||||
* Launch [testApp]
|
||||
* Check if pip window moves up (visually)
|
||||
*
|
||||
* 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)
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@Group3
|
||||
class PipShelfHeightTest(testSpec: FlickerTestParameter) : PipTransition(testSpec) {
|
||||
private val taplInstrumentation = LauncherInstrumentation()
|
||||
private val testApp = FixedAppHelper(instrumentation)
|
||||
|
||||
class MovePipUpShelfHeightChangeTest(
|
||||
testSpec: FlickerTestParameter
|
||||
) : MovePipShelfHeightTransition(testSpec) {
|
||||
/**
|
||||
* Defines the transition used to run the test
|
||||
*/
|
||||
override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
|
||||
get() = buildTransition(eachRun = false) {
|
||||
teardown {
|
||||
@@ -61,33 +74,17 @@ class PipShelfHeightTest(testSpec: FlickerTestParameter) : PipTransition(testSpe
|
||||
}
|
||||
}
|
||||
|
||||
@Presubmit
|
||||
@Test
|
||||
fun pipAlwaysVisible() = testSpec.assertWm { this.isAppWindowVisible(pipApp.component) }
|
||||
|
||||
@Presubmit
|
||||
@Test
|
||||
fun pipLayerInsideDisplay() {
|
||||
testSpec.assertLayersStart {
|
||||
visibleRegion(pipApp.component).coversAtMost(displayBounds)
|
||||
}
|
||||
}
|
||||
|
||||
@Presubmit
|
||||
@Test
|
||||
fun pipWindowMovesUp() = testSpec.assertWmEnd {
|
||||
val initialState = this.trace?.first()?.wmState
|
||||
?: error("Trace should not be empty")
|
||||
val startPos = initialState.pinnedWindows.first().frame
|
||||
val currPos = this.wmState.pinnedWindows.first().frame
|
||||
val subject = Truth.assertWithMessage("Pip should have moved up")
|
||||
subject.that(currPos.top).isGreaterThan(startPos.top)
|
||||
subject.that(currPos.bottom).isGreaterThan(startPos.bottom)
|
||||
subject.that(currPos.left).isEqualTo(startPos.left)
|
||||
subject.that(currPos.right).isEqualTo(startPos.right)
|
||||
override fun assertRegionMovement(previous: RegionSubject, current: RegionSubject) {
|
||||
current.isLowerOrEqual(previous.region)
|
||||
}
|
||||
|
||||
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