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

Commit a7370b11 authored by Nataniel Borges's avatar Nataniel Borges
Browse files

6/ Add tapl support on app launch CUJs

Previously we used UiAutomator directly but this was not well-supported and caused flakiness

Bug: 236131465
Test: atest FlickerTests
Change-Id: Ia6cae9bc4b47e9f14aa6c2fb15b49b1663224e07
parent c9cd787b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Instrumentation
import android.platform.test.annotations.Presubmit
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import com.android.launcher3.tapl.LauncherInstrumentation
import com.android.server.wm.flicker.FlickerBuilderProvider
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
@@ -61,6 +62,7 @@ import org.junit.runners.Parameterized
class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val testApp: TwoActivitiesAppHelper = TwoActivitiesAppHelper(instrumentation)
    private val tapl = LauncherInstrumentation()

    /**
     * Entry point for the test runner. It will use this method to initialize and cache
@@ -71,6 +73,7 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
        return FlickerBuilder(instrumentation).apply {
            setup {
                test {
                    tapl.setExpectedRotation(testSpec.startRotation)
                    testApp.launchViaIntent(wmHelper)
                }
            }
@@ -81,7 +84,7 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
            }
            transitions {
                testApp.openSecondActivity(device, wmHelper)
                device.pressBack()
                tapl.pressBack()
                wmHelper.StateSyncBuilder()
                    .withFullScreenApp(testApp.component)
                    .waitForAndVerify()
+0 −3
Original line number Diff line number Diff line
@@ -51,9 +51,6 @@ abstract class OpenAppFromLockTransition(testSpec: FlickerTestParameter) :
            }
            transitions {
                testApp.launchViaIntent(wmHelper)
                wmHelper.StateSyncBuilder()
                    .withFullScreenApp(testApp.component)
                    .waitForAndVerify()
            }
        }

+7 −7
Original line number Diff line number Diff line
@@ -42,8 +42,8 @@ import org.junit.runners.Parameterized
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
@Postsubmit
open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter)
    : OpenAppFromNotificationWarm(testSpec) {
open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter) :
    OpenAppFromNotificationWarm(testSpec) {
    override val transition: FlickerBuilder.() -> Unit
        get() = {
            super.transition(this)
@@ -52,9 +52,9 @@ open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter)
                eachRun {
                    // Close the app that posted the notification to trigger a cold start next time
                    // it is open - can't just kill it because that would remove the notification.
                    taplInstrumentation.goHome()
                    taplInstrumentation.workspace.switchToOverview()
                    taplInstrumentation.overview.dismissAllTasks()
                    tapl.goHome()
                    tapl.workspace.switchToOverview()
                    tapl.overview.dismissAllTasks()
                }
            }
        }
@@ -77,7 +77,7 @@ open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter)
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<FlickerTestParameter> {
            return com.android.server.wm.flicker.FlickerTestParameterFactory.getInstance()
            return FlickerTestParameterFactory.getInstance()
                    .getConfigNonRotationTests(repetitions = 3)
        }
    }
+1 −4
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.view.WindowInsets
import android.view.WindowManager
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import com.android.launcher3.tapl.LauncherInstrumentation
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameterFactory
@@ -55,8 +54,6 @@ import org.junit.runners.Parameterized
@Postsubmit
open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) :
    OpenAppTransition(testSpec) {
    protected val taplInstrumentation = LauncherInstrumentation()

    override val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation)

    open val openingNotificationsFromLockScreen = false
@@ -74,7 +71,7 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) :
                        .withFullScreenApp(testApp.component)
                        .waitForAndVerify()
                    testApp.postNotification(wmHelper)
                    device.pressHome()
                    tapl.goHome()
                    wmHelper.StateSyncBuilder()
                        .withHomeActivityVisible()
                        .waitForAndVerify()
+6 −3
Original line number Diff line number Diff line
@@ -19,13 +19,13 @@ package com.android.server.wm.flicker.launch
import android.platform.test.annotations.FlakyTest
import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.RequiresDevice
import android.view.Surface
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameterFactory
import com.android.server.wm.flicker.annotation.Group1
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled
import com.android.server.wm.flicker.helpers.reopenAppFromOverview
import com.android.server.wm.flicker.helpers.setRotation
import org.junit.Assume
import org.junit.FixMethodOrder
@@ -72,11 +72,14 @@ open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) :
                    testApp.launchViaIntent(wmHelper)
                }
                eachRun {
                    // Can't use tapl.goHome() because of b/235841947
                    device.pressHome()
                    wmHelper.StateSyncBuilder()
                        .withHomeActivityVisible()
                        .waitForAndVerify()
                    device.pressRecentApps()
                    // Launcher is always ROTATION_0
                    tapl.setExpectedRotation(Surface.ROTATION_0)
                    tapl.workspace.switchToOverview()
                    wmHelper.StateSyncBuilder()
                        .withRecentsActivityVisible()
                        .waitForAndVerify()
@@ -84,7 +87,7 @@ open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) :
                }
            }
            transitions {
                device.reopenAppFromOverview(wmHelper)
                tapl.overview.currentTask.open()
                wmHelper.StateSyncBuilder()
                    .withFullScreenApp(testApp.component)
                    .waitForAndVerify()
Loading