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

Commit 80fb40fa authored by Toshiki Kikuchi's avatar Toshiki Kikuchi Committed by Android (Google) Code Review
Browse files

Merge "Define a flicker test for open-app-with-external-display-connected" into main

parents b7b68024 9b25447d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@
    <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" />
    <!-- Allow the test to connect to perfetto trace processor -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <!-- Use trusted virtual displays to emulate an external display -->
    <uses-permission android:name="android.permission.ADD_TRUSTED_DISPLAY"/>

    <!-- Allow the test to write directly to /sdcard/ and connect to trace processor -->
    <application android:requestLegacyExternalStorage="true"
+24 −0
Original line number Diff line number Diff line
@@ -546,5 +546,29 @@ class DesktopModeFlickerScenarios {
                        AppWindowBecomesPinned(DESKTOP_MODE_APP),
                    ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING })
            )

        val OPEN_APP_WHEN_EXTERNAL_DISPLAY_CONNECTED =
            FlickerConfigEntry(
                scenarioId = ScenarioId("OPEN_APP_WHEN_EXTERNAL_DISPLAY_CONNECTED"),
                extractor =
                ShellTransitionScenarioExtractor(
                    transitionMatcher =
                    object : ITransitionMatcher {
                        override fun findAll(
                            transitions: Collection<Transition>
                        ): Collection<Transition> {
                                return listOf(transitions
                                    .filter { it.type == TransitionType.OPEN }
                                    .maxByOrNull { it.id }!!)
                        }
                    }
                ),
                assertions =
                        listOf(
                            AppWindowBecomesVisible(DESKTOP_MODE_APP),
                            AppWindowOnTopAtEnd(DESKTOP_MODE_APP),
                            AppWindowBecomesVisible(DESKTOP_WALLPAPER),
                        ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING }),
            )
    }
}
+49 −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.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 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.
 */
@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)
    }
}