Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f889a16 authored by Chilun Huang's avatar Chilun Huang Committed by Android (Google) Code Review
Browse files

Merge "Use generic way to enter split-screen"

parents 8f74fb3b b52ad523
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -150,6 +150,9 @@ fun FlickerTestParameter.splitAppLayerBoundsChanges(
) {
    assertLayers {
        if (landscapePosLeft) {
            this.splitAppLayerBoundsSnapToDivider(
                component, landscapePosLeft, portraitPosTop, endRotation)
        } else {
            this.splitAppLayerBoundsSnapToDivider(
                component, landscapePosLeft, portraitPosTop, endRotation)
                .then()
@@ -157,9 +160,6 @@ fun FlickerTestParameter.splitAppLayerBoundsChanges(
                .then()
                .splitAppLayerBoundsSnapToDivider(
                    component, landscapePosLeft, portraitPosTop, endRotation)
        } else {
            this.splitAppLayerBoundsSnapToDivider(
                component, landscapePosLeft, portraitPosTop, endRotation)
        }
    }
}
+33 −6
Original line number Diff line number Diff line
@@ -97,13 +97,29 @@ class SplitScreenHelper(
            secondaryApp: IComponentMatcher,
        ) {
            wmHelper.StateSyncBuilder()
                .withAppTransitionIdle()
                .withWindowSurfaceAppeared(primaryApp)
                .withWindowSurfaceAppeared(secondaryApp)
                .withSplitDividerVisible()
                .waitForAndVerify()
        }

        fun enterSplit(
            wmHelper: WindowManagerStateHelper,
            tapl: LauncherInstrumentation,
            primaryApp: SplitScreenHelper,
            secondaryApp: SplitScreenHelper
        ) {
            tapl.workspace.switchToOverview().dismissAllTasks()
            primaryApp.launchViaIntent(wmHelper)
            secondaryApp.launchViaIntent(wmHelper)
            tapl.goHome()
            wmHelper.StateSyncBuilder()
                .withHomeActivityVisible()
                .waitForAndVerify()
            splitFromOverview(tapl)
            waitForSplitComplete(wmHelper, primaryApp, secondaryApp)
        }

        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
@@ -267,24 +283,35 @@ class SplitScreenHelper(
                ?.layerStackSpace
                ?: error("Display not found")
            val dividerBar = device.wait(Until.findObject(dividerBarSelector), TIMEOUT_MS)
            dividerBar.drag(Point(displayBounds.width * 2 / 3, displayBounds.height * 2 / 3))
            dividerBar.drag(Point(displayBounds.width * 1 / 3, displayBounds.height * 2 / 3))

            wmHelper.StateSyncBuilder()
                .withAppTransitionIdle()
                .withWindowSurfaceDisappeared(SPLIT_DECOR_MANAGER)
                .waitForAndVerify()
        }

        fun dragDividerToDismissSplit(
            device: UiDevice,
            wmHelper: WindowManagerStateHelper
            wmHelper: WindowManagerStateHelper,
            dragToRight: Boolean,
            dragToBottom: Boolean
        ) {
            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 * 4 / 5, displayBounds.height * 4 / 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) {
@@ -296,7 +323,7 @@ class SplitScreenHelper(
            dividerBar.click()
        }

        fun copyContentFromLeftToRight(
        fun copyContentInSplit(
            instrumentation: Instrumentation,
            device: UiDevice,
            sourceApp: IComponentNameMatcher,
+5 −19
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@ import com.android.wm.shell.flicker.appWindowKeepVisible
import com.android.wm.shell.flicker.helpers.SplitScreenHelper
import com.android.wm.shell.flicker.layerKeepVisible
import com.android.wm.shell.flicker.splitAppLayerBoundsKeepVisible
import org.junit.Assume
import org.junit.Before
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
@@ -49,30 +47,18 @@ import org.junit.runners.Parameterized
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class CopyContentInSplit(testSpec: FlickerTestParameter) : SplitScreenBase(testSpec) {
    protected val textEditApp = SplitScreenHelper.getIme(instrumentation)

    // TODO(b/231399940): Remove this once we can use recent shortcut to enter split.
    @Before
    open fun before() {
        Assume.assumeTrue(tapl.isTablet)
    }
    private val textEditApp = SplitScreenHelper.getIme(instrumentation)

    override val transition: FlickerBuilder.() -> Unit
        get() = {
            super.transition(this)
            setup {
                eachRun {
                    textEditApp.launchViaIntent(wmHelper)
                    // TODO(b/231399940): Use recent shortcut to enter split.
                    tapl.launchedAppState.taskbar
                        .openAllApps()
                        .getAppIcon(primaryApp.appName)
                        .dragToSplitscreen(primaryApp.`package`, textEditApp.`package`)
                    SplitScreenHelper.waitForSplitComplete(wmHelper, textEditApp, primaryApp)
                    SplitScreenHelper.enterSplit(wmHelper, tapl, primaryApp, textEditApp)
                }
            }
            transitions {
                SplitScreenHelper.copyContentFromLeftToRight(
                SplitScreenHelper.copyContentInSplit(
                    instrumentation, device, primaryApp, textEditApp)
            }
        }
@@ -92,12 +78,12 @@ class CopyContentInSplit(testSpec: FlickerTestParameter) : SplitScreenBase(testS
    @Presubmit
    @Test
    fun primaryAppBoundsKeepVisible() = testSpec.splitAppLayerBoundsKeepVisible(
        primaryApp, landscapePosLeft = true, portraitPosTop = true)
        primaryApp, landscapePosLeft = tapl.isTablet, portraitPosTop = false)

    @Presubmit
    @Test
    fun textEditAppBoundsKeepVisible() = testSpec.splitAppLayerBoundsKeepVisible(
        textEditApp, landscapePosLeft = false, portraitPosTop = false)
        textEditApp, landscapePosLeft = !tapl.isTablet, portraitPosTop = true)

    @Presubmit
    @Test
+17 −21
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ 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.server.wm.flicker.helpers.WindowUtils
import com.android.wm.shell.flicker.SPLIT_SCREEN_DIVIDER_COMPONENT
import com.android.wm.shell.flicker.appWindowBecomesInvisible
import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd
import com.android.wm.shell.flicker.helpers.SplitScreenHelper
@@ -33,14 +34,11 @@ import com.android.wm.shell.flicker.layerBecomesInvisible
import com.android.wm.shell.flicker.layerIsVisibleAtEnd
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 dragging the divider bar.
 *
@@ -53,31 +51,23 @@ import org.junit.runners.Parameterized
@Group1
class DismissSplitScreenByDivider (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 {
                    tapl.goHome()
                    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)
                    SplitScreenHelper.enterSplit(wmHelper, tapl, primaryApp, secondaryApp)
                }
            }
            transitions {
                SplitScreenHelper.dragDividerToDismissSplit(device, wmHelper)
                if (tapl.isTablet) {
                    SplitScreenHelper.dragDividerToDismissSplit(device, wmHelper,
                        dragToRight = false, dragToBottom = true)
                } else {
                    SplitScreenHelper.dragDividerToDismissSplit(device, wmHelper,
                        dragToRight = true, dragToBottom = true)
                }
                wmHelper.StateSyncBuilder()
                    .withAppTransitionIdle()
                    .withFullScreenApp(secondaryApp)
                    .waitForAndVerify()
            }
@@ -98,17 +88,23 @@ class DismissSplitScreenByDivider (testSpec: FlickerTestParameter) : SplitScreen
    @Presubmit
    @Test
    fun primaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible(
        primaryApp, landscapePosLeft = false, portraitPosTop = false)
        primaryApp, landscapePosLeft = tapl.isTablet, portraitPosTop = false)

    @Presubmit
    @Test
    fun secondaryAppBoundsIsFullscreenAtEnd() {
        testSpec.assertLayers {
            this.isVisible(secondaryApp)
                .isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
                .then()
                .isInvisible(secondaryApp)
                .isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
                .then()
                .isVisible(secondaryApp, isOptional = true)
                .isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT, isOptional = true)
                .then()
                .contains(SPLIT_SCREEN_DIVIDER_COMPONENT)
                .then()
                .isVisible(secondaryApp)
                .invoke("secondaryAppBoundsIsFullscreenAtEnd") {
                    val displayBounds = WindowUtils.getDisplayBounds(testSpec.endRotation)
                    it.visibleRegion(secondaryApp).coversExactly(displayBounds)
+3 −18
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@ 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
@@ -52,30 +50,17 @@ 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)
                    SplitScreenHelper.enterSplit(wmHelper, tapl, primaryApp, secondaryApp)
                }
            }
            transitions {
                tapl.goHome()
                wmHelper.StateSyncBuilder()
                    .withAppTransitionIdle()
                    .withHomeActivityVisible()
                    .waitForAndVerify()
            }
@@ -96,12 +81,12 @@ class DismissSplitScreenByGoHome(
    @Presubmit
    @Test
    fun primaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible(
        primaryApp, landscapePosLeft = false, portraitPosTop = false)
        primaryApp, landscapePosLeft = tapl.isTablet, portraitPosTop = false)

    @Presubmit
    @Test
    fun secondaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible(
        secondaryApp, landscapePosLeft = true, portraitPosTop = true)
        secondaryApp, landscapePosLeft = !tapl.isTablet, portraitPosTop = true)

    @Presubmit
    @Test
Loading