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

Commit d51274d4 authored by Orhan Uysal's avatar Orhan Uysal
Browse files

Fix back navigation test

Instead of using UiDevice#pressBack use tapl#pressBack. Also pass
multiple navigation modes to test all of them.

Bug: 418216106
Test: atest CloseAllAppsWithBackNavigationTest
Flag: EXEMPT adding tests
Change-Id: I3da6853fe4b9a4eb23efb8be234ec8c3a23ac5d8
parent b16f1c27
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -45,7 +45,10 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class CloseAllAppsWithBackNavigationTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(flicker) {
    inner class CloseAllAppsWithBackNavigationScenario :
        CloseAllAppsWithBackNavigation(flicker.scenario.startRotation)
        CloseAllAppsWithBackNavigation(
            navigationMode = flicker.scenario.navBarMode,
            rotation = flicker.scenario.startRotation
        )

    @Rule
    @JvmField
@@ -83,9 +86,7 @@ class CloseAllAppsWithBackNavigationTest(flicker: LegacyFlickerTest) : DesktopMo
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<FlickerTest> {
            return LegacyFlickerTestFactory.nonRotationTests(
                supportedNavigationModes = listOf(NavBar.MODE_GESTURAL)
            )
            return LegacyFlickerTestFactory.nonRotationTests()
        }
    }
}
 No newline at end of file
+11 −4
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import org.junit.Test

@Ignore("Base Test Class")
abstract class CloseAllAppsWithBackNavigation(
    val navigationMode: NavBar = NavBar.MODE_GESTURAL,
    val rotation: Rotation = Rotation.ROTATION_0
) : TestScenarioBase() {
    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
@@ -52,7 +53,7 @@ abstract class CloseAllAppsWithBackNavigation(

    val appsInZOrder: ArrayList<DesktopModeAppHelper> = ArrayList()

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

    @Before
    fun setup() {
@@ -78,10 +79,16 @@ abstract class CloseAllAppsWithBackNavigation(

    @Test
    open fun closeAllAppsInDesktop() {
        nonResizeableApp.closeDesktopApp(wmHelper, device, usingBackNavigation = true)
        mailApp.closeDesktopApp(wmHelper, device, usingBackNavigation = true)
        testApp.closeDesktopApp(wmHelper, device, usingBackNavigation = true)
        repeat(appsInZOrder.size) {
            useBackNavigation()
        }
    }

    private fun useBackNavigation() {
        tapl.pressBack()
        wmHelper.StateSyncBuilder().withAppTransitionIdle().waitForAndVerify()
    }


    @After
    fun teardown() {
+6 −11
Original line number Diff line number Diff line
@@ -308,20 +308,15 @@ open class DesktopModeAppHelper(private val innerHelper: StandardAppHelper) :
            .waitForAndVerify()
    }

    /** Close a desktop app by clicking the close button on the app header for the given app or by
     *  pressing back. */
    /** Close a desktop app by clicking the close button on the app header for the given app. */
    fun closeDesktopApp(
        wmHelper: WindowManagerStateHelper,
        device: UiDevice,
        usingBackNavigation: Boolean = false
        ) {
        if (usingBackNavigation) {
            device.pressBack()
        } else {
        val caption = getCaptionForTheApp(wmHelper, device)
        val closeButton = caption?.children?.find { it.resourceName.endsWith(CLOSE_BUTTON) }
        closeButton?.click()
        }

        wmHelper
            .StateSyncBuilder()
            .withAppTransitionIdle()