Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b596930 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Improve documentation for rotation tests"

parents 639ea6ab d404a118
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -23,12 +23,20 @@ import com.android.server.wm.traces.common.FlickerComponentName
val LAUNCHER_COMPONENT = FlickerComponentName("com.google.android.apps.nexuslauncher",
        "com.google.android.apps.nexuslauncher.NexusLauncherActivity")

/**
 * Checks that [FlickerComponentName.STATUS_BAR] window is visible and above the app windows in
 * all WM trace entries
 */
fun FlickerTestParameter.statusBarWindowIsVisible() {
    assertWm {
        this.isAboveAppWindowVisible(FlickerComponentName.STATUS_BAR)
    }
}

/**
 * Checks that [FlickerComponentName.NAV_BAR] window is visible and above the app windows in
 * all WM trace entries
 */
fun FlickerTestParameter.navBarWindowIsVisible() {
    assertWm {
        this.isAboveAppWindowVisible(FlickerComponentName.NAV_BAR)
@@ -68,6 +76,10 @@ fun FlickerTestParameter.entireScreenCovered(allStates: Boolean = true) {
    }
}

/**
 * Checks that [FlickerComponentName.NAV_BAR] layer is visible at the start and end of the SF
 * trace
 */
fun FlickerTestParameter.navBarLayerIsVisible() {
    assertLayersStart {
        this.isVisible(FlickerComponentName.NAV_BAR)
@@ -77,6 +89,10 @@ fun FlickerTestParameter.navBarLayerIsVisible() {
    }
}

/**
 * Checks that [FlickerComponentName.STATUS_BAR] layer is visible at the start and end of the SF
 * trace
 */
fun FlickerTestParameter.statusBarLayerIsVisible() {
    assertLayersStart {
        this.isVisible(FlickerComponentName.STATUS_BAR)
+2 −2
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
    }

    /**
     * Checks that the navigation bar layer is visible during the whole transition
     * Checks that the navigation bar layer is visible at the start and end of the trace
     */
    open fun navBarLayerIsVisible() {
        testSpec.navBarLayerIsVisible()
@@ -109,7 +109,7 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
    }

    /**
     * Checks that the status bar layer is visible during the whole transition
     * Checks that the status bar layer is visible at the start and end of the trace
     */
    @Presubmit
    @Test
+56 −2
Original line number Diff line number Diff line
@@ -38,8 +38,39 @@ import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized

/**
 * Cycle through supported app rotations.
 * Test opening an app and cycling through app rotations
 *
 * Currently runs:
 *      0 -> 90 degrees
 *      90 -> 0 degrees
 *
 * Actions:
 *     Launch an app (via intent)
 *     Set initial device orientation
 *     Start tracing
 *     Change device orientation
 *     Stop tracing
 *
 * To run this test: `atest FlickerTests:ChangeAppRotationTest`
 *
 * To run only the presubmit assertions add: `--
 *      --module-arg FlickerTests:exclude-annotation:androidx.test.filters.FlakyTest
 *      --module-arg FlickerTests:include-annotation:android.platform.test.annotations.Presubmit`
 *
 * To run only the postsubmit assertions add: `--
 *      --module-arg FlickerTests:exclude-annotation:androidx.test.filters.FlakyTest
 *      --module-arg FlickerTests:include-annotation:android.platform.test.annotations.Postsubmit`
 *
 * To run only the flaky assertions add: `--
 *      --module-arg FlickerTests:include-annotation:androidx.test.filters.FlakyTest`
 *
 * Notes:
 *     1. Some default assertions (e.g., nav bar, status bar and screen covered)
 *        are inherited [RotationTransition]
 *     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)
@@ -60,15 +91,20 @@ class ChangeAppRotationTest(
            }
        }

    /** {@inheritDoc} */
    @FlakyTest(bugId = 190185577)
    @Test
    override fun focusDoesNotChange() {
        super.focusDoesNotChange()
    }

    /**
     * Checks that the [FlickerComponentName.ROTATION] layer appears during the transition,
     * doesn't flicker, and disappears before the transition is complete
     */
    @Presubmit
    @Test
    fun screenshotLayerBecomesInvisible() {
    fun rotationLayerAppearsAndVanishes() {
        testSpec.assertLayers {
            this.isVisible(testApp.component)
                .then()
@@ -78,18 +114,28 @@ class ChangeAppRotationTest(
        }
    }

    /**
     * Checks that the status bar window is visible and above the app windows in all WM
     * trace entries
     */
    @Presubmit
    @Test
    fun statusBarWindowIsVisible() {
        testSpec.statusBarWindowIsVisible()
    }

    /**
     * Checks that the status bar layer is visible at the start and end of the transition
     */
    @Presubmit
    @Test
    fun statusBarLayerIsVisible() {
        testSpec.statusBarLayerIsVisible()
    }

    /**
     * Checks the position of the status bar at the start and end of the transition
     */
    @Presubmit
    @Test
    fun statusBarLayerRotatesScales() {
@@ -97,18 +143,26 @@ class ChangeAppRotationTest(
            testSpec.config.startRotation, testSpec.config.endRotation)
    }

    /** {@inheritDoc} */
    @FlakyTest
    @Test
    override fun navBarLayerRotatesAndScales() {
        super.navBarLayerRotatesAndScales()
    }

    /** {@inheritDoc} */
    @FlakyTest
    @Test
    override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
        super.visibleLayersShownMoreThanOneConsecutiveEntry()

    companion object {
        /**
         * Creates the test configurations.
         *
         * See [FlickerTestParameterFactory.getConfigRotationTests] for configuring
         * repetitions, screen orientation and navigation modes.
         */
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<FlickerTestParameter> {
+37 −0
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@ import com.android.server.wm.flicker.startRotation
import com.android.server.wm.traces.common.FlickerComponentName
import org.junit.Test

/**
 * Base class for app rotation tests
 */
abstract class RotationTransition(protected val testSpec: FlickerTestParameter) {
    protected abstract val testApp: StandardAppHelper

@@ -54,6 +57,10 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter)
        }
    }

    /**
     * Entry point for the test runner. It will use this method to initialize and cache
     * flicker executions
     */
    @FlickerBuilderProvider
    fun buildFlicker(): FlickerBuilder {
        return FlickerBuilder(instrumentation).apply {
@@ -61,18 +68,28 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter)
        }
    }

    /**
     * Checks that the navigation bar window is visible and above the app windows in all WM
     * trace entries
     */
    @Presubmit
    @Test
    open fun navBarWindowIsVisible() {
        testSpec.navBarWindowIsVisible()
    }

    /**
     * Checks that the navigation bar layer is visible at the start and end of the transition
     */
    @Presubmit
    @Test
    open fun navBarLayerIsVisible() {
        testSpec.navBarLayerIsVisible()
    }

    /**
     * Checks the position of the navigation bar at the start and end of the transition
     */
    @Presubmit
    @Test
    open fun navBarLayerRotatesAndScales() {
@@ -80,6 +97,10 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter)
            testSpec.config.startRotation, testSpec.config.endRotation)
    }

    /**
     * Checks that all layers that are visible on the trace, are visible for at least 2
     * consecutive entries.
     */
    @Presubmit
    @Test
    open fun visibleLayersShownMoreThanOneConsecutiveEntry() {
@@ -93,6 +114,10 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter)
        }
    }

    /**
     * Checks that all windows that are visible on the trace, are visible for at least 2
     * consecutive entries.
     */
    @Presubmit
    @Test
    open fun visibleWindowsShownMoreThanOneConsecutiveEntry() {
@@ -101,10 +126,16 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter)
        }
    }

    /**
     * Checks that all parts of the screen are covered during the transition
     */
    @Presubmit
    @Test
    open fun entireScreenCovered() = testSpec.entireScreenCovered()

    /**
     * Checks that the focus doesn't change during animation
     */
    @Presubmit
    @Test
    open fun focusDoesNotChange() {
@@ -113,6 +144,9 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter)
        }
    }

    /**
     * Checks that [testApp] layer covers the entire screen at the start of the transition
     */
    @Presubmit
    @Test
    open fun appLayerRotates_StartingPos() {
@@ -123,6 +157,9 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter)
        }
    }

    /**
     * Checks that [testApp] layer covers the entire screen at the end of the transition
     */
    @Presubmit
    @Test
    open fun appLayerRotates_EndingPos() {
+78 −12
Original line number Diff line number Diff line
@@ -35,8 +35,41 @@ import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized

/**
 * Cycle through supported app rotations using seamless rotations.
 * Test opening an app and cycling through app rotations using seamless rotations
 *
 * Currently runs:
 *      0 -> 90 degrees
 *      0 -> 90 degrees (with starved UI thread)
 *      90 -> 0 degrees
 *      90 -> 0 degrees (with starved UI thread)
 *
 * Actions:
 *     Launch an app in fullscreen and supporting seamless rotation (via intent)
 *     Set initial device orientation
 *     Start tracing
 *     Change device orientation
 *     Stop tracing
 *
 * To run this test: `atest FlickerTests:SeamlessAppRotationTest`
 *
 * To run only the presubmit assertions add: `--
 *      --module-arg FlickerTests:exclude-annotation:androidx.test.filters.FlakyTest
 *      --module-arg FlickerTests:include-annotation:android.platform.test.annotations.Presubmit`
 *
 * To run only the postsubmit assertions add: `--
 *      --module-arg FlickerTests:exclude-annotation:androidx.test.filters.FlakyTest
 *      --module-arg FlickerTests:include-annotation:android.platform.test.annotations.Postsubmit`
 *
 * To run only the flaky assertions add: `--
 *      --module-arg FlickerTests:include-annotation:androidx.test.filters.FlakyTest`
 *
 * Notes:
 *     1. Some default assertions (e.g., nav bar, status bar and screen covered)
 *        are inherited [RotationTransition]
 *     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)
@@ -61,6 +94,9 @@ class SeamlessAppRotationTest(
            }
        }

    /**
     * Checks that [testApp] window is always in full screen
     */
    @Presubmit
    @Test
    fun appWindowFullScreen() {
@@ -75,6 +111,9 @@ class SeamlessAppRotationTest(
        }
    }

    /**
     * Checks that [testApp] window is always with seamless rotation
     */
    @Presubmit
    @Test
    fun appWindowSeamlessRotation() {
@@ -90,6 +129,9 @@ class SeamlessAppRotationTest(
        }
    }

    /**
     * Checks that [testApp] window is always visible
     */
    @Presubmit
    @Test
    fun appLayerAlwaysVisible() {
@@ -98,6 +140,9 @@ class SeamlessAppRotationTest(
        }
    }

    /**
     * Checks that [testApp] layer covers the entire screen during the whole transition
     */
    @Presubmit
    @Test
    fun appLayerRotates() {
@@ -110,6 +155,10 @@ class SeamlessAppRotationTest(
        }
    }

    /**
     * Checks that the [FlickerComponentName.STATUS_BAR] window is invisible during the whole
     * transition
     */
    @Presubmit
    @Test
    fun statusBarWindowIsAlwaysInvisible() {
@@ -118,6 +167,10 @@ class SeamlessAppRotationTest(
        }
    }

    /**
     * Checks that the [FlickerComponentName.STATUS_BAR] layer is invisible during the whole
     * transition
     */
    @Presubmit
    @Test
    fun statusBarLayerIsAlwaysInvisible() {
@@ -126,13 +179,12 @@ class SeamlessAppRotationTest(
        }
    }

    /** {@inheritDoc} */
    @FlakyTest
    @Test
    override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales()

    companion object {
        private val testFactory = FlickerTestParameterFactory.getInstance()

        private val Map<String, Any?>.starveUiThread
            get() = this.getOrDefault(ActivityOptions.EXTRA_STARVE_UI_THREAD, false) as Boolean

@@ -144,9 +196,17 @@ class SeamlessAppRotationTest(
            return config
        }

        /**
         * Creates the test configurations for seamless rotation based on the default rotation
         * tests from [FlickerTestParameterFactory.getConfigRotationTests], but adding an
         * additional flag ([ActivityOptions.EXTRA_STARVE_UI_THREAD]) to indicate if the app
         * should starve the UI thread of not
         */
        @JvmStatic
        private fun getConfigurations(): List<FlickerTestParameter> {
            return testFactory.getConfigRotationTests(repetitions = 2).flatMap {
            return FlickerTestParameterFactory.getInstance()
                .getConfigRotationTests(repetitions = 2)
                .flatMap {
                    val defaultRun = it.createConfig(starveUiThread = false)
                    val busyUiRun = it.createConfig(starveUiThread = true)
                    listOf(
@@ -158,6 +218,12 @@ class SeamlessAppRotationTest(
                }
        }

        /**
         * Creates the test configurations.
         *
         * See [FlickerTestParameterFactory.getConfigRotationTests] for configuring
         * repetitions, screen orientation and navigation modes.
         */
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<FlickerTestParameter> {