Add CUJ for dismiss split by go home

Add CUJ for dismiss split-screen by go home.

Bug: 231399944
Test: atest WMShellFlickerTests:DismissSplitScreenByGoHome

Change-Id: Ic90c0efaa5c06674ea9402edc302d9c683719f2a
This commit is contained in:
Chilun Huang
2022-04-12 10:46:32 +08:00
parent 6c5af4cd94
commit 38a6014994
6 changed files with 298 additions and 42 deletions

View File

@@ -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
)
}

View File

@@ -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)

View File

@@ -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))
}
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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