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

Commit 0be367a1 authored by CHIA-HSUAN HSU's avatar CHIA-HSUAN HSU
Browse files

b/434615720 Migrate OpenAppWithExternalDisplayConnected to flicker test

Test: USE_RBE=false atest WMShellFlickerTestsDesktopMode:com.android.wm.shell.flicker.externaldisplay.OpenAppWithExternalDisplayConnectedFlickerTest -c (http://ab/I01400010428019511)
Video: http://recall/-/f3lzK86NZh87wU1KB0f4vx
Flag: EXEMPT migrate flicker test
Bug: 434615720
Change-Id: Ib81dadd79383a8a3a70b10306879f7fca70bcdfb
parent 91adddbc
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ test_module_config {
    base: "WMShellFlickerTestsDesktopMode",
    test_suites: ["device-tests"],
    exclude_filters: [
        "com.android.wm.shell.flicker.externaldisplay.OpenAppWithExternalDisplayConnectedFlickerTest",
        "com.android.wm.shell.flicker.fundamentals.CloseAllAppsViaAppHeaderExitTest",
        "com.android.wm.shell.flicker.fundamentals.CloseAllAppsWithBackNavigationTest",
        "com.android.wm.shell.flicker.fundamentals.EnterDesktopFromSplitScreenWithAppHandleMenuFlickerTest",
@@ -91,6 +92,13 @@ test_module_config {
    ],
}

test_module_config {
    name: "WMShellFlickerTestsDesktopMode-externaldisplay-OpenAppWithExternalDisplayConnectedFlickerTest",
    base: "WMShellFlickerTestsDesktopMode",
    test_suites: ["device-tests"],
    include_filters: ["com.android.wm.shell.flicker.externaldisplay.OpenAppWithExternalDisplayConnectedFlickerTest"],
}

test_module_config {
    name: "WMShellFlickerTestsDesktopMode-keyboardshortcuts-AltTabSwitchInDesktopModeFlickerTest",
    base: "WMShellFlickerTestsDesktopMode",
+3 −0
Original line number Diff line number Diff line
{
  "wm": [
    {
      "name": "WMShellFlickerTestsDesktopMode-externaldisplay-OpenAppWithExternalDisplayConnectedFlickerTest"
    },
    {
      "name": "WMShellFlickerTestsDesktopMode-fundamentals-CloseAllAppsViaAppHeaderExitTest"
    },
+0 −51
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.flicker.FlickerConfig
import android.tools.flicker.annotation.ExpectedScenarios
import android.tools.flicker.annotation.FlickerConfigProvider
import android.tools.flicker.config.FlickerConfig
import android.tools.flicker.config.FlickerServiceConfig
import android.tools.flicker.junit.FlickerServiceJUnit4ClassRunner
import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.OPEN_APP_WHEN_EXTERNAL_DISPLAY_CONNECTED
import com.android.wm.shell.scenarios.OpenAppWithExternalDisplayConnected
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Open an app on the default display when an external display is connected.
 *
 * Assert that the app launches in desktop mode.
 */
@RequiresDevice
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class OpenAppWithExternalDisplayConnected : OpenAppWithExternalDisplayConnected() {
    @ExpectedScenarios(["OPEN_APP_WHEN_EXTERNAL_DISPLAY_CONNECTED"])
    @Test
    override fun openAppWithExternalDisplayConnected() = super.openAppWithExternalDisplayConnected()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig()
                .use(FlickerServiceConfig.DEFAULT)
                .use(OPEN_APP_WHEN_EXTERNAL_DISPLAY_CONNECTED)
    }
}
+99 −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.externaldisplay

import androidx.test.filters.RequiresDevice
import android.tools.NavBar
import android.tools.flicker.assertions.FlickerChecker
import android.tools.flicker.junit.FlickerParametersRunnerFactory
import android.tools.flicker.FlickerBuilder
import android.tools.flicker.FlickerTest
import android.tools.flicker.FlickerTestFactory
import android.tools.traces.component.ComponentNameMatcher
import android.tools.traces.component.IComponentNameMatcher
import com.android.wm.shell.flicker.DesktopModeBaseTest
import com.android.wm.shell.scenarios.OpenAppWithExternalDisplayConnected
import com.android.wm.shell.Utils
import com.android.wm.shell.flicker.utils.appWindowBecomesVisible
import com.android.wm.shell.flicker.utils.appWindowInsideDisplayBoundsAtEnd
import com.android.wm.shell.flicker.utils.appWindowOnDefaultDisplayAtEnd
import com.android.wm.shell.flicker.utils.appWindowOnTopAtEnd
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

/**
 * Open an app on the default display when an external display is connected.
 *
 * Assert that the app launches in desktop mode.
 */

@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class OpenAppWithExternalDisplayConnectedFlickerTest(flicker: FlickerTest) :
    DesktopModeBaseTest(flicker) {
    inner class OpenAppWithExternalDisplayConnectedScenario :
        OpenAppWithExternalDisplayConnected(flicker.scenario.startRotation)

    @Rule
    @JvmField
    val testSetupRule =
        Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation)
    val scenario = OpenAppWithExternalDisplayConnectedScenario()
    private val testApp = scenario.testApp
    private val desktopWallpaperMatcher: IComponentNameMatcher = ComponentNameMatcher.DESKTOP_WALLPAPER_ACTIVITY

    override val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                scenario.setup()
            }
            transitions {
                scenario.openAppWithExternalDisplayConnected()
            }
            teardown {
                scenario.teardown()
            }
        }

    @Test
    fun appWindowBecomesVisible() = flicker.appWindowBecomesVisible(testApp)

    @Test
    fun appWindowInsideDisplayBoundsAtEnd() = flicker.appWindowInsideDisplayBoundsAtEnd(testApp)

    @Test
    fun appWindowOnTopAtEnd() = flicker.appWindowOnTopAtEnd(testApp)

    @Test
    fun appWindowOnDefaultDisplayAtEnd() = flicker.appWindowOnDefaultDisplayAtEnd(testApp)

    @Test
    fun wallpaperActivityBecomesVisible() = flicker.appWindowBecomesVisible(desktopWallpaperMatcher)

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<FlickerChecker> {
            return FlickerTestFactory.nonRotationTests(
                supportedNavigationModes = listOf(NavBar.MODE_GESTURAL)
            )
        }
    }
}
+8 −8
Original line number Diff line number Diff line
@@ -105,7 +105,6 @@ test_module_config {
        "com.android.wm.shell.functional.FocusAppFromAllAppsTest",
        "com.android.wm.shell.functional.FocusAppFromTaskbarTest",
        "com.android.wm.shell.functional.MoveToNextDisplayTest",
        "com.android.wm.shell.functional.OpenAppWithExternalDisplayConnectedTest",
        "com.android.wm.shell.functional.OpenTrampolineAppInDesktopModeTaskLimitTest",
        "com.android.wm.shell.functional.OpenUnlimitedAppsTest",
        "com.android.wm.shell.functional.TabTearingDesktopWindowingLimitTest",
@@ -113,6 +112,7 @@ test_module_config {
        "com.android.wm.shell.functional.UnmaximizeAppWindowTest",
        "com.android.wm.shell.functional.UnminimizeAppFromAllAppsTest",
        "com.android.wm.shell.functional.UnminimizeAppFromTaskbarTest",
        "com.android.wm.shell.functional.externaldisplay.OpenAppWithExternalDisplayConnectedTest",
        "com.android.wm.shell.functional.fundamentals.CloseAllAppsViaAppHeaderExitTest",
        "com.android.wm.shell.functional.fundamentals.CloseAllAppsWithBackNavigationTest",
        "com.android.wm.shell.functional.fundamentals.DragAppWindowMultiWindowAndPipTest",
@@ -254,13 +254,6 @@ test_module_config {
    include_filters: ["com.android.wm.shell.functional.MoveToNextDisplayTest"],
}

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

test_module_config {
    name: "FunctionalTestsDesktopMode-OpenTrampolineAppInDesktopModeTaskLimitTest",
    base: "FunctionalTestsDesktopMode",
@@ -310,6 +303,13 @@ test_module_config {
    include_filters: ["com.android.wm.shell.functional.UnminimizeAppFromTaskbarTest"],
}

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

test_module_config {
    name: "FunctionalTestsDesktopMode-fundamentals-CloseAllAppsViaAppHeaderExitTest",
    base: "FunctionalTestsDesktopMode",
Loading