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

Commit 9e42918c authored by Chilun Huang's avatar Chilun Huang
Browse files

Add CUJ for copy content in split

Add CUJ for copy content from the left to the right side of the
split-screen.

Bug: 231400127
Test: atest WMShellFlickerTests:CopyContentInSplit
Change-Id: Ibc16b3997008b64d0ca831ffa19035cdd5bb6774
parent 2611ae2b
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -84,6 +84,14 @@ fun FlickerTestParameter.layerIsVisibleAtEnd(
    }
}

fun FlickerTestParameter.layerKeepVisible(
    component: IComponentMatcher
) {
    assertLayers {
        this.isVisible(component)
    }
}

fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible(
    component: IComponentMatcher,
    splitLeftTop: Boolean
@@ -128,6 +136,15 @@ fun FlickerTestParameter.splitAppLayerBoundsIsVisibleAtEnd(
    }
}

fun FlickerTestParameter.splitAppLayerBoundsKeepVisible(
    component: IComponentMatcher,
    splitLeftTop: Boolean
) {
    assertLayers {
        this.splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
    }
}

fun FlickerTestParameter.splitAppLayerBoundsChanges(
    component: IComponentMatcher,
    splitLeftTop: Boolean
@@ -190,6 +207,14 @@ fun FlickerTestParameter.appWindowIsVisibleAtEnd(
    }
}

fun FlickerTestParameter.appWindowKeepVisible(
        component: IComponentMatcher
) {
    assertWm {
        this.isAppWindowVisible(component)
    }
}

