Generalize rotation transition

Share code and assertions between transitions to improve maintainability

Test: atest FlickerTests:com.android.server.wm.flicker.rotation
Bug: 167521849
Change-Id: I448363e87272614ec694e01a52049143de913fb4
This commit is contained in:
Nataniel Borges
2021-03-05 17:07:14 +01:00
parent 3f0a1f40a5
commit b4252090b0
3 changed files with 101 additions and 129 deletions

View File

@@ -17,25 +17,12 @@
package com.android.server.wm.flicker.rotation
import android.platform.test.annotations.Presubmit
import androidx.test.filters.FlakyTest
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.dsl.FlickerBuilder
import com.android.server.wm.flicker.endRotation
import com.android.server.wm.flicker.focusDoesNotChange
import com.android.server.wm.flicker.helpers.SimpleAppHelper
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.startRotation
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
@@ -64,24 +51,6 @@ class ChangeAppRotationTest(
}
}
@Presubmit
@Test
fun navBarWindowIsAlwaysVisible() = testSpec.navBarWindowIsAlwaysVisible()
@Presubmit
@Test
fun statusBarWindowIsAlwaysVisible() = testSpec.statusBarWindowIsAlwaysVisible()
@Presubmit
@Test
fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
testSpec.visibleWindowsShownMoreThanOneConsecutiveEntry()
@Presubmit
@Test
fun noUncoveredRegions() = testSpec.noUncoveredRegions(testSpec.config.startRotation,
testSpec.config.endRotation, allStates = false)
@Presubmit
@Test
fun screenshotLayerBecomesInvisible() {
@@ -94,49 +63,6 @@ class ChangeAppRotationTest(
}
}
@FlakyTest(bugId = 140855415)
@Test
fun navBarLayerIsAlwaysVisible() = testSpec.navBarLayerIsAlwaysVisible()
@FlakyTest(bugId = 140855415)
@Test
fun statusBarLayerIsAlwaysVisible() = testSpec.statusBarLayerIsAlwaysVisible()
@FlakyTest(bugId = 140855415)
@Test
fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales(
testSpec.config.startRotation, testSpec.config.endRotation)
@FlakyTest(bugId = 140855415)
@Test
fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales(
testSpec.config.startRotation, testSpec.config.endRotation)
@FlakyTest(bugId = 140855415)
@Test
fun visibleLayersShownMoreThanOneConsecutiveEntry() =
testSpec.visibleLayersShownMoreThanOneConsecutiveEntry()
@FlakyTest(bugId = 140855415)
@Test
fun appLayerRotates_StartingPos() {
testSpec.assertLayersStart {
this.coversExactly(startingPos, testApp.getPackage())
}
}
@FlakyTest(bugId = 140855415)
@Test
fun appLayerRotates_EndingPos() {
testSpec.assertLayersEnd {
this.coversExactly(endingPos, testApp.getPackage())
}
}
@FlakyTest(bugId = 151179149)
@Test
fun focusDoesNotChange() = testSpec.focusDoesNotChange()
companion object {
private const val SCREENSHOT_LAYER = "RotationLayer"

View File

@@ -17,17 +17,30 @@
package com.android.server.wm.flicker.rotation
import android.app.Instrumentation
import android.platform.test.annotations.Presubmit
import androidx.test.filters.FlakyTest
import androidx.test.platform.app.InstrumentationRegistry
import com.android.server.wm.flicker.FlickerBuilderProvider
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.endRotation
import com.android.server.wm.flicker.focusDoesNotChange
import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.startRotation
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry
import org.junit.Test
abstract class RotationTransition(protected val testSpec: FlickerTestParameter) {
protected abstract val testApp: StandardAppHelper
@@ -63,4 +76,82 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter)
transition(testSpec.config)
}
}
@Presubmit
@Test
open fun navBarWindowIsAlwaysVisible() {
testSpec.navBarWindowIsAlwaysVisible()
}
@FlakyTest(bugId = 140855415)
@Test
open fun navBarLayerIsAlwaysVisible() {
testSpec.navBarLayerIsAlwaysVisible()
}
@FlakyTest(bugId = 140855415)
@Test
open fun navBarLayerRotatesAndScales() {
testSpec.navBarLayerRotatesAndScales(
testSpec.config.startRotation, testSpec.config.endRotation)
}
@Presubmit
@Test
open fun statusBarWindowIsAlwaysVisible() {
testSpec.statusBarWindowIsAlwaysVisible()
}
@FlakyTest(bugId = 140855415)
@Test
open fun statusBarLayerIsAlwaysVisible() {
testSpec.statusBarLayerIsAlwaysVisible()
}
@FlakyTest(bugId = 140855415)
@Test
open fun statusBarLayerRotatesScales() {
testSpec.statusBarLayerRotatesScales(
testSpec.config.startRotation, testSpec.config.endRotation)
}
@FlakyTest(bugId = 140855415)
@Test
open fun visibleLayersShownMoreThanOneConsecutiveEntry() =
testSpec.visibleLayersShownMoreThanOneConsecutiveEntry()
@Presubmit
@Test
open fun visibleWindowsShownMoreThanOneConsecutiveEntry() {
testSpec.visibleWindowsShownMoreThanOneConsecutiveEntry()
}
@Presubmit
@Test
open fun noUncoveredRegions() {
testSpec.noUncoveredRegions(testSpec.config.startRotation,
testSpec.config.endRotation, allStates = false)
}
@FlakyTest(bugId = 151179149)
@Test
open fun focusDoesNotChange() {
testSpec.focusDoesNotChange()
}
@FlakyTest(bugId = 140855415)
@Test
open fun appLayerRotates_StartingPos() {
testSpec.assertLayersStart {
this.coversExactly(startingPos, testApp.getPackage())
}
}
@FlakyTest(bugId = 140855415)
@Test
open fun appLayerRotates_EndingPos() {
testSpec.assertLayersEnd {
this.coversExactly(endingPos, testApp.getPackage())
}
}
}

View File

@@ -24,21 +24,9 @@ import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameterFactory
import com.android.server.wm.flicker.appWindowAlwaysVisibleOnTop
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.endRotation
import com.android.server.wm.flicker.focusDoesNotChange
import com.android.server.wm.flicker.helpers.SeamlessRotationAppHelper
import com.android.server.wm.flicker.layerAlwaysVisible
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.startRotation
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
@@ -71,10 +59,17 @@ class SeamlessAppRotationTest(
}
}
@Presubmit
@FlakyTest(bugId = 140855415)
@Test
fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
testSpec.visibleWindowsShownMoreThanOneConsecutiveEntry()
override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()
@FlakyTest(bugId = 140855415)
@Test
override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()
@FlakyTest(bugId = 147659548)
@Test
override fun noUncoveredRegions() = super.noUncoveredRegions()
@Presubmit
@Test
@@ -84,42 +79,6 @@ class SeamlessAppRotationTest(
@Test
fun layerAlwaysVisible() = testSpec.layerAlwaysVisible(testApp.`package`)
@FlakyTest(bugId = 140855415)
@Test
fun navBarWindowIsAlwaysVisible() = testSpec.navBarWindowIsAlwaysVisible()
@FlakyTest(bugId = 140855415)
@Test
fun statusBarWindowIsAlwaysVisible() = testSpec.statusBarWindowIsAlwaysVisible()
@FlakyTest(bugId = 140855415)
@Test
fun navBarLayerIsAlwaysVisible() = testSpec.navBarLayerIsAlwaysVisible()
@FlakyTest(bugId = 140855415)
@Test
fun statusBarLayerIsAlwaysVisible() = testSpec.statusBarLayerIsAlwaysVisible()
@FlakyTest(bugId = 147659548)
@Test
fun noUncoveredRegions() = testSpec.noUncoveredRegions(testSpec.config.startRotation,
testSpec.config.endRotation, allStates = false)
@FlakyTest
@Test
fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales(
testSpec.config.startRotation, testSpec.config.endRotation)
@FlakyTest
@Test
fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales(
testSpec.config.startRotation, testSpec.config.endRotation)
@FlakyTest
@Test
fun visibleLayersShownMoreThanOneConsecutiveEntry() =
testSpec.visibleLayersShownMoreThanOneConsecutiveEntry()
@FlakyTest(bugId = 147659548)
@Test
fun appLayerRotates() {
@@ -128,10 +87,6 @@ class SeamlessAppRotationTest(
}
}
@FlakyTest(bugId = 151179149)
@Test
fun focusDoesNotChange() = testSpec.focusDoesNotChange()
companion object {
private val testFactory = FlickerTestParameterFactory.getInstance()