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

Commit 6249cf23 authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Add test for move-to-next-display in projected mode

This CL adds an end-to-end test for the move-to-next-display
keyboard shortcut when the device is in projected mode.

The test verifies that a task can be moved from the internal display
to an external display, and back again.

Bug: 435069150
Test: MoveToNextDisplayProjectedTest
Flag: com.android.window.flags.move_to_next_display_shortcut_with_projected_mode
Change-Id: I463cb4619bb5933b83990928f5e66fdec5b9e370
parent 75c82c24
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ test_module_config {
        "com.android.wm.shell.functional.FocusAppFromTaskbarTest",
        "com.android.wm.shell.functional.FocusAppFromTaskbarOverflowTest",
        "com.android.wm.shell.functional.MoveToNextDisplayTest",
        "com.android.wm.shell.functional.MoveToNextDisplayProjectedTest",
        "com.android.wm.shell.functional.OpenTrampolineAppInDesktopModeTaskLimitTest",
        "com.android.wm.shell.functional.OpenUnlimitedAppsTest",
        "com.android.wm.shell.functional.TabTearingDesktopWindowingLimitTest",
@@ -263,6 +264,13 @@ test_module_config {
    include_filters: ["com.android.wm.shell.functional.MoveToNextDisplayTest"],
}

test_module_config {
    name: "FunctionalTestsDesktopMode-MoveToNextDisplayProjectedTest",
    base: "FunctionalTestsDesktopMode",
    test_suites: ["device-tests"],
    include_filters: ["com.android.wm.shell.functional.MoveToNextDisplayProjectedTest"],
}

test_module_config {
    name: "FunctionalTestsDesktopMode-OpenTrampolineAppInDesktopModeTaskLimitTest",
    base: "FunctionalTestsDesktopMode",
+3 −0
Original line number Diff line number Diff line
@@ -60,6 +60,9 @@
    {
      "name": "FunctionalTestsDesktopMode-MoveToNextDisplayTest"
    },
    {
      "name": "FunctionalTestsDesktopMode-MoveToNextDisplayProjectedTest"
    },
    {
      "name": "FunctionalTestsDesktopMode-OpenTrampolineAppInDesktopModeTaskLimitTest"
    },
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.functional

import android.platform.test.annotations.Presubmit
import com.android.wm.shell.scenarios.MoveToNextDisplayProjected
import org.junit.runner.RunWith
import org.junit.runners.BlockJUnit4ClassRunner

/* Functional test for [MoveToNextDisplayProjected]. */
@RunWith(BlockJUnit4ClassRunner::class)
@Presubmit
class MoveToNextDisplayProjectedTest : MoveToNextDisplayProjected()
+81 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.platform.test.annotations.RequiresFlagsEnabled
import android.platform.test.flag.junit.DeviceFlagsValueProvider
import android.tools.NavBar
import android.tools.PlatformConsts.DEFAULT_DISPLAY
import android.tools.Rotation
import android.tools.traces.parsers.WindowManagerStateHelper
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
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 com.android.wm.shell.shared.desktopmode.DesktopState
import org.junit.After
import org.junit.Assume
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import platform.test.desktop.SimulatedConnectedDisplayTestRule

/**
 * Base scenario test for moving a projected task to another display via the keyboard shortcut.
 */
@Ignore("Test Base Class")
@RequiresFlagsEnabled(
    Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE,
    Flags.FLAG_ENABLE_MOVE_TO_NEXT_DISPLAY_SHORTCUT,
    Flags.FLAG_MOVE_TO_NEXT_DISPLAY_SHORTCUT_WITH_PROJECTED_MODE,
)
abstract class MoveToNextDisplayProjected {
    private val tapl = LauncherInstrumentation()
    private val wmHelper = WindowManagerStateHelper(getInstrumentation())
    private val testApp = DesktopModeAppHelper(SimpleAppHelper(getInstrumentation()))

    @get:Rule(order = 0) val checkFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule()
    @get:Rule(order = 1) val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, Rotation.ROTATION_0)
    @get:Rule(order = 2) val connectedDisplayRule = SimulatedConnectedDisplayTestRule()

    @Before
    fun setup() {
        val desktopState = DesktopState.fromContext(getInstrumentation().context)
        Assume.assumeTrue(desktopState.canEnterDesktopMode)
        Assume.assumeFalse(desktopState.isDesktopModeSupportedOnDisplay(DEFAULT_DISPLAY))
    }

    @Test
    open fun moveToNextDisplayProjected() {
        val connectedDisplayId = connectedDisplayRule.setupTestDisplay()
        testApp.launchViaIntent(wmHelper)

        // Move from internal to external
        testApp.moveToNextDisplayViaKeyboard(wmHelper, connectedDisplayId)

        // Move from external to internal
        testApp.moveToNextDisplayViaKeyboard(wmHelper, DEFAULT_DISPLAY)
    }

    @After
    fun teardown() {
        testApp.exit(wmHelper)
    }
}