From 3e2cf2ea9c349f2b2623e3904d5cca5192e098a8 Mon Sep 17 00:00:00 2001 From: Bill Lin Date: Tue, 1 Dec 2020 11:25:58 +0800 Subject: [PATCH] 5-1/ Migrate CTS split screen testNonResizeable tests 1. testNonResizeableNotDocked 2. testNonResizeableWhenAlreadyInSplitScreenPrimary 3. testNonResizeableWhenAlreadyInSplitScreenSecondary 4. Refine the test flow to be more effeciency Test: atest WMShellFlickerTests:EnterSplitScreenTest Test: atest WMShellFlickerTests:AppPairsTest Bug: 161435597 Change-Id: I271a522f220a65b1be7de6599a9ed185f06888b3 --- .../wm/shell/flicker/CommonConstants.kt | 1 + .../wm/shell/flicker/apppairs/AppPairsTest.kt | 46 ++++++- .../flicker/apppairs/AppPairsTestBase.kt | 4 + .../splitscreen/EnterSplitScreenTest.kt | 112 +++++++++++++++++- .../splitscreen/SplitScreenTestBase.kt | 4 + .../test-apps/flickerapp/AndroidManifest.xml | 11 ++ .../res/layout/activity_non_resizeable.xml | 32 +++++ .../wm/shell/flicker/testapp/Components.java | 7 ++ .../testapp/NonResizeableActivity.java | 29 +++++ 9 files changed, 235 insertions(+), 11 deletions(-) create mode 100644 libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/res/layout/activity_non_resizeable.xml create mode 100644 libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/NonResizeableActivity.java diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt index 96234fcc85708..5125a3972cf43 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt @@ -37,3 +37,4 @@ const val TEST_APP_FIXED_ACTIVITY_LABEL = "FixedApp" // Test App > SplitScreen Activity const val TEST_APP_SPLITSCREEN_PRIMARY_LABEL = "SplitScreenPrimaryApp" const val TEST_APP_SPLITSCREEN_SECONDARY_LABEL = "SplitScreenSecondaryApp" +const val TEST_APP_NONRESIZEABLE_LABEL = "NonResizeableApp" diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTest.kt index 0f8d30a94ec6f..379ec95b67927 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTest.kt @@ -61,10 +61,9 @@ class AppPairsTest( setup { eachRun { uiDevice.wakeUpAndGoToHomeScreen() - primaryApp.open() - uiDevice.pressHome() - secondaryApp.open() - uiDevice.pressHome() + primaryApp.launchViaIntent() + secondaryApp.launchViaIntent() + nonResizeableApp.launchViaIntent() updateTaskId() } } @@ -90,7 +89,7 @@ class AppPairsTest( @Test fun testAppPairs_pairPrimaryAndSecondaryApps() { - val testTag = "testAppPaired_pairPrimaryAndSecondary" + val testTag = "testAppPairs_pairPrimaryAndSecondaryApps" runWithFlicker(appPairsSetup) { withTestName { testTag } repeat { @@ -176,6 +175,36 @@ class AppPairsTest( } } + @Test + fun testAppPairs_canNotPairNonResizeableApps() { + val testTag = "testAppPairs_canNotPairNonResizeableApps" + runWithFlicker(appPairsSetup) { + withTestName { testTag } + repeat { + TEST_REPETITIONS + } + transitions { + nonResizeableApp.launchViaIntent() + // TODO pair apps through normal UX flow + executeShellCommand(composePairsCommand( + primaryTaskId, nonResizeableTaskId, true /* pair */)) + SystemClock.sleep(AppPairsHelper.TIMEOUT_MS) + } + assertions { + layersTrace { + appPairsDividerIsInvisible() + } + windowManagerTrace { + end { + showsAppWindow(nonResizeableApp.defaultWindowName) + .and() + .hidesAppWindow(primaryApp.defaultWindowName) + } + } + } + } + } + private fun composePairsCommand( primaryApp: String, secondaryApp: String, @@ -202,6 +231,7 @@ class AppPairsTest( private fun updateTaskId() { val primaryAppComponent = primaryApp.openAppIntent.component val secondaryAppComponent = secondaryApp.openAppIntent.component + val nonResizeableAppComponent = nonResizeableApp.openAppIntent.component if (primaryAppComponent != null) { primaryTaskId = appPairsHelper.getTaskIdForActivity( primaryAppComponent.packageName, primaryAppComponent.className).toString() @@ -210,11 +240,17 @@ class AppPairsTest( secondaryTaskId = appPairsHelper.getTaskIdForActivity( secondaryAppComponent.packageName, secondaryAppComponent.className).toString() } + if (nonResizeableAppComponent != null) { + nonResizeableTaskId = appPairsHelper.getTaskIdForActivity( + nonResizeableAppComponent.packageName, + nonResizeableAppComponent.className).toString() + } } companion object { var primaryTaskId = "" var secondaryTaskId = "" + var nonResizeableTaskId = "" @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection> { diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestBase.kt index f32cd88420745..4d46f2856704c 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTestBase.kt @@ -17,6 +17,7 @@ package com.android.wm.shell.flicker.apppairs import com.android.wm.shell.flicker.NonRotationTestBase +import com.android.wm.shell.flicker.TEST_APP_NONRESIZEABLE_LABEL import com.android.wm.shell.flicker.TEST_APP_SPLITSCREEN_PRIMARY_LABEL import com.android.wm.shell.flicker.TEST_APP_SPLITSCREEN_SECONDARY_LABEL import com.android.wm.shell.flicker.helpers.AppPairsHelper @@ -36,4 +37,7 @@ abstract class AppPairsTestBase( protected val secondaryApp = SplitScreenHelper(instrumentation, TEST_APP_SPLITSCREEN_SECONDARY_LABEL, Components.SplitScreenSecondaryActivity()) + protected val nonResizeableApp = SplitScreenHelper(instrumentation, + TEST_APP_NONRESIZEABLE_LABEL, + Components.NonResizeableActivity()) } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenTest.kt index 5570a562a5150..d36ad930a13b4 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenTest.kt @@ -21,14 +21,21 @@ import android.view.Surface import androidx.test.filters.RequiresDevice import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.dsl.runWithFlicker +import com.android.server.wm.flicker.helpers.WindowUtils +import com.android.server.wm.flicker.helpers.canSplitScreen +import com.android.server.wm.flicker.helpers.exitSplitScreen +import com.android.server.wm.flicker.helpers.isInSplitScreen import com.android.server.wm.flicker.helpers.launchSplitScreen +import com.android.server.wm.flicker.helpers.openQuickstep import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen +import com.android.wm.shell.flicker.dockedStackDividerIsInvisible import com.android.wm.shell.flicker.dockedStackDividerIsVisible import com.android.wm.shell.flicker.helpers.SplitScreenHelper.Companion.TEST_REPETITIONS import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible +import org.junit.Assert import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -56,14 +63,16 @@ class EnterSplitScreenTest( setup { eachRun { uiDevice.wakeUpAndGoToHomeScreen() - splitScreenApp.open() - uiDevice.pressHome() } } teardown { eachRun { + if (uiDevice.isInSplitScreen()) { + uiDevice.exitSplitScreen() + } splitScreenApp.exit() secondaryApp.exit() + nonResizeableApp.exit() } } assertions { @@ -87,6 +96,7 @@ class EnterSplitScreenTest( TEST_REPETITIONS } transitions { + splitScreenApp.launchViaIntent() uiDevice.launchSplitScreen() } assertions { @@ -118,10 +128,8 @@ class EnterSplitScreenTest( TEST_REPETITIONS } transitions { - secondaryApp.open() - uiDevice.pressHome() - splitScreenApp.open() - uiDevice.pressHome() + secondaryApp.launchViaIntent() + splitScreenApp.launchViaIntent() uiDevice.launchSplitScreen() splitScreenApp.reopenAppFromOverview() } @@ -150,6 +158,98 @@ class EnterSplitScreenTest( } } + @Test + fun testNonResizeableNotDocked() { + val testTag = "testNonResizeableNotDocked" + runWithFlicker(splitScreenSetup) { + withTestName { testTag } + repeat { + TEST_REPETITIONS + } + transitions { + nonResizeableApp.launchViaIntent() + uiDevice.openQuickstep() + if (uiDevice.canSplitScreen()) { + Assert.fail("Non-resizeable app should not enter split screen") + } + } + assertions { + layersTrace { + dockedStackDividerIsInvisible() + } + windowManagerTrace { + end { + hidesAppWindow(nonResizeableApp.defaultWindowName) + } + } + } + } + } + + @Test + fun testNonResizeableWhenAlreadyInSplitScreenPrimary() { + val testTag = "testNonResizeableWhenAlreadyInSplitScreenPrimary" + runWithFlicker(splitScreenSetup) { + withTestName { testTag } + repeat { + TEST_REPETITIONS + } + transitions { + nonResizeableApp.launchViaIntent() + splitScreenApp.launchViaIntent() + uiDevice.launchSplitScreen() + nonResizeableApp.reopenAppFromOverview() + } + assertions { + layersTrace { + dockedStackDividerIsInvisible() + end("appsEndingBounds", enabled = false) { + val displayBounds = WindowUtils.getDisplayBounds(rotation) + this.hasVisibleRegion(nonResizeableApp.defaultWindowName, displayBounds) + } + } + windowManagerTrace { + end { + showsAppWindow(nonResizeableApp.defaultWindowName) + hidesAppWindow(splitScreenApp.defaultWindowName) + } + } + } + } + } + + @Test + fun testNonResizeableWhenAlreadyInSplitScreenSecondary() { + val testTag = "testNonResizeableWhenAlreadyInSplitScreenSecondary" + runWithFlicker(splitScreenSetup) { + withTestName { testTag } + repeat { + TEST_REPETITIONS + } + transitions { + splitScreenApp.launchViaIntent() + uiDevice.launchSplitScreen() + uiDevice.pressBack() + nonResizeableApp.launchViaIntent() + } + assertions { + layersTrace { + dockedStackDividerIsInvisible() + end("appsEndingBounds", enabled = false) { + val displayBounds = WindowUtils.getDisplayBounds(rotation) + this.hasVisibleRegion(nonResizeableApp.defaultWindowName, displayBounds) + } + } + windowManagerTrace { + end { + showsAppWindow(nonResizeableApp.defaultWindowName) + hidesAppWindow(splitScreenApp.defaultWindowName) + } + } + } + } + } + companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenTestBase.kt index a3440df9ddf8f..42c509d6eba8d 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenTestBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenTestBase.kt @@ -17,6 +17,7 @@ package com.android.wm.shell.flicker.splitscreen import com.android.wm.shell.flicker.NonRotationTestBase +import com.android.wm.shell.flicker.TEST_APP_NONRESIZEABLE_LABEL import com.android.wm.shell.flicker.TEST_APP_SPLITSCREEN_PRIMARY_LABEL import com.android.wm.shell.flicker.TEST_APP_SPLITSCREEN_SECONDARY_LABEL import com.android.wm.shell.flicker.helpers.SplitScreenHelper @@ -32,4 +33,7 @@ abstract class SplitScreenTestBase( protected val secondaryApp = SplitScreenHelper(instrumentation, TEST_APP_SPLITSCREEN_SECONDARY_LABEL, Components.SplitScreenSecondaryActivity()) + protected val nonResizeableApp = SplitScreenHelper(instrumentation, + TEST_APP_NONRESIZEABLE_LABEL, + Components.NonResizeableActivity()) } diff --git a/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/AndroidManifest.xml b/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/AndroidManifest.xml index a583b725899bd..28ed3431db62e 100644 --- a/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/AndroidManifest.xml +++ b/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/AndroidManifest.xml @@ -86,6 +86,17 @@ + + + + + + + + + + + + + diff --git a/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/Components.java b/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/Components.java index 8e9b4cb2d53e2..f729ea5540725 100644 --- a/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/Components.java +++ b/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/Components.java @@ -38,6 +38,13 @@ public class Components { } } + public static class NonResizeableActivity extends ComponentsInfo { + @Override + public String getActivityName() { + return NonResizeableActivity.class.getSimpleName(); + } + } + public static class PipActivity extends ComponentsInfo { // Intent action that this activity dynamically registers to enter picture-in-picture public static final String ACTION_ENTER_PIP = PACKAGE_NAME + ".PipActivity.ENTER_PIP"; diff --git a/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/NonResizeableActivity.java b/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/NonResizeableActivity.java new file mode 100644 index 0000000000000..24275e002c7f5 --- /dev/null +++ b/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/NonResizeableActivity.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 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.testapp; + +import android.app.Activity; +import android.os.Bundle; + +public class NonResizeableActivity extends Activity { + + @Override + protected void onCreate(Bundle icicle) { + super.onCreate(icicle); + setContentView(R.layout.activity_non_resizeable); + } +}