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 Original line Diff line number Diff line
@@ -45,7 +45,10 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class CloseAllAppsWithBackNavigationTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(flicker) {
class CloseAllAppsWithBackNavigationTest(flicker: LegacyFlickerTest) : DesktopModeBaseTest(flicker) {
    inner class CloseAllAppsWithBackNavigationScenario :
    inner class CloseAllAppsWithBackNavigationScenario :
        CloseAllAppsWithBackNavigation(flicker.scenario.startRotation)
        CloseAllAppsWithBackNavigation(
            navigationMode = flicker.scenario.navBarMode,
            rotation = flicker.scenario.startRotation
        )


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


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


    val appsInZOrder: ArrayList<DesktopModeAppHelper> = ArrayList()
    val appsInZOrder: ArrayList<DesktopModeAppHelper> = ArrayList()


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


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


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

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



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


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

        wmHelper
        wmHelper
            .StateSyncBuilder()
            .StateSyncBuilder()
            .withAppTransitionIdle()
            .withAppTransitionIdle()