diff options
| author | 2022-08-02 02:24:55 +0000 | |
|---|---|---|
| committer | 2022-08-02 02:24:55 +0000 | |
| commit | 7d7725efa9becbb097788d1231e20c7cbf7e9664 (patch) | |
| tree | fa26a21ab2df05aeda794336bd181cd0e97db90a | |
| parent | 9991cfe39239328ae67e9ad15039a71df354c4bd (diff) | |
| parent | 38a601499479599f31a40d6a270d86166edbec2d (diff) | |
Merge "Add CUJ for dismiss split by go home"
6 files changed, 298 insertions, 42 deletions
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 c1d743b4e9e8..1e4d23c924e7 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 @@ -47,6 +47,14 @@ fun FlickerTestParameter.splitScreenDividerBecomesVisible() { layerBecomesVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) } +fun FlickerTestParameter.splitScreenDividerBecomesInvisible() { + assertLayers { + this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) + .then() + .isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) + } +} + fun FlickerTestParameter.layerBecomesVisible( component: IComponentMatcher ) { @@ -57,6 +65,16 @@ fun FlickerTestParameter.layerBecomesVisible( } } +fun FlickerTestParameter.layerBecomesInvisible( + component: IComponentMatcher +) { + assertLayers { + this.isVisible(component) + .then() + .isInvisible(component) + } +} + fun FlickerTestParameter.layerIsVisibleAtEnd( component: IComponentMatcher ) { @@ -66,7 +84,6 @@ fun FlickerTestParameter.layerIsVisibleAtEnd( } fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible( - rotation: Int, component: IComponentMatcher, splitLeftTop: Boolean ) { @@ -75,29 +92,50 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible( this.isInvisible(component) .then() .invoke("splitAppLayerBoundsBecomesVisible") { - it.visibleRegion(component).overlaps( + it.visibleRegion(component).coversAtMost( if (splitLeftTop) { - getSplitLeftTopRegion(dividerRegion, rotation) + getSplitLeftTopRegion(dividerRegion, endRotation) } else { - getSplitRightBottomRegion(dividerRegion, rotation) + getSplitRightBottomRegion(dividerRegion, endRotation) } ) } } } +fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible( + component: IComponentMatcher, + splitLeftTop: Boolean +) { + assertLayers { + val dividerRegion = this.first().layer(SPLIT_SCREEN_DIVIDER_COMPONENT).visibleRegion.region + this.invoke("splitAppLayerBoundsBecomesVisible") { + it.visibleRegion(component).coversAtMost( + if (splitLeftTop) { + getSplitLeftTopRegion(dividerRegion, endRotation) + } else { + getSplitRightBottomRegion(dividerRegion, endRotation) + } + ) + } + .then() + .isVisible(component, true) + .then() + .isInvisible(component) + } +} + fun FlickerTestParameter.splitAppLayerBoundsIsVisibleAtEnd( - rotation: Int, component: IComponentMatcher, splitLeftTop: Boolean ) { assertLayersEnd { val dividerRegion = layer(SPLIT_SCREEN_DIVIDER_COMPONENT).visibleRegion.region - visibleRegion(component).overlaps( + visibleRegion(component).coversAtMost( if (splitLeftTop) { - getSplitLeftTopRegion(dividerRegion, rotation) + getSplitLeftTopRegion(dividerRegion, endRotation) } else { - getSplitRightBottomRegion(dividerRegion, rotation) + getSplitRightBottomRegion(dividerRegion, endRotation) } ) } @@ -113,6 +151,16 @@ fun FlickerTestParameter.appWindowBecomesVisible( } } +fun FlickerTestParameter.appWindowBecomesInvisible( + component: IComponentMatcher +) { + assertWm { + this.isAppWindowVisible(component) + .then() + .isAppWindowInvisible(component) + } +} + fun FlickerTestParameter.appWindowIsVisibleAtEnd( component: IComponentMatcher ) { @@ -226,9 +274,17 @@ fun getSecondaryRegion(dividerRegion: Region, rotation: Int): Region { fun getSplitLeftTopRegion(dividerRegion: Region, rotation: Int): Region { val displayBounds = WindowUtils.getDisplayBounds(rotation) return if (displayBounds.width > displayBounds.height) { - Region.from(0, 0, dividerRegion.bounds.left, displayBounds.bounds.bottom) + Region.from( + 0, + 0, + (dividerRegion.bounds.left + dividerRegion.bounds.right) / 2, + displayBounds.bounds.bottom) } else { - Region.from(0, 0, displayBounds.bounds.right, dividerRegion.bounds.top) + Region.from( + 0, + 0, + displayBounds.bounds.right, + (dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2) } } @@ -236,12 +292,16 @@ fun getSplitRightBottomRegion(dividerRegion: Region, rotation: Int): Region { val displayBounds = WindowUtils.getDisplayBounds(rotation) return if (displayBounds.width > displayBounds.height) { Region.from( - dividerRegion.bounds.right, 0, displayBounds.bounds.right, + (dividerRegion.bounds.left + dividerRegion.bounds.right) / 2, + 0, + displayBounds.bounds.right, displayBounds.bounds.bottom ) } else { Region.from( - 0, dividerRegion.bounds.bottom, displayBounds.bounds.right, + 0, + (dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2, + displayBounds.bounds.right, displayBounds.bounds.bottom ) } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SplitScreenHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SplitScreenHelper.kt index ccd5f02e4413..6c9ea7b8c43a 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SplitScreenHelper.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SplitScreenHelper.kt @@ -78,6 +78,19 @@ class SplitScreenHelper( Components.SendNotificationActivity.COMPONENT.toFlickerComponent() ) + fun waitForSplitComplete( + wmHelper: WindowManagerStateHelper, + primaryApp: IComponentMatcher, + secondaryApp: IComponentMatcher, + ) { + wmHelper.StateSyncBuilder() + .withAppTransitionIdle() + .withWindowSurfaceAppeared(primaryApp) + .withWindowSurfaceAppeared(secondaryApp) + .withSplitDividerVisible() + .waitForAndVerify() + } + fun dragFromNotificationToSplit( instrumentation: Instrumentation, device: UiDevice, @@ -190,12 +203,11 @@ class SplitScreenHelper( } fun createShortcutOnHotseatIfNotExist( - taplInstrumentation: LauncherInstrumentation, + tapl: LauncherInstrumentation, appName: String ) { - taplInstrumentation.workspace - .deleteAppIcon(taplInstrumentation.workspace.getHotseatAppIcon(0)) - val allApps = taplInstrumentation.workspace.switchToAllApps() + tapl.workspace.deleteAppIcon(tapl.workspace.getHotseatAppIcon(0)) + val allApps = tapl.workspace.switchToAllApps() allApps.freeze() try { allApps.getAppIcon(appName).dragToHotseat(0) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/DismissSplitScreenByGoHome.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/DismissSplitScreenByGoHome.kt new file mode 100644 index 000000000000..4f48ff021bb2 --- /dev/null +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/DismissSplitScreenByGoHome.kt @@ -0,0 +1,191 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.flicker.splitscreen + +import android.platform.test.annotations.Postsubmit +import android.platform.test.annotations.Presubmit +import android.view.WindowManagerPolicyConstants +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.FlickerParametersRunnerFactory +import com.android.server.wm.flicker.FlickerTestParameter +import com.android.server.wm.flicker.FlickerTestParameterFactory +import com.android.server.wm.flicker.annotation.Group1 +import com.android.server.wm.flicker.dsl.FlickerBuilder +import com.android.wm.shell.flicker.appWindowBecomesInvisible +import com.android.wm.shell.flicker.helpers.SplitScreenHelper +import com.android.wm.shell.flicker.layerBecomesInvisible +import com.android.wm.shell.flicker.splitAppLayerBoundsBecomesInvisible +import com.android.wm.shell.flicker.splitScreenDividerBecomesInvisible +import org.junit.Assume +import org.junit.Before +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test dismiss split screen by go home. + * + * To run this test: `atest WMShellFlickerTests:DismissSplitScreenByGoHome` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Group1 +class DismissSplitScreenByGoHome( + testSpec: FlickerTestParameter +) : SplitScreenBase(testSpec) { + + // TODO(b/231399940): Remove this once we can use recent shortcut to enter split. + @Before + open fun before() { + Assume.assumeTrue(tapl.isTablet) + } + + override val transition: FlickerBuilder.() -> Unit + get() = { + super.transition(this) + setup { + eachRun { + primaryApp.launchViaIntent(wmHelper) + // TODO(b/231399940): Use recent shortcut to enter split. + tapl.launchedAppState.taskbar + .openAllApps() + .getAppIcon(secondaryApp.appName) + .dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`) + SplitScreenHelper.waitForSplitComplete(wmHelper, primaryApp, secondaryApp) + } + } + transitions { + tapl.goHome() + wmHelper.StateSyncBuilder() + .withAppTransitionIdle() + .withHomeActivityVisible() + .waitForAndVerify() + } + } + + @Presubmit + @Test + fun splitScreenDividerBecomesVisible() = testSpec.splitScreenDividerBecomesInvisible() + + @Presubmit + @Test + fun primaryAppLayerBecomesInvisible() = testSpec.layerBecomesInvisible(primaryApp) + + @Presubmit + @Test + fun secondaryAppLayerBecomesInvisible() = testSpec.layerBecomesInvisible(primaryApp) + + @Presubmit + @Test + fun primaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible( + primaryApp, splitLeftTop = false) + + @Presubmit + @Test + fun secondaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible( + secondaryApp, splitLeftTop = true) + + @Presubmit + @Test + fun primaryAppWindowBecomesInvisible() = testSpec.appWindowBecomesInvisible(primaryApp) + + @Presubmit + @Test + fun secondaryAppWindowBecomesInvisible() = testSpec.appWindowBecomesInvisible(secondaryApp) + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = + super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = + super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = + super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = + super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = + super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + companion object { + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): List<FlickerTestParameter> { + return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests( + repetitions = SplitScreenHelper.TEST_REPETITIONS, + // 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/EnterSplitScreenByDragFromAllApps.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromAllApps.kt index 779be0ad95e3..9564d975194b 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromAllApps.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromAllApps.kt @@ -72,15 +72,16 @@ class EnterSplitScreenByDragFromAllApps( } transitions { tapl.launchedAppState.taskbar - .openAllApps() - .getAppIcon(secondaryApp.appName) - .dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`) + .openAllApps() + .getAppIcon(secondaryApp.appName) + .dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`) + SplitScreenHelper.waitForSplitComplete(wmHelper, primaryApp, secondaryApp) } } @Presubmit @Test - fun dividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible() + fun splitScreenDividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible() @Presubmit @Test @@ -93,12 +94,12 @@ class EnterSplitScreenByDragFromAllApps( @Presubmit @Test fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd( - testSpec.endRotation, primaryApp, false /* splitLeftTop */) + primaryApp, splitLeftTop = false) @Presubmit @Test fun secondaryAppBoundsBecomesVisible() = testSpec.splitAppLayerBoundsBecomesVisible( - testSpec.endRotation, secondaryApp, true /* splitLeftTop */) + secondaryApp, splitLeftTop = true) @Presubmit @Test @@ -106,8 +107,7 @@ class EnterSplitScreenByDragFromAllApps( @Presubmit @Test - fun secondaryAppWindowBecomesVisible() = - testSpec.appWindowBecomesVisible(secondaryApp) + fun secondaryAppWindowBecomesVisible() = testSpec.appWindowBecomesVisible(secondaryApp) /** {@inheritDoc} */ @Postsubmit diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromNotification.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromNotification.kt index d47d81b4287a..3b59716180b6 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromNotification.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromNotification.kt @@ -84,6 +84,7 @@ class EnterSplitScreenByDragFromNotification( } transitions { SplitScreenHelper.dragFromNotificationToSplit(instrumentation, device, wmHelper) + SplitScreenHelper.waitForSplitComplete(wmHelper, primaryApp, sendNotificationApp) } teardown { eachRun { @@ -94,7 +95,7 @@ class EnterSplitScreenByDragFromNotification( @Presubmit @Test - fun dividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible() + fun splitScreenDividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible() @Presubmit @Test @@ -108,14 +109,12 @@ class EnterSplitScreenByDragFromNotification( @Presubmit @Test fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd( - testSpec.endRotation, primaryApp, false /* splitLeftTop */ - ) + primaryApp, splitLeftTop = false) @Presubmit @Test fun secondaryAppBoundsBecomesVisible() = testSpec.splitAppLayerBoundsBecomesVisible( - testSpec.endRotation, sendNotificationApp, true /* splitLeftTop */ - ) + sendNotificationApp, splitLeftTop = true) @Presubmit @Test @@ -123,8 +122,7 @@ class EnterSplitScreenByDragFromNotification( @Presubmit @Test - fun secondaryAppWindowIsVisibleAtEnd() = - testSpec.appWindowIsVisibleAtEnd(sendNotificationApp) + fun secondaryAppWindowIsVisibleAtEnd() = testSpec.appWindowIsVisibleAtEnd(sendNotificationApp) /** {@inheritDoc} */ @Postsubmit diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromTaskbar.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromTaskbar.kt index 1493d1fd3cce..3de98723e132 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromTaskbar.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromTaskbar.kt @@ -77,16 +77,14 @@ class EnterSplitScreenByDragFromTaskbar( transitions { tapl.launchedAppState.taskbar .getAppIcon(secondaryApp.appName) - .dragToSplitscreen( - secondaryApp.`package`, - primaryApp.`package` - ) + .dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`) + SplitScreenHelper.waitForSplitComplete(wmHelper, primaryApp, secondaryApp) } } @Presubmit @Test - fun dividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible() + fun splitScreenDividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible() @Presubmit @Test @@ -99,14 +97,12 @@ class EnterSplitScreenByDragFromTaskbar( @Presubmit @Test fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd( - testSpec.endRotation, primaryApp, splitLeftTop = false - ) + primaryApp, splitLeftTop = false) @Presubmit @Test fun secondaryAppBoundsBecomesVisible() = testSpec.splitAppLayerBoundsBecomesVisible( - testSpec.endRotation, secondaryApp, splitLeftTop = true - ) + secondaryApp, splitLeftTop = true) @Presubmit @Test @@ -114,8 +110,7 @@ class EnterSplitScreenByDragFromTaskbar( @Presubmit @Test - fun secondaryAppWindowBecomesVisible() = - testSpec.appWindowBecomesVisible(secondaryApp) + fun secondaryAppWindowBecomesVisible() = testSpec.appWindowBecomesVisible(secondaryApp) /** {@inheritDoc} */ @Postsubmit |