diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonAssertions.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonAssertions.kt index 7ad75532ecedd..3282ece999ac8 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonAssertions.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonAssertions.kt @@ -18,12 +18,116 @@ package com.android.wm.shell.flicker import android.graphics.Region import android.view.Surface +import com.android.server.wm.flicker.dsl.LayersAssertionBuilder import com.android.server.wm.flicker.dsl.LayersAssertionBuilderLegacy import com.android.server.wm.flicker.APP_PAIR_SPLIT_DIVIDER import com.android.server.wm.flicker.DOCKED_STACK_DIVIDER import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.flicker.traces.layers.getVisibleBounds +@JvmOverloads +fun LayersAssertionBuilder.appPairsDividerIsVisible(bugId: Int = 0) { + end("appPairsDividerIsVisible", bugId) { + this.isVisible(APP_PAIR_SPLIT_DIVIDER) + } +} + +@JvmOverloads +fun LayersAssertionBuilder.appPairsDividerIsInvisible(bugId: Int = 0) { + end("appPairsDividerIsInVisible", bugId) { + this.notExists(APP_PAIR_SPLIT_DIVIDER) + } +} + +@JvmOverloads +fun LayersAssertionBuilder.appPairsDividerBecomesVisible(bugId: Int = 0) { + all("dividerLayerBecomesVisible", bugId) { + this.hidesLayer(DOCKED_STACK_DIVIDER) + .then() + .showsLayer(DOCKED_STACK_DIVIDER) + } +} + +@JvmOverloads +fun LayersAssertionBuilder.dockedStackDividerIsVisible(bugId: Int = 0) { + end("dockedStackDividerIsVisible", bugId) { + this.isVisible(DOCKED_STACK_DIVIDER) + } +} + +@JvmOverloads +fun LayersAssertionBuilder.dockedStackDividerBecomesVisible(bugId: Int = 0) { + all("dividerLayerBecomesVisible", bugId) { + this.hidesLayer(DOCKED_STACK_DIVIDER) + .then() + .showsLayer(DOCKED_STACK_DIVIDER) + } +} + +@JvmOverloads +fun LayersAssertionBuilder.dockedStackDividerBecomesInvisible(bugId: Int = 0) { + all("dividerLayerBecomesInvisible", bugId) { + this.showsLayer(DOCKED_STACK_DIVIDER) + .then() + .hidesLayer(DOCKED_STACK_DIVIDER) + } +} + +@JvmOverloads +fun LayersAssertionBuilder.dockedStackDividerIsInvisible(bugId: Int = 0) { + end("dockedStackDividerIsInvisible", bugId) { + this.notExists(DOCKED_STACK_DIVIDER) + } +} + +@JvmOverloads +fun LayersAssertionBuilder.appPairsPrimaryBoundsIsVisible( + rotation: Int, + primaryLayerName: String, + bugId: Int = 0 +) { + end("PrimaryAppBounds", bugId) { + val dividerRegion = entry.getVisibleBounds(APP_PAIR_SPLIT_DIVIDER) + this.hasVisibleRegion(primaryLayerName, getPrimaryRegion(dividerRegion, rotation)) + } +} + +@JvmOverloads +fun LayersAssertionBuilder.appPairsSecondaryBoundsIsVisible( + rotation: Int, + secondaryLayerName: String, + bugId: Int = 0 +) { + end("SecondaryAppBounds", bugId) { + val dividerRegion = entry.getVisibleBounds(APP_PAIR_SPLIT_DIVIDER) + this.hasVisibleRegion(secondaryLayerName, getSecondaryRegion(dividerRegion, rotation)) + } +} + +@JvmOverloads +fun LayersAssertionBuilder.dockedStackPrimaryBoundsIsVisible( + rotation: Int, + primaryLayerName: String, + bugId: Int = 0 +) { + end("PrimaryAppBounds", bugId) { + val dividerRegion = entry.getVisibleBounds(DOCKED_STACK_DIVIDER) + this.hasVisibleRegion(primaryLayerName, getPrimaryRegion(dividerRegion, rotation)) + } +} + +@JvmOverloads +fun LayersAssertionBuilder.dockedStackSecondaryBoundsIsVisible( + rotation: Int, + secondaryLayerName: String, + bugId: Int = 0 +) { + end("SecondaryAppBounds", bugId) { + val dividerRegion = entry.getVisibleBounds(DOCKED_STACK_DIVIDER) + this.hasVisibleRegion(secondaryLayerName, getSecondaryRegion(dividerRegion, rotation)) + } +} + @JvmOverloads fun LayersAssertionBuilderLegacy.appPairsDividerIsVisible( bugId: Int = 0, @@ -51,8 +155,8 @@ fun LayersAssertionBuilderLegacy.appPairsDividerBecomesVisible( ) { all("dividerLayerBecomesVisible", bugId, enabled) { this.hidesLayer(DOCKED_STACK_DIVIDER) - .then() - .showsLayer(DOCKED_STACK_DIVIDER) + .then() + .showsLayer(DOCKED_STACK_DIVIDER) } } @@ -73,8 +177,8 @@ fun LayersAssertionBuilderLegacy.dockedStackDividerBecomesVisible( ) { all("dividerLayerBecomesVisible", bugId, enabled) { this.hidesLayer(DOCKED_STACK_DIVIDER) - .then() - .showsLayer(DOCKED_STACK_DIVIDER) + .then() + .showsLayer(DOCKED_STACK_DIVIDER) } } @@ -85,8 +189,8 @@ fun LayersAssertionBuilderLegacy.dockedStackDividerBecomesInvisible( ) { all("dividerLayerBecomesInvisible", bugId, enabled) { this.showsLayer(DOCKED_STACK_DIVIDER) - .then() - .hidesLayer(DOCKED_STACK_DIVIDER) + .then() + .hidesLayer(DOCKED_STACK_DIVIDER) } } 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) + } } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt index 89c6663df3433..c5447c1ccf71c 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt @@ -17,8 +17,11 @@ package com.android.server.wm.flicker import android.platform.helpers.IAppHelper +import com.android.server.wm.flicker.dsl.EventLogAssertionBuilder import com.android.server.wm.flicker.dsl.EventLogAssertionBuilderLegacy +import com.android.server.wm.flicker.dsl.LayersAssertionBuilder import com.android.server.wm.flicker.dsl.LayersAssertionBuilderLegacy +import com.android.server.wm.flicker.dsl.WmAssertionBuilder import com.android.server.wm.flicker.dsl.WmAssertionBuilderLegacy import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper.Companion.NAV_BAR_LAYER_NAME @@ -31,115 +34,88 @@ const val DOCKED_STACK_DIVIDER = "DockedStackDivider" const val WALLPAPER_TITLE = "Wallpaper" @JvmOverloads -fun WmAssertionBuilderLegacy.statusBarWindowIsAlwaysVisible( - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all("statusBarWindowIsAlwaysVisible", bugId, enabled) { - this.showsAboveAppWindow(STATUS_BAR_WINDOW_NAME) +fun WmAssertionBuilder.statusBarWindowIsAlwaysVisible(bugId: Int = 0) { + all("statusBarWindowIsAlwaysVisible", bugId) { + this.showsAboveAppWindow(NAV_BAR_LAYER_NAME) } } @JvmOverloads -fun WmAssertionBuilderLegacy.navBarWindowIsAlwaysVisible( - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all("navBarWindowIsAlwaysVisible", bugId, enabled) { - this.showsAboveAppWindow(NAV_BAR_WINDOW_NAME) +fun WmAssertionBuilder.navBarWindowIsAlwaysVisible(bugId: Int = 0) { + all("navBarWindowIsAlwaysVisible", bugId) { + this.showsAboveAppWindow(NAV_BAR_LAYER_NAME) } } -fun WmAssertionBuilderLegacy.visibleWindowsShownMoreThanOneConsecutiveEntry( +fun WmAssertionBuilder.visibleWindowsShownMoreThanOneConsecutiveEntry( ignoreWindows: List = emptyList(), - bugId: Int = 0, - enabled: Boolean = bugId == 0 + bugId: Int = 0 ) { - all("visibleWindowsShownMoreThanOneConsecutiveEntry", bugId, enabled) { + all("visibleWindowsShownMoreThanOneConsecutiveEntry", bugId) { this.visibleWindowsShownMoreThanOneConsecutiveEntry(ignoreWindows) } } -fun WmAssertionBuilderLegacy.launcherReplacesAppWindowAsTopWindow( - testApp: IAppHelper, - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all("launcherReplacesAppWindowAsTopWindow", bugId, enabled) { +fun WmAssertionBuilder.launcherReplacesAppWindowAsTopWindow(testApp: IAppHelper, bugId: Int = 0) { + all("launcherReplacesAppWindowAsTopWindow", bugId) { this.showsAppWindowOnTop(testApp.getPackage()) .then() .showsAppWindowOnTop("Launcher") } } -fun WmAssertionBuilderLegacy.wallpaperWindowBecomesVisible( - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all("wallpaperWindowBecomesVisible", bugId, enabled) { +fun WmAssertionBuilder.wallpaperWindowBecomesVisible(bugId: Int = 0) { + all("wallpaperWindowBecomesVisible", bugId) { this.hidesBelowAppWindow(WALLPAPER_TITLE) .then() .showsBelowAppWindow(WALLPAPER_TITLE) } } -fun WmAssertionBuilderLegacy.wallpaperWindowBecomesInvisible( - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all("wallpaperWindowBecomesInvisible", bugId, enabled) { +fun WmAssertionBuilder.wallpaperWindowBecomesInvisible(bugId: Int = 0) { + all("wallpaperWindowBecomesInvisible", bugId) { this.showsBelowAppWindow("Wallpaper") .then() .hidesBelowAppWindow("Wallpaper") } } -fun WmAssertionBuilderLegacy.appWindowAlwaysVisibleOnTop( +fun WmAssertionBuilder.appWindowAlwaysVisibleOnTop( packageName: String, - bugId: Int = 0, - enabled: Boolean = bugId == 0 + bugId: Int = 0 ) { - all("appWindowAlwaysVisibleOnTop", bugId, enabled) { + all("appWindowAlwaysVisibleOnTop", bugId) { this.showsAppWindowOnTop(packageName) } } -fun WmAssertionBuilderLegacy.appWindowBecomesVisible( - appName: String, - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all("appWindowBecomesVisible", bugId, enabled) { +fun WmAssertionBuilder.appWindowBecomesVisible(appName: String, bugId: Int = 0) { + all("appWindowBecomesVisible", bugId) { this.hidesAppWindow(appName) .then() .showsAppWindow(appName) } } -fun WmAssertionBuilderLegacy.appWindowBecomesInVisible( - appName: String, - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all("appWindowBecomesInVisible", bugId, enabled) { +fun WmAssertionBuilder.appWindowBecomesInVisible(appName: String, bugId: Int = 0) { + all("appWindowBecomesInVisible", bugId) { this.showsAppWindow(appName) - .then() - .hidesAppWindow(appName) + .then() + .hidesAppWindow(appName) } } @JvmOverloads -fun LayersAssertionBuilderLegacy.noUncoveredRegions( +fun LayersAssertionBuilder.noUncoveredRegions( beginRotation: Int, endRotation: Int = beginRotation, allStates: Boolean = true, - bugId: Int = 0, - enabled: Boolean = bugId == 0 + bugId: Int = 0 ) { val startingBounds = WindowUtils.getDisplayBounds(beginRotation) val endingBounds = WindowUtils.getDisplayBounds(endRotation) if (allStates) { - all("noUncoveredRegions", bugId, enabled) { + all("noUncoveredRegions", bugId) { if (startingBounds == endingBounds) { this.coversAtLeastRegion(startingBounds) } else { @@ -158,6 +134,284 @@ fun LayersAssertionBuilderLegacy.noUncoveredRegions( } } +@JvmOverloads +fun LayersAssertionBuilder.navBarLayerIsAlwaysVisible( + rotatesScreen: Boolean = false, + bugId: Int = 0 +) { + if (rotatesScreen) { + all("navBarLayerIsAlwaysVisible", bugId) { + this.showsLayer(NAV_BAR_LAYER_NAME) + .then() + .hidesLayer(NAV_BAR_LAYER_NAME) + .then() + .showsLayer(NAV_BAR_LAYER_NAME) + } + } else { + all("navBarLayerIsAlwaysVisible", bugId) { + this.showsLayer(NAV_BAR_LAYER_NAME) + } + } +} + +@JvmOverloads +fun LayersAssertionBuilder.statusBarLayerIsAlwaysVisible( + rotatesScreen: Boolean = false, + bugId: Int = 0 +) { + if (rotatesScreen) { + all("statusBarLayerIsAlwaysVisible", bugId) { + this.showsLayer(STATUS_BAR_WINDOW_NAME) + .then() + hidesLayer(STATUS_BAR_WINDOW_NAME) + .then() + .showsLayer(STATUS_BAR_WINDOW_NAME) + } + } else { + all("statusBarLayerIsAlwaysVisible", bugId) { + this.showsLayer(STATUS_BAR_WINDOW_NAME) + } + } +} + +@JvmOverloads +fun LayersAssertionBuilder.navBarLayerRotatesAndScales( + beginRotation: Int, + endRotation: Int = beginRotation, + bugId: Int = 0 +) { + val startingPos = WindowUtils.getNavigationBarPosition(beginRotation) + val endingPos = WindowUtils.getNavigationBarPosition(endRotation) + + start("navBarLayerRotatesAndScales_StartingPos", bugId) { + this.hasVisibleRegion(NAV_BAR_LAYER_NAME, startingPos) + } + end("navBarLayerRotatesAndScales_EndingPost", bugId) { + this.hasVisibleRegion(NAV_BAR_LAYER_NAME, endingPos) + } + + /*if (startingPos == endingPos) { + all("navBarLayerRotatesAndScales", enabled = false, bugId = 167747321) { + this.hasVisibleRegion(NAVIGATION_BAR_WINDOW_TITLE, startingPos) + } + }*/ +} + +@JvmOverloads +fun LayersAssertionBuilder.statusBarLayerRotatesScales( + beginRotation: Int, + endRotation: Int = beginRotation, + bugId: Int = 0 +) { + val startingPos = WindowUtils.getStatusBarPosition(beginRotation) + val endingPos = WindowUtils.getStatusBarPosition(endRotation) + + start("statusBarLayerRotatesScales_StartingPos", bugId) { + this.hasVisibleRegion(STATUS_BAR_WINDOW_NAME, startingPos) + } + end("statusBarLayerRotatesScales_EndingPos", bugId) { + this.hasVisibleRegion(STATUS_BAR_WINDOW_NAME, endingPos) + } +} + +fun LayersAssertionBuilder.visibleLayersShownMoreThanOneConsecutiveEntry( + ignoreLayers: List = emptyList(), + bugId: Int = 0 +) { + all("visibleLayersShownMoreThanOneConsecutiveEntry", bugId) { + this.visibleLayersShownMoreThanOneConsecutiveEntry(ignoreLayers) + } +} + +fun LayersAssertionBuilder.appLayerReplacesWallpaperLayer(appName: String, bugId: Int = 0) { + all("appLayerReplacesWallpaperLayer", bugId) { + this.showsLayer("Wallpaper") + .then() + .replaceVisibleLayer("Wallpaper", appName) + } +} + +fun LayersAssertionBuilder.wallpaperLayerReplacesAppLayer(testApp: IAppHelper, bugId: Int = 0) { + all("appLayerReplacesWallpaperLayer", bugId) { + this.showsLayer(testApp.getPackage()) + .then() + .replaceVisibleLayer(testApp.getPackage(), WALLPAPER_TITLE) + } +} + +fun LayersAssertionBuilder.layerAlwaysVisible(packageName: String, bugId: Int = 0) { + all("layerAlwaysVisible", bugId) { + this.showsLayer(packageName) + } +} + +fun LayersAssertionBuilder.layerBecomesVisible(packageName: String, bugId: Int = 0) { + all("layerBecomesVisible", bugId) { + this.hidesLayer(packageName) + .then() + .showsLayer(packageName) + } +} + +fun LayersAssertionBuilder.layerBecomesInvisible(packageName: String, bugId: Int = 0) { + all("layerBecomesInvisible", bugId) { + this.showsLayer(packageName) + .then() + .hidesLayer(packageName) + } +} + +fun EventLogAssertionBuilder.focusChanges(vararg windows: String, bugId: Int = 0) { + all("focusChanges", bugId) { + this.focusChanges(windows) + } +} + +fun EventLogAssertionBuilder.focusDoesNotChange(bugId: Int = 0) { + all("focusDoesNotChange", bugId) { + this.focusDoesNotChange() + } +} + +@JvmOverloads +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") +fun WmAssertionBuilderLegacy.statusBarWindowIsAlwaysVisible( + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("statusBarWindowIsAlwaysVisible", bugId, enabled) { + this.showsAboveAppWindow(STATUS_BAR_WINDOW_NAME) + } +} + +@JvmOverloads +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") +fun WmAssertionBuilderLegacy.navBarWindowIsAlwaysVisible( + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("navBarWindowIsAlwaysVisible", bugId, enabled) { + this.showsAboveAppWindow(NAV_BAR_WINDOW_NAME) + } +} + +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") +fun WmAssertionBuilderLegacy.visibleWindowsShownMoreThanOneConsecutiveEntry( + ignoreWindows: List = emptyList(), + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("visibleWindowsShownMoreThanOneConsecutiveEntry", bugId, enabled) { + this.visibleWindowsShownMoreThanOneConsecutiveEntry(ignoreWindows) + } +} + +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") +fun WmAssertionBuilderLegacy.launcherReplacesAppWindowAsTopWindow( + testApp: IAppHelper, + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("launcherReplacesAppWindowAsTopWindow", bugId, enabled) { + this.showsAppWindowOnTop(testApp.getPackage()) + .then() + .showsAppWindowOnTop("Launcher") + } +} + +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") +fun WmAssertionBuilderLegacy.wallpaperWindowBecomesVisible( + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("wallpaperWindowBecomesVisible", bugId, enabled) { + this.hidesBelowAppWindow(WALLPAPER_TITLE) + .then() + .showsBelowAppWindow(WALLPAPER_TITLE) + } +} + +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") +fun WmAssertionBuilderLegacy.wallpaperWindowBecomesInvisible( + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("wallpaperWindowBecomesInvisible", bugId, enabled) { + this.showsBelowAppWindow("Wallpaper") + .then() + .hidesBelowAppWindow("Wallpaper") + } +} + +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") +fun WmAssertionBuilderLegacy.appWindowAlwaysVisibleOnTop( + packageName: String, + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("appWindowAlwaysVisibleOnTop", bugId, enabled) { + this.showsAppWindowOnTop(packageName) + } +} + +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") +fun WmAssertionBuilderLegacy.appWindowBecomesVisible( + appName: String, + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("appWindowBecomesVisible", bugId, enabled) { + this.hidesAppWindow(appName) + .then() + .showsAppWindow(appName) + } +} + +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") +fun WmAssertionBuilderLegacy.appWindowBecomesInVisible( + appName: String, + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("appWindowBecomesInVisible", bugId, enabled) { + this.showsAppWindow(appName) + .then() + .hidesAppWindow(appName) + } +} + +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") +@JvmOverloads +fun LayersAssertionBuilderLegacy.noUncoveredRegions( + beginRotation: Int, + endRotation: Int = beginRotation, + allStates: Boolean = true, + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + val startingBounds = WindowUtils.getDisplayBounds(beginRotation) + val endingBounds = WindowUtils.getDisplayBounds(endRotation) + if (allStates) { + all("noUncoveredRegions", bugId, enabled) { + if (startingBounds == endingBounds) { + this.coversAtLeastRegion(startingBounds) + } else { + this.coversAtLeastRegion(startingBounds) + .then() + .coversAtLeastRegion(endingBounds) + } + } + } else { + start("noUncoveredRegions_StartingPos") { + this.coversAtLeastRegion(startingBounds) + } + end("noUncoveredRegions_EndingPos") { + this.coversAtLeastRegion(endingBounds) + } + } +} + +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") @JvmOverloads fun LayersAssertionBuilderLegacy.navBarLayerIsAlwaysVisible( rotatesScreen: Boolean = false, @@ -167,10 +421,10 @@ fun LayersAssertionBuilderLegacy.navBarLayerIsAlwaysVisible( if (rotatesScreen) { all("navBarLayerIsAlwaysVisible", bugId, enabled) { this.showsLayer(NAV_BAR_LAYER_NAME) - .then() - .hidesLayer(NAV_BAR_LAYER_NAME) - .then() - .showsLayer(NAV_BAR_LAYER_NAME) + .then() + .hidesLayer(NAV_BAR_LAYER_NAME) + .then() + .showsLayer(NAV_BAR_LAYER_NAME) } } else { all("navBarLayerIsAlwaysVisible", bugId, enabled) { @@ -179,6 +433,7 @@ fun LayersAssertionBuilderLegacy.navBarLayerIsAlwaysVisible( } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") @JvmOverloads fun LayersAssertionBuilderLegacy.statusBarLayerIsAlwaysVisible( rotatesScreen: Boolean = false, @@ -188,10 +443,10 @@ fun LayersAssertionBuilderLegacy.statusBarLayerIsAlwaysVisible( if (rotatesScreen) { all("statusBarLayerIsAlwaysVisible", bugId, enabled) { this.showsLayer(STATUS_BAR_LAYER_NAME) - .then() - hidesLayer(STATUS_BAR_LAYER_NAME) - .then() - .showsLayer(STATUS_BAR_LAYER_NAME) + .then() + .hidesLayer(STATUS_BAR_LAYER_NAME) + .then() + .showsLayer(STATUS_BAR_LAYER_NAME) } } else { all("statusBarLayerIsAlwaysVisible", bugId, enabled) { @@ -200,6 +455,7 @@ fun LayersAssertionBuilderLegacy.statusBarLayerIsAlwaysVisible( } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") @JvmOverloads fun LayersAssertionBuilderLegacy.navBarLayerRotatesAndScales( beginRotation: Int, @@ -224,6 +480,7 @@ fun LayersAssertionBuilderLegacy.navBarLayerRotatesAndScales( } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") @JvmOverloads fun LayersAssertionBuilderLegacy.statusBarLayerRotatesScales( beginRotation: Int, @@ -242,8 +499,9 @@ fun LayersAssertionBuilderLegacy.statusBarLayerRotatesScales( } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") fun LayersAssertionBuilderLegacy.visibleLayersShownMoreThanOneConsecutiveEntry( - ignoreLayers: List = emptyList(), + ignoreLayers: List = kotlin.collections.emptyList(), bugId: Int = 0, enabled: Boolean = bugId == 0 ) { @@ -252,6 +510,7 @@ fun LayersAssertionBuilderLegacy.visibleLayersShownMoreThanOneConsecutiveEntry( } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") fun LayersAssertionBuilderLegacy.appLayerReplacesWallpaperLayer( appName: String, bugId: Int = 0, @@ -259,11 +518,12 @@ fun LayersAssertionBuilderLegacy.appLayerReplacesWallpaperLayer( ) { all("appLayerReplacesWallpaperLayer", bugId, enabled) { this.showsLayer("Wallpaper") - .then() - .replaceVisibleLayer("Wallpaper", appName) + .then() + .replaceVisibleLayer("Wallpaper", appName) } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") fun LayersAssertionBuilderLegacy.wallpaperLayerReplacesAppLayer( testApp: IAppHelper, bugId: Int = 0, @@ -271,11 +531,12 @@ fun LayersAssertionBuilderLegacy.wallpaperLayerReplacesAppLayer( ) { all("appLayerReplacesWallpaperLayer", bugId, enabled) { this.showsLayer(testApp.getPackage()) - .then() - .replaceVisibleLayer(testApp.getPackage(), WALLPAPER_TITLE) + .then() + .replaceVisibleLayer(testApp.getPackage(), WALLPAPER_TITLE) } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") fun LayersAssertionBuilderLegacy.layerAlwaysVisible( packageName: String, bugId: Int = 0, @@ -286,6 +547,7 @@ fun LayersAssertionBuilderLegacy.layerAlwaysVisible( } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") fun LayersAssertionBuilderLegacy.layerBecomesVisible( packageName: String, bugId: Int = 0, @@ -293,11 +555,12 @@ fun LayersAssertionBuilderLegacy.layerBecomesVisible( ) { all("layerBecomesVisible", bugId, enabled) { this.hidesLayer(packageName) - .then() - .showsLayer(packageName) + .then() + .showsLayer(packageName) } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") fun LayersAssertionBuilderLegacy.layerBecomesInvisible( packageName: String, bugId: Int = 0, @@ -305,11 +568,12 @@ fun LayersAssertionBuilderLegacy.layerBecomesInvisible( ) { all("layerBecomesInvisible", bugId, enabled) { this.showsLayer(packageName) - .then() - .hidesLayer(packageName) + .then() + .hidesLayer(packageName) } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") fun EventLogAssertionBuilderLegacy.focusChanges( vararg windows: String, bugId: Int = 0, @@ -320,6 +584,7 @@ fun EventLogAssertionBuilderLegacy.focusChanges( } } +@Deprecated("Move the assertion into one of the specific blocks (presubmit, postsubmit, flaky)") fun EventLogAssertionBuilderLegacy.focusDoesNotChange( bugId: Int = 0, enabled: Boolean = bugId == 0 diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt index 1a4744980b1e5..323236ed99626 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt @@ -43,7 +43,7 @@ fun Flicker.setRotation(rotation: Int) { wmHelper.waitForAppTransitionIdle() // Ensure WindowManagerService wait until all animations have completed - instrumentation.getUiAutomation().syncInputTransactions() + instrumentation.uiAutomation.syncInputTransactions() } catch (e: RemoteException) { throw RuntimeException(e) } @@ -71,8 +71,8 @@ fun buildTestTag( /** * Build a test tag for the test * @param testName Name of the transition(s) being tested - * @param app App being launcher * @param configuration Configuration for the test + * @param extraInfo Additional information to append to the tag * * @return test tag with pattern ____- */ @@ -90,11 +90,32 @@ fun buildTestTag( extraInfo = extraInfo) } +/** + * Build a test tag for the test + * @param configuration Configuration for the test + * @param extraInfo Additional information to append to the tag + * + * @return test tag with pattern ____- + */ +@JvmOverloads +fun buildTestTag( + configuration: Bundle, + extraInfo: String = "" +): String { + return buildTestTag(testName = null, + app = null, + beginRotation = configuration.startRotation, + endRotation = configuration.endRotation, + app2 = null, + extraInfo = extraInfo) +} + /** * Build a test tag for the test * @param testName Name of the transition(s) being tested * @param app App being launcher * @param configuration Configuration for the test + * @param extraInfo Additional information to append to the tag * * @return test tag with pattern ____- */ @@ -121,14 +142,17 @@ fun buildTestTag( * @return test tag with pattern __(S)>__(S)>[__] */ fun buildTestTag( - testName: String, + testName: String?, app: String?, beginRotation: Int, endRotation: Int, app2: String?, extraInfo: String ): String { - var testTag = testName + var testTag = "" + if (testName != null) { + testTag += testName + } if (app != null) { testTag += "__$app" } @@ -142,5 +166,9 @@ fun buildTestTag( if (extraInfo.isNotEmpty()) { testTag += "__$extraInfo" } + + if (testTag.startsWith("__")) { + testTag = testTag.drop(2) + } return testTag }