diff options
| author | 2024-08-30 11:42:27 +0000 | |
|---|---|---|
| committer | 2024-08-30 11:42:27 +0000 | |
| commit | 2f426237f72d00cf89ffa16f2c00b3ed5a23983d (patch) | |
| tree | ad898b36c5c87269914b933351570dc548fd1678 | |
| parent | 008fa711cd6613c726e4c372785bba9b28d2b213 (diff) | |
| parent | 8f2b62e5d2b3fc818be2340a36235664567494fd (diff) | |
Merge "Allow custom test app for enter and exit desktop tests" into main
3 files changed, 65 insertions, 28 deletions
diff --git a/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/DesktopScenarioCustomAppTestBase.kt b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/DesktopScenarioCustomAppTestBase.kt new file mode 100644 index 000000000000..5a69b27d9fbb --- /dev/null +++ b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/DesktopScenarioCustomAppTestBase.kt @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024 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.scenarios + +import android.app.Instrumentation +import android.tools.traces.parsers.WindowManagerStateHelper +import android.tools.traces.parsers.toFlickerComponent +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.helpers.DesktopModeAppHelper +import com.android.server.wm.flicker.helpers.LetterboxAppHelper +import com.android.server.wm.flicker.helpers.NonResizeableAppHelper +import com.android.server.wm.flicker.helpers.SimpleAppHelper +import com.android.server.wm.flicker.testapp.ActivityOptions +import org.junit.Ignore + +/** Base test class for desktop CUJ with customizable test app. */ +@Ignore("Base Test Class") +abstract class DesktopScenarioCustomAppTestBase( + isResizeable: Boolean = true, + isLandscapeApp: Boolean = true +) { + val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + val tapl = LauncherInstrumentation() + val wmHelper = WindowManagerStateHelper(instrumentation) + val device = UiDevice.getInstance(instrumentation) + // TODO(b/363181411): Consolidate in LetterboxAppHelper. + val testApp = when { + isResizeable && isLandscapeApp -> SimpleAppHelper(instrumentation) + isResizeable && !isLandscapeApp -> SimpleAppHelper( + instrumentation, + launcherName = ActivityOptions.PortraitOnlyActivity.LABEL, + component = ActivityOptions.PortraitOnlyActivity.COMPONENT.toFlickerComponent() + ) + // NonResizeablAppHelper has no fixed orientation. + !isResizeable && isLandscapeApp -> NonResizeableAppHelper(instrumentation) + // Opens NonResizeablePortraitActivity. + else -> LetterboxAppHelper(instrumentation) + }.let { DesktopModeAppHelper(it) } +}
\ No newline at end of file diff --git a/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/EnterDesktopWithDrag.kt b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/EnterDesktopWithDrag.kt index 0f0d2df4337c..5f759e8ee682 100644 --- a/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/EnterDesktopWithDrag.kt +++ b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/EnterDesktopWithDrag.kt @@ -17,15 +17,8 @@ package com.android.wm.shell.scenarios import android.platform.test.annotations.Postsubmit -import android.app.Instrumentation import android.tools.NavBar import android.tools.Rotation -import android.tools.traces.parsers.WindowManagerStateHelper -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.uiautomator.UiDevice -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.helpers.DesktopModeAppHelper -import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.window.flags.Flags import com.android.wm.shell.Utils import org.junit.After @@ -40,13 +33,11 @@ import org.junit.runners.BlockJUnit4ClassRunner @Postsubmit open class EnterDesktopWithDrag @JvmOverloads -constructor(val rotation: Rotation = Rotation.ROTATION_0) { - - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() - private val tapl = LauncherInstrumentation() - private val wmHelper = WindowManagerStateHelper(instrumentation) - private val device = UiDevice.getInstance(instrumentation) - private val testApp = DesktopModeAppHelper(SimpleAppHelper(instrumentation)) +constructor( + val rotation: Rotation = Rotation.ROTATION_0, + isResizeable: Boolean = true, + isLandscapeApp: Boolean = true +) : DesktopScenarioCustomAppTestBase(isResizeable, isLandscapeApp) { @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, rotation) diff --git a/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/ExitDesktopWithDragToTopDragZone.kt b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/ExitDesktopWithDragToTopDragZone.kt index 533be8895fb9..b616e5347ac9 100644 --- a/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/ExitDesktopWithDragToTopDragZone.kt +++ b/libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/ExitDesktopWithDragToTopDragZone.kt @@ -17,15 +17,8 @@ package com.android.wm.shell.scenarios import android.platform.test.annotations.Postsubmit -import android.app.Instrumentation import android.tools.NavBar import android.tools.Rotation -import android.tools.traces.parsers.WindowManagerStateHelper -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.uiautomator.UiDevice -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.helpers.DesktopModeAppHelper -import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.window.flags.Flags import com.android.wm.shell.Utils import org.junit.After @@ -40,13 +33,11 @@ import org.junit.runners.BlockJUnit4ClassRunner @Postsubmit open class ExitDesktopWithDragToTopDragZone @JvmOverloads -constructor(val rotation: Rotation = Rotation.ROTATION_0) { - - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() - private val tapl = LauncherInstrumentation() - private val wmHelper = WindowManagerStateHelper(instrumentation) - private val device = UiDevice.getInstance(instrumentation) - private val testApp = DesktopModeAppHelper(SimpleAppHelper(instrumentation)) +constructor( + val rotation: Rotation = Rotation.ROTATION_0, + isResizeable: Boolean = true, + isLandscapeApp: Boolean = true +) : DesktopScenarioCustomAppTestBase(isResizeable, isLandscapeApp) { @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, rotation) |