diff options
| author | 2022-08-16 12:21:15 +0000 | |
|---|---|---|
| committer | 2022-08-16 12:21:15 +0000 | |
| commit | 2d35e6f58a6fcd1781594a2db9646c95d0de617e (patch) | |
| tree | 7879d68c1b58d9c588d3a86bf59dd3d9810ad6ab | |
| parent | dbb1522d52a9230750cf2198d188e498cebc51ba (diff) | |
| parent | 9e42918c6980daf4357146e6c46ba891275d9ea5 (diff) | |
Merge "Add CUJ for copy content in split"
6 files changed, 267 insertions, 25 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 9da51796a8c1..330c9c95e484 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 @@ -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) 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 42b7b1162d93..a1226e682e05 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 @@ -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") + } + } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/CopyContentInSplit.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/CopyContentInSplit.kt new file mode 100644 index 000000000000..f69107eae638 --- /dev/null +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/CopyContentInSplit.kt @@ -0,0 +1,187 @@ +/* + * 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)) + } + } +} diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/DragDividerToResize.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/DragDividerToResize.kt index cf2dc39637df..0f4d98d69c00 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/DragDividerToResize.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/DragDividerToResize.kt @@ -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 diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchAppByDoubleTapDivider.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchAppByDoubleTapDivider.kt index 38279a3dfd17..bdfd9c7de32f 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchAppByDoubleTapDivider.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SwitchAppByDoubleTapDivider.kt @@ -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 diff --git a/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/res/layout/activity_splitscreen.xml b/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/res/layout/activity_splitscreen.xml index 84789f5a6c02..642a08b5bbe0 100644 --- a/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/res/layout/activity_splitscreen.xml +++ b/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/res/layout/activity_splitscreen.xml @@ -26,6 +26,7 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical|center_horizontal" + android:textIsSelectable="true" android:text="PrimaryActivity" android:textAppearance="?android:attr/textAppearanceLarge"/> |