fun FlickerTestParameter.dockedStackDividerIsVisibleAtEnd() {
    assertLayersEnd {
        this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT)
+46 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ class SplitScreenHelper(
        const val NOTIFICATION_SCROLLER = "notification_stack_scroller"
        const val DIVIDER_BAR = "docked_divider_handle"
        const val GESTURE_STEP_MS = 16L
        const val LONG_PRESS_TIME_MS = 100L

        private val notificationScrollerSelector: BySelector
            get() = By.res(SYSTEM_UI_PACKAGE_NAME, NOTIFICATION_SCROLLER)
@@ -83,6 +84,13 @@ class SplitScreenHelper(
                Components.SendNotificationActivity.COMPONENT.toFlickerComponent()
            )

        fun getIme(instrumentation: Instrumentation): SplitScreenHelper =
            SplitScreenHelper(
                instrumentation,
                Components.ImeActivity.LABEL,
                Components.ImeActivity.COMPONENT.toFlickerComponent()
            )

        fun waitForSplitComplete(
            wmHelper: WindowManagerStateHelper,
            primaryApp: IComponentMatcher,
@@ -207,6 +215,16 @@ class SplitScreenHelper(
            }
        }

        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
@@ -258,5 +276,33 @@ class SplitScreenHelper(
            SystemClock.sleep(interval.toLong())
            dividerBar.click()
        }

        fun copyContentFromLeftToRight(
            instrumentation: Instrumentation,
            device: UiDevice,
            sourceApp: IComponentMatcher,
            destinationApp: IComponentMatcher,
        ) {
            // Copy text from sourceApp
            val textView = device.wait(Until.findObject(
                By.res(sourceApp.packageNames.firstOrNull(), "SplitScreenTest")), TIMEOUT_MS)
            longPress(instrumentation, textView.getVisibleCenter())

            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.packageNames.firstOrNull(), "plain_text_input")), TIMEOUT_MS)
            longPress(instrumentation, editText.getVisibleCenter())

            val pasteBtn = device.wait(Until.findObject(By.text("Paste")), TIMEOUT_MS)
            pasteBtn.click()

            // Verify text
            if (!textView.getText().contentEquals(editText.getText())) {
                error("Fail to copy content in split")
            }
        }
    }
}
+187 −0
Original line number Diff line number Diff line
/*
 * 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.SPLIT_SCREEN_DIVIDER_COMPONENT
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
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized

/**
 * Test copy content from the left to the right side of the split-screen.
 *
 * To run this test: `atest WMShellFlickerTests:CopyContentInSplit`
 */
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@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)
    }

    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)
                }
            }
            transitions {
                SplitScreenHelper.copyContentFromLeftToRight(
                    instrumentation, device, primaryApp, textEditApp)
            }
        }

    @Presubmit
    @Test
    fun splitScreenDividerKeepVisible() = testSpec.layerKeepVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)

    @Presubmit
    @Test
    fun primaryAppLayerKeepVisible() = testSpec.layerKeepVisible(primaryApp)

    @Presubmit
    @Test
    fun textEditAppLayerKeepVisible() = testSpec.layerKeepVisible(textEditApp)

    @Presubmit
    @Test
    fun primaryAppBoundsKeepVisible() = testSpec.splitAppLayerBoundsKeepVisible(
        primaryApp, splitLeftTop = true)

    @Presubmit
    @Test
    fun textEditAppBoundsKeepVisible() = testSpec.splitAppLayerBoundsKeepVisible(
        textEditApp, splitLeftTop = false)

    @Presubmit
    @Test
    fun primaryAppWindowKeepVisible() = testSpec.appWindowKeepVisible(primaryApp)

    @Presubmit
    @Test
    fun textEditAppWindowKeepVisible() = testSpec.appWindowKeepVisible(textEditApp)

    /** {@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))
        }
    }
}
+6 −20
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@ 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.SPLIT_SCREEN_DIVIDER_COMPONENT
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.splitAppLayerBoundsChanges
import org.junit.Assume
import org.junit.Before
@@ -77,19 +79,11 @@ class DragDividerToResize (testSpec: FlickerTestParameter) : SplitScreenBase(tes

    @Presubmit
    @Test
    fun splitScreenDividerKeepVisible() {
        testSpec.assertLayers {
            this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
        }
    }
    fun splitScreenDividerKeepVisible() = testSpec.layerKeepVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)

    @Presubmit
    @Test
    fun primaryAppLayerKeepVisible() {
        testSpec.assertLayers {
            this.isVisible(primaryApp)
        }
    }
    fun primaryAppLayerKeepVisible() = testSpec.layerKeepVisible(primaryApp)

    @Presubmit
    @Test
@@ -105,19 +99,11 @@ class DragDividerToResize (testSpec: FlickerTestParameter) : SplitScreenBase(tes

    @Presubmit
    @Test
    fun primaryAppWindowKeepVisible() {
        testSpec.assertWm {
            this.isAppWindowVisible(primaryApp)
        }
    }
    fun primaryAppWindowKeepVisible() = testSpec.appWindowKeepVisible(primaryApp)

    @Presubmit
    @Test
    fun secondaryAppWindowKeepVisible() {
        testSpec.assertWm {
            this.isAppWindowVisible(secondaryApp)
        }
    }
    fun secondaryAppWindowKeepVisible() = testSpec.appWindowKeepVisible(secondaryApp)

    @Presubmit
    @Test
+2 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.wm.shell.flicker.SPLIT_SCREEN_DIVIDER_COMPONENT
import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd
import com.android.wm.shell.flicker.helpers.SplitScreenHelper
import com.android.wm.shell.flicker.layerIsVisibleAtEnd
import com.android.wm.shell.flicker.layerKeepVisible
import com.android.wm.shell.flicker.splitAppLayerBoundsIsVisibleAtEnd
import org.junit.Assume
import org.junit.Before
@@ -80,11 +81,7 @@ class SwitchAppByDoubleTapDivider (testSpec: FlickerTestParameter) : SplitScreen

    @Presubmit
    @Test
    fun splitScreenDividerKeepVisible() {
        testSpec.assertLayers {
            this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
        }
    }
    fun splitScreenDividerKeepVisible() = testSpec.layerKeepVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)

    @Presubmit
    @Test
Loading