Loading libs/WindowManager/Shell/tests/e2e/desktopmode/flicker-service/src/com/android/wm/shell/flicker/AltTabSwitchToUnminimizeInDesktopModeFlickerTest.kt 0 → 100644 +98 −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.flicker import android.tools.NavBar import android.tools.flicker.FlickerBuilder import android.tools.flicker.FlickerTest import android.tools.flicker.FlickerTestFactory import android.tools.flicker.assertions.FlickerChecker import android.tools.flicker.junit.FlickerParametersRunnerFactory import androidx.test.filters.RequiresDevice import com.android.wm.shell.Utils import com.android.wm.shell.flicker.utils.appWindowInsideDisplayBoundsAtEnd import com.android.wm.shell.flicker.utils.appWindowOnTopAtEnd import com.android.wm.shell.flicker.utils.appWindowOnTopAtStart import com.android.wm.shell.flicker.utils.layerBecomesVisible import com.android.wm.shell.scenarios.AltTabSwitchToUnminimizeInDesktopMode import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized /** * Flicker test suite for verifying the Alt-Tab switching behavior to unminimize applications * in Desktop Mode. * * The tests assert that the target application (YouTube): * - Remains within display bounds after being unminimized. * - Is the top-most window after the Alt-Tab switch. * - Its layer becomes visible. * * The tests assert that the Clock application is the top-most window before the Alt-Tab switch. */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) class AltTabSwitchToUnminimizeInDesktopModeFlickerTest(flicker: FlickerTest) : DesktopModeBaseTest(flicker) { inner class AltTabSwitchToUnminimizeInDesktopModeScenario : AltTabSwitchToUnminimizeInDesktopMode( rotation = flicker.scenario.startRotation ) @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation) val scenario = AltTabSwitchToUnminimizeInDesktopModeScenario() private val clockApp = scenario.clockApp private val youtubeApp = scenario.youtubeApp override val transition: FlickerBuilder.() -> Unit get() = { setup { scenario.setup() } transitions { scenario.switchApp() } teardown { scenario.teardown() } } @Test fun appWindowInsideDisplayBoundsAtEnd() = flicker.appWindowInsideDisplayBoundsAtEnd(youtubeApp) @Test fun appWindowOnTopAtStart() = flicker.appWindowOnTopAtStart(clockApp) @Test fun appWindowOnTopAtEnd() = flicker.appWindowOnTopAtEnd(youtubeApp) @Test fun layerBecomesVisible() = flicker.layerBecomesVisible(youtubeApp) companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerChecker> { return FlickerTestFactory.nonRotationTests( supportedNavigationModes = listOf(NavBar.MODE_GESTURAL) ) } } } libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/Android.bp +8 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,13 @@ test_module_config { include_filters: ["com.android.wm.shell.functional.AltTabSwitchOutDesktopModeTest"], } test_module_config { name: "FunctionalTestsDesktopMode-AltTabSwitchToUnminimizeInDesktopModeTest", base: "FunctionalTestsDesktopMode", test_suites: ["device-tests"], include_filters: ["com.android.wm.shell.functional.AltTabSwitchToUnminimizeInDesktopModeTest"], } test_module_config { name: "FunctionalTestsDesktopMode-CatchAll", base: "FunctionalTestsDesktopMode", Loading @@ -84,6 +91,7 @@ test_module_config { exclude_filters: [ "com.android.wm.shell.functional.AltTabSwitchInDesktopModeTest", "com.android.wm.shell.functional.AltTabSwitchOutDesktopModeTest", "com.android.wm.shell.functional.AltTabSwitchToUnminimizeInDesktopModeTest", "com.android.wm.shell.functional.ChromeNewTabAtWindowLimitTest", "com.android.wm.shell.functional.CloseAllAppsWithAppHeaderExitTest", "com.android.wm.shell.functional.DisableDisplayMirroringSwitchTest", Loading libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/TEST_MAPPING +3 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,9 @@ { "name": "FunctionalTestsDesktopMode-AltTabSwitchOutDesktopModeTest" }, { "name": "FunctionalTestsDesktopMode-AltTabSwitchToUnminimizeInDesktopModeFlickerTest" }, { "name": "FunctionalTestsDesktopMode-CatchAll" }, Loading libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/functional/AltTabSwitchToUnminimizeInDesktopModeTest.kt 0 → 100644 +29 −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 android.platform.test.rule.ScreenRecordRule import com.android.wm.shell.scenarios.AltTabSwitchToUnminimizeInDesktopMode import org.junit.runner.RunWith import org.junit.runners.BlockJUnit4ClassRunner /* Functional test for [AltTabSwitchToUnminimizeInDesktopMode]. */ @RunWith(BlockJUnit4ClassRunner::class) @Presubmit @ScreenRecordRule.ScreenRecord class AltTabSwitchToUnminimizeInDesktopModeTest : AltTabSwitchToUnminimizeInDesktopMode() libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/AltTabSwitchToUnminimizeInDesktopMode.kt 0 → 100644 +86 −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.app.Instrumentation import android.tools.Rotation import android.tools.device.apphelpers.CalculatorAppHelper import android.tools.device.apphelpers.ClockAppHelper import android.tools.device.apphelpers.YouTubeAppHelper 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 org.junit.After import org.junit.Before import org.junit.Ignore import org.junit.Test /** * Base class for testing unminimizing apps via Alt-Tab in Desktop Mode. * * Sets up Calculator, Clock, and YouTube in Desktop Mode, minimises YouTube, then tests if * a quick switch action re-opens YouTube. */ @Ignore("Test Base Class") abstract class AltTabSwitchToUnminimizeInDesktopMode( val rotation: Rotation = Rotation.ROTATION_0 ) : TestScenarioBase(rotation) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() private val tapl = LauncherInstrumentation() private val wmHelper = WindowManagerStateHelper(instrumentation) private val device = UiDevice.getInstance(instrumentation) val calculatorApp = DesktopModeAppHelper(CalculatorAppHelper(instrumentation)) val clockApp = DesktopModeAppHelper(ClockAppHelper(instrumentation)) val youtubeApp = DesktopModeAppHelper(YouTubeAppHelper(instrumentation)) private val appsInDesktop = listOf(calculatorApp, clockApp, youtubeApp) @Before fun setup() { appsInDesktop.forEachIndexed { index, app -> if (index == 0) { app.enterDesktopMode(wmHelper, device) } else { app.launchViaIntent(wmHelper) } } appsInDesktop.last().minimizeDesktopApp(wmHelper, device) } @Test open fun switchApp() { tapl.launchedAppState .showQuickSwitchView() .launchFocusedAppTask(appsInDesktop.last().packageName) wmHelper .StateSyncBuilder() .withTopVisibleApps(appsInDesktop.last().packageNameMatcher) .waitForAndVerify() } @After fun teardown() { appsInDesktop.reversed().forEach { desktopApp -> desktopApp.exit(wmHelper) } } } Loading
libs/WindowManager/Shell/tests/e2e/desktopmode/flicker-service/src/com/android/wm/shell/flicker/AltTabSwitchToUnminimizeInDesktopModeFlickerTest.kt 0 → 100644 +98 −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.flicker import android.tools.NavBar import android.tools.flicker.FlickerBuilder import android.tools.flicker.FlickerTest import android.tools.flicker.FlickerTestFactory import android.tools.flicker.assertions.FlickerChecker import android.tools.flicker.junit.FlickerParametersRunnerFactory import androidx.test.filters.RequiresDevice import com.android.wm.shell.Utils import com.android.wm.shell.flicker.utils.appWindowInsideDisplayBoundsAtEnd import com.android.wm.shell.flicker.utils.appWindowOnTopAtEnd import com.android.wm.shell.flicker.utils.appWindowOnTopAtStart import com.android.wm.shell.flicker.utils.layerBecomesVisible import com.android.wm.shell.scenarios.AltTabSwitchToUnminimizeInDesktopMode import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized /** * Flicker test suite for verifying the Alt-Tab switching behavior to unminimize applications * in Desktop Mode. * * The tests assert that the target application (YouTube): * - Remains within display bounds after being unminimized. * - Is the top-most window after the Alt-Tab switch. * - Its layer becomes visible. * * The tests assert that the Clock application is the top-most window before the Alt-Tab switch. */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) class AltTabSwitchToUnminimizeInDesktopModeFlickerTest(flicker: FlickerTest) : DesktopModeBaseTest(flicker) { inner class AltTabSwitchToUnminimizeInDesktopModeScenario : AltTabSwitchToUnminimizeInDesktopMode( rotation = flicker.scenario.startRotation ) @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation) val scenario = AltTabSwitchToUnminimizeInDesktopModeScenario() private val clockApp = scenario.clockApp private val youtubeApp = scenario.youtubeApp override val transition: FlickerBuilder.() -> Unit get() = { setup { scenario.setup() } transitions { scenario.switchApp() } teardown { scenario.teardown() } } @Test fun appWindowInsideDisplayBoundsAtEnd() = flicker.appWindowInsideDisplayBoundsAtEnd(youtubeApp) @Test fun appWindowOnTopAtStart() = flicker.appWindowOnTopAtStart(clockApp) @Test fun appWindowOnTopAtEnd() = flicker.appWindowOnTopAtEnd(youtubeApp) @Test fun layerBecomesVisible() = flicker.layerBecomesVisible(youtubeApp) companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerChecker> { return FlickerTestFactory.nonRotationTests( supportedNavigationModes = listOf(NavBar.MODE_GESTURAL) ) } } }
libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/Android.bp +8 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,13 @@ test_module_config { include_filters: ["com.android.wm.shell.functional.AltTabSwitchOutDesktopModeTest"], } test_module_config { name: "FunctionalTestsDesktopMode-AltTabSwitchToUnminimizeInDesktopModeTest", base: "FunctionalTestsDesktopMode", test_suites: ["device-tests"], include_filters: ["com.android.wm.shell.functional.AltTabSwitchToUnminimizeInDesktopModeTest"], } test_module_config { name: "FunctionalTestsDesktopMode-CatchAll", base: "FunctionalTestsDesktopMode", Loading @@ -84,6 +91,7 @@ test_module_config { exclude_filters: [ "com.android.wm.shell.functional.AltTabSwitchInDesktopModeTest", "com.android.wm.shell.functional.AltTabSwitchOutDesktopModeTest", "com.android.wm.shell.functional.AltTabSwitchToUnminimizeInDesktopModeTest", "com.android.wm.shell.functional.ChromeNewTabAtWindowLimitTest", "com.android.wm.shell.functional.CloseAllAppsWithAppHeaderExitTest", "com.android.wm.shell.functional.DisableDisplayMirroringSwitchTest", Loading
libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/TEST_MAPPING +3 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,9 @@ { "name": "FunctionalTestsDesktopMode-AltTabSwitchOutDesktopModeTest" }, { "name": "FunctionalTestsDesktopMode-AltTabSwitchToUnminimizeInDesktopModeFlickerTest" }, { "name": "FunctionalTestsDesktopMode-CatchAll" }, Loading
libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/functional/AltTabSwitchToUnminimizeInDesktopModeTest.kt 0 → 100644 +29 −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 android.platform.test.rule.ScreenRecordRule import com.android.wm.shell.scenarios.AltTabSwitchToUnminimizeInDesktopMode import org.junit.runner.RunWith import org.junit.runners.BlockJUnit4ClassRunner /* Functional test for [AltTabSwitchToUnminimizeInDesktopMode]. */ @RunWith(BlockJUnit4ClassRunner::class) @Presubmit @ScreenRecordRule.ScreenRecord class AltTabSwitchToUnminimizeInDesktopModeTest : AltTabSwitchToUnminimizeInDesktopMode()
libs/WindowManager/Shell/tests/e2e/desktopmode/scenarios/src/com/android/wm/shell/scenarios/AltTabSwitchToUnminimizeInDesktopMode.kt 0 → 100644 +86 −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.app.Instrumentation import android.tools.Rotation import android.tools.device.apphelpers.CalculatorAppHelper import android.tools.device.apphelpers.ClockAppHelper import android.tools.device.apphelpers.YouTubeAppHelper 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 org.junit.After import org.junit.Before import org.junit.Ignore import org.junit.Test /** * Base class for testing unminimizing apps via Alt-Tab in Desktop Mode. * * Sets up Calculator, Clock, and YouTube in Desktop Mode, minimises YouTube, then tests if * a quick switch action re-opens YouTube. */ @Ignore("Test Base Class") abstract class AltTabSwitchToUnminimizeInDesktopMode( val rotation: Rotation = Rotation.ROTATION_0 ) : TestScenarioBase(rotation) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() private val tapl = LauncherInstrumentation() private val wmHelper = WindowManagerStateHelper(instrumentation) private val device = UiDevice.getInstance(instrumentation) val calculatorApp = DesktopModeAppHelper(CalculatorAppHelper(instrumentation)) val clockApp = DesktopModeAppHelper(ClockAppHelper(instrumentation)) val youtubeApp = DesktopModeAppHelper(YouTubeAppHelper(instrumentation)) private val appsInDesktop = listOf(calculatorApp, clockApp, youtubeApp) @Before fun setup() { appsInDesktop.forEachIndexed { index, app -> if (index == 0) { app.enterDesktopMode(wmHelper, device) } else { app.launchViaIntent(wmHelper) } } appsInDesktop.last().minimizeDesktopApp(wmHelper, device) } @Test open fun switchApp() { tapl.launchedAppState .showQuickSwitchView() .launchFocusedAppTask(appsInDesktop.last().packageName) wmHelper .StateSyncBuilder() .withTopVisibleApps(appsInDesktop.last().packageNameMatcher) .waitForAndVerify() } @After fun teardown() { appsInDesktop.reversed().forEach { desktopApp -> desktopApp.exit(wmHelper) } } }