From 628b65f91e010bcd1a652186ac52cb85dfa46e8a Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Mon, 1 Feb 2021 20:15:30 +0100 Subject: [PATCH] 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 --- ...AppPairsTestCannotPairNonResizeableApps.kt | 22 ++++----- ...AppPairsTestPairPrimaryAndSecondaryApps.kt | 36 +++++++------- ...pPairsTestUnpairPrimaryAndSecondaryApps.kt | 42 +++++++++-------- .../RotateTwoLaunchedAppsInAppPairsMode.kt | 41 ++++++++-------- ...oLaunchedAppsRotateAndEnterAppPairsMode.kt | 47 ++++++++++++------- 5 files changed, 107 insertions(+), 81 deletions(-) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestCannotPairNonResizeableApps.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestCannotPairNonResizeableApps.kt index d25774935e867..c3fd663953663 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestCannotPairNonResizeableApps.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestCannotPairNonResizeableApps.kt @@ -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> { - val testTag = "testAppPairs_cannotPairNonResizeableApps" val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration -> withTestName { - buildTestTag(testTag, configuration) + buildTestTag(configuration) } transitions { nonResizeableApp?.launchViaIntent(wmHelper) @@ -64,17 +61,20 @@ class AppPairsTestCannotPairNonResizeableApps( SystemClock.sleep(AppPairsHelper.TIMEOUT_MS) } assertions { - layersTrace { - appPairsDividerIsInvisible() - } - windowManagerTrace { - end("onlyResizeableAppWindowVisible") { + presubmit { + layersTrace { + appPairsDividerIsInvisible() + } + windowManagerTrace { val nonResizeableApp = nonResizeableApp require(nonResizeableApp != null) { "Non resizeable app not initialized" } - isVisible(nonResizeableApp.defaultWindowName) - isInvisible(primaryApp.defaultWindowName) + + end("onlyResizeableAppWindowVisible") { + isVisible(nonResizeableApp.defaultWindowName) + isInvisible(primaryApp.defaultWindowName) + } } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestPairPrimaryAndSecondaryApps.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestPairPrimaryAndSecondaryApps.kt index 257350b6950bf..7a2a5e482d983 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestPairPrimaryAndSecondaryApps.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestPairPrimaryAndSecondaryApps.kt @@ -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> { - 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,20 +58,27 @@ class AppPairsTestPairPrimaryAndSecondaryApps( SystemClock.sleep(AppPairsHelper.TIMEOUT_MS) } assertions { - layersTrace { - appPairsDividerIsVisible() - end("appsEndingBounds", enabled = false) { - val dividerRegion = entry.getVisibleBounds(APP_PAIR_SPLIT_DIVIDER) - this.hasVisibleRegion(primaryApp.defaultWindowName, - appPairsHelper.getPrimaryBounds(dividerRegion)) - .hasVisibleRegion(secondaryApp.defaultWindowName, - appPairsHelper.getSecondaryBounds(dividerRegion)) + presubmit { + layersTrace { + appPairsDividerIsVisible() + } + windowManagerTrace { + end("bothAppWindowsVisible") { + isVisible(primaryApp.defaultWindowName) + isVisible(secondaryApp.defaultWindowName) + } } } - 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)) + .hasVisibleRegion(secondaryApp.defaultWindowName, + appPairsHelper.getSecondaryBounds(dividerRegion)) + } } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestUnpairPrimaryAndSecondaryApps.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestUnpairPrimaryAndSecondaryApps.kt index 0b001f5ac1b6a..d8dc4c2b56f60 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestUnpairPrimaryAndSecondaryApps.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestUnpairPrimaryAndSecondaryApps.kt @@ -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> { - val testTag = "testAppPairs_unpairPrimaryAndSecondaryApps" val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration -> withTestName { - buildTestTag(testTag, configuration) + buildTestTag(configuration) } setup { executeShellCommand( @@ -66,24 +63,31 @@ class AppPairsTestUnpairPrimaryAndSecondaryApps( SystemClock.sleep(AppPairsHelper.TIMEOUT_MS) } assertions { - layersTrace { - appPairsDividerIsInvisible() - start("appsStartingBounds", enabled = false) { - val dividerRegion = entry.getVisibleBounds(APP_PAIR_SPLIT_DIVIDER) - this.hasVisibleRegion(primaryApp.defaultWindowName, - appPairsHelper.getPrimaryBounds(dividerRegion)) - .hasVisibleRegion(secondaryApp.defaultWindowName, - appPairsHelper.getSecondaryBounds(dividerRegion)) + presubmit { + layersTrace { + appPairsDividerIsInvisible() } - end("appsEndingBounds", enabled = false) { - this.notExists(primaryApp.defaultWindowName) - .notExists(secondaryApp.defaultWindowName) + windowManagerTrace { + end("bothAppWindowsInvisible") { + isInvisible(primaryApp.defaultWindowName) + isInvisible(secondaryApp.defaultWindowName) + } } } - 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") { + this.notExists(primaryApp.defaultWindowName) + .notExists(secondaryApp.defaultWindowName) + } } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppsInAppPairsMode.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppsInAppPairsMode.kt index aafa9bfbd6764..8aee005b7513e 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppsInAppPairsMode.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppsInAppPairsMode.kt @@ -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> { val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration -> withTestName { - buildTestTag("testRotateTwoLaunchedAppsInAppPairsMode", configuration) + buildTestTag(configuration) } transitions { executeShellCommand(composePairsCommand( @@ -69,23 +67,28 @@ 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() + end("bothAppWindowsVisible") { + isVisible(primaryApp.defaultWindowName) + .isVisible(secondaryApp.defaultWindowName) + } + } } - windowManagerTrace { - navBarWindowIsAlwaysVisible() - statusBarWindowIsAlwaysVisible() - end("bothAppWindowsVisible") { - isVisible(primaryApp.defaultWindowName) - .isVisible(secondaryApp.defaultWindowName) + + 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) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppsRotateAndEnterAppPairsMode.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppsRotateAndEnterAppPairsMode.kt index 19ca31fbee4a8..bc99c9430f138 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppsRotateAndEnterAppPairsMode.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppsRotateAndEnterAppPairsMode.kt @@ -62,7 +62,7 @@ class RotateTwoLaunchedAppsRotateAndEnterAppPairsMode( fun getParams(): Collection> { val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration -> withTestName { - buildTestTag("testRotateAndEnterAppPairsMode", configuration) + buildTestTag(configuration) } transitions { this.setRotation(configuration.endRotation) @@ -71,22 +71,37 @@ class RotateTwoLaunchedAppsRotateAndEnterAppPairsMode( SystemClock.sleep(AppPairsHelper.TIMEOUT_MS) } assertions { - layersTrace { - navBarLayerRotatesAndScales(Surface.ROTATION_0, configuration.endRotation, - enabled = !configuration.startRotation.isRotated()) - statusBarLayerRotatesScales(Surface.ROTATION_0, configuration.endRotation) - appPairsDividerIsVisible() - appPairsPrimaryBoundsIsVisible(configuration.endRotation, - primaryApp.defaultWindowName, 172776659) - appPairsSecondaryBoundsIsVisible(configuration.endRotation, - secondaryApp.defaultWindowName, 172776659) + val isRotated = configuration.startRotation.isRotated() + presubmit { + layersTrace { + statusBarLayerRotatesScales(Surface.ROTATION_0, + configuration.endRotation) + appPairsDividerIsVisible() + if (!isRotated) { + navBarLayerRotatesAndScales(Surface.ROTATION_0, + configuration.endRotation) + } + } + windowManagerTrace { + navBarWindowIsAlwaysVisible() + statusBarWindowIsAlwaysVisible() + end("bothAppWindowsVisible") { + isVisible(primaryApp.defaultWindowName) + isVisible(secondaryApp.defaultWindowName) + } + } } - windowManagerTrace { - navBarWindowIsAlwaysVisible() - statusBarWindowIsAlwaysVisible() - end("bothAppWindowsVisible") { - isVisible(primaryApp.defaultWindowName) - isVisible(secondaryApp.defaultWindowName) + flaky { + layersTrace { + appPairsPrimaryBoundsIsVisible(configuration.endRotation, + primaryApp.defaultWindowName, 172776659) + appPairsSecondaryBoundsIsVisible(configuration.endRotation, + secondaryApp.defaultWindowName, 172776659) + + if (isRotated) { + navBarLayerRotatesAndScales(Surface.ROTATION_0, + configuration.endRotation) + } } } }