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

Commit 8350ab41 authored by Orhan Uysal's avatar Orhan Uysal Committed by Android (Google) Code Review
Browse files

Merge "Add back nav flicker test" into main

parents b73e93fd 072ccd30
Loading
Loading
Loading
Loading
+0 −51
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
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.CLOSE_APP
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.CLOSE_LAST_APP
import com.android.wm.shell.scenarios.CloseAllAppsWithBackNavigation
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(FlickerServiceJUnit4ClassRunner::class)
class CloseAllAppsWithBackNavigationLandscape : CloseAllAppsWithBackNavigation(
    Rotation.ROTATION_90
) {
    // TODO(b/390043833): Add verifications that TO_BACK transition is captured when the back
    // navigation button is pressed.
    @ExpectedScenarios(["CLOSE_APP", "CLOSE_LAST_APP"])
    @Test
    override fun closeAllAppsInDesktop() = super.closeAllAppsInDesktop()

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

import android.platform.test.annotations.RequiresDevice
import android.tools.NavBar
import android.tools.flicker.assertions.FlickerTest
import android.tools.flicker.junit.FlickerParametersRunnerFactory
import android.tools.flicker.legacy.FlickerBuilder
import android.tools.flicker.legacy.LegacyFlickerTest
import android.tools.flicker.legacy.LegacyFlickerTestFactory
import android.tools.traces.component.ComponentNameMatcher
import android.tools.traces.component.ComponentNameMatcher.Companion.DESKTOP_WALLPAPER_ACTIVITY
import com.android.wm.shell.Utils
import com.android.wm.shell.flicker.DesktopModeBaseTest
import com.android.wm.shell.flicker.utils.appWindowIsInvisibleAtEnd
import com.android.wm.shell.flicker.utils.appWindowIsVisibleAtEnd
import com.android.wm.shell.scenarios.CloseAllAppsWithBackNavigation
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

/**
 * Test closing all apps in desktop mode by using back navigation.
 *
 * To run this test: atest CloseAllAppsWithBackNavigationTest
 */
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class CloseAllAppsWithBackNavigationTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(flicker) {
    inner class CloseAllAppsWithBackNavigationScenario :
        CloseAllAppsWithBackNavigation(flicker.scenario.startRotation)

    @Rule
    @JvmField
    val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation)
    val scenario = CloseAllAppsWithBackNavigationScenario()
    private val appsInZOrder = scenario.appsInZOrder


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

    @Test
    fun appWindowIsInvisibleAtEnd() =
        appsInZOrder.forEach { flicker.appWindowIsInvisibleAtEnd(it) }

    @Test
    fun launcherWindowIsInvisibleAtEnd() =
        flicker.appWindowIsInvisibleAtEnd(ComponentNameMatcher.LAUNCHER)

    @Test
    fun wallpaperActivityOnTopAtEnd() =
        flicker.appWindowIsVisibleAtEnd(DESKTOP_WALLPAPER_ACTIVITY)

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<FlickerTest> {
            return LegacyFlickerTestFactory.nonRotationTests(
                supportedNavigationModes = listOf(NavBar.MODE_GESTURAL)
            )
        }
    }
}
 No newline at end of file
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 * 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.
@@ -14,35 +14,16 @@
 * limitations under the License.
 */

package com.android.wm.shell.flicker
package com.android.wm.shell.functional.fundamentals

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.CLOSE_APP
import com.android.wm.shell.flicker.DesktopModeFlickerScenarios.Companion.CLOSE_LAST_APP
import android.platform.test.annotations.Postsubmit
import android.platform.test.rule.ScreenRecordRule
import com.android.wm.shell.scenarios.CloseAllAppsWithBackNavigation
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.BlockJUnit4ClassRunner

@RunWith(FlickerServiceJUnit4ClassRunner::class)
class CloseAllAppsWithBackNavigationPortrait : CloseAllAppsWithBackNavigation() {
    // TODO(b/390043833): Add verifications that TO_BACK transition is captured when the back
    // navigation button is pressed.
    @ExpectedScenarios(["CLOSE_APP", "CLOSE_LAST_APP"])
    @Test
    override fun closeAllAppsInDesktop() = super.closeAllAppsInDesktop()

    companion object {
        @JvmStatic
        @FlickerConfigProvider
        fun flickerConfigProvider(): FlickerConfig =
            FlickerConfig()
                .use(FlickerServiceConfig.DEFAULT)
                .use(CLOSE_APP)
                .use(CLOSE_LAST_APP)
    }
}
/* Functional test for [CloseAllAppsWithBackNavigation]. */
@RunWith(BlockJUnit4ClassRunner::class)
@Postsubmit
@ScreenRecordRule.ScreenRecord
class CloseAllAppsWithBackNavigationTest : CloseAllAppsWithBackNavigation()
+10 −0
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ abstract class CloseAllAppsWithBackNavigation(
    private val mailApp = DesktopModeAppHelper(MailAppHelper(instrumentation))
    private val nonResizeableApp = DesktopModeAppHelper(NonResizeableAppHelper(instrumentation))

    val appsInZOrder: ArrayList<DesktopModeAppHelper> = ArrayList()

    @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, rotation)

    @Before
@@ -59,11 +61,19 @@ abstract class CloseAllAppsWithBackNavigation(
                .isDesktopModeSupportedOnDisplay(DEFAULT_DISPLAY)
        )
        Assume.assumeTrue(Flags.enableDesktopWindowingBackNavigation())
        Assume.assumeTrue(Flags.enableEmptyDeskOnMinimize())
        tapl.setEnableRotation(true)
        tapl.setExpectedRotation(rotation.value)

        // Set up apps
        testApp.enterDesktopMode(wmHelper, device)
        appsInZOrder.add(testApp)

        mailApp.launchViaIntent(wmHelper)
        appsInZOrder.add( mailApp)

        nonResizeableApp.launchViaIntent(wmHelper)
        appsInZOrder.add(nonResizeableApp)
    }

    @Test