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

Commit fa2741fe authored by Jorge Gil's avatar Jorge Gil
Browse files

Add flicker test for moving desktop apps to front

Bug: 378909010
Flag: EXEMPT adding tests
Test: atest WMShellFlickerTestsDesktopMode
Change-Id: If41b85cb6ec6bd8ef77b73ac05f421beba1d6c33
parent 320144b8
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.Rotation.ROTATION_90
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.BRING_APPS_TO_FRONT
import com.android.wm.shell.scenarios.BringDesktopAppsToFront
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Bring apps to front by clicking on the App Header.
 *
 * Assert that the app windows move to front.
 */
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class BringDesktopAppsToFrontLandscape : BringDesktopAppsToFront(rotation = ROTATION_90) {

    @ExpectedScenarios(["BRING_APPS_TO_FRONT"])
    @Test
    override fun bringDesktopAppsToFront() = super.bringDesktopAppsToFront()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig()
                .use(FlickerServiceConfig.DEFAULT)
                .use(BRING_APPS_TO_FRONT)
    }
}
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.Rotation.ROTATION_0
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.BRING_APPS_TO_FRONT
import com.android.wm.shell.scenarios.BringDesktopAppsToFront
import org.junit.Test
import org.junit.runner.RunWith

/**
 * Bring apps to front by clicking on the App Header.
 *
 * Assert that the app windows move to front.
 */
@RunWith(FlickerServiceJUnit4ClassRunner::class)
class BringDesktopAppsToFrontPortrait : BringDesktopAppsToFront(rotation = ROTATION_0) {

    @ExpectedScenarios(["BRING_APPS_TO_FRONT"])
    @Test
    override fun bringDesktopAppsToFront() = super.bringDesktopAppsToFront()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig()
                .use(FlickerServiceConfig.DEFAULT)
                .use(BRING_APPS_TO_FRONT)
    }
}
+25 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.tools.flicker.assertors.assertions.AppLayerIsVisibleAlways
import android.tools.flicker.assertors.assertions.AppLayerIsVisibleAtStart
import android.tools.flicker.assertors.assertions.AppWindowAlignsWithOnlyOneDisplayCornerAtEnd
import android.tools.flicker.assertors.assertions.AppWindowBecomesInvisible
import android.tools.flicker.assertors.assertions.AppWindowBecomesTopWindow
import android.tools.flicker.assertors.assertions.AppWindowBecomesVisible
import android.tools.flicker.assertors.assertions.AppWindowCoversLeftHalfScreenAtEnd
import android.tools.flicker.assertors.assertions.AppWindowCoversRightHalfScreenAtEnd
@@ -345,6 +346,30 @@ class DesktopModeFlickerScenarios {
                        ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING }),
            )

        val BRING_APPS_TO_FRONT =
            FlickerConfigEntry(
                scenarioId = ScenarioId("BRING_APPS_TO_FRONT"),
                extractor =
                    ShellTransitionScenarioExtractor(
                        transitionMatcher =
                            object : ITransitionMatcher {
                                override fun findAll(
                                    transitions: Collection<Transition>
                                ): Collection<Transition> {
                                    return transitions.filter {
                                        it.type == TransitionType.TO_FRONT
                                    }
                                }
                            }
                    ),
                assertions =
                    AssertionTemplates.COMMON_ASSERTIONS +
                            listOf(
                                AppWindowBecomesTopWindow(DESKTOP_MODE_APP),
                                AppWindowOnTopAtEnd(DESKTOP_MODE_APP),
                            ).associateBy({ it }, { AssertionInvocationGroup.BLOCKING })
            )

        val CASCADE_APP =
            FlickerConfigEntry(
                scenarioId = ScenarioId("CASCADE_APP"),