From b4252090b0904be8271fbe7689033d72df2d2fba Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Fri, 5 Mar 2021 17:07:14 +0100 Subject: [PATCH] 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 --- .../flicker/rotation/ChangeAppRotationTest.kt | 74 --------------- .../wm/flicker/rotation/RotationTransition.kt | 91 +++++++++++++++++++ .../rotation/SeamlessAppRotationTest.kt | 65 ++----------- 3 files changed, 101 insertions(+), 129 deletions(-) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt index 20e4b88ff13bd..6985b360c9cc8 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt @@ -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" diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt index c391112a53ecd..9d78eb86539a7 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt @@ -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()) + } + } } \ No newline at end of file diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt index fc5bcc7eef1b1..45d3006b94812 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt @@ -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()