diff options
| author | 2022-09-28 12:17:29 +0000 | |
|---|---|---|
| committer | 2022-10-03 16:37:37 +0000 | |
| commit | 9d7d75873ce9ba38d6c0c20b90a9794941f87d35 (patch) | |
| tree | 90dcb54c8294a5dd0dd970bd274700570c38d9fb /libs | |
| parent | a77b86f6f8435a62cfc8ce5a6001cf2b56a9109c (diff) | |
Fix code formatting according to ktfmt rules
Bug: 246905204
Test: atest FlickerTests WMShellFlickerTests
Change-Id: I1192107a280eb5b068f9da4ba5b92092496351a2
Diffstat (limited to 'libs')
39 files changed, 818 insertions, 961 deletions
diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/BaseTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/BaseTest.kt index 2b162aec34ca..c9c894317ff8 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/BaseTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/BaseTest.kt @@ -38,50 +38,44 @@ import org.junit.Test /** * Base test class containing common assertions for [ComponentMatcher.NAV_BAR], - * [ComponentMatcher.TASK_BAR], [ComponentMatcher.STATUS_BAR], and general assertions - * (layers visible in consecutive states, entire screen covered, etc.) + * [ComponentMatcher.TASK_BAR], [ComponentMatcher.STATUS_BAR], and general assertions (layers + * visible in consecutive states, entire screen covered, etc.) */ -abstract class BaseTest @JvmOverloads constructor( +abstract class BaseTest +@JvmOverloads +constructor( protected val testSpec: FlickerTestParameter, protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(), protected val tapl: LauncherInstrumentation = LauncherInstrumentation() ) { init { testSpec.setIsTablet( - WindowManagerStateHelper( - instrumentation, - clearCacheAfterParsing = false - ).currentState.wmState.isTablet + WindowManagerStateHelper(instrumentation, clearCacheAfterParsing = false) + .currentState + .wmState + .isTablet ) } - /** - * Specification of the test transition to execute - */ + /** Specification of the test transition to execute */ abstract val transition: FlickerBuilder.() -> Unit /** - * Entry point for the test runner. It will use this method to initialize and cache - * flicker executions + * 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 { - setup { - testSpec.setIsTablet(wmHelper.currentState.wmState.isTablet) - } + setup { testSpec.setIsTablet(wmHelper.currentState.wmState.isTablet) } transition() } } - /** - * Checks that all parts of the screen are covered during the transition - */ + /** Checks that all parts of the screen are covered during the transition */ open fun entireScreenCovered() = testSpec.entireScreenCovered() - /** - * Checks that the [ComponentMatcher.NAV_BAR] layer is visible during the whole transition - */ + /** Checks that the [ComponentMatcher.NAV_BAR] layer is visible during the whole transition */ @Presubmit @Test open fun navBarLayerIsVisibleAtStartAndEnd() { @@ -111,9 +105,7 @@ abstract class BaseTest @JvmOverloads constructor( testSpec.navBarWindowIsAlwaysVisible() } - /** - * Checks that the [ComponentMatcher.TASK_BAR] layer is visible during the whole transition - */ + /** Checks that the [ComponentMatcher.TASK_BAR] layer is visible during the whole transition */ @Presubmit @Test open fun taskBarLayerIsVisibleAtStartAndEnd() { @@ -142,7 +134,8 @@ abstract class BaseTest @JvmOverloads constructor( testSpec.statusBarLayerIsVisibleAtStartAndEnd() /** - * Checks the position of the [ComponentMatcher.STATUS_BAR] at the start and end of the transition + * Checks the position of the [ComponentMatcher.STATUS_BAR] at the start and end of the + * transition */ @Presubmit @Test @@ -156,26 +149,22 @@ abstract class BaseTest @JvmOverloads constructor( open fun statusBarWindowIsAlwaysVisible() = testSpec.statusBarWindowIsAlwaysVisible() /** - * Checks that all layers that are visible on the trace, are visible for at least 2 - * consecutive entries. + * Checks that all layers that are visible on the trace, are visible for at least 2 consecutive + * entries. */ @Presubmit @Test open fun visibleLayersShownMoreThanOneConsecutiveEntry() { - testSpec.assertLayers { - this.visibleLayersShownMoreThanOneConsecutiveEntry() - } + testSpec.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry() } } /** - * Checks that all windows that are visible on the trace, are visible for at least 2 - * consecutive entries. + * Checks that all windows that are visible on the trace, are visible for at least 2 consecutive + * entries. */ @Presubmit @Test open fun visibleWindowsShownMoreThanOneConsecutiveEntry() { - testSpec.assertWm { - this.visibleWindowsShownMoreThanOneConsecutiveEntry() - } + testSpec.assertWm { this.visibleWindowsShownMoreThanOneConsecutiveEntry() } } } 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 6d133779ea60..6f1ff99cb0b3 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 @@ -15,6 +15,7 @@ */ @file:JvmName("CommonAssertions") + package com.android.wm.shell.flicker import android.view.Surface @@ -26,15 +27,11 @@ import com.android.server.wm.traces.common.IComponentMatcher import com.android.server.wm.traces.common.region.Region fun FlickerTestParameter.appPairsDividerIsVisibleAtEnd() { - assertLayersEnd { - this.isVisible(APP_PAIR_SPLIT_DIVIDER_COMPONENT) - } + assertLayersEnd { this.isVisible(APP_PAIR_SPLIT_DIVIDER_COMPONENT) } } fun FlickerTestParameter.appPairsDividerIsInvisibleAtEnd() { - assertLayersEnd { - this.notContains(APP_PAIR_SPLIT_DIVIDER_COMPONENT) - } + assertLayersEnd { this.notContains(APP_PAIR_SPLIT_DIVIDER_COMPONENT) } } fun FlickerTestParameter.appPairsDividerBecomesVisible() { @@ -82,27 +79,19 @@ fun FlickerTestParameter.splitScreenDismissed( } fun FlickerTestParameter.splitScreenDividerIsVisibleAtStart() { - assertLayersStart { - this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) - } + assertLayersStart { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } fun FlickerTestParameter.splitScreenDividerIsVisibleAtEnd() { - assertLayersEnd { - this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) - } + assertLayersEnd { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } fun FlickerTestParameter.splitScreenDividerIsInvisibleAtStart() { - assertLayersStart { - this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) - } + assertLayersStart { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } fun FlickerTestParameter.splitScreenDividerIsInvisibleAtEnd() { - assertLayersEnd { - this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) - } + assertLayersEnd { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } } fun FlickerTestParameter.splitScreenDividerBecomesVisible() { @@ -117,40 +106,20 @@ fun FlickerTestParameter.splitScreenDividerBecomesInvisible() { } } -fun FlickerTestParameter.layerBecomesVisible( - component: IComponentMatcher -) { - assertLayers { - this.isInvisible(component) - .then() - .isVisible(component) - } +fun FlickerTestParameter.layerBecomesVisible(component: IComponentMatcher) { + assertLayers { this.isInvisible(component).then().isVisible(component) } } -fun FlickerTestParameter.layerBecomesInvisible( - component: IComponentMatcher -) { - assertLayers { - this.isVisible(component) - .then() - .isInvisible(component) - } +fun FlickerTestParameter.layerBecomesInvisible(component: IComponentMatcher) { + assertLayers { this.isVisible(component).then().isInvisible(component) } } -fun FlickerTestParameter.layerIsVisibleAtEnd( - component: IComponentMatcher -) { - assertLayersEnd { - this.isVisible(component) - } +fun FlickerTestParameter.layerIsVisibleAtEnd(component: IComponentMatcher) { + assertLayersEnd { this.isVisible(component) } } -fun FlickerTestParameter.layerKeepVisible( - component: IComponentMatcher -) { - assertLayers { - this.isVisible(component) - } +fun FlickerTestParameter.layerKeepVisible(component: IComponentMatcher) { + assertLayers { this.isVisible(component) } } fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible( @@ -164,13 +133,15 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible( .isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component)) .then() .splitAppLayerBoundsSnapToDivider( - component, landscapePosLeft, portraitPosTop, endRotation) + component, + landscapePosLeft, + portraitPosTop, + endRotation + ) } } -fun FlickerTestParameter.splitAppLayerBoundsBecomesVisibleByDrag( - component: IComponentMatcher -) { +fun FlickerTestParameter.splitAppLayerBoundsBecomesVisibleByDrag(component: IComponentMatcher) { assertLayers { this.notContains(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component), isOptional = true) .then() @@ -188,7 +159,11 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible( ) { assertLayers { this.splitAppLayerBoundsSnapToDivider( - component, landscapePosLeft, portraitPosTop, endRotation) + component, + landscapePosLeft, + portraitPosTop, + endRotation + ) .then() .isVisible(component, true) .then() @@ -224,15 +199,27 @@ fun FlickerTestParameter.splitAppLayerBoundsChanges( assertLayers { if (landscapePosLeft) { this.splitAppLayerBoundsSnapToDivider( - component, landscapePosLeft, portraitPosTop, endRotation) + component, + landscapePosLeft, + portraitPosTop, + endRotation + ) } else { this.splitAppLayerBoundsSnapToDivider( - component, landscapePosLeft, portraitPosTop, endRotation) + component, + landscapePosLeft, + portraitPosTop, + endRotation + ) .then() .isInvisible(component) .then() .splitAppLayerBoundsSnapToDivider( - component, landscapePosLeft, portraitPosTop, endRotation) + component, + landscapePosLeft, + portraitPosTop, + endRotation + ) } } } @@ -257,45 +244,46 @@ fun LayerTraceEntrySubject.splitAppLayerBoundsSnapToDivider( val displayBounds = WindowUtils.getDisplayBounds(rotation) return invoke { val dividerRegion = layer(SPLIT_SCREEN_DIVIDER_COMPONENT).visibleRegion.region - visibleRegion(component).coversAtMost( - if (displayBounds.width > displayBounds.height) { - if (landscapePosLeft) { - Region.from( - 0, - 0, - (dividerRegion.bounds.left + dividerRegion.bounds.right) / 2, - displayBounds.bounds.bottom) - } else { - Region.from( - (dividerRegion.bounds.left + dividerRegion.bounds.right) / 2, - 0, - displayBounds.bounds.right, - displayBounds.bounds.bottom - ) - } - } else { - if (portraitPosTop) { - Region.from( - 0, - 0, - displayBounds.bounds.right, - (dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2) + visibleRegion(component) + .coversAtMost( + if (displayBounds.width > displayBounds.height) { + if (landscapePosLeft) { + Region.from( + 0, + 0, + (dividerRegion.bounds.left + dividerRegion.bounds.right) / 2, + displayBounds.bounds.bottom + ) + } else { + Region.from( + (dividerRegion.bounds.left + dividerRegion.bounds.right) / 2, + 0, + displayBounds.bounds.right, + displayBounds.bounds.bottom + ) + } } else { - Region.from( - 0, - (dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2, - displayBounds.bounds.right, - displayBounds.bounds.bottom - ) + if (portraitPosTop) { + Region.from( + 0, + 0, + displayBounds.bounds.right, + (dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2 + ) + } else { + Region.from( + 0, + (dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2, + displayBounds.bounds.right, + displayBounds.bounds.bottom + ) + } } - } - ) + ) } } -fun FlickerTestParameter.appWindowBecomesVisible( - component: IComponentMatcher -) { +fun FlickerTestParameter.appWindowBecomesVisible(component: IComponentMatcher) { assertWm { this.isAppWindowInvisible(component) .then() @@ -307,60 +295,32 @@ fun FlickerTestParameter.appWindowBecomesVisible( } } -fun FlickerTestParameter.appWindowBecomesInvisible( - component: IComponentMatcher -) { - assertWm { - this.isAppWindowVisible(component) - .then() - .isAppWindowInvisible(component) - } +fun FlickerTestParameter.appWindowBecomesInvisible(component: IComponentMatcher) { + assertWm { this.isAppWindowVisible(component).then().isAppWindowInvisible(component) } } -fun FlickerTestParameter.appWindowIsVisibleAtStart( - component: IComponentMatcher -) { - assertWmStart { - this.isAppWindowVisible(component) - } +fun FlickerTestParameter.appWindowIsVisibleAtStart(component: IComponentMatcher) { + assertWmStart { this.isAppWindowVisible(component) } } -fun FlickerTestParameter.appWindowIsVisibleAtEnd( - component: IComponentMatcher -) { - assertWmEnd { - this.isAppWindowVisible(component) - } +fun FlickerTestParameter.appWindowIsVisibleAtEnd(component: IComponentMatcher) { + assertWmEnd { this.isAppWindowVisible(component) } } -fun FlickerTestParameter.appWindowIsInvisibleAtStart( - component: IComponentMatcher -) { - assertWmStart { - this.isAppWindowInvisible(component) - } +fun FlickerTestParameter.appWindowIsInvisibleAtStart(component: IComponentMatcher) { + assertWmStart { this.isAppWindowInvisible(component) } } -fun FlickerTestParameter.appWindowIsInvisibleAtEnd( - component: IComponentMatcher -) { - assertWmEnd { - this.isAppWindowInvisible(component) - } +fun FlickerTestParameter.appWindowIsInvisibleAtEnd(component: IComponentMatcher) { + assertWmEnd { this.isAppWindowInvisible(component) } } -fun FlickerTestParameter.appWindowKeepVisible( - component: IComponentMatcher -) { - assertWm { - this.isAppWindowVisible(component) - } +fun FlickerTestParameter.appWindowKeepVisible(component: IComponentMatcher) { + assertWm { this.isAppWindowVisible(component) } } fun FlickerTestParameter.dockedStackDividerIsVisibleAtEnd() { - assertLayersEnd { - this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) - } + assertLayersEnd { this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) } } fun FlickerTestParameter.dockedStackDividerBecomesVisible() { @@ -380,9 +340,7 @@ fun FlickerTestParameter.dockedStackDividerBecomesInvisible() { } fun FlickerTestParameter.dockedStackDividerNotExistsAtEnd() { - assertLayersEnd { - this.notContains(DOCKED_STACK_DIVIDER_COMPONENT) - } + assertLayersEnd { this.notContains(DOCKED_STACK_DIVIDER_COMPONENT) } } fun FlickerTestParameter.appPairsPrimaryBoundsIsVisibleAtEnd( @@ -391,8 +349,7 @@ fun FlickerTestParameter.appPairsPrimaryBoundsIsVisibleAtEnd( ) { assertLayersEnd { val dividerRegion = layer(APP_PAIR_SPLIT_DIVIDER_COMPONENT).visibleRegion.region - visibleRegion(primaryComponent) - .overlaps(getPrimaryRegion(dividerRegion, rotation)) + visibleRegion(primaryComponent).overlaps(getPrimaryRegion(dividerRegion, rotation)) } } @@ -402,8 +359,7 @@ fun FlickerTestParameter.dockedStackPrimaryBoundsIsVisibleAtEnd( ) { assertLayersEnd { val dividerRegion = layer(DOCKED_STACK_DIVIDER_COMPONENT).visibleRegion.region - visibleRegion(primaryComponent) - .overlaps(getPrimaryRegion(dividerRegion, rotation)) + visibleRegion(primaryComponent).overlaps(getPrimaryRegion(dividerRegion, rotation)) } } @@ -413,8 +369,7 @@ fun FlickerTestParameter.appPairsSecondaryBoundsIsVisibleAtEnd( ) { assertLayersEnd { val dividerRegion = layer(APP_PAIR_SPLIT_DIVIDER_COMPONENT).visibleRegion.region - visibleRegion(secondaryComponent) - .overlaps(getSecondaryRegion(dividerRegion, rotation)) + visibleRegion(secondaryComponent).overlaps(getSecondaryRegion(dividerRegion, rotation)) } } @@ -424,8 +379,7 @@ fun FlickerTestParameter.dockedStackSecondaryBoundsIsVisibleAtEnd( ) { assertLayersEnd { val dividerRegion = layer(DOCKED_STACK_DIVIDER_COMPONENT).visibleRegion.region - visibleRegion(secondaryComponent) - .overlaps(getSecondaryRegion(dividerRegion, rotation)) + visibleRegion(secondaryComponent).overlaps(getSecondaryRegion(dividerRegion, rotation)) } } @@ -433,12 +387,16 @@ fun getPrimaryRegion(dividerRegion: Region, rotation: Int): Region { val displayBounds = WindowUtils.getDisplayBounds(rotation) return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { Region.from( - 0, 0, displayBounds.bounds.right, + 0, + 0, + displayBounds.bounds.right, dividerRegion.bounds.top + WindowUtils.dockedStackDividerInset ) } else { Region.from( - 0, 0, dividerRegion.bounds.left + WindowUtils.dockedStackDividerInset, + 0, + 0, + dividerRegion.bounds.left + WindowUtils.dockedStackDividerInset, displayBounds.bounds.bottom ) } @@ -448,13 +406,17 @@ fun getSecondaryRegion(dividerRegion: Region, rotation: Int): Region { val displayBounds = WindowUtils.getDisplayBounds(rotation) return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { Region.from( - 0, dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset, - displayBounds.bounds.right, displayBounds.bounds.bottom + 0, + dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset, + displayBounds.bounds.right, + displayBounds.bounds.bottom ) } else { Region.from( - dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset, 0, - displayBounds.bounds.right, displayBounds.bounds.bottom + dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset, + 0, + displayBounds.bounds.right, + displayBounds.bounds.bottom ) } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt index 53dd8b04afeb..79978929cf3e 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt @@ -15,6 +15,7 @@ */ @file:JvmName("CommonConstants") + package com.android.wm.shell.flicker import com.android.server.wm.traces.common.ComponentNameMatcher @@ -26,5 +27,8 @@ val SPLIT_SCREEN_DIVIDER_COMPONENT = ComponentNameMatcher("", "StageCoordinatorS val SPLIT_DECOR_MANAGER = ComponentNameMatcher("", "SplitDecorManager#") enum class Direction { - UP, DOWN, LEFT, RIGHT + UP, + DOWN, + LEFT, + RIGHT } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/MultiWindowUtils.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/MultiWindowUtils.kt index c045325f19c3..87b94ff8668b 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/MultiWindowUtils.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/MultiWindowUtils.kt @@ -33,17 +33,23 @@ object MultiWindowUtils { } fun getDevEnableNonResizableMultiWindow(context: Context): Int = - Settings.Global.getInt(context.contentResolver, - Settings.Global.DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW) + Settings.Global.getInt( + context.contentResolver, + Settings.Global.DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW + ) fun setDevEnableNonResizableMultiWindow(context: Context, configValue: Int) = - Settings.Global.putInt(context.contentResolver, - Settings.Global.DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW, configValue) + Settings.Global.putInt( + context.contentResolver, + Settings.Global.DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW, + configValue + ) fun setSupportsNonResizableMultiWindow(instrumentation: Instrumentation, configValue: Int) = executeShellCommand( instrumentation, - createConfigSupportsNonResizableMultiWindowCommand(configValue)) + createConfigSupportsNonResizableMultiWindowCommand(configValue) + ) fun resetMultiWindowConfig(instrumentation: Instrumentation) = executeShellCommand(instrumentation, resetMultiWindowConfigCommand) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/NotificationListener.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/NotificationListener.kt index 51f7a18f60dd..e0ef92457f58 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/NotificationListener.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/NotificationListener.kt @@ -51,7 +51,7 @@ class NotificationListener : NotificationListenerService() { private const val CMD_NOTIFICATION_ALLOW_LISTENER = "cmd notification allow_listener %s" private const val CMD_NOTIFICATION_DISALLOW_LISTENER = - "cmd notification disallow_listener %s" + "cmd notification disallow_listener %s" private const val COMPONENT_NAME = "com.android.wm.shell.flicker/.NotificationListener" private var instance: NotificationListener? = null @@ -79,25 +79,23 @@ class NotificationListener : NotificationListenerService() { ): StatusBarNotification? { instance?.run { return notifications.values.firstOrNull(predicate) - } ?: throw IllegalStateException("NotificationListenerService is not connected") + } + ?: throw IllegalStateException("NotificationListenerService is not connected") } fun waitForNotificationToAppear( predicate: (StatusBarNotification) -> Boolean ): StatusBarNotification? { instance?.let { - return waitForResult(extractor = { - it.notifications.values.firstOrNull(predicate) - }).second - } ?: throw IllegalStateException("NotificationListenerService is not connected") + return waitForResult(extractor = { it.notifications.values.firstOrNull(predicate) }) + .second + } + ?: throw IllegalStateException("NotificationListenerService is not connected") } - fun waitForNotificationToDisappear( - predicate: (StatusBarNotification) -> Boolean - ): Boolean { - return instance?.let { - wait { it.notifications.values.none(predicate) } - } ?: throw IllegalStateException("NotificationListenerService is not connected") + fun waitForNotificationToDisappear(predicate: (StatusBarNotification) -> Boolean): Boolean { + return instance?.let { wait { it.notifications.values.none(predicate) } } + ?: throw IllegalStateException("NotificationListenerService is not connected") } } -}
\ No newline at end of file +} diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/WaitUtils.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/WaitUtils.kt index 4d87ec9e872f..556cb06f3ca1 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/WaitUtils.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/WaitUtils.kt @@ -15,6 +15,7 @@ */ @file:JvmName("WaitUtils") + package com.android.wm.shell.flicker import android.os.SystemClock diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt index cbe085be8952..0fc2004ce7f9 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt @@ -34,21 +34,21 @@ import com.android.server.wm.flicker.helpers.SYSTEMUI_PACKAGE import com.android.wm.shell.flicker.BaseTest import org.junit.runners.Parameterized -/** - * Base configurations for Bubble flicker tests - */ -abstract class BaseBubbleScreen( - testSpec: FlickerTestParameter -) : BaseTest(testSpec) { +/** Base configurations for Bubble flicker tests */ +abstract class BaseBubbleScreen(testSpec: FlickerTestParameter) : BaseTest(testSpec) { protected val context: Context = instrumentation.context protected val testApp = LaunchBubbleHelper(instrumentation) - private val notifyManager = INotificationManager.Stub.asInterface( - ServiceManager.getService(Context.NOTIFICATION_SERVICE)) + private val notifyManager = + INotificationManager.Stub.asInterface( + ServiceManager.getService(Context.NOTIFICATION_SERVICE) + ) - private val uid = context.packageManager.getApplicationInfo( - testApp.`package`, PackageManager.ApplicationInfoFlags.of(0)).uid + private val uid = + context.packageManager + .getApplicationInfo(testApp.`package`, PackageManager.ApplicationInfoFlags.of(0)) + .uid @JvmOverloads protected open fun buildTransition( @@ -56,16 +56,22 @@ abstract class BaseBubbleScreen( ): FlickerBuilder.() -> Unit { return { setup { - notifyManager.setBubblesAllowed(testApp.`package`, - uid, NotificationManager.BUBBLE_PREFERENCE_ALL) + notifyManager.setBubblesAllowed( + testApp.`package`, + uid, + NotificationManager.BUBBLE_PREFERENCE_ALL + ) testApp.launchViaIntent(wmHelper) waitAndGetAddBubbleBtn() waitAndGetCancelAllBtn() } teardown { - notifyManager.setBubblesAllowed(testApp.`package`, - uid, NotificationManager.BUBBLE_PREFERENCE_NONE) + notifyManager.setBubblesAllowed( + testApp.`package`, + uid, + NotificationManager.BUBBLE_PREFERENCE_NONE + ) testApp.exit() } @@ -73,17 +79,17 @@ abstract class BaseBubbleScreen( } } - protected fun Flicker.waitAndGetAddBubbleBtn(): UiObject2? = device.wait(Until.findObject( - By.text("Add Bubble")), FIND_OBJECT_TIMEOUT) - protected fun Flicker.waitAndGetCancelAllBtn(): UiObject2? = device.wait(Until.findObject( - By.text("Cancel All Bubble")), FIND_OBJECT_TIMEOUT) + protected fun Flicker.waitAndGetAddBubbleBtn(): UiObject2? = + device.wait(Until.findObject(By.text("Add Bubble")), FIND_OBJECT_TIMEOUT) + protected fun Flicker.waitAndGetCancelAllBtn(): UiObject2? = + device.wait(Until.findObject(By.text("Cancel All Bubble")), FIND_OBJECT_TIMEOUT) companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): List<FlickerTestParameter> { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0)) + .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0)) } const val FIND_OBJECT_TIMEOUT = 2000L diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/DismissBubbleScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/DismissBubbleScreen.kt index 4a914a3eaf5c..ab721173763e 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/DismissBubbleScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/DismissBubbleScreen.kt @@ -38,7 +38,9 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:DismissBubbleScreen` * * Actions: + * ``` * Dismiss a bubble notification + * ``` */ @RequiresDevice @RunWith(Parameterized::class) @@ -58,11 +60,11 @@ open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScree transitions { wm.run { wm.defaultDisplay.getMetrics(displaySize) } val dist = Point((displaySize.widthPixels / 2), displaySize.heightPixels) - val showBubble = device.wait( - Until.findObject( - By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME) - ), FIND_OBJECT_TIMEOUT - ) + val showBubble = + device.wait( + Until.findObject(By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME)), + FIND_OBJECT_TIMEOUT + ) showBubble?.run { drag(dist, 1000) } ?: error("Show bubble not found") } } @@ -70,22 +72,18 @@ open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScree @Presubmit @Test open fun testAppIsAlwaysVisible() { - testSpec.assertLayers { - this.isVisible(testApp) - } + testSpec.assertLayers { this.isVisible(testApp) } } /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarLayerIsVisibleAtStartAndEnd() = - super.taskBarLayerIsVisibleAtStartAndEnd() + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarWindowIsAlwaysVisible() = - super.taskBarWindowIsAlwaysVisible() + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/ExpandBubbleScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/ExpandBubbleScreen.kt index d48175e5f49a..226eab89920f 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/ExpandBubbleScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/ExpandBubbleScreen.kt @@ -33,9 +33,11 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:ExpandBubbleScreen` * * Actions: + * ``` * Launch an app and enable app's bubble notification * Send a bubble notification * The activity for the bubble is launched + * ``` */ @RequiresDevice @RunWith(Parameterized::class) @@ -50,11 +52,11 @@ open class ExpandBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen addBubbleBtn?.click() ?: error("Add Bubble not found") } transitions { - val showBubble = device.wait( - Until.findObject( - By.res("com.android.systemui", "bubble_view") - ), FIND_OBJECT_TIMEOUT - ) + val showBubble = + device.wait( + Until.findObject(By.res("com.android.systemui", "bubble_view")), + FIND_OBJECT_TIMEOUT + ) showBubble?.run { showBubble.click() } ?: error("Bubble notify not found") } } @@ -62,8 +64,6 @@ open class ExpandBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen @Presubmit @Test open fun testAppIsAlwaysVisible() { - testSpec.assertLayers { - this.isVisible(testApp) - } + testSpec.assertLayers { this.isVisible(testApp) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt index 83dcb5a3fb8b..275f6c802293 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt @@ -36,7 +36,9 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:LaunchBubbleFromLockScreen` * * Actions: + * ``` * Launch an bubble from notification on lock screen + * ``` */ @RequiresDevice @RunWith(Parameterized::class) @@ -50,36 +52,32 @@ class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScr val addBubbleBtn = waitAndGetAddBubbleBtn() addBubbleBtn?.click() ?: error("Bubble widget not found") device.sleep() - wmHelper.StateSyncBuilder() - .withoutTopVisibleAppWindows() - .waitForAndVerify() + wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() device.wakeUp() } transitions { // Swipe & wait for the notification shade to expand so all can be seen - val wm = context.getSystemService(WindowManager::class.java) - ?: error("Unable to obtain WM service") + val wm = + context.getSystemService(WindowManager::class.java) + ?: error("Unable to obtain WM service") val metricInsets = wm.currentWindowMetrics.windowInsets - val insets = metricInsets.getInsetsIgnoringVisibility( - WindowInsets.Type.statusBars() - or WindowInsets.Type.displayCutout() - ) + val insets = + metricInsets.getInsetsIgnoringVisibility( + WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout() + ) device.swipe(100, insets.top + 100, 100, device.displayHeight / 2, 4) device.waitForIdle(2000) instrumentation.uiAutomation.syncInputTransactions() - val notification = device.wait( - Until.findObject( - By.text("BubbleChat") - ), FIND_OBJECT_TIMEOUT - ) + val notification = + device.wait(Until.findObject(By.text("BubbleChat")), FIND_OBJECT_TIMEOUT) notification?.click() ?: error("Notification not found") instrumentation.uiAutomation.syncInputTransactions() - val showBubble = device.wait( - Until.findObject( - By.res("com.android.systemui", "bubble_view") - ), FIND_OBJECT_TIMEOUT - ) + val showBubble = + device.wait( + Until.findObject(By.res("com.android.systemui", "bubble_view")), + FIND_OBJECT_TIMEOUT + ) showBubble?.click() ?: error("Bubble notify not found") instrumentation.uiAutomation.syncInputTransactions() val cancelAllBtn = waitAndGetCancelAllBtn() @@ -90,9 +88,7 @@ class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScr @FlakyTest(bugId = 242088970) @Test fun testAppIsVisibleAtEnd() { - testSpec.assertLayersEnd { - this.isVisible(testApp) - } + testSpec.assertLayersEnd { this.isVisible(testApp) } } /** {@inheritDoc} */ @@ -104,32 +100,27 @@ class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScr /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun navBarLayerIsVisibleAtStartAndEnd() = - super.navBarLayerIsVisibleAtStartAndEnd() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun navBarLayerPositionAtStartAndEnd() = - super.navBarLayerPositionAtStartAndEnd() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun navBarWindowIsAlwaysVisible() = - super.navBarWindowIsAlwaysVisible() + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @FlakyTest(bugId = 242088970) @Test - override fun taskBarLayerIsVisibleAtStartAndEnd() = - super.taskBarLayerIsVisibleAtStartAndEnd() + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarWindowIsAlwaysVisible() = - super.taskBarWindowIsAlwaysVisible() + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @FlakyTest(bugId = 242088970) @@ -140,14 +131,12 @@ class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScr /** {@inheritDoc} */ @FlakyTest(bugId = 242088970) @Test - override fun statusBarLayerPositionAtStartAndEnd() = - super.statusBarLayerPositionAtStartAndEnd() + override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @FlakyTest(bugId = 242088970) @Test - override fun statusBarWindowIsAlwaysVisible() = - super.statusBarWindowIsAlwaysVisible() + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @FlakyTest(bugId = 242088970) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleScreen.kt index 81204f49d03b..b86599913649 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleScreen.kt @@ -32,8 +32,10 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:LaunchBubbleScreen` * * Actions: + * ``` * Launch an app and enable app's bubble notification * Send a bubble notification + * ``` */ @RequiresDevice @RunWith(Parameterized::class) @@ -48,17 +50,15 @@ open class LaunchBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen addBubbleBtn?.click() ?: error("Bubble widget not found") device.wait( - Until.findObjects( - By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME) - ), FIND_OBJECT_TIMEOUT - ) ?: error("No bubbles found") + Until.findObjects(By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME)), + FIND_OBJECT_TIMEOUT + ) + ?: error("No bubbles found") } } @Test open fun testAppIsAlwaysVisible() { - testSpec.assertLayers { - this.isVisible(testApp) - } + testSpec.assertLayers { this.isVisible(testApp) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt index 364090510138..bf4d7d4e7734 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt @@ -38,7 +38,9 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:MultiBubblesScreen` * * Actions: + * ``` * Switch in different bubble notifications + * ``` */ @RequiresDevice @RunWith(Parameterized::class) @@ -59,20 +61,22 @@ open class MultiBubblesScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen addBubbleBtn.click() SystemClock.sleep(1000) } - val showBubble = device.wait( - Until.findObject( - By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME) - ), FIND_OBJECT_TIMEOUT - ) ?: error("Show bubble not found") + val showBubble = + device.wait( + Until.findObject(By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME)), + FIND_OBJECT_TIMEOUT + ) + ?: error("Show bubble not found") showBubble.click() SystemClock.sleep(1000) } transitions { - val bubbles: List<UiObject2> = device.wait( - Until.findObjects( - By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME) - ), FIND_OBJECT_TIMEOUT - ) ?: error("No bubbles found") + val bubbles: List<UiObject2> = + device.wait( + Until.findObjects(By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME)), + FIND_OBJECT_TIMEOUT + ) + ?: error("No bubbles found") for (entry in bubbles) { entry.click() SystemClock.sleep(1000) @@ -83,8 +87,6 @@ open class MultiBubblesScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen @Presubmit @Test open fun testAppIsAlwaysVisible() { - testSpec.assertLayers { - this.isVisible(testApp) - } + testSpec.assertLayers { this.isVisible(testApp) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreenShellTransit.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreenShellTransit.kt index 839fef904244..57adeab7b070 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreenShellTransit.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreenShellTransit.kt @@ -30,9 +30,8 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FlakyTest(bugId = 217777115) -class MultiBubblesScreenShellTransit( - testSpec: FlickerTestParameter -) : MultiBubblesScreen(testSpec) { +class MultiBubblesScreenShellTransit(testSpec: FlickerTestParameter) : + MultiBubblesScreen(testSpec) { @Before override fun before() { Assume.assumeTrue(isShellTransitionsEnabled) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt index 1be93527e0e5..1fc0375e9feb 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt @@ -40,16 +40,19 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:AutoEnterPipOnGoToHomeTest` * * Actions: + * ``` * Launch an app in full screen * Select "Auto-enter PiP" radio button * Press Home button or swipe up to go Home and put [pipApp] in pip mode - * + * ``` * Notes: + * ``` * 1. All assertions are inherited from [EnterPipTest] * 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) @@ -57,9 +60,7 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) @FlakyTest(bugId = 238367575) class AutoEnterPipOnGoToHomeTest(testSpec: FlickerTestParameter) : EnterPipTest(testSpec) { - /** - * Defines the transition used to run the test - */ + /** Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit get() = { setup { @@ -76,9 +77,7 @@ class AutoEnterPipOnGoToHomeTest(testSpec: FlickerTestParameter) : EnterPipTest( RemoveAllTasksButHomeRule.removeAllTasksButHome() pipApp.exit(wmHelper) } - transitions { - tapl.goHome() - } + transitions { tapl.goHome() } } @FlakyTest @@ -92,9 +91,7 @@ class AutoEnterPipOnGoToHomeTest(testSpec: FlickerTestParameter) : EnterPipTest( } } - /** - * Checks that [pipApp] window is animated towards default position in right bottom corner - */ + /** Checks that [pipApp] window is animated towards default position in right bottom corner */ @Presubmit @Test fun pipLayerMovesTowardsRightBottomCorner() { diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipOnUserLeaveHintTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipOnUserLeaveHintTest.kt index 75543cfed1ac..4f9ab6f00838 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipOnUserLeaveHintTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipOnUserLeaveHintTest.kt @@ -40,25 +40,26 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:EnterPipOnUserLeaveHintTest` * * Actions: + * ``` * Launch an app in full screen * Select "Via code behind" radio button * Press Home button or swipe up to go Home and put [pipApp] in pip mode - * + * ``` * Notes: + * ``` * 1. All assertions are inherited from [EnterPipTest] * 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) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) class EnterPipOnUserLeaveHintTest(testSpec: FlickerTestParameter) : EnterPipTest(testSpec) { - /** - * Defines the transition used to run the test - */ + /** Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit get() = { setup { @@ -73,20 +74,17 @@ class EnterPipOnUserLeaveHintTest(testSpec: FlickerTestParameter) : EnterPipTest RemoveAllTasksButHomeRule.removeAllTasksButHome() pipApp.exit(wmHelper) } - transitions { - tapl.goHome() - } + transitions { tapl.goHome() } } @Presubmit @Test override fun pipAppLayerAlwaysVisible() { - if (!testSpec.isGesturalNavigation) super.pipAppLayerAlwaysVisible() else { + if (!testSpec.isGesturalNavigation) super.pipAppLayerAlwaysVisible() + else { // pip layer in gesture nav will disappear during transition testSpec.assertLayers { - this.isVisible(pipApp) - .then().isInvisible(pipApp) - .then().isVisible(pipApp) + this.isVisible(pipApp).then().isInvisible(pipApp).then().isVisible(pipApp) } } } @@ -124,14 +122,11 @@ class EnterPipOnUserLeaveHintTest(testSpec: FlickerTestParameter) : EnterPipTest @Presubmit @Test override fun pipLayerRemainInsideVisibleBounds() { - if (!testSpec.isGesturalNavigation) super.pipLayerRemainInsideVisibleBounds() else { + if (!testSpec.isGesturalNavigation) super.pipLayerRemainInsideVisibleBounds() + else { // pip layer in gesture nav will disappear during transition - testSpec.assertLayersStart { - this.visibleRegion(pipApp).coversAtMost(displayBounds) - } - testSpec.assertLayersEnd { - this.visibleRegion(pipApp).coversAtMost(displayBounds) - } + testSpec.assertLayersStart { this.visibleRegion(pipApp).coversAtMost(displayBounds) } + testSpec.assertLayersEnd { this.visibleRegion(pipApp).coversAtMost(displayBounds) } } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipTest.kt index 239d337be991..56e5e27e21ce 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipTest.kt @@ -40,16 +40,19 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:EnterPipTest` * * Actions: + * ``` * Launch an app in full screen * Press an "enter pip" button to put [pipApp] in pip mode - * + * ``` * Notes: + * ``` * 1. Some default assertions (e.g., nav bar, status bar and screen covered) * are inherited from [PipTransition] * 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) @@ -57,7 +60,7 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) open class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec) { - /** {@inheritDoc} */ + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { setup { @@ -70,31 +73,21 @@ open class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec RemoveAllTasksButHomeRule.removeAllTasksButHome() pipApp.exit(wmHelper) } - transitions { - pipApp.clickEnterPipButton(wmHelper) - } + transitions { pipApp.clickEnterPipButton(wmHelper) } } - /** - * Checks [pipApp] window remains visible throughout the animation - */ + /** Checks [pipApp] window remains visible throughout the animation */ @Presubmit @Test open fun pipAppWindowAlwaysVisible() { - testSpec.assertWm { - this.isAppWindowVisible(pipApp) - } + testSpec.assertWm { this.isAppWindowVisible(pipApp) } } - /** - * Checks [pipApp] layer remains visible throughout the animation - */ + /** Checks [pipApp] layer remains visible throughout the animation */ @FlakyTest(bugId = 239807171) @Test open fun pipAppLayerAlwaysVisible() { - testSpec.assertLayers { - this.isVisible(pipApp) - } + testSpec.assertLayers { this.isVisible(pipApp) } } /** @@ -104,9 +97,7 @@ open class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec @Presubmit @Test fun pipWindowRemainInsideVisibleBounds() { - testSpec.assertWmVisibleRegion(pipApp) { - coversAtMost(displayBounds) - } + testSpec.assertWmVisibleRegion(pipApp) { coversAtMost(displayBounds) } } /** @@ -116,14 +107,10 @@ open class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec @FlakyTest(bugId = 239807171) @Test open fun pipLayerRemainInsideVisibleBounds() { - testSpec.assertLayersVisibleRegion(pipApp) { - coversAtMost(displayBounds) - } + testSpec.assertLayersVisibleRegion(pipApp) { coversAtMost(displayBounds) } } - /** - * Checks that the visible region of [pipApp] always reduces during the animation - */ + /** Checks that the visible region of [pipApp] always reduces during the animation */ @Presubmit @Test open fun pipLayerReduces() { @@ -135,9 +122,7 @@ open class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec } } - /** - * Checks that [pipApp] window becomes pinned - */ + /** Checks that [pipApp] window becomes pinned */ @Presubmit @Test fun pipWindowBecomesPinned() { @@ -148,9 +133,7 @@ open class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec } } - /** - * Checks [ComponentMatcher.LAUNCHER] layer remains visible throughout the animation - */ + /** Checks [ComponentMatcher.LAUNCHER] layer remains visible throughout the animation */ @Presubmit @Test fun launcherLayerBecomesVisible() { @@ -162,31 +145,27 @@ open class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec } /** - * Checks that the focus changes between the [pipApp] window and the launcher when - * closing the pip window + * Checks that the focus changes between the [pipApp] window and the launcher when closing the + * pip window */ @Presubmit @Test open fun focusChanges() { - testSpec.assertEventLog { - this.focusChanges(pipApp.`package`, "NexusLauncherActivity") - } + testSpec.assertEventLog { this.focusChanges(pipApp.`package`, "NexusLauncherActivity") } } companion object { /** * Creates the test configurations. * - * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring - * repetitions, screen orientation and navigation modes. + * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring repetitions, + * screen orientation and navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): List<FlickerTestParameter> { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests( - supportedRotations = listOf(Surface.ROTATION_0) - ) + .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0)) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipToAppTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipToAppTransition.kt index 628599160c65..3d8525b3d4ad 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipToAppTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipToAppTransition.kt @@ -21,9 +21,7 @@ import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.helpers.FixedOrientationAppHelper import org.junit.Test -/** - * Base class for pip expand tests - */ +/** Base class for pip expand tests */ abstract class ExitPipToAppTransition(testSpec: FlickerTestParameter) : PipTransition(testSpec) { protected val testApp = FixedOrientationAppHelper(instrumentation) @@ -34,9 +32,7 @@ abstract class ExitPipToAppTransition(testSpec: FlickerTestParameter) : PipTrans @Presubmit @Test open fun pipAppWindowRemainInsideVisibleBounds() { - testSpec.assertWmVisibleRegion(pipApp) { - coversAtMost(displayBounds) - } + testSpec.assertWmVisibleRegion(pipApp) { coversAtMost(displayBounds) } } /** @@ -46,9 +42,7 @@ abstract class ExitPipToAppTransition(testSpec: FlickerTestParameter) : PipTrans @Presubmit @Test open fun pipAppLayerRemainInsideVisibleBounds() { - testSpec.assertLayersVisibleRegion(pipApp) { - coversAtMost(displayBounds) - } + testSpec.assertLayersVisibleRegion(pipApp) { coversAtMost(displayBounds) } } /** @@ -78,44 +72,34 @@ abstract class ExitPipToAppTransition(testSpec: FlickerTestParameter) : PipTrans @Test open fun showBothAppLayersThenHidePip() { testSpec.assertLayers { - isVisible(testApp) - .isVisible(pipApp) - .then() - .isInvisible(testApp) - .isVisible(pipApp) + isVisible(testApp).isVisible(pipApp).then().isInvisible(testApp).isVisible(pipApp) } } /** - * Checks that the visible region of [testApp] plus the visible region of [pipApp] - * cover the full display area at the start of the transition + * Checks that the visible region of [testApp] plus the visible region of [pipApp] cover the + * full display area at the start of the transition */ @Presubmit @Test open fun testPlusPipAppsCoverFullScreenAtStart() { testSpec.assertLayersStart { val pipRegion = visibleRegion(pipApp).region - visibleRegion(testApp) - .plus(pipRegion) - .coversExactly(displayBounds) + visibleRegion(testApp).plus(pipRegion).coversExactly(displayBounds) } } /** - * Checks that the visible region oft [pipApp] covers the full display area at the end of - * the transition + * Checks that the visible region oft [pipApp] covers the full display area at the end of the + * transition */ @Presubmit @Test open fun pipAppCoversFullScreenAtEnd() { - testSpec.assertLayersEnd { - visibleRegion(pipApp).coversExactly(displayBounds) - } + testSpec.assertLayersEnd { visibleRegion(pipApp).coversExactly(displayBounds) } } - /** - * Checks that the visible region of [pipApp] always expands during the animation - */ + /** Checks that the visible region of [pipApp] always expands during the animation */ @Presubmit @Test open fun pipLayerExpands() { @@ -127,8 +111,6 @@ abstract class ExitPipToAppTransition(testSpec: FlickerTestParameter) : PipTrans } } - /** {@inheritDoc} */ - @Presubmit - @Test - override fun entireScreenCovered() = super.entireScreenCovered() + /** {@inheritDoc} */ + @Presubmit @Test override fun entireScreenCovered() = super.entireScreenCovered() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt index 39be89d2592b..3b8bb90988f9 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt @@ -25,24 +25,18 @@ import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.traces.common.ComponentNameMatcher.Companion.LAUNCHER import org.junit.Test -/** - * Base class for exiting pip (closing pip window) without returning to the app - */ +/** Base class for exiting pip (closing pip window) without returning to the app */ abstract class ExitPipTransition(testSpec: FlickerTestParameter) : PipTransition(testSpec) { override val transition: FlickerBuilder.() -> Unit get() = buildTransition { - setup { - this.setRotation(testSpec.startRotation) - } - teardown { - this.setRotation(Surface.ROTATION_0) - } + setup { this.setRotation(testSpec.startRotation) } + teardown { this.setRotation(Surface.ROTATION_0) } } /** - * Checks that [pipApp] window is pinned and visible at the start and then becomes - * unpinned and invisible at the same moment, and remains unpinned and invisible - * until the end of the transition + * Checks that [pipApp] window is pinned and visible at the start and then becomes unpinned and + * invisible at the same moment, and remains unpinned and invisible until the end of the + * transition */ @Presubmit @Test @@ -53,30 +47,24 @@ abstract class ExitPipTransition(testSpec: FlickerTestParameter) : PipTransition // and isAppWindowInvisible in the same assertion block. testSpec.assertWm { this.invoke("hasPipWindow") { - it.isPinned(pipApp) - .isAppWindowVisible(pipApp) - .isAppWindowOnTop(pipApp) - }.then().invoke("!hasPipWindow") { - it.isNotPinned(pipApp) - .isAppWindowNotOnTop(pipApp) - } + it.isPinned(pipApp).isAppWindowVisible(pipApp).isAppWindowOnTop(pipApp) + } + .then() + .invoke("!hasPipWindow") { it.isNotPinned(pipApp).isAppWindowNotOnTop(pipApp) } } testSpec.assertWmEnd { isAppWindowInvisible(pipApp) } } else { testSpec.assertWm { - this.invoke("hasPipWindow") { - it.isPinned(pipApp).isAppWindowVisible(pipApp) - }.then().invoke("!hasPipWindow") { - it.isNotPinned(pipApp).isAppWindowInvisible(pipApp) - } + this.invoke("hasPipWindow") { it.isPinned(pipApp).isAppWindowVisible(pipApp) } + .then() + .invoke("!hasPipWindow") { it.isNotPinned(pipApp).isAppWindowInvisible(pipApp) } } } } /** - * Checks that [pipApp] and [LAUNCHER] layers are visible at the start - * of the transition. Then [pipApp] layer becomes invisible, and remains invisible - * until the end of the transition + * Checks that [pipApp] and [LAUNCHER] layers are visible at the start of the transition. Then + * [pipApp] layer becomes invisible, and remains invisible until the end of the transition */ @Presubmit @Test diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt index 7ef332399246..18790713a828 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt @@ -38,17 +38,20 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:ExitPipViaIntentTest` * * Actions: + * ``` * Launch an app in pip mode [pipApp], * Launch another full screen mode [testApp] * Expand [pipApp] app to full screen via an intent - * + * ``` * Notes: + * ``` * 1. Some default assertions (e.g., nav bar, status bar and screen covered) * are inherited from [PipTransition] * 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) @@ -56,9 +59,7 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) class ExitPipViaIntentTest(testSpec: FlickerTestParameter) : ExitPipToAppTransition(testSpec) { - /** - * Defines the transition used to run the test - */ + /** Defines the transition used to run the test */ override val transition: FlickerBuilder.() -> Unit get() = buildTransition { setup { @@ -69,18 +70,14 @@ class ExitPipViaIntentTest(testSpec: FlickerTestParameter) : ExitPipToAppTransit // This will bring PipApp to fullscreen pipApp.exitPipToFullScreenViaIntent(wmHelper) // Wait until the other app is no longer visible - wmHelper.StateSyncBuilder() - .withWindowSurfaceDisappeared(testApp) - .waitForAndVerify() + wmHelper.StateSyncBuilder().withWindowSurfaceDisappeared(testApp).waitForAndVerify() } } - /** {@inheritDoc} */ - @FlakyTest - @Test - override fun entireScreenCovered() = super.entireScreenCovered() + /** {@inheritDoc} */ + @FlakyTest @Test override fun entireScreenCovered() = super.entireScreenCovered() - /** {@inheritDoc} */ + /** {@inheritDoc} */ @Presubmit @Test override fun statusBarLayerPositionAtStartAndEnd() { @@ -95,7 +92,7 @@ class ExitPipViaIntentTest(testSpec: FlickerTestParameter) : ExitPipToAppTransit super.statusBarLayerPositionAtStartAndEnd() } - /** {@inheritDoc} */ + /** {@inheritDoc} */ @FlakyTest(bugId = 197726610) @Test override fun pipLayerExpands() { @@ -114,14 +111,14 @@ class ExitPipViaIntentTest(testSpec: FlickerTestParameter) : ExitPipToAppTransit /** * Creates the test configurations. * - * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring - * repetitions, screen orientation and navigation modes. + * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring repetitions, + * screen orientation and navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): List<FlickerTestParameter> { - return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests( - supportedRotations = listOf(Surface.ROTATION_0)) + return FlickerTestParameterFactory.getInstance() + .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0)) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithDismissButtonTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithDismissButtonTest.kt index a33d9144fbbb..d195abb2aaec 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithDismissButtonTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithDismissButtonTest.kt @@ -35,17 +35,20 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:ExitPipWithDismissButtonTest` * * Actions: + * ``` * Launch an app in pip mode [pipApp], * Click on the pip window * Click on dismiss button and wait window disappear - * + * ``` * Notes: + * ``` * 1. Some default assertions (e.g., nav bar, status bar and screen covered) * are inherited [PipTransition] * 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) @@ -56,9 +59,7 @@ class ExitPipWithDismissButtonTest(testSpec: FlickerTestParameter) : ExitPipTran override val transition: FlickerBuilder.() -> Unit get() = { super.transition(this) - transitions { - pipApp.closePipWindow(wmHelper) - } + transitions { pipApp.closePipWindow(wmHelper) } } /** @@ -68,23 +69,21 @@ class ExitPipWithDismissButtonTest(testSpec: FlickerTestParameter) : ExitPipTran @Presubmit @Test fun focusChanges() { - testSpec.assertEventLog { - this.focusChanges("PipMenuView", "NexusLauncherActivity") - } + testSpec.assertEventLog { this.focusChanges("PipMenuView", "NexusLauncherActivity") } } companion object { /** * Creates the test configurations. * - * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring - * repetitions, screen orientation and navigation modes. + * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring repetitions, + * screen orientation and navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): List<FlickerTestParameter> { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0)) + .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0)) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithSwipeDownTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithSwipeDownTest.kt index e5695694dfbc..f7a244717141 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithSwipeDownTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithSwipeDownTest.kt @@ -36,16 +36,19 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:ExitPipWithSwipeDownTest` * * Actions: + * ``` * Launch an app in pip mode [pipApp], * Swipe the pip window to the bottom-center of the screen and wait it disappear - * + * ``` * Notes: + * ``` * 1. Some default assertions (e.g., nav bar, status bar and screen covered) * are inherited [PipTransition] * 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,20 +63,24 @@ class ExitPipWithSwipeDownTest(testSpec: FlickerTestParameter) : ExitPipTransiti val pipCenterX = pipRegion.centerX() val pipCenterY = pipRegion.centerY() val displayCenterX = device.displayWidth / 2 - val barComponent = if (testSpec.isTablet) { - ComponentNameMatcher.TASK_BAR - } else { - ComponentNameMatcher.NAV_BAR - } - val barLayerHeight = wmHelper.currentState.layerState - .getLayerWithBuffer(barComponent) - ?.visibleRegion - ?.height ?: error("Couldn't find Nav or Task bar layer") + val barComponent = + if (testSpec.isTablet) { + ComponentNameMatcher.TASK_BAR + } else { + ComponentNameMatcher.NAV_BAR + } + val barLayerHeight = + wmHelper.currentState.layerState + .getLayerWithBuffer(barComponent) + ?.visibleRegion + ?.height + ?: error("Couldn't find Nav or Task bar layer") // The dismiss button doesn't appear at the complete bottom of the screen, val displayY = device.displayHeight - barLayerHeight device.swipe(pipCenterX, pipCenterY, displayCenterX, displayY, 50) // Wait until the other app is no longer visible - wmHelper.StateSyncBuilder() + wmHelper + .StateSyncBuilder() .withPipGone() .withWindowSurfaceDisappeared(pipApp) .withAppTransitionIdle() @@ -81,29 +88,25 @@ class ExitPipWithSwipeDownTest(testSpec: FlickerTestParameter) : ExitPipTransiti } } - /** - * Checks that the focus doesn't change between windows during the transition - */ + /** Checks that the focus doesn't change between windows during the transition */ @Presubmit @Test fun focusDoesNotChange() { - testSpec.assertEventLog { - this.focusDoesNotChange() - } + testSpec.assertEventLog { this.focusDoesNotChange() } } companion object { /** * Creates the test configurations. * - * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring - * repetitions, screen orientation and navigation modes. + * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring repetitions, + * screen orientation and navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): List<FlickerTestParameter> { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0)) + .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0)) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt index 5f9419694c13..b40106790b6c 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt @@ -23,34 +23,23 @@ import com.android.server.wm.flicker.traces.region.RegionSubject import com.android.wm.shell.flicker.Direction import org.junit.Test -/** - * Base class for pip tests with Launcher shelf height change - */ -abstract class MovePipShelfHeightTransition( - testSpec: FlickerTestParameter -) : PipTransition(testSpec) { +/** Base class for pip tests with Launcher shelf height change */ +abstract class MovePipShelfHeightTransition(testSpec: FlickerTestParameter) : + PipTransition(testSpec) { protected val testApp = FixedOrientationAppHelper(instrumentation) - /** - * Checks [pipApp] window remains visible throughout the animation - */ + /** Checks [pipApp] window remains visible throughout the animation */ @Presubmit @Test open fun pipWindowIsAlwaysVisible() { - testSpec.assertWm { - isAppWindowVisible(pipApp) - } + testSpec.assertWm { isAppWindowVisible(pipApp) } } - /** - * Checks [pipApp] layer remains visible throughout the animation - */ + /** Checks [pipApp] layer remains visible throughout the animation */ @Presubmit @Test open fun pipLayerIsAlwaysVisible() { - testSpec.assertLayers { - isVisible(pipApp) - } + testSpec.assertLayers { isVisible(pipApp) } } /** @@ -60,9 +49,7 @@ abstract class MovePipShelfHeightTransition( @Presubmit @Test open fun pipWindowRemainInsideVisibleBounds() { - testSpec.assertWmVisibleRegion(pipApp) { - coversAtMost(displayBounds) - } + testSpec.assertWmVisibleRegion(pipApp) { coversAtMost(displayBounds) } } /** @@ -72,9 +59,7 @@ abstract class MovePipShelfHeightTransition( @Presubmit @Test open fun pipLayerRemainInsideVisibleBounds() { - testSpec.assertLayersVisibleRegion(pipApp) { - coversAtMost(displayBounds) - } + testSpec.assertLayersVisibleRegion(pipApp) { coversAtMost(displayBounds) } } /** @@ -83,9 +68,8 @@ abstract class MovePipShelfHeightTransition( */ protected fun pipWindowMoves(direction: Direction) { testSpec.assertWm { - val pipWindowFrameList = this.windowStates { - pipApp.windowMatchesAnyOf(it) && it.isVisible - }.map { it.frame } + val pipWindowFrameList = + this.windowStates { pipApp.windowMatchesAnyOf(it) && it.isVisible }.map { it.frame } when (direction) { Direction.UP -> assertRegionMovementUp(pipWindowFrameList) Direction.DOWN -> assertRegionMovementDown(pipWindowFrameList) @@ -100,9 +84,9 @@ abstract class MovePipShelfHeightTransition( */ protected fun pipLayerMoves(direction: Direction) { testSpec.assertLayers { - val pipLayerRegionList = this.layers { - pipApp.layerMatchesAnyOf(it) && it.isVisible - }.map { it.visibleRegion } + val pipLayerRegionList = + this.layers { pipApp.layerMatchesAnyOf(it) && it.isVisible } + .map { it.visibleRegion } when (direction) { Direction.UP -> assertRegionMovementUp(pipLayerRegionList) Direction.DOWN -> assertRegionMovementDown(pipLayerRegionList) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt index ca086e850f52..3b64d218a73d 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt @@ -36,10 +36,7 @@ import org.junit.runner.RunWith import org.junit.runners.MethodSorters import org.junit.runners.Parameterized -/** - * Test Pip launch. - * To run this test: `atest WMShellFlickerTests:PipKeyboardTest` - */ +/** Test Pip launch. To run this test: `atest WMShellFlickerTests:PipKeyboardTest` */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @@ -52,7 +49,7 @@ open class PipKeyboardTest(testSpec: FlickerTestParameter) : PipTransition(testS assumeFalse(isShellTransitionsEnabled) } - /** {@inheritDoc} */ + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = buildTransition { setup { @@ -73,9 +70,7 @@ open class PipKeyboardTest(testSpec: FlickerTestParameter) : PipTransition(testS } } - /** - * Ensure the pip window remains visible throughout any keyboard interactions - */ + /** Ensure the pip window remains visible throughout any keyboard interactions */ @Presubmit @Test open fun pipInVisibleBounds() { @@ -85,15 +80,11 @@ open class PipKeyboardTest(testSpec: FlickerTestParameter) : PipTransition(testS } } - /** - * Ensure that the pip window does not obscure the keyboard - */ + /** Ensure that the pip window does not obscure the keyboard */ @Presubmit @Test open fun pipIsAboveAppWindow() { - testSpec.assertWmTag(TAG_IME_VISIBLE) { - isAboveWindow(ComponentNameMatcher.IME, pipApp) - } + testSpec.assertWmTag(TAG_IME_VISIBLE) { isAboveWindow(ComponentNameMatcher.IME, pipApp) } } companion object { diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTestShellTransit.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTestShellTransit.kt index 3b6d7da1eaa8..2a82c00bebd3 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTestShellTransit.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTestShellTransit.kt @@ -42,6 +42,5 @@ class PipKeyboardTestShellTransit(testSpec: FlickerTestParameter) : PipKeyboardT @Presubmit @Test - override fun statusBarLayerPositionAtStartAndEnd() = - super.statusBarLayerPositionAtStartAndEnd() + override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt index 61cb2b0c0ca8..1d12154d9be5 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt @@ -42,18 +42,21 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:PipRotationTest` * * Actions: + * ``` * Launch a [pipApp] in pip mode * Launch another app [fixedApp] (appears below pip) * Rotate the screen from [testSpec.startRotation] to [testSpec.endRotation] * (usually, 0->90 and 90->0) - * + * ``` * Notes: + * ``` * 1. Some default assertions (e.g., nav bar, status bar and screen covered) * are inherited from [PipTransition] * 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) @@ -75,43 +78,31 @@ open class PipRotationTest(testSpec: FlickerTestParameter) : PipTransition(testS testApp.launchViaIntent(wmHelper) setRotation(testSpec.startRotation) } - transitions { - setRotation(testSpec.endRotation) - } + transitions { setRotation(testSpec.endRotation) } } - /** - * Checks the position of the navigation bar at the start and end of the transition - */ + /** Checks the position of the navigation bar at the start and end of the transition */ @FlakyTest(bugId = 240499181) @Test override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() - /** - * Checks that [testApp] layer is within [screenBoundsStart] at the start of the transition - */ + /** Checks that [testApp] layer is within [screenBoundsStart] at the start of the transition */ @Presubmit @Test fun fixedAppLayer_StartingBounds() { - testSpec.assertLayersStart { - visibleRegion(testApp).coversAtMost(screenBoundsStart) - } + testSpec.assertLayersStart { visibleRegion(testApp).coversAtMost(screenBoundsStart) } } - /** - * Checks that [testApp] layer is within [screenBoundsEnd] at the end of the transition - */ + /** Checks that [testApp] layer is within [screenBoundsEnd] at the end of the transition */ @Presubmit @Test fun fixedAppLayer_EndingBounds() { - testSpec.assertLayersEnd { - visibleRegion(testApp).coversAtMost(screenBoundsEnd) - } + testSpec.assertLayersEnd { visibleRegion(testApp).coversAtMost(screenBoundsEnd) } } /** - * Checks that [testApp] plus [pipApp] layers are within [screenBoundsEnd] at the start - * of the transition + * Checks that [testApp] plus [pipApp] layers are within [screenBoundsEnd] at the start of the + * transition */ @Presubmit @Test @@ -122,8 +113,8 @@ open class PipRotationTest(testSpec: FlickerTestParameter) : PipTransition(testS } /** - * Checks that [testApp] plus [pipApp] layers are within [screenBoundsEnd] at the end - * of the transition + * Checks that [testApp] plus [pipApp] layers are within [screenBoundsEnd] at the end of the + * transition */ @Presubmit @Test @@ -133,57 +124,41 @@ open class PipRotationTest(testSpec: FlickerTestParameter) : PipTransition(testS } } - /** - * Checks that [pipApp] layer is within [screenBoundsStart] at the start of the transition - */ + /** Checks that [pipApp] layer is within [screenBoundsStart] at the start of the transition */ private fun pipLayerRotates_StartingBounds_internal() { - testSpec.assertLayersStart { - visibleRegion(pipApp).coversAtMost(screenBoundsStart) - } + testSpec.assertLayersStart { visibleRegion(pipApp).coversAtMost(screenBoundsStart) } } - /** - * Checks that [pipApp] layer is within [screenBoundsStart] at the start of the transition - */ + /** Checks that [pipApp] layer is within [screenBoundsStart] at the start of the transition */ @Presubmit @Test fun pipLayerRotates_StartingBounds() { pipLayerRotates_StartingBounds_internal() } - /** - * Checks that [pipApp] layer is within [screenBoundsEnd] at the end of the transition - */ + /** Checks that [pipApp] layer is within [screenBoundsEnd] at the end of the transition */ @Presubmit @Test fun pipLayerRotates_EndingBounds() { - testSpec.assertLayersEnd { - visibleRegion(pipApp).coversAtMost(screenBoundsEnd) - } + testSpec.assertLayersEnd { visibleRegion(pipApp).coversAtMost(screenBoundsEnd) } } /** - * Ensure that the [pipApp] window does not obscure the [testApp] at the start of the - * transition + * Ensure that the [pipApp] window does not obscure the [testApp] at the start of the transition */ @Presubmit @Test fun pipIsAboveFixedAppWindow_Start() { - testSpec.assertWmStart { - isAboveWindow(pipApp, testApp) - } + testSpec.assertWmStart { isAboveWindow(pipApp, testApp) } } /** - * Ensure that the [pipApp] window does not obscure the [testApp] at the end of the - * transition + * Ensure that the [pipApp] window does not obscure the [testApp] at the end of the transition */ @Presubmit @Test fun pipIsAboveFixedAppWindow_End() { - testSpec.assertWmEnd { - isAboveWindow(pipApp, testApp) - } + testSpec.assertWmEnd { isAboveWindow(pipApp, testApp) } } @FlakyTest(bugId = 240499181) @@ -196,15 +171,16 @@ open class PipRotationTest(testSpec: FlickerTestParameter) : PipTransition(testS /** * Creates the test configurations. * - * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring - * repetitions, screen orientation and navigation modes. + * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring repetitions, + * screen orientation and navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTestParameter> { - return FlickerTestParameterFactory.getInstance().getConfigRotationTests( - supportedRotations = listOf(Surface.ROTATION_0, Surface.ROTATION_90) - ) + return FlickerTestParameterFactory.getInstance() + .getConfigRotationTests( + supportedRotations = listOf(Surface.ROTATION_0, Surface.ROTATION_90) + ) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest_ShellTransit.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest_ShellTransit.kt index d868e98d0cf8..983cb1c6bafd 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest_ShellTransit.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest_ShellTransit.kt @@ -35,18 +35,21 @@ import org.junit.runners.Parameterized * To run this test: `atest WMShellFlickerTests:PipRotationTest_ShellTransit` * * Actions: + * ``` * Launch a [pipApp] in pip mode * Launch another app [fixedApp] (appears below pip) * Rotate the screen from [testSpec.startRotation] to [testSpec.endRotation] * (usually, 0->90 and 90->0) - * + * ``` * Notes: + * ``` * 1. Some default assertions (e.g., nav bar, status bar and screen covered) * are inherited from [PipTransition] * 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) @@ -59,9 +62,8 @@ class PipRotationTest_ShellTransit(testSpec: FlickerTestParameter) : PipRotation Assume.assumeTrue(isShellTransitionsEnabled) } - /** {@inheritDoc} */ + /** {@inheritDoc} */ @FlakyTest @Test - override fun navBarLayerPositionAtStartAndEnd() = - super.navBarLayerPositionAtStartAndEnd() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt index ff505a04290b..dfa25104ccc8 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt @@ -40,24 +40,21 @@ abstract class PipTransition(testSpec: FlickerTestParameter) : BaseTest(testSpec } fun doAction(broadcastAction: String) { - instrumentation.context - .sendBroadcast(createIntentWithAction(broadcastAction)) + instrumentation.context.sendBroadcast(createIntentWithAction(broadcastAction)) } companion object { // Corresponds to ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE - @JvmStatic - val ORIENTATION_LANDSCAPE = 0 + @JvmStatic val ORIENTATION_LANDSCAPE = 0 // Corresponds to ActivityInfo.SCREEN_ORIENTATION_PORTRAIT - @JvmStatic - val ORIENTATION_PORTRAIT = 1 + @JvmStatic val ORIENTATION_PORTRAIT = 1 } } /** - * Gets a configuration that handles basic setup and teardown of pip tests and that - * launches the Pip app for test + * Gets a configuration that handles basic setup and teardown of pip tests and that launches the + * Pip app for test * * @param eachRun If the pip app should be launched in each run (otherwise only 1x per test) * @param stringExtras Arguments to pass to the PIP launch intent diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipAppHelperTv.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipAppHelperTv.kt index cdd768abd5bd..36909dd74245 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipAppHelperTv.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipAppHelperTv.kt @@ -24,9 +24,7 @@ import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.PipAppHelper import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper -/** - * Helper class for PIP app on AndroidTV - */ +/** Helper class for PIP app on AndroidTV */ open class PipAppHelperTv(instrumentation: Instrumentation) : PipAppHelper(instrumentation) { private val appSelector = By.pkg(`package`).depth(0) @@ -61,17 +59,12 @@ open class PipAppHelperTv(instrumentation: Instrumentation) : PipAppHelper(instr uiDevice.closeTvPipWindow() } - /** - * Taps the pip window and dismisses it by clicking on the X button. - */ + /** Taps the pip window and dismisses it by clicking on the X button. */ override fun closePipWindow(wmHelper: WindowManagerStateHelper) { uiDevice.closeTvPipWindow() // Wait for animation to complete. - wmHelper.StateSyncBuilder() - .withPipGone() - .withHomeActivityVisible() - .waitForAndVerify() + wmHelper.StateSyncBuilder().withPipGone().withHomeActivityVisible().waitForAndVerify() } fun waitUntilClosed(): Boolean { diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipTestBase.kt index a16f5f6f1620..2cb18f948f0e 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipTestBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipTestBase.kt @@ -24,10 +24,7 @@ import androidx.test.uiautomator.UiDevice import org.junit.Before import org.junit.runners.Parameterized -abstract class PipTestBase( - protected val rotationName: String, - protected val rotation: Int -) { +abstract class PipTestBase(protected val rotationName: String, protected val rotation: Int) { val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() val uiDevice = UiDevice.getInstance(instrumentation) val packageManager: PackageManager = instrumentation.context.packageManager diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipBasicTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipBasicTest.kt index 31fb16ffbd3e..8a073abf032c 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipBasicTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipBasicTest.kt @@ -25,16 +25,11 @@ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized -/** - * Test Pip Menu on TV. - * To run this test: `atest WMShellFlickerTests:TvPipBasicTest` - */ +/** Test Pip Menu on TV. To run this test: `atest WMShellFlickerTests:TvPipBasicTest` */ @RequiresDevice @RunWith(Parameterized::class) -class TvPipBasicTest( - private val radioButtonId: String, - private val pipWindowRatio: Rational? -) : TvPipTestBase() { +class TvPipBasicTest(private val radioButtonId: String, private val pipWindowRatio: Rational?) : + TvPipTestBase() { @Test fun enterPip_openMenu_pressBack_closePip() { @@ -45,8 +40,8 @@ class TvPipBasicTest( testApp.clickObject(radioButtonId) testApp.clickEnterPipButton(wmHelper) - val actualRatio: Float = testApp.ui?.visibleBounds?.ratio - ?: fail("Application UI not found") + val actualRatio: Float = + testApp.ui?.visibleBounds?.ratio ?: fail("Application UI not found") pipWindowRatio?.let { expectedRatio -> assertEquals("Wrong Pip window ratio", expectedRatio.toFloat(), actualRatio) } @@ -62,7 +57,8 @@ class TvPipBasicTest( // Make sure Pip Window ration remained the same after Pip menu was closed testApp.ui?.visibleBounds?.let { newBounds -> assertEquals("Pip window ratio has changed", actualRatio, newBounds.ratio) - } ?: fail("Application UI not found") + } + ?: fail("Application UI not found") // Close Pip testApp.closePipWindow() @@ -77,10 +73,10 @@ class TvPipBasicTest( fun getParams(): Collection<Array<Any?>> { infix fun Int.to(denominator: Int) = Rational(this, denominator) return listOf( - arrayOf("ratio_default", null), - arrayOf("ratio_square", 1 to 1), - arrayOf("ratio_wide", 2 to 1), - arrayOf("ratio_tall", 1 to 2) + arrayOf("ratio_default", null), + arrayOf("ratio_square", 1 to 1), + arrayOf("ratio_wide", 2 to 1), + arrayOf("ratio_tall", 1 to 2) ) } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt index 68dbbfb89b6c..7403aab7d4c0 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt @@ -27,28 +27,26 @@ import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test -/** - * Test Pip Menu on TV. - * To run this test: `atest WMShellFlickerTests:TvPipMenuTests` - */ +/** Test Pip Menu on TV. To run this test: `atest WMShellFlickerTests:TvPipMenuTests` */ @RequiresDevice class TvPipMenuTests : TvPipTestBase() { private val systemUiResources = - packageManager.getResourcesForApplication(SYSTEM_UI_PACKAGE_NAME) - private val pipBoundsWhileInMenu: Rect = systemUiResources.run { - val bounds = getString(getIdentifier("pip_menu_bounds", "string", - SYSTEM_UI_PACKAGE_NAME)) - Rect.unflattenFromString(bounds) ?: error("Could not retrieve PiP menu bounds") - } - private val playButtonDescription = systemUiResources.run { - getString(getIdentifier("pip_play", "string", - SYSTEM_UI_PACKAGE_NAME)) - } - private val pauseButtonDescription = systemUiResources.run { - getString(getIdentifier("pip_pause", "string", - SYSTEM_UI_PACKAGE_NAME)) - } + packageManager.getResourcesForApplication(SYSTEM_UI_PACKAGE_NAME) + private val pipBoundsWhileInMenu: Rect = + systemUiResources.run { + val bounds = + getString(getIdentifier("pip_menu_bounds", "string", SYSTEM_UI_PACKAGE_NAME)) + Rect.unflattenFromString(bounds) ?: error("Could not retrieve PiP menu bounds") + } + private val playButtonDescription = + systemUiResources.run { + getString(getIdentifier("pip_play", "string", SYSTEM_UI_PACKAGE_NAME)) + } + private val pauseButtonDescription = + systemUiResources.run { + getString(getIdentifier("pip_pause", "string", SYSTEM_UI_PACKAGE_NAME)) + } @Before fun tvPipMenuTestsTestUp() { @@ -61,20 +59,29 @@ class TvPipMenuTests : TvPipTestBase() { enterPip_openMenu_assertShown() // Make sure the PiP task is positioned where it should be. - val activityBounds: Rect = testApp.ui?.visibleBounds - ?: error("Could not retrieve Pip Activity bounds") - assertTrue("Pip Activity is positioned correctly while Pip menu is shown", - pipBoundsWhileInMenu == activityBounds) + val activityBounds: Rect = + testApp.ui?.visibleBounds ?: error("Could not retrieve Pip Activity bounds") + assertTrue( + "Pip Activity is positioned correctly while Pip menu is shown", + pipBoundsWhileInMenu == activityBounds + ) // Make sure the Pip Menu Actions are positioned correctly. uiDevice.findTvPipMenuControls()?.visibleBounds?.run { - assertTrue("Pip Menu Actions should be positioned below the Activity in Pip", - top >= activityBounds.bottom) - assertTrue("Pip Menu Actions should be positioned central horizontally", - centerX() == uiDevice.displayWidth / 2) - assertTrue("Pip Menu Actions should be fully shown on the screen", - left >= 0 && right <= uiDevice.displayWidth && bottom <= uiDevice.displayHeight) - } ?: error("Could not retrieve Pip Menu Actions bounds") + assertTrue( + "Pip Menu Actions should be positioned below the Activity in Pip", + top >= activityBounds.bottom + ) + assertTrue( + "Pip Menu Actions should be positioned central horizontally", + centerX() == uiDevice.displayWidth / 2 + ) + assertTrue( + "Pip Menu Actions should be fully shown on the screen", + left >= 0 && right <= uiDevice.displayWidth && bottom <= uiDevice.displayHeight + ) + } + ?: error("Could not retrieve Pip Menu Actions bounds") testApp.closePipWindow() } @@ -107,7 +114,7 @@ class TvPipMenuTests : TvPipTestBase() { // PiP menu should contain the Close button uiDevice.findTvPipMenuCloseButton() - ?: fail("\"Close PIP\" button should be shown in Pip menu") + ?: fail("\"Close PIP\" button should be shown in Pip menu") // Clicking on the Close button should close the app uiDevice.clickTvPipMenuCloseButton() @@ -120,13 +127,15 @@ class TvPipMenuTests : TvPipTestBase() { // PiP menu should contain the Fullscreen button uiDevice.findTvPipMenuFullscreenButton() - ?: fail("\"Full screen\" button should be shown in Pip menu") + ?: fail("\"Full screen\" button should be shown in Pip menu") // Clicking on the fullscreen button should return app to the fullscreen mode. // Click, wait for the app to go fullscreen uiDevice.clickTvPipMenuFullscreenButton() - assertTrue("\"Full screen\" button should open the app fullscreen", - wait { testApp.ui?.isFullscreen(uiDevice) ?: false }) + assertTrue( + "\"Full screen\" button should open the app fullscreen", + wait { testApp.ui?.isFullscreen(uiDevice) ?: false } + ) // Close the app uiDevice.pressBack() @@ -143,8 +152,10 @@ class TvPipMenuTests : TvPipTestBase() { // PiP menu should contain the Pause button uiDevice.findTvPipMenuElementWithDescription(pauseButtonDescription) - ?: fail("\"Pause\" button should be shown in Pip menu if there is an active " + - "playing media session.") + ?: fail( + "\"Pause\" button should be shown in Pip menu if there is an active " + + "playing media session." + ) // When we pause media, the button should change from Pause to Play uiDevice.clickTvPipMenuElementWithDescription(pauseButtonDescription) @@ -152,8 +163,10 @@ class TvPipMenuTests : TvPipTestBase() { assertFullscreenAndCloseButtonsAreShown() // PiP menu should contain the Play button now uiDevice.waitForTvPipMenuElementWithDescription(playButtonDescription) - ?: fail("\"Play\" button should be shown in Pip menu if there is an active " + - "paused media session.") + ?: fail( + "\"Play\" button should be shown in Pip menu if there is an active " + + "paused media session." + ) testApp.closePipWindow() } @@ -166,11 +179,11 @@ class TvPipMenuTests : TvPipTestBase() { // PiP menu should contain "No-Op", "Off" and "Clear" buttons... uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_NO_OP) - ?: fail("\"No-Op\" button should be shown in Pip menu") + ?: fail("\"No-Op\" button should be shown in Pip menu") uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_OFF) - ?: fail("\"Off\" button should be shown in Pip menu") + ?: fail("\"Off\" button should be shown in Pip menu") uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_CLEAR) - ?: fail("\"Clear\" button should be shown in Pip menu") + ?: fail("\"Clear\" button should be shown in Pip menu") // ... and should also contain the "Full screen" and "Close" buttons. assertFullscreenAndCloseButtonsAreShown() @@ -178,31 +191,34 @@ class TvPipMenuTests : TvPipTestBase() { // Invoking the "Off" action should replace it with the "On" action/button and should // remove the "No-Op" action/button. "Clear" action/button should remain in the menu ... uiDevice.waitForTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_ON) - ?: fail("\"On\" button should be shown in Pip for a corresponding custom action") - assertNull("\"No-Op\" button should not be shown in Pip menu", - uiDevice.findTvPipMenuElementWithDescription( - ActivityOptions.Pip.MENU_ACTION_NO_OP)) + ?: fail("\"On\" button should be shown in Pip for a corresponding custom action") + assertNull( + "\"No-Op\" button should not be shown in Pip menu", + uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_NO_OP) + ) uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_CLEAR) - ?: fail("\"Clear\" button should be shown in Pip menu") + ?: fail("\"Clear\" button should be shown in Pip menu") // ... as well as the "Full screen" and "Close" buttons. assertFullscreenAndCloseButtonsAreShown() uiDevice.clickTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_CLEAR) // Invoking the "Clear" action should remove all the custom actions and their corresponding // buttons, ... - uiDevice.waitUntilTvPipMenuElementWithDescriptionIsGone( - ActivityOptions.Pip.MENU_ACTION_ON)?.also { - isGone -> if (!isGone) fail("\"On\" button should not be shown in Pip menu") - } - assertNull("\"Off\" button should not be shown in Pip menu", - uiDevice.findTvPipMenuElementWithDescription( - ActivityOptions.Pip.MENU_ACTION_OFF)) - assertNull("\"Clear\" button should not be shown in Pip menu", - uiDevice.findTvPipMenuElementWithDescription( - ActivityOptions.Pip.MENU_ACTION_CLEAR)) - assertNull("\"No-Op\" button should not be shown in Pip menu", - uiDevice.findTvPipMenuElementWithDescription( - ActivityOptions.Pip.MENU_ACTION_NO_OP)) + uiDevice + .waitUntilTvPipMenuElementWithDescriptionIsGone(ActivityOptions.Pip.MENU_ACTION_ON) + ?.also { isGone -> if (!isGone) fail("\"On\" button should not be shown in Pip menu") } + assertNull( + "\"Off\" button should not be shown in Pip menu", + uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_OFF) + ) + assertNull( + "\"Clear\" button should not be shown in Pip menu", + uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_CLEAR) + ) + assertNull( + "\"No-Op\" button should not be shown in Pip menu", + uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_NO_OP) + ) // ... but the menu should still contain the "Full screen" and "Close" buttons. assertFullscreenAndCloseButtonsAreShown() @@ -218,25 +234,31 @@ class TvPipMenuTests : TvPipTestBase() { // PiP menu should contain "No-Op", "Off" and "Clear" buttons for the custom actions... uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_NO_OP) - ?: fail("\"No-Op\" button should be shown in Pip menu") + ?: fail("\"No-Op\" button should be shown in Pip menu") uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_OFF) - ?: fail("\"Off\" button should be shown in Pip menu") + ?: fail("\"Off\" button should be shown in Pip menu") uiDevice.findTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_CLEAR) - ?: fail("\"Clear\" button should be shown in Pip menu") + ?: fail("\"Clear\" button should be shown in Pip menu") // ... should also contain the "Full screen" and "Close" buttons, ... assertFullscreenAndCloseButtonsAreShown() // ... but should not contain media buttons. - assertNull("\"Play\" button should not be shown in menu when there are custom actions", - uiDevice.findTvPipMenuElementWithDescription(playButtonDescription)) - assertNull("\"Pause\" button should not be shown in menu when there are custom actions", - uiDevice.findTvPipMenuElementWithDescription(pauseButtonDescription)) + assertNull( + "\"Play\" button should not be shown in menu when there are custom actions", + uiDevice.findTvPipMenuElementWithDescription(playButtonDescription) + ) + assertNull( + "\"Pause\" button should not be shown in menu when there are custom actions", + uiDevice.findTvPipMenuElementWithDescription(pauseButtonDescription) + ) uiDevice.clickTvPipMenuElementWithDescription(ActivityOptions.Pip.MENU_ACTION_CLEAR) // Invoking the "Clear" action should remove all the custom actions, which should bring up // media buttons... uiDevice.waitForTvPipMenuElementWithDescription(pauseButtonDescription) - ?: fail("\"Pause\" button should be shown in Pip menu if there is an active " + - "playing media session.") + ?: fail( + "\"Pause\" button should be shown in Pip menu if there is an active " + + "playing media session." + ) // ... while the "Full screen" and "Close" buttons should remain in the menu. assertFullscreenAndCloseButtonsAreShown() @@ -252,8 +274,8 @@ class TvPipMenuTests : TvPipTestBase() { private fun assertFullscreenAndCloseButtonsAreShown() { uiDevice.findTvPipMenuCloseButton() - ?: fail("\"Close PIP\" button should be shown in Pip menu") + ?: fail("\"Close PIP\" button should be shown in Pip menu") uiDevice.findTvPipMenuFullscreenButton() - ?: fail("\"Full screen\" button should be shown in Pip menu") + ?: fail("\"Full screen\" button should be shown in Pip menu") } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt index 134e97bd46e7..90406c510bad 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt @@ -34,8 +34,8 @@ import org.junit.Before import org.junit.Test /** - * Test Pip Notifications on TV. - * To run this test: `atest WMShellFlickerTests:TvPipNotificationTests` + * Test Pip Notifications on TV. To run this test: `atest + * WMShellFlickerTests:TvPipNotificationTests` */ @RequiresDevice class TvPipNotificationTests : TvPipTestBase() { @@ -58,13 +58,17 @@ class TvPipNotificationTests : TvPipTestBase() { testApp.launchViaIntent() testApp.clickEnterPipButton(wmHelper) - assertNotNull("Pip notification should have been posted", - waitForNotificationToAppear { it.isPipNotificationWithTitle(testApp.appName) }) + assertNotNull( + "Pip notification should have been posted", + waitForNotificationToAppear { it.isPipNotificationWithTitle(testApp.appName) } + ) testApp.closePipWindow() - assertTrue("Pip notification should have been dismissed", - waitForNotificationToDisappear { it.isPipNotificationWithTitle(testApp.appName) }) + assertTrue( + "Pip notification should have been dismissed", + waitForNotificationToDisappear { it.isPipNotificationWithTitle(testApp.appName) } + ) } @Test @@ -72,17 +76,20 @@ class TvPipNotificationTests : TvPipTestBase() { testApp.launchViaIntent() testApp.clickEnterPipButton(wmHelper) - val notification: StatusBarNotification = waitForNotificationToAppear { - it.isPipNotificationWithTitle(testApp.appName) - } ?: fail("Pip notification should have been posted") + val notification: StatusBarNotification = + waitForNotificationToAppear { it.isPipNotificationWithTitle(testApp.appName) } + ?: fail("Pip notification should have been posted") - notification.deleteIntent?.send() - ?: fail("Pip notification should contain `delete_intent`") + notification.deleteIntent?.send() ?: fail("Pip notification should contain `delete_intent`") - assertTrue("Pip should have closed by sending the `delete_intent`", - testApp.waitUntilClosed()) - assertTrue("Pip notification should have been dismissed", - waitForNotificationToDisappear { it.isPipNotificationWithTitle(testApp.appName) }) + assertTrue( + "Pip should have closed by sending the `delete_intent`", + testApp.waitUntilClosed() + ) + assertTrue( + "Pip notification should have been dismissed", + waitForNotificationToDisappear { it.isPipNotificationWithTitle(testApp.appName) } + ) } @Test @@ -90,15 +97,17 @@ class TvPipNotificationTests : TvPipTestBase() { testApp.launchViaIntent(wmHelper) testApp.clickEnterPipButton(wmHelper) - val notification: StatusBarNotification = waitForNotificationToAppear { - it.isPipNotificationWithTitle(testApp.appName) - } ?: fail("Pip notification should have been posted") + val notification: StatusBarNotification = + waitForNotificationToAppear { it.isPipNotificationWithTitle(testApp.appName) } + ?: fail("Pip notification should have been posted") notification.contentIntent?.send() ?: fail("Pip notification should contain `content_intent`") - assertNotNull("Pip menu should have been shown after sending `content_intent`", - uiDevice.waitForTvPipMenu()) + assertNotNull( + "Pip menu should have been shown after sending `content_intent`", + uiDevice.waitForTvPipMenu() + ) uiDevice.pressBack() testApp.closePipWindow() @@ -112,35 +121,38 @@ class TvPipNotificationTests : TvPipTestBase() { testApp.clickEnterPipButton(wmHelper) // Wait for the correct notification to show up... - waitForNotificationToAppear { - it.isPipNotificationWithTitle(TITLE_MEDIA_SESSION_PLAYING) - } ?: fail("Pip notification with media session title should have been posted") + waitForNotificationToAppear { it.isPipNotificationWithTitle(TITLE_MEDIA_SESSION_PLAYING) } + ?: fail("Pip notification with media session title should have been posted") // ... and make sure "regular" PiP notification is now shown - assertNull("Regular notification should not have been posted", - findNotification { it.isPipNotificationWithTitle(testApp.appName) }) + assertNull( + "Regular notification should not have been posted", + findNotification { it.isPipNotificationWithTitle(testApp.appName) } + ) // Pause the media session. When paused the application updates the title for the media // session. This change should be reflected in the notification. testApp.pauseMedia() // Wait for the "paused" notification to show up... - waitForNotificationToAppear { - it.isPipNotificationWithTitle(TITLE_MEDIA_SESSION_PAUSED) - } ?: fail("Pip notification with media session title should have been posted") + waitForNotificationToAppear { it.isPipNotificationWithTitle(TITLE_MEDIA_SESSION_PAUSED) } + ?: fail("Pip notification with media session title should have been posted") // ... and make sure "playing" PiP notification is gone - assertNull("Regular notification should not have been posted", - findNotification { it.isPipNotificationWithTitle(TITLE_MEDIA_SESSION_PLAYING) }) + assertNull( + "Regular notification should not have been posted", + findNotification { it.isPipNotificationWithTitle(TITLE_MEDIA_SESSION_PLAYING) } + ) // Now stop the media session, which should revert the title to the "default" one. testApp.stopMedia() // Wait for the "regular" notification to show up... - waitForNotificationToAppear { - it.isPipNotificationWithTitle(testApp.appName) - } ?: fail("Pip notification with media session title should have been posted") + waitForNotificationToAppear { it.isPipNotificationWithTitle(testApp.appName) } + ?: fail("Pip notification with media session title should have been posted") // ... and make sure previous ("paused") notification is gone - assertNull("Regular notification should not have been posted", - findNotification { it.isPipNotificationWithTitle(TITLE_MEDIA_SESSION_PAUSED) }) + assertNull( + "Regular notification should not have been posted", + findNotification { it.isPipNotificationWithTitle(TITLE_MEDIA_SESSION_PAUSED) } + ) testApp.closePipWindow() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt index aeff0ac9f4f2..dc1fe4761757 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt @@ -68,7 +68,8 @@ abstract class TvPipTestBase : PipTestBase(rotationToString(ROTATION_0), ROTATIO fun start() { hasDied = false uiAutomation.adoptShellPermissionIdentity( - android.Manifest.permission.SET_ACTIVITY_WATCHER) + android.Manifest.permission.SET_ACTIVITY_WATCHER + ) activityManager.registerProcessObserver(this) } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvUtils.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvUtils.kt index 1c663409b913..b0adbe1d07ce 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvUtils.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvUtils.kt @@ -33,32 +33,31 @@ private const val TV_PIP_MENU_FULLSCREEN_BUTTON_ID = "tv_pip_menu_fullscreen_but private const val FOCUS_ATTEMPTS = 10 private const val WAIT_TIME_MS = 3_000L -private val TV_PIP_MENU_SELECTOR = - By.res(SYSTEM_UI_PACKAGE_NAME, TV_PIP_MENU_ROOT_ID) +private val TV_PIP_MENU_SELECTOR = By.res(SYSTEM_UI_PACKAGE_NAME, TV_PIP_MENU_ROOT_ID) private val TV_PIP_MENU_BUTTONS_CONTAINER_SELECTOR = - By.res(SYSTEM_UI_PACKAGE_NAME, TV_PIP_MENU_BUTTONS_CONTAINER_ID) + By.res(SYSTEM_UI_PACKAGE_NAME, TV_PIP_MENU_BUTTONS_CONTAINER_ID) private val TV_PIP_MENU_CLOSE_BUTTON_SELECTOR = - By.res(SYSTEM_UI_PACKAGE_NAME, TV_PIP_MENU_CLOSE_BUTTON_ID) + By.res(SYSTEM_UI_PACKAGE_NAME, TV_PIP_MENU_CLOSE_BUTTON_ID) private val TV_PIP_MENU_FULLSCREEN_BUTTON_SELECTOR = - By.res(SYSTEM_UI_PACKAGE_NAME, TV_PIP_MENU_FULLSCREEN_BUTTON_ID) + By.res(SYSTEM_UI_PACKAGE_NAME, TV_PIP_MENU_FULLSCREEN_BUTTON_ID) fun UiDevice.waitForTvPipMenu(): UiObject2? = - wait(Until.findObject(TV_PIP_MENU_SELECTOR), WAIT_TIME_MS) + wait(Until.findObject(TV_PIP_MENU_SELECTOR), WAIT_TIME_MS) fun UiDevice.waitForTvPipMenuToClose(): Boolean = - wait(Until.gone(TV_PIP_MENU_SELECTOR), WAIT_TIME_MS) + wait(Until.gone(TV_PIP_MENU_SELECTOR), WAIT_TIME_MS) fun UiDevice.findTvPipMenuControls(): UiObject2? = - findTvPipMenuElement(TV_PIP_MENU_BUTTONS_CONTAINER_SELECTOR) + findTvPipMenuElement(TV_PIP_MENU_BUTTONS_CONTAINER_SELECTOR) fun UiDevice.findTvPipMenuCloseButton(): UiObject2? = - findTvPipMenuElement(TV_PIP_MENU_CLOSE_BUTTON_SELECTOR) + findTvPipMenuElement(TV_PIP_MENU_CLOSE_BUTTON_SELECTOR) fun UiDevice.findTvPipMenuFullscreenButton(): UiObject2? = - findTvPipMenuElement(TV_PIP_MENU_FULLSCREEN_BUTTON_SELECTOR) + findTvPipMenuElement(TV_PIP_MENU_FULLSCREEN_BUTTON_SELECTOR) fun UiDevice.findTvPipMenuElementWithDescription(desc: String): UiObject2? = - findTvPipMenuElement(By.desc(desc)) + findTvPipMenuElement(By.desc(desc)) private fun UiDevice.findTvPipMenuElement(selector: BySelector): UiObject2? = findObject(TV_PIP_MENU_SELECTOR)?.findObject(selector) @@ -70,11 +69,10 @@ fun UiDevice.waitForTvPipMenuElementWithDescription(desc: String): UiObject2? { // descendant and then retrieve the element from the menu and return to the caller of this // method. val elementSelector = By.desc(desc) - val menuContainingElementSelector = By.copy(TV_PIP_MENU_SELECTOR) - .hasDescendant(elementSelector) + val menuContainingElementSelector = By.copy(TV_PIP_MENU_SELECTOR).hasDescendant(elementSelector) return wait(Until.findObject(menuContainingElementSelector), WAIT_TIME_MS) - ?.findObject(elementSelector) + ?.findObject(elementSelector) } fun UiDevice.waitUntilTvPipMenuElementWithDescriptionIsGone(desc: String): Boolean? { @@ -86,18 +84,17 @@ fun UiDevice.waitUntilTvPipMenuElementWithDescriptionIsGone(desc: String): Boole fun UiDevice.clickTvPipMenuCloseButton() { focusOnAndClickTvPipMenuElement(TV_PIP_MENU_CLOSE_BUTTON_SELECTOR) || - error("Could not focus on the Close button") + error("Could not focus on the Close button") } fun UiDevice.clickTvPipMenuFullscreenButton() { focusOnAndClickTvPipMenuElement(TV_PIP_MENU_FULLSCREEN_BUTTON_SELECTOR) || - error("Could not focus on the Fullscreen button") + error("Could not focus on the Fullscreen button") } fun UiDevice.clickTvPipMenuElementWithDescription(desc: String) { - focusOnAndClickTvPipMenuElement(By.desc(desc) - .pkg(SYSTEM_UI_PACKAGE_NAME)) || - error("Could not focus on the Pip menu object with \"$desc\" description") + focusOnAndClickTvPipMenuElement(By.desc(desc).pkg(SYSTEM_UI_PACKAGE_NAME)) || + error("Could not focus on the Pip menu object with \"$desc\" description") // So apparently Accessibility framework on TV is not very reliable and sometimes the state of // the tree of accessibility nodes as seen by the accessibility clients kind of lags behind of // the "real" state of the "UI tree". It seems, however, that moving focus around the tree @@ -110,7 +107,8 @@ fun UiDevice.clickTvPipMenuElementWithDescription(desc: String) { private fun UiDevice.focusOnAndClickTvPipMenuElement(selector: BySelector): Boolean { repeat(FOCUS_ATTEMPTS) { - val element = findTvPipMenuElement(selector) + val element = + findTvPipMenuElement(selector) ?: error("The Pip Menu element we try to focus on is gone.") if (element.isFocusedOrHasFocusedChild) { @@ -119,10 +117,11 @@ private fun UiDevice.focusOnAndClickTvPipMenuElement(selector: BySelector): Bool } findTvPipMenuElement(By.focused(true))?.let { focused -> - if (element.visibleCenter.x < focused.visibleCenter.x) - pressDPadLeft() else pressDPadRight() + if (element.visibleCenter.x < focused.visibleCenter.x) pressDPadLeft() + else pressDPadRight() waitForIdle() - } ?: error("Pip menu does not contain a focused element") + } + ?: error("Pip menu does not contain a focused element") } return false @@ -155,9 +154,8 @@ private fun UiDevice.moveFocus() { fun UiDevice.pressWindowKey() = pressKeyCode(KeyEvent.KEYCODE_WINDOW) -fun UiObject2.isFullscreen(uiDevice: UiDevice): Boolean = visibleBounds.run { - height() == uiDevice.displayHeight && width() == uiDevice.displayWidth -} +fun UiObject2.isFullscreen(uiDevice: UiDevice): Boolean = + visibleBounds.run { height() == uiDevice.displayHeight && width() == uiDevice.displayWidth } val UiObject2.isFocusedOrHasFocusedChild: Boolean get() = isFocused || findObject(By.focused(true)) != null diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/CopyContentInSplit.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/CopyContentInSplit.kt index 5bed66339ee5..93be15484335 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/CopyContentInSplit.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/CopyContentInSplit.kt @@ -54,12 +54,14 @@ class CopyContentInSplit(testSpec: FlickerTestParameter) : SplitScreenBase(testS override val transition: FlickerBuilder.() -> Unit get() = { super.transition(this) - setup { - SplitScreenUtils.enterSplit(wmHelper, tapl, primaryApp, textEditApp) - } + setup { SplitScreenUtils.enterSplit(wmHelper, tapl, primaryApp, textEditApp) } transitions { SplitScreenUtils.copyContentInSplit( - instrumentation, device, primaryApp, textEditApp) + instrumentation, + device, + primaryApp, + textEditApp + ) } } @@ -82,55 +84,49 @@ class CopyContentInSplit(testSpec: FlickerTestParameter) : SplitScreenBase(testS @Test fun splitScreenDividerKeepVisible() = testSpec.layerKeepVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) - @Presubmit - @Test - fun primaryAppLayerKeepVisible() = testSpec.layerKeepVisible(primaryApp) + @Presubmit @Test fun primaryAppLayerKeepVisible() = testSpec.layerKeepVisible(primaryApp) - @Presubmit - @Test - fun textEditAppLayerKeepVisible() = testSpec.layerKeepVisible(textEditApp) + @Presubmit @Test fun textEditAppLayerKeepVisible() = testSpec.layerKeepVisible(textEditApp) @Presubmit @Test - fun primaryAppBoundsKeepVisible() = testSpec.splitAppLayerBoundsKeepVisible( - primaryApp, landscapePosLeft = tapl.isTablet, portraitPosTop = false) + fun primaryAppBoundsKeepVisible() = + testSpec.splitAppLayerBoundsKeepVisible( + primaryApp, + landscapePosLeft = tapl.isTablet, + portraitPosTop = false + ) @Presubmit @Test - fun textEditAppBoundsKeepVisible() = testSpec.splitAppLayerBoundsKeepVisible( - textEditApp, landscapePosLeft = !tapl.isTablet, portraitPosTop = true) + fun textEditAppBoundsKeepVisible() = + testSpec.splitAppLayerBoundsKeepVisible( + textEditApp, + landscapePosLeft = !tapl.isTablet, + portraitPosTop = true + ) - @Presubmit - @Test - fun primaryAppWindowKeepVisible() = testSpec.appWindowKeepVisible(primaryApp) + @Presubmit @Test fun primaryAppWindowKeepVisible() = testSpec.appWindowKeepVisible(primaryApp) - @Presubmit - @Test - fun textEditAppWindowKeepVisible() = testSpec.appWindowKeepVisible(textEditApp) + @Presubmit @Test fun textEditAppWindowKeepVisible() = testSpec.appWindowKeepVisible(textEditApp) /** {@inheritDoc} */ - @Postsubmit - @Test - override fun entireScreenCovered() = - super.entireScreenCovered() + @Postsubmit @Test override fun entireScreenCovered() = super.entireScreenCovered() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerIsVisibleAtStartAndEnd() = - super.navBarLayerIsVisibleAtStartAndEnd() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerPositionAtStartAndEnd() = - super.navBarLayerPositionAtStartAndEnd() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarWindowIsAlwaysVisible() = - super.navBarWindowIsAlwaysVisible() + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -141,26 +137,22 @@ class CopyContentInSplit(testSpec: FlickerTestParameter) : SplitScreenBase(testS /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarLayerPositionAtStartAndEnd() = - super.statusBarLayerPositionAtStartAndEnd() + override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarWindowIsAlwaysVisible() = - super.statusBarWindowIsAlwaysVisible() + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarLayerIsVisibleAtStartAndEnd() = - super.taskBarLayerIsVisibleAtStartAndEnd() + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarWindowIsAlwaysVisible() = - super.taskBarWindowIsAlwaysVisible() + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -178,10 +170,12 @@ class CopyContentInSplit(testSpec: FlickerTestParameter) : SplitScreenBase(testS @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): List<FlickerTestParameter> { - return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests( - // TODO(b/176061063):The 3 buttons of nav bar do not exist in the hierarchy. - supportedNavigationModes = - listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY)) + return FlickerTestParameterFactory.getInstance() + .getConfigNonRotationTests( + // TODO(b/176061063):The 3 buttons of nav bar do not exist in the hierarchy. + supportedNavigationModes = + listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY) + ) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenUtils.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenUtils.kt index e57ac91617b7..6453ed869681 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenUtils.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenUtils.kt @@ -76,15 +76,15 @@ internal object SplitScreenUtils { fun getSendNotification(instrumentation: Instrumentation): NotificationAppHelper = NotificationAppHelper(instrumentation) - fun getIme(instrumentation: Instrumentation): ImeAppHelper = - ImeAppHelper(instrumentation) + fun getIme(instrumentation: Instrumentation): ImeAppHelper = ImeAppHelper(instrumentation) fun waitForSplitComplete( wmHelper: WindowManagerStateHelper, primaryApp: IComponentMatcher, secondaryApp: IComponentMatcher, ) { - wmHelper.StateSyncBuilder() + wmHelper + .StateSyncBuilder() .withWindowSurfaceAppeared(primaryApp) .withWindowSurfaceAppeared(secondaryApp) .withSplitDividerVisible() @@ -101,9 +101,7 @@ internal object SplitScreenUtils { primaryApp.launchViaIntent(wmHelper) secondaryApp.launchViaIntent(wmHelper) tapl.goHome() - wmHelper.StateSyncBuilder() - .withHomeActivityVisible() - .waitForAndVerify() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() splitFromOverview(tapl) waitForSplitComplete(wmHelper, primaryApp, secondaryApp) } @@ -113,12 +111,11 @@ internal object SplitScreenUtils { // In landscape, tablet will let the first app split to right side, and phone will // split to left side. if (tapl.isTablet) { - tapl.workspace.switchToOverview().overviewActions - .clickSplit() - .currentTask - .open() + tapl.workspace.switchToOverview().overviewActions.clickSplit().currentTask.open() } else { - tapl.workspace.switchToOverview().currentTask + tapl.workspace + .switchToOverview() + .currentTask .tapMenu() .tapSplitMenuItem() .currentTask @@ -132,28 +129,33 @@ internal object SplitScreenUtils { device: UiDevice, wmHelper: WindowManagerStateHelper ) { - val displayBounds = wmHelper.currentState.layerState - .displays.firstOrNull { !it.isVirtual } - ?.layerStackSpace - ?: error("Display not found") + val displayBounds = + wmHelper.currentState.layerState.displays.firstOrNull { !it.isVirtual }?.layerStackSpace + ?: error("Display not found") // Pull down the notifications device.swipe( - displayBounds.centerX(), 5, - displayBounds.centerX(), displayBounds.bottom, 50 /* steps */ + displayBounds.centerX(), + 5, + displayBounds.centerX(), + displayBounds.bottom, + 50 /* steps */ ) SystemClock.sleep(TIMEOUT_MS) // Find the target notification - val notificationScroller = device.wait( - Until.findObject(notificationScrollerSelector), TIMEOUT_MS - ) ?: error ("Unable to find view $notificationScrollerSelector") + val notificationScroller = + device.wait(Until.findObject(notificationScrollerSelector), TIMEOUT_MS) + ?: error("Unable to find view $notificationScrollerSelector") var notificationContent = notificationScroller.findObject(notificationContentSelector) while (notificationContent == null) { device.swipe( - displayBounds.centerX(), displayBounds.centerY(), - displayBounds.centerX(), displayBounds.centerY() - 150, 20 /* steps */ + displayBounds.centerX(), + displayBounds.centerY(), + displayBounds.centerX(), + displayBounds.centerY() - 150, + 20 /* steps */ ) notificationContent = notificationScroller.findObject(notificationContentSelector) } @@ -164,24 +166,33 @@ internal object SplitScreenUtils { val dragEnd = Point(displayBounds.width / 4, displayBounds.width / 4) val downTime = SystemClock.uptimeMillis() - touch( - instrumentation, MotionEvent.ACTION_DOWN, downTime, downTime, - TIMEOUT_MS, dragStart - ) + touch(instrumentation, MotionEvent.ACTION_DOWN, downTime, downTime, TIMEOUT_MS, dragStart) // It needs a horizontal movement to trigger the drag touchMove( - instrumentation, downTime, SystemClock.uptimeMillis(), - DRAG_DURATION_MS, dragStart, dragMiddle + instrumentation, + downTime, + SystemClock.uptimeMillis(), + DRAG_DURATION_MS, + dragStart, + dragMiddle ) touchMove( - instrumentation, downTime, SystemClock.uptimeMillis(), - DRAG_DURATION_MS, dragMiddle, dragEnd + instrumentation, + downTime, + SystemClock.uptimeMillis(), + DRAG_DURATION_MS, + dragMiddle, + dragEnd ) // Wait for a while to start splitting SystemClock.sleep(TIMEOUT_MS) touch( - instrumentation, MotionEvent.ACTION_UP, downTime, SystemClock.uptimeMillis(), - GESTURE_STEP_MS, dragEnd + instrumentation, + MotionEvent.ACTION_UP, + downTime, + SystemClock.uptimeMillis(), + GESTURE_STEP_MS, + dragEnd ) SystemClock.sleep(TIMEOUT_MS) } @@ -194,9 +205,8 @@ internal object SplitScreenUtils { duration: Long, point: Point ) { - val motionEvent = MotionEvent.obtain( - downTime, eventTime, action, point.x.toFloat(), point.y.toFloat(), 0 - ) + val motionEvent = + MotionEvent.obtain(downTime, eventTime, action, point.x.toFloat(), point.y.toFloat(), 0) motionEvent.source = InputDevice.SOURCE_TOUCHSCREEN instrumentation.uiAutomation.injectInputEvent(motionEvent, true) motionEvent.recycle() @@ -219,9 +229,15 @@ internal object SplitScreenUtils { val stepY = (to.y.toFloat() - from.y.toFloat()) / steps.toFloat() for (i in 1..steps) { - val motionMove = MotionEvent.obtain( - downTime, currentTime, MotionEvent.ACTION_MOVE, currentX, currentY, 0 - ) + val motionMove = + MotionEvent.obtain( + downTime, + currentTime, + MotionEvent.ACTION_MOVE, + currentX, + currentY, + 0 + ) motionMove.source = InputDevice.SOURCE_TOUCHSCREEN instrumentation.uiAutomation.injectInputEvent(motionMove, true) motionMove.recycle() @@ -238,20 +254,14 @@ internal object SplitScreenUtils { } } - fun longPress( - instrumentation: Instrumentation, - point: Point - ) { + fun longPress(instrumentation: Instrumentation, point: Point) { val downTime = SystemClock.uptimeMillis() touch(instrumentation, MotionEvent.ACTION_DOWN, downTime, downTime, TIMEOUT_MS, point) SystemClock.sleep(LONG_PRESS_TIME_MS) touch(instrumentation, MotionEvent.ACTION_UP, downTime, downTime, TIMEOUT_MS, point) } - fun createShortcutOnHotseatIfNotExist( - tapl: LauncherInstrumentation, - appName: String - ) { + fun createShortcutOnHotseatIfNotExist(tapl: LauncherInstrumentation, appName: String) { tapl.workspace.deleteAppIcon(tapl.workspace.getHotseatAppIcon(0)) val allApps = tapl.workspace.switchToAllApps() allApps.freeze() @@ -262,18 +272,15 @@ internal object SplitScreenUtils { } } - fun dragDividerToResizeAndWait( - device: UiDevice, - wmHelper: WindowManagerStateHelper - ) { - val displayBounds = wmHelper.currentState.layerState - .displays.firstOrNull { !it.isVirtual } - ?.layerStackSpace - ?: error("Display not found") + fun dragDividerToResizeAndWait(device: UiDevice, wmHelper: WindowManagerStateHelper) { + val displayBounds = + wmHelper.currentState.layerState.displays.firstOrNull { !it.isVirtual }?.layerStackSpace + ?: error("Display not found") val dividerBar = device.wait(Until.findObject(dividerBarSelector), TIMEOUT_MS) dividerBar.drag(Point(displayBounds.width * 1 / 3, displayBounds.height * 2 / 3)) - wmHelper.StateSyncBuilder() + wmHelper + .StateSyncBuilder() .withWindowSurfaceDisappeared(SPLIT_DECOR_MANAGER) .waitForAndVerify() } @@ -284,28 +291,30 @@ internal object SplitScreenUtils { dragToRight: Boolean, dragToBottom: Boolean ) { - val displayBounds = wmHelper.currentState.layerState - .displays.firstOrNull { !it.isVirtual } - ?.layerStackSpace - ?: error("Display not found") + val displayBounds = + wmHelper.currentState.layerState.displays.firstOrNull { !it.isVirtual }?.layerStackSpace + ?: error("Display not found") val dividerBar = device.wait(Until.findObject(dividerBarSelector), TIMEOUT_MS) - dividerBar.drag(Point( - if (dragToRight) { - displayBounds.width * 4 / 5 - } else { - displayBounds.width * 1 / 5 - }, - if (dragToBottom) { - displayBounds.height * 4 / 5 - } else { - displayBounds.height * 1 / 5 - })) + dividerBar.drag( + Point( + if (dragToRight) { + displayBounds.width * 4 / 5 + } else { + displayBounds.width * 1 / 5 + }, + if (dragToBottom) { + displayBounds.height * 4 / 5 + } else { + displayBounds.height * 1 / 5 + } + ) + ) } fun doubleTapDividerToSwitch(device: UiDevice) { val dividerBar = device.wait(Until.findObject(dividerBarSelector), TIMEOUT_MS) - val interval = (ViewConfiguration.getDoubleTapTimeout() + - ViewConfiguration.getDoubleTapMinTime()) / 2 + val interval = + (ViewConfiguration.getDoubleTapTimeout() + ViewConfiguration.getDoubleTapMinTime()) / 2 dividerBar.click() SystemClock.sleep(interval.toLong()) dividerBar.click() @@ -318,16 +327,22 @@ internal object SplitScreenUtils { destinationApp: IComponentNameMatcher, ) { // Copy text from sourceApp - val textView = device.wait(Until.findObject( - By.res(sourceApp.packageName, "SplitScreenTest")), TIMEOUT_MS) + val textView = + device.wait( + Until.findObject(By.res(sourceApp.packageName, "SplitScreenTest")), + TIMEOUT_MS + ) longPress(instrumentation, textView.visibleCenter) val copyBtn = device.wait(Until.findObject(By.text("Copy")), TIMEOUT_MS) copyBtn.click() // Paste text to destinationApp - val editText = device.wait(Until.findObject( - By.res(destinationApp.packageName, "plain_text_input")), TIMEOUT_MS) + val editText = + device.wait( + Until.findObject(By.res(destinationApp.packageName, "plain_text_input")), + TIMEOUT_MS + ) longPress(instrumentation, editText.visibleCenter) val pasteBtn = device.wait(Until.findObject(By.text("Paste")), TIMEOUT_MS) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromAnotherApp.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromAnotherApp.kt index 274a58c136c8..a340f6061ffb 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromAnotherApp.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromAnotherApp.kt @@ -55,9 +55,7 @@ class SwitchBackToSplitFromAnotherApp(testSpec: FlickerTestParameter) : SplitScr SplitScreenUtils.enterSplit(wmHelper, tapl, primaryApp, secondaryApp) thirdApp.launchViaIntent(wmHelper) - wmHelper.StateSyncBuilder() - .withWindowSurfaceAppeared(thirdApp) - .waitForAndVerify() + wmHelper.StateSyncBuilder().withWindowSurfaceAppeared(thirdApp).waitForAndVerify() } transitions { tapl.launchedAppState.quickSwitchToPreviousApp() @@ -74,9 +72,7 @@ class SwitchBackToSplitFromAnotherApp(testSpec: FlickerTestParameter) : SplitScr @Test fun splitScreenDividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible() - @Presubmit - @Test - fun primaryAppLayerBecomesVisible() = testSpec.layerBecomesVisible(primaryApp) + @Presubmit @Test fun primaryAppLayerBecomesVisible() = testSpec.layerBecomesVisible(primaryApp) @Presubmit @Test @@ -84,13 +80,21 @@ class SwitchBackToSplitFromAnotherApp(testSpec: FlickerTestParameter) : SplitScr @Presubmit @Test - fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd( - primaryApp, landscapePosLeft = tapl.isTablet, portraitPosTop = false) + fun primaryAppBoundsIsVisibleAtEnd() = + testSpec.splitAppLayerBoundsIsVisibleAtEnd( + primaryApp, + landscapePosLeft = tapl.isTablet, + portraitPosTop = false + ) @Presubmit @Test - fun secondaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd( - secondaryApp, landscapePosLeft = !tapl.isTablet, portraitPosTop = true) + fun secondaryAppBoundsIsVisibleAtEnd() = + testSpec.splitAppLayerBoundsIsVisibleAtEnd( + secondaryApp, + landscapePosLeft = !tapl.isTablet, + portraitPosTop = true + ) @Presubmit @Test @@ -101,28 +105,22 @@ class SwitchBackToSplitFromAnotherApp(testSpec: FlickerTestParameter) : SplitScr fun secondaryAppWindowBecomesVisible() = testSpec.appWindowBecomesVisible(secondaryApp) /** {@inheritDoc} */ - @Postsubmit - @Test - override fun entireScreenCovered() = - super.entireScreenCovered() + @Postsubmit @Test override fun entireScreenCovered() = super.entireScreenCovered() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerIsVisibleAtStartAndEnd() = - super.navBarLayerIsVisibleAtStartAndEnd() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerPositionAtStartAndEnd() = - super.navBarLayerPositionAtStartAndEnd() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarWindowIsAlwaysVisible() = - super.navBarWindowIsAlwaysVisible() + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -133,26 +131,22 @@ class SwitchBackToSplitFromAnotherApp(testSpec: FlickerTestParameter) : SplitScr /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarLayerPositionAtStartAndEnd() = - super.statusBarLayerPositionAtStartAndEnd() + override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarWindowIsAlwaysVisible() = - super.statusBarWindowIsAlwaysVisible() + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarLayerIsVisibleAtStartAndEnd() = - super.taskBarLayerIsVisibleAtStartAndEnd() + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarWindowIsAlwaysVisible() = - super.taskBarWindowIsAlwaysVisible() + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -170,10 +164,12 @@ class SwitchBackToSplitFromAnotherApp(testSpec: FlickerTestParameter) : SplitScr @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): List<FlickerTestParameter> { - return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests( - // TODO(b/176061063):The 3 buttons of nav bar do not exist in the hierarchy. - supportedNavigationModes = - listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY)) + return FlickerTestParameterFactory.getInstance() + .getConfigNonRotationTests( + // TODO(b/176061063):The 3 buttons of nav bar do not exist in the hierarchy. + supportedNavigationModes = + listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY) + ) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromHome.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromHome.kt index 3da4a943af4e..8fdc9d6cb3bf 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromHome.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromHome.kt @@ -54,9 +54,7 @@ class SwitchBackToSplitFromHome(testSpec: FlickerTestParameter) : SplitScreenBas SplitScreenUtils.enterSplit(wmHelper, tapl, primaryApp, secondaryApp) tapl.goHome() - wmHelper.StateSyncBuilder() - .withHomeActivityVisible() - .waitForAndVerify() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() } transitions { tapl.workspace.quickSwitchToPreviousApp() @@ -73,9 +71,7 @@ class SwitchBackToSplitFromHome(testSpec: FlickerTestParameter) : SplitScreenBas @Test fun splitScreenDividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible() - @Presubmit - @Test - fun primaryAppLayerBecomesVisible() = testSpec.layerBecomesVisible(primaryApp) + @Presubmit @Test fun primaryAppLayerBecomesVisible() = testSpec.layerBecomesVisible(primaryApp) @Presubmit @Test @@ -83,13 +79,21 @@ class SwitchBackToSplitFromHome(testSpec: FlickerTestParameter) : SplitScreenBas @Presubmit @Test - fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd( - primaryApp, landscapePosLeft = tapl.isTablet, portraitPosTop = false) + fun primaryAppBoundsIsVisibleAtEnd() = + testSpec.splitAppLayerBoundsIsVisibleAtEnd( + primaryApp, + landscapePosLeft = tapl.isTablet, + portraitPosTop = false + ) @Presubmit @Test - fun secondaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd( - secondaryApp, landscapePosLeft = !tapl.isTablet, portraitPosTop = true) + fun secondaryAppBoundsIsVisibleAtEnd() = + testSpec.splitAppLayerBoundsIsVisibleAtEnd( + secondaryApp, + landscapePosLeft = !tapl.isTablet, + portraitPosTop = true + ) @Presubmit @Test @@ -100,28 +104,22 @@ class SwitchBackToSplitFromHome(testSpec: FlickerTestParameter) : SplitScreenBas fun secondaryAppWindowBecomesVisible() = testSpec.appWindowBecomesVisible(secondaryApp) /** {@inheritDoc} */ - @Postsubmit - @Test - override fun entireScreenCovered() = - super.entireScreenCovered() + @Postsubmit @Test override fun entireScreenCovered() = super.entireScreenCovered() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerIsVisibleAtStartAndEnd() = - super.navBarLayerIsVisibleAtStartAndEnd() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerPositionAtStartAndEnd() = - super.navBarLayerPositionAtStartAndEnd() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarWindowIsAlwaysVisible() = - super.navBarWindowIsAlwaysVisible() + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -132,26 +130,22 @@ class SwitchBackToSplitFromHome(testSpec: FlickerTestParameter) : SplitScreenBas /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarLayerPositionAtStartAndEnd() = - super.statusBarLayerPositionAtStartAndEnd() + override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarWindowIsAlwaysVisible() = - super.statusBarWindowIsAlwaysVisible() + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarLayerIsVisibleAtStartAndEnd() = - super.taskBarLayerIsVisibleAtStartAndEnd() + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarWindowIsAlwaysVisible() = - super.taskBarWindowIsAlwaysVisible() + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -169,10 +163,12 @@ class SwitchBackToSplitFromHome(testSpec: FlickerTestParameter) : SplitScreenBas @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): List<FlickerTestParameter> { - return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests( - // TODO(b/176061063):The 3 buttons of nav bar do not exist in the hierarchy. - supportedNavigationModes = - listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY)) + return FlickerTestParameterFactory.getInstance() + .getConfigNonRotationTests( + // TODO(b/176061063):The 3 buttons of nav bar do not exist in the hierarchy. + supportedNavigationModes = + listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY) + ) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromRecent.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromRecent.kt index f87d2951f265..5180389b9e7c 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromRecent.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchBackToSplitFromRecent.kt @@ -54,14 +54,10 @@ class SwitchBackToSplitFromRecent(testSpec: FlickerTestParameter) : SplitScreenB SplitScreenUtils.enterSplit(wmHelper, tapl, primaryApp, secondaryApp) tapl.goHome() - wmHelper.StateSyncBuilder() - .withHomeActivityVisible() - .waitForAndVerify() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() } transitions { - tapl.workspace.switchToOverview() - .currentTask - .open() + tapl.workspace.switchToOverview().currentTask.open() SplitScreenUtils.waitForSplitComplete(wmHelper, primaryApp, secondaryApp) } } @@ -75,9 +71,7 @@ class SwitchBackToSplitFromRecent(testSpec: FlickerTestParameter) : SplitScreenB @Test fun splitScreenDividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible() - @Presubmit - @Test - fun primaryAppLayerBecomesVisible() = testSpec.layerBecomesVisible(primaryApp) + @Presubmit @Test fun primaryAppLayerBecomesVisible() = testSpec.layerBecomesVisible(primaryApp) @Presubmit @Test @@ -85,13 +79,21 @@ class SwitchBackToSplitFromRecent(testSpec: FlickerTestParameter) : SplitScreenB @Presubmit @Test - fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd( - primaryApp, landscapePosLeft = tapl.isTablet, portraitPosTop = false) + fun primaryAppBoundsIsVisibleAtEnd() = + testSpec.splitAppLayerBoundsIsVisibleAtEnd( + primaryApp, + landscapePosLeft = tapl.isTablet, + portraitPosTop = false + ) @Presubmit @Test - fun secondaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd( - secondaryApp, landscapePosLeft = !tapl.isTablet, portraitPosTop = true) + fun secondaryAppBoundsIsVisibleAtEnd() = + testSpec.splitAppLayerBoundsIsVisibleAtEnd( + secondaryApp, + landscapePosLeft = !tapl.isTablet, + portraitPosTop = true + ) @Presubmit @Test @@ -102,28 +104,22 @@ class SwitchBackToSplitFromRecent(testSpec: FlickerTestParameter) : SplitScreenB fun secondaryAppWindowBecomesVisible() = testSpec.appWindowBecomesVisible(secondaryApp) /** {@inheritDoc} */ - @Postsubmit - @Test - override fun entireScreenCovered() = - super.entireScreenCovered() + @Postsubmit @Test override fun entireScreenCovered() = super.entireScreenCovered() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerIsVisibleAtStartAndEnd() = - super.navBarLayerIsVisibleAtStartAndEnd() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerPositionAtStartAndEnd() = - super.navBarLayerPositionAtStartAndEnd() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarWindowIsAlwaysVisible() = - super.navBarWindowIsAlwaysVisible() + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -134,26 +130,22 @@ class SwitchBackToSplitFromRecent(testSpec: FlickerTestParameter) : SplitScreenB /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarLayerPositionAtStartAndEnd() = - super.statusBarLayerPositionAtStartAndEnd() + override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarWindowIsAlwaysVisible() = - super.statusBarWindowIsAlwaysVisible() + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarLayerIsVisibleAtStartAndEnd() = - super.taskBarLayerIsVisibleAtStartAndEnd() + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun taskBarWindowIsAlwaysVisible() = - super.taskBarWindowIsAlwaysVisible() + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -171,10 +163,12 @@ class SwitchBackToSplitFromRecent(testSpec: FlickerTestParameter) : SplitScreenB @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): List<FlickerTestParameter> { - return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests( - // TODO(b/176061063):The 3 buttons of nav bar do not exist in the hierarchy. - supportedNavigationModes = - listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY)) + return FlickerTestParameterFactory.getInstance() + .getConfigNonRotationTests( + // TODO(b/176061063):The 3 buttons of nav bar do not exist in the hierarchy. + supportedNavigationModes = + listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY) + ) } } } |