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

Commit 6f6c9d66 authored by Nataniel Borges's avatar Nataniel Borges
Browse files

Improve documentation for app launch tests

- Improve class documentation with better description of the test, setup and teardown.
- Add documentation explaining each assertion

Bug: 182978180
Test: atest FlickerTests:com.android.server.wm.flicker.launch
Change-Id: I6f716c42ec605b92c158841f54762e46290c4b07
parent d535b268
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -40,7 +40,19 @@ import org.junit.runners.Parameterized

/**
 * Test the back and forward transition between 2 activities.
 *
 * To run this test: `atest FlickerTests:ActivitiesTransitionTest`
 *
 * Actions:
 *     Launch an app
 *     Launch a secondary activity within the app
 *     Close the secondary activity back to the initial one
 *
 * Notes:
 *     1. Part of the test setup occurs automatically via
 *        [com.android.server.wm.flicker.TransitionRunnerWithRules],
 *        including configuring navigation mode, initial orientation and ensuring no
 *        apps are running before setup
 */
@RequiresDevice
@RunWith(Parameterized::class)
@@ -51,6 +63,10 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
    val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val testApp: TwoActivitiesAppHelper = TwoActivitiesAppHelper(instrumentation)

    /**
     * Entry point for the test runner. It will use this method to initialize and cache
     * flicker executions
     */
    @FlickerBuilderProvider
    fun buildFlicker(): FlickerBuilder {
        return FlickerBuilder(instrumentation).apply {
@@ -76,6 +92,13 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
        }
    }

    /**
     * Checks that the [ActivityOptions.BUTTON_ACTIVITY_COMPONENT_NAME] activity is visible at
     * the start of the transition, that
     * [ActivityOptions.SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME] becomes visible during the
     * transition, and that [ActivityOptions.BUTTON_ACTIVITY_COMPONENT_NAME] is again visible
     * at the end
     */
    @Presubmit
    @Test
    fun finishSubActivity() {
@@ -92,6 +115,9 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
        }
    }

    /**
     * Checks that all parts of the screen are covered during the transition
     */
    @Presubmit
    @Test
    fun entireScreenCovered() = testSpec.entireScreenCovered()
@@ -109,6 +135,9 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
        }
    }

    /**
     * Checks that the [LAUNCHER_COMPONENT] layer is never visible during the transition
     */
    @Presubmit
    @Test
    fun launcherLayerNotVisible() {
@@ -116,6 +145,12 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
    }

    companion object {
        /**
         * Creates the test configurations.
         *
         * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring
         * repetitions, screen orientation and navigation modes.
         */
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<FlickerTestParameter> {
+3 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ import com.android.server.wm.flicker.statusBarWindowIsVisible
import com.android.server.wm.traces.common.FlickerComponentName
import org.junit.Test

/**
 * Base class for app launch tests
 */
abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
    protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    protected open val testApp: StandardAppHelper = SimpleAppHelper(instrumentation)