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

Commit f71ccb22 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "e2e test for focusing a task from taskbar overflow" into main

parents 9de81d9f e1df5d22
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ test_module_config {
        "com.android.wm.shell.functional.EnterDesktopWithDragWindowsLimitTest",
        "com.android.wm.shell.functional.FocusAppFromAllAppsTest",
        "com.android.wm.shell.functional.FocusAppFromTaskbarTest",
        "com.android.wm.shell.functional.FocusAppFromTaskbarOverflowTest",
        "com.android.wm.shell.functional.MoveToNextDisplayTest",
        "com.android.wm.shell.functional.OpenTrampolineAppInDesktopModeTaskLimitTest",
        "com.android.wm.shell.functional.OpenUnlimitedAppsTest",
@@ -247,6 +248,13 @@ test_module_config {
    include_filters: ["com.android.wm.shell.functional.FocusAppFromTaskbarTest"],
}

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

test_module_config {
    name: "FunctionalTestsDesktopMode-MoveToNextDisplayTest",
    base: "FunctionalTestsDesktopMode",
+3 −0
Original line number Diff line number Diff line
@@ -54,6 +54,9 @@
    {
      "name": "FunctionalTestsDesktopMode-FocusAppFromTaskbarTest"
    },
    {
      "name": "FunctionalTestsDesktopMode-FocusAppFromTaskbarOverflowTest"
    },
    {
      "name": "FunctionalTestsDesktopMode-MoveToNextDisplayTest"
    },
+30 −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.Postsubmit
import android.platform.test.rule.ScreenRecordRule
import com.android.wm.shell.scenarios.FocusAppFromTaskbarOverflow
import org.junit.runner.RunWith
import org.junit.runners.BlockJUnit4ClassRunner

/* Functional test for [FocusAppFromTaskbarOverflow]. */
@RunWith(BlockJUnit4ClassRunner::class)
@Postsubmit
@ScreenRecordRule.ScreenRecord
class FocusAppFromTaskbarOverflowTest : FocusAppFromTaskbarOverflow()
+82 −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.BrowserAppHelper
import android.tools.traces.parsers.WindowManagerStateHelper
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import android.tools.device.apphelpers.CalculatorAppHelper
import android.tools.device.apphelpers.CameraAppHelper
import android.tools.device.apphelpers.ClockAppHelper
import android.tools.device.apphelpers.MessagingAppHelper
import com.android.launcher3.tapl.LauncherInstrumentation
import com.android.server.wm.flicker.helpers.DesktopModeAppHelper
import com.android.server.wm.flicker.helpers.SimpleAppHelper
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Test

@Ignore("Test Base Class")
abstract class FocusAppFromTaskbarOverflow(val rotation: Rotation = Rotation.ROTATION_0) : TestScenarioBase() {

    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val tapl = LauncherInstrumentation()
    private val wmHelper = WindowManagerStateHelper(instrumentation)
    private val device = UiDevice.getInstance(instrumentation)
    private val browserApp = DesktopModeAppHelper(BrowserAppHelper(instrumentation))

    private val firstApp = DesktopModeAppHelper(CalculatorAppHelper(instrumentation))
    private val secondApp = DesktopModeAppHelper(ClockAppHelper())
    private val thirdApp = DesktopModeAppHelper(SimpleAppHelper(instrumentation))
    private val fourthApp = DesktopModeAppHelper(MessagingAppHelper(instrumentation))
    private val fifthApp = DesktopModeAppHelper(CameraAppHelper(instrumentation))

    @Before
    fun setup() {
        browserApp.enterDesktopMode(wmHelper, device)
        tapl.limitMaxNumberOfTaskbarIcons(8)
        tapl.showTaskbarIfHidden()

        firstApp.launchViaIntent(wmHelper)
        secondApp.launchViaIntent(wmHelper)
        thirdApp.launchViaIntent(wmHelper)
        fourthApp.launchViaIntent(wmHelper)
        fifthApp.launchViaIntent(wmHelper)
    }

    @Test
    open fun focusAppFromTaskbarOverflow() {
        tapl.launchedAppState.taskbar.launchTaskFromTaskbarOverflowByRecencyIndex(0)
        tapl.launchedAppState.assertAppInDesktop(firstApp.packageName)
    }

    @After
    fun teardown() {
        browserApp.exit(wmHelper)
        firstApp.exit(wmHelper)
        secondApp.exit(wmHelper)
        thirdApp.exit(wmHelper)
        fourthApp.exit(wmHelper)
        fifthApp.exit(wmHelper)

        tapl.limitMaxNumberOfTaskbarIcons(-1)
    }
}