Merge "Add CUJ for enter split-screen from overview"

This commit is contained in:
Chilun Huang
2022-08-24 16:27:36 +00:00
committed by Android (Google) Code Review
14 changed files with 293 additions and 88 deletions

View File

@@ -20,6 +20,7 @@ package com.android.wm.shell.flicker
import android.view.Surface
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.traces.layers.LayerTraceEntrySubject
import com.android.server.wm.flicker.traces.layers.LayersTraceSubject
import com.android.server.wm.traces.common.IComponentMatcher
import com.android.server.wm.traces.common.region.Region
@@ -94,25 +95,27 @@ fun FlickerTestParameter.layerKeepVisible(
fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible(
component: IComponentMatcher,
splitLeftTop: Boolean
landscapePosLeft: Boolean,
portraitPosTop: Boolean
) {
assertLayers {
this.isInvisible(component)
this.notContains(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component), isOptional = true)
.then()
.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
.isVisible(component)
.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component))
.then()
.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
.splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
.splitAppLayerBoundsSnapToDivider(
component, landscapePosLeft, portraitPosTop, endRotation)
}
}
fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible(
component: IComponentMatcher,
splitLeftTop: Boolean
landscapePosLeft: Boolean,
portraitPosTop: Boolean
) {
assertLayers {
this.splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
this.splitAppLayerBoundsSnapToDivider(
component, landscapePosLeft, portraitPosTop, endRotation)
.then()
.isVisible(component, true)
.then()
@@ -122,58 +125,96 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible(
fun FlickerTestParameter.splitAppLayerBoundsIsVisibleAtEnd(
component: IComponentMatcher,
splitLeftTop: Boolean
landscapePosLeft: Boolean,
portraitPosTop: Boolean
) {
assertLayersEnd {
val dividerRegion = layer(SPLIT_SCREEN_DIVIDER_COMPONENT).visibleRegion.region
visibleRegion(component).coversAtMost(
if (splitLeftTop) {
getSplitLeftTopRegion(dividerRegion, endRotation)
} else {
getSplitRightBottomRegion(dividerRegion, endRotation)
}
)
splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, endRotation)
}
}
fun FlickerTestParameter.splitAppLayerBoundsKeepVisible(
component: IComponentMatcher,
splitLeftTop: Boolean
landscapePosLeft: Boolean,
portraitPosTop: Boolean
) {
assertLayers {
this.splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, endRotation)
}
}
fun FlickerTestParameter.splitAppLayerBoundsChanges(
component: IComponentMatcher,
splitLeftTop: Boolean
landscapePosLeft: Boolean,
portraitPosTop: Boolean
) {
assertLayers {
if (splitLeftTop) {
this.splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
if (landscapePosLeft) {
this.splitAppLayerBoundsSnapToDivider(
component, landscapePosLeft, portraitPosTop, endRotation)
.then()
.isInvisible(component)
.then()
.splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
.splitAppLayerBoundsSnapToDivider(
component, landscapePosLeft, portraitPosTop, endRotation)
} else {
this.splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
this.splitAppLayerBoundsSnapToDivider(
component, landscapePosLeft, portraitPosTop, endRotation)
}
}
}
fun LayersTraceSubject.splitAppLayerBoundsSnapToDivider(
component: IComponentMatcher,
splitLeftTop: Boolean,
landscapePosLeft: Boolean,
portraitPosTop: Boolean,
rotation: Int
): LayersTraceSubject {
return invoke("splitAppLayerBoundsSnapToDivider") {
val dividerRegion = it.layer(SPLIT_SCREEN_DIVIDER_COMPONENT).visibleRegion.region
it.visibleRegion(component).coversAtMost(
if (splitLeftTop) {
getSplitLeftTopRegion(dividerRegion, rotation)
it.splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, rotation)
}
}
fun LayerTraceEntrySubject.splitAppLayerBoundsSnapToDivider(
component: IComponentMatcher,
landscapePosLeft: Boolean,
portraitPosTop: Boolean,
rotation: Int
): LayerTraceEntrySubject {
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 {
getSplitRightBottomRegion(dividerRegion, rotation)
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
)
}
}
)
}
@@ -184,6 +225,10 @@ fun FlickerTestParameter.appWindowBecomesVisible(
) {
assertWm {
this.isAppWindowInvisible(component)
.then()
.notContains(component, isOptional = true)
.then()
.isAppWindowInvisible(component, isOptional = true)
.then()
.isAppWindowVisible(component)
}
@@ -208,7 +253,7 @@ fun FlickerTestParameter.appWindowIsVisibleAtEnd(
}
fun FlickerTestParameter.appWindowKeepVisible(
component: IComponentMatcher
component: IComponentMatcher
) {
assertWm {
this.isAppWindowVisible(component)
@@ -316,39 +361,3 @@ 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 + dividerRegion.bounds.right) / 2,
displayBounds.bounds.bottom)
} else {
Region.from(
0,
0,
displayBounds.bounds.right,
(dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2)
}
}
fun getSplitRightBottomRegion(dividerRegion: Region, rotation: Int): Region {
val displayBounds = WindowUtils.getDisplayBounds(rotation)
return if (displayBounds.width > displayBounds.height) {
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
)
}
}

View File

@@ -105,6 +105,25 @@ class SplitScreenHelper(
.waitForAndVerify()
}
fun splitFromOverview(tapl: LauncherInstrumentation) {
// Note: The initial split position in landscape is different between tablet and phone.
// 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()
} else {
tapl.workspace.switchToOverview().currentTask
.tapMenu()
.tapSplitMenuItem()
.currentTask
.open()
}
SystemClock.sleep(TIMEOUT_MS)
}
fun dragFromNotificationToSplit(
instrumentation: Instrumentation,
device: UiDevice,

View File

@@ -92,12 +92,12 @@ class CopyContentInSplit(testSpec: FlickerTestParameter) : SplitScreenBase(testS
@Presubmit
@Test
fun primaryAppBoundsKeepVisible() = testSpec.splitAppLayerBoundsKeepVisible(
primaryApp, splitLeftTop = true)
primaryApp, landscapePosLeft = true, portraitPosTop = true)
@Presubmit
@Test
fun textEditAppBoundsKeepVisible() = testSpec.splitAppLayerBoundsKeepVisible(
textEditApp, splitLeftTop = false)
textEditApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test

View File

@@ -98,7 +98,7 @@ class DismissSplitScreenByDivider (testSpec: FlickerTestParameter) : SplitScreen
@Presubmit
@Test
fun primaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible(
primaryApp, splitLeftTop = false)
primaryApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test

View File

@@ -96,12 +96,12 @@ class DismissSplitScreenByGoHome(
@Presubmit
@Test
fun primaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible(
primaryApp, splitLeftTop = false)
primaryApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test
fun secondaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible(
secondaryApp, splitLeftTop = true)
secondaryApp, landscapePosLeft = true, portraitPosTop = true)
@Presubmit
@Test

View File

@@ -108,12 +108,12 @@ class DragDividerToResize (testSpec: FlickerTestParameter) : SplitScreenBase(tes
@Presubmit
@Test
fun primaryAppBoundsChanges() = testSpec.splitAppLayerBoundsChanges(
primaryApp, splitLeftTop = false)
primaryApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test
fun secondaryAppBoundsChanges() = testSpec.splitAppLayerBoundsChanges(
secondaryApp, splitLeftTop = true)
secondaryApp, landscapePosLeft = true, portraitPosTop = true)
/** {@inheritDoc} */
@Postsubmit

View File

@@ -94,12 +94,12 @@ class EnterSplitScreenByDragFromAllApps(
@Presubmit
@Test
fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
primaryApp, splitLeftTop = false)
primaryApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test
fun secondaryAppBoundsBecomesVisible() = testSpec.splitAppLayerBoundsBecomesVisible(
secondaryApp, splitLeftTop = true)
secondaryApp, landscapePosLeft = true, portraitPosTop = true)
@Presubmit
@Test

View File

@@ -109,12 +109,12 @@ class EnterSplitScreenByDragFromNotification(
@Presubmit
@Test
fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
primaryApp, splitLeftTop = false)
primaryApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test
fun secondaryAppBoundsBecomesVisible() = testSpec.splitAppLayerBoundsBecomesVisible(
sendNotificationApp, splitLeftTop = true)
sendNotificationApp, landscapePosLeft = true, portraitPosTop = true)
@Presubmit
@Test

View File

@@ -97,12 +97,12 @@ class EnterSplitScreenByDragFromTaskbar(
@Presubmit
@Test
fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
primaryApp, splitLeftTop = false)
primaryApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test
fun secondaryAppBoundsBecomesVisible() = testSpec.splitAppLayerBoundsBecomesVisible(
secondaryApp, splitLeftTop = true)
secondaryApp, landscapePosLeft = true, portraitPosTop = true)
@Presubmit
@Test

View File

@@ -0,0 +1,177 @@
/*
* 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 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.appWindowBecomesVisible
import com.android.wm.shell.flicker.helpers.SplitScreenHelper
import com.android.wm.shell.flicker.layerBecomesVisible
import com.android.wm.shell.flicker.layerIsVisibleAtEnd
import com.android.wm.shell.flicker.splitAppLayerBoundsBecomesVisible
import com.android.wm.shell.flicker.splitAppLayerBoundsIsVisibleAtEnd
import com.android.wm.shell.flicker.splitScreenDividerBecomesVisible
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/**
* Test enter split screen from Overview.
*
* To run this test: `atest WMShellFlickerTests:EnterSplitScreenFromOverview`
*/
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class EnterSplitScreenFromOverview(testSpec: FlickerTestParameter) : SplitScreenBase(testSpec) {
override val transition: FlickerBuilder.() -> Unit
get() = {
super.transition(this)
setup {
eachRun {
tapl.workspace.switchToOverview().dismissAllTasks()
primaryApp.launchViaIntent(wmHelper)
secondaryApp.launchViaIntent(wmHelper)
tapl.goHome()
wmHelper.StateSyncBuilder()
.withAppTransitionIdle()
.withHomeActivityVisible()
.waitForAndVerify()
}
}
transitions {
SplitScreenHelper.splitFromOverview(tapl)
SplitScreenHelper.waitForSplitComplete(wmHelper, primaryApp, secondaryApp)
}
}
@Presubmit
@Test
fun splitScreenDividerBecomesVisible() = testSpec.splitScreenDividerBecomesVisible()
@Presubmit
@Test
fun primaryAppLayerIsVisibleAtEnd() = testSpec.layerIsVisibleAtEnd(primaryApp)
@Presubmit
@Test
fun secondaryAppLayerBecomesVisible() = testSpec.layerBecomesVisible(secondaryApp)
@Presubmit
@Test
fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
primaryApp, landscapePosLeft = tapl.isTablet, portraitPosTop = false)
@Presubmit
@Test
fun secondaryAppBoundsBecomesVisible() = testSpec.splitAppLayerBoundsBecomesVisible(
secondaryApp, landscapePosLeft = !tapl.isTablet, portraitPosTop = true)
@Presubmit
@Test
fun primaryAppWindowBecomesVisible() = testSpec.appWindowBecomesVisible(primaryApp)
@Presubmit
@Test
fun secondaryAppWindowBecomesVisible() = testSpec.appWindowBecomesVisible(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)
}
}
}

View File

@@ -94,12 +94,12 @@ class SwitchAppByDoubleTapDivider (testSpec: FlickerTestParameter) : SplitScreen
@Presubmit
@Test
fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
primaryApp, splitLeftTop = true)
primaryApp, landscapePosLeft = true, portraitPosTop = true)
@Presubmit
@Test
fun secondaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
secondaryApp, splitLeftTop = false)
secondaryApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test

View File

@@ -98,12 +98,12 @@ class SwitchBackToSplitFromAnotherApp(testSpec: FlickerTestParameter) : SplitScr
@Presubmit
@Test
fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
primaryApp, splitLeftTop = false)
primaryApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test
fun secondaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
secondaryApp, splitLeftTop = true)
secondaryApp, landscapePosLeft = true, portraitPosTop = true)
@Presubmit
@Test

View File

@@ -97,12 +97,12 @@ class SwitchBackToSplitFromHome(testSpec: FlickerTestParameter) : SplitScreenBas
@Presubmit
@Test
fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
primaryApp, splitLeftTop = false)
primaryApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test
fun secondaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
secondaryApp, splitLeftTop = true)
secondaryApp, landscapePosLeft = true, portraitPosTop = true)
@Presubmit
@Test

View File

@@ -99,12 +99,12 @@ class SwitchBackToSplitFromRecent(testSpec: FlickerTestParameter) : SplitScreenB
@Presubmit
@Test
fun primaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
primaryApp, splitLeftTop = false)
primaryApp, landscapePosLeft = false, portraitPosTop = false)
@Presubmit
@Test
fun secondaryAppBoundsIsVisibleAtEnd() = testSpec.splitAppLayerBoundsIsVisibleAtEnd(
secondaryApp, splitLeftTop = true)
secondaryApp, landscapePosLeft = true, portraitPosTop = true)
@Presubmit
@Test