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

Commit 628b65f9 authored by Nataniel Borges's avatar Nataniel Borges
Browse files

Update app pairs tests to new DSL format

Move the existing assertions into presubmit and flaky blocks

Bug: 162923992
Test: atest FlickerTests
Change-Id: I08071058fdaec33f65e03bd97d41c4bc91125040
parent 0d56c0f5
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.wm.shell.flicker.apppairs

import android.os.Bundle
import android.platform.test.annotations.Presubmit
import android.os.SystemClock
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
@@ -40,7 +39,6 @@ import org.junit.runners.Parameterized
 * Test cold launch app from launcher.
 * To run this test: `atest WMShellFlickerTests:AppPairsTestCannotPairNonResizeableApps`
 */
@Presubmit
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -51,10 +49,9 @@ class AppPairsTestCannotPairNonResizeableApps(
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): List<Array<Any>> {
            val testTag = "testAppPairs_cannotPairNonResizeableApps"
            val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration ->
                withTestName {
                    buildTestTag(testTag, configuration)
                    buildTestTag(configuration)
                }
                transitions {
                    nonResizeableApp?.launchViaIntent(wmHelper)
@@ -64,21 +61,24 @@ class AppPairsTestCannotPairNonResizeableApps(
                    SystemClock.sleep(AppPairsHelper.TIMEOUT_MS)
                }
                assertions {
                    presubmit {
                        layersTrace {
                            appPairsDividerIsInvisible()
                        }
                        windowManagerTrace {
                        end("onlyResizeableAppWindowVisible") {
                            val nonResizeableApp = nonResizeableApp
                            require(nonResizeableApp != null) {
                                "Non resizeable app not initialized"
                            }

                            end("onlyResizeableAppWindowVisible") {
                                isVisible(nonResizeableApp.defaultWindowName)
                                isInvisible(primaryApp.defaultWindowName)
                            }
                        }
                    }
                }
            }

            return FlickerTestRunnerFactory.getInstance().buildTest(instrumentation,
                transition, testSpec, repetitions = AppPairsHelper.TEST_REPETITIONS)
+20 −16
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.wm.shell.flicker.apppairs

import android.os.Bundle
import android.os.SystemClock
import android.platform.test.annotations.Presubmit
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import com.android.server.wm.flicker.APP_PAIR_SPLIT_DIVIDER
@@ -38,7 +37,6 @@ import org.junit.runners.Parameterized
 * Test cold launch app from launcher.
 * To run this test: `atest WMShellFlickerTests:AppPairsTestPairPrimaryAndSecondaryApps`
 */
@Presubmit
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -49,10 +47,9 @@ class AppPairsTestPairPrimaryAndSecondaryApps(
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): List<Array<Any>> {
            val testTag = "testAppPairs_pairPrimaryAndSecondaryApps"
            val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration ->
                withTestName {
                    buildTestTag(testTag, configuration)
                    buildTestTag(configuration)
                }
                transitions {
                    // TODO pair apps through normal UX flow
@@ -61,9 +58,21 @@ class AppPairsTestPairPrimaryAndSecondaryApps(
                    SystemClock.sleep(AppPairsHelper.TIMEOUT_MS)
                }
                assertions {
                    presubmit {
                        layersTrace {
                            appPairsDividerIsVisible()
                        end("appsEndingBounds", enabled = false) {
                        }
                        windowManagerTrace {
                            end("bothAppWindowsVisible") {
                                isVisible(primaryApp.defaultWindowName)
                                isVisible(secondaryApp.defaultWindowName)
                            }
                        }
                    }

                    flaky {
                        layersTrace {
                            end("appsEndingBounds") {
                                val dividerRegion = entry.getVisibleBounds(APP_PAIR_SPLIT_DIVIDER)
                                this.hasVisibleRegion(primaryApp.defaultWindowName,
                                    appPairsHelper.getPrimaryBounds(dividerRegion))
@@ -71,11 +80,6 @@ class AppPairsTestPairPrimaryAndSecondaryApps(
                                        appPairsHelper.getSecondaryBounds(dividerRegion))
                            }
                        }
                    windowManagerTrace {
                        end("bothAppWindowsVisible") {
                            isVisible(primaryApp.defaultWindowName)
                            isVisible(secondaryApp.defaultWindowName)
                        }
                    }
                }
            }
+23 −19
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.wm.shell.flicker.apppairs

import android.os.Bundle
import android.os.SystemClock
import android.platform.test.annotations.Presubmit
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import com.android.server.wm.flicker.APP_PAIR_SPLIT_DIVIDER
@@ -38,7 +37,6 @@ import org.junit.runners.Parameterized
 * Test cold launch app from launcher.
 * To run this test: `atest WMShellFlickerTests:AppPairsTestUnpairPrimaryAndSecondaryApps`
 */
@Presubmit
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -49,10 +47,9 @@ class AppPairsTestUnpairPrimaryAndSecondaryApps(
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): List<Array<Any>> {
            val testTag = "testAppPairs_unpairPrimaryAndSecondaryApps"
            val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration ->
                withTestName {
                    buildTestTag(testTag, configuration)
                    buildTestTag(configuration)
                }
                setup {
                    executeShellCommand(
@@ -66,25 +63,32 @@ class AppPairsTestUnpairPrimaryAndSecondaryApps(
                    SystemClock.sleep(AppPairsHelper.TIMEOUT_MS)
                }
                assertions {
                    presubmit {
                        layersTrace {
                            appPairsDividerIsInvisible()
                        start("appsStartingBounds", enabled = false) {
                        }
                        windowManagerTrace {
                            end("bothAppWindowsInvisible") {
                                isInvisible(primaryApp.defaultWindowName)
                                isInvisible(secondaryApp.defaultWindowName)
                            }
                        }
                    }

                    flaky {
                        layersTrace {
                            start("appsStartingBounds") {
                                val dividerRegion = entry.getVisibleBounds(APP_PAIR_SPLIT_DIVIDER)
                                this.hasVisibleRegion(primaryApp.defaultWindowName,
                                    appPairsHelper.getPrimaryBounds(dividerRegion))
                                    .hasVisibleRegion(secondaryApp.defaultWindowName,
                                        appPairsHelper.getSecondaryBounds(dividerRegion))
                            }
                        end("appsEndingBounds", enabled = false) {
                            end("appsEndingBounds") {
                                this.notExists(primaryApp.defaultWindowName)
                                    .notExists(secondaryApp.defaultWindowName)
                            }
                        }
                    windowManagerTrace {
                        end("bothAppWindowsInvisible") {
                            isInvisible(primaryApp.defaultWindowName)
                            isInvisible(secondaryApp.defaultWindowName)
                        }
                    }
                }
            }
+22 −19
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.wm.shell.flicker.apppairs

import android.os.Bundle
import android.os.SystemClock
import android.platform.test.annotations.Presubmit
import android.view.Surface
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
@@ -46,7 +45,6 @@ import org.junit.runners.Parameterized
 * Test open apps to app pairs and rotate.
 * To run this test: `atest WMShellFlickerTests:RotateTwoLaunchedAppsInAppPairsMode`
 */
@Presubmit
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -60,7 +58,7 @@ class RotateTwoLaunchedAppsInAppPairsMode(
        fun getParams(): Collection<Array<Any>> {
            val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration ->
                withTestName {
                    buildTestTag("testRotateTwoLaunchedAppsInAppPairsMode", configuration)
                    buildTestTag(configuration)
                }
                transitions {
                    executeShellCommand(composePairsCommand(
@@ -69,17 +67,7 @@ class RotateTwoLaunchedAppsInAppPairsMode(
                    setRotation(configuration.endRotation)
                }
                assertions {
                    layersTrace {
                        navBarLayerRotatesAndScales(Surface.ROTATION_0, configuration.endRotation,
                            enabled = false)
                        statusBarLayerRotatesScales(Surface.ROTATION_0, configuration.endRotation,
                            enabled = false)
                        appPairsDividerIsVisible(enabled = false)
                        appPairsPrimaryBoundsIsVisible(configuration.endRotation,
                            primaryApp.defaultWindowName, bugId = 172776659)
                        appPairsSecondaryBoundsIsVisible(configuration.endRotation,
                            secondaryApp.defaultWindowName, bugId = 172776659)
                    }
                    presubmit {
                        windowManagerTrace {
                            navBarWindowIsAlwaysVisible()
                            statusBarWindowIsAlwaysVisible()
@@ -89,6 +77,21 @@ class RotateTwoLaunchedAppsInAppPairsMode(
                            }
                        }
                    }

                    flaky {
                        layersTrace {
                            appPairsDividerIsVisible()
                            navBarLayerRotatesAndScales(Surface.ROTATION_0,
                                configuration.endRotation)
                            statusBarLayerRotatesScales(Surface.ROTATION_0,
                                configuration.endRotation)
                            appPairsPrimaryBoundsIsVisible(configuration.endRotation,
                                primaryApp.defaultWindowName, bugId = 172776659)
                            appPairsSecondaryBoundsIsVisible(configuration.endRotation,
                                secondaryApp.defaultWindowName, bugId = 172776659)
                        }
                    }
                }
            }

            return FlickerTestRunnerFactory.getInstance().buildTest(instrumentation,
+31 −16
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ class RotateTwoLaunchedAppsRotateAndEnterAppPairsMode(
        fun getParams(): Collection<Array<Any>> {
            val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration ->
                withTestName {
                    buildTestTag("testRotateAndEnterAppPairsMode", configuration)
                    buildTestTag(configuration)
                }
                transitions {
                    this.setRotation(configuration.endRotation)
@@ -71,15 +71,16 @@ class RotateTwoLaunchedAppsRotateAndEnterAppPairsMode(
                    SystemClock.sleep(AppPairsHelper.TIMEOUT_MS)
                }
                assertions {
                    val isRotated = configuration.startRotation.isRotated()
                    presubmit {
                        layersTrace {
                        navBarLayerRotatesAndScales(Surface.ROTATION_0, configuration.endRotation,
                            enabled = !configuration.startRotation.isRotated())
                        statusBarLayerRotatesScales(Surface.ROTATION_0, configuration.endRotation)
                            statusBarLayerRotatesScales(Surface.ROTATION_0,
                                configuration.endRotation)
                            appPairsDividerIsVisible()
                        appPairsPrimaryBoundsIsVisible(configuration.endRotation,
                            primaryApp.defaultWindowName, 172776659)
                        appPairsSecondaryBoundsIsVisible(configuration.endRotation,
                            secondaryApp.defaultWindowName, 172776659)
                            if (!isRotated) {
                                navBarLayerRotatesAndScales(Surface.ROTATION_0,
                                    configuration.endRotation)
                            }
                        }
                        windowManagerTrace {
                            navBarWindowIsAlwaysVisible()
@@ -90,6 +91,20 @@ class RotateTwoLaunchedAppsRotateAndEnterAppPairsMode(
                            }
                        }
                    }
                    flaky {
                        layersTrace {
                            appPairsPrimaryBoundsIsVisible(configuration.endRotation,
                                primaryApp.defaultWindowName, 172776659)
                            appPairsSecondaryBoundsIsVisible(configuration.endRotation,
                                secondaryApp.defaultWindowName, 172776659)

                            if (isRotated) {
                                navBarLayerRotatesAndScales(Surface.ROTATION_0,
                                    configuration.endRotation)
                            }
                        }
                    }
                }
            }

            return FlickerTestRunnerFactory.getInstance().buildTest(instrumentation,