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

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

Add support for Tablets on app launch tests

Moreover, refactor the test to reuse the base test class with general assertions and fix ktlint errors

Bug: 234735502
Test: atest FlickerTests
Change-Id: Ia3dcc9977bd620db0e53c704517c33c0c1339426
parent 389f1d9a
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -111,19 +111,6 @@ fun FlickerTestParameter.taskBarLayerIsVisibleAtStartAndEnd() {
    }
}

/**
 * Checks that [ComponentMatcher.TASK_BAR] layer is visible at the start and end of the SF
 * trace
 */
fun FlickerTestParameter.navTaskLayerIsVisibleAtStartAndEnd() {
    assertLayersStart {
        this.isVisible(ComponentMatcher.TASK_BAR)
    }
    assertLayersEnd {
        this.isVisible(ComponentMatcher.TASK_BAR)
    }
}

/**
 * Checks that [ComponentMatcher.STATUS_BAR] layer is visible at the start and end of the SF
 * trace
+75 −39
Original line number Diff line number Diff line
@@ -16,18 +16,15 @@

package com.android.server.wm.flicker.launch

import android.app.Instrumentation
import android.platform.test.annotations.Postsubmit
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.BaseTest
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.Group4
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.entireScreenCovered
import com.android.server.wm.flicker.helpers.TwoActivitiesAppHelper
import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.traces.common.ComponentMatcher
@@ -59,18 +56,11 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group4
class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
class ActivitiesTransitionTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) {
    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
     * flicker executions
     */
    @FlickerBuilderProvider
    fun buildFlicker(): FlickerBuilder {
        return FlickerBuilder(instrumentation).apply {
    /** {@inheritDoc} */
    override val transition: FlickerBuilder.() -> Unit = {
        setup {
            test {
                tapl.setExpectedRotation(testSpec.startRotation)
@@ -90,7 +80,60 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
                .waitForAndVerify()
        }
    }
    }

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun statusBarLayerIsVisibleAtStartAndEnd() =
        super.statusBarLayerIsVisibleAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun statusBarLayerPositionAtStartAndEnd() =
        super.statusBarLayerPositionAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
        super.visibleLayersShownMoreThanOneConsecutiveEntry()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
        super.visibleWindowsShownMoreThanOneConsecutiveEntry()

    /**
     * Checks that the [ActivityOptions.BUTTON_ACTIVITY_COMPONENT_NAME] activity is visible at
@@ -115,13 +158,6 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
        }
    }

    /**
     * Checks that all parts of the screen are covered during the transition
     */
    @Presubmit
    @Test
    fun entireScreenCovered() = testSpec.entireScreenCovered()

    /**
     * Checks that the [ComponentMatcher.LAUNCHER] window is not on top. The launcher cannot be
     * asserted with `isAppWindowVisible` because it contains 2 windows with the exact same name,
+50 −29
Original line number Diff line number Diff line
@@ -54,11 +54,10 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class OpenAppColdFromIcon(testSpec: FlickerTestParameter) :
    OpenAppFromLauncherTransition(testSpec) {
    /**
     * Defines the transition used to run the test
     */
class OpenAppColdFromIcon(
    testSpec: FlickerTestParameter
) : OpenAppFromLauncherTransition(testSpec) {
    /** {@inheritDoc} */
    override val transition: FlickerBuilder.() -> Unit
        get() = {
            super.transition(this)
@@ -82,85 +81,107 @@ class OpenAppColdFromIcon(testSpec: FlickerTestParameter) :
            }
        }

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun appWindowAsTopWindowAtEnd() =
        super.appWindowAsTopWindowAtEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun appWindowReplacesLauncherAsTopWindow() =
        super.appWindowReplacesLauncherAsTopWindow()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun appLayerBecomesVisible() =
        super.appLayerBecomesVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun appLayerReplacesLauncher() =
        super.appLayerReplacesLauncher()
    override fun appWindowBecomesVisible() = super.appWindowBecomesVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun appWindowBecomesTopWindow() =
        super.appWindowBecomesTopWindow()
    override fun entireScreenCovered() = super.entireScreenCovered()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun appWindowBecomesVisible() =
        super.appWindowBecomesVisible()
    override fun focusChanges() = super.focusChanges()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun entireScreenCovered() =
        super.entireScreenCovered()
    override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun focusChanges() =
        super.focusChanges()
    override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun navBarLayerIsVisible() =
        super.navBarLayerIsVisible()
    override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun navBarLayerRotatesAndScales() =
        super.navBarLayerRotatesAndScales()
    override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun navBarWindowIsVisible() =
        super.navBarWindowIsVisible()
    override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun statusBarLayerRotatesScales() =
        super.statusBarLayerRotatesScales()
    override fun statusBarLayerPositionAtStartAndEnd() =
        super.statusBarLayerPositionAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun statusBarLayerIsVisible() =
        super.statusBarLayerIsVisible()
    override fun statusBarLayerIsVisibleAtStartAndEnd() =
        super.statusBarLayerIsVisibleAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun statusBarWindowIsVisible() =
        super.statusBarWindowIsVisible()
    override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
        super.visibleLayersShownMoreThanOneConsecutiveEntry()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
        super.visibleWindowsShownMoreThanOneConsecutiveEntry()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun appWindowIsTopWindowAtEnd() =
        super.appWindowIsTopWindowAtEnd()
    override fun appWindowIsTopWindowAtEnd() = super.appWindowIsTopWindowAtEnd()

    companion object {
        /**
+8 −29
Original line number Diff line number Diff line
@@ -54,11 +54,10 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
open class OpenAppColdTest(testSpec: FlickerTestParameter) :
    OpenAppFromLauncherTransition(testSpec) {
    /**
     * Defines the transition used to run the test
     */
open class OpenAppColdTest(
    testSpec: FlickerTestParameter
) : OpenAppFromLauncherTransition(testSpec) {
    /** {@inheritDoc} */
    override val transition: FlickerBuilder.() -> Unit
        get() = {
            super.transition(this)
@@ -81,13 +80,14 @@ open class OpenAppColdTest(testSpec: FlickerTestParameter) :
    /** {@inheritDoc} */
    @FlakyTest(bugId = 206753786)
    @Test
    override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales()
    override fun statusBarLayerPositionAtStartAndEnd() =
        super.statusBarLayerPositionAtStartAndEnd()

    /** {@inheritDoc} */
    @FlakyTest(bugId = 206753786)
    @Test
    override fun navBarLayerRotatesAndScales() {
        super.navBarLayerRotatesAndScales()
    override fun navBarLayerPositionAtStartAndEnd() {
        super.navBarLayerPositionAtStartAndEnd()
    }

    /** {@inheritDoc} */
@@ -95,27 +95,6 @@ open class OpenAppColdTest(testSpec: FlickerTestParameter) :
    @Test
    override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher()

    /** {@inheritDoc} */
    @Presubmit
    @Test
    override fun appWindowReplacesLauncherAsTopWindow() =
        super.appWindowReplacesLauncherAsTopWindow()

    /** {@inheritDoc} */
    @Presubmit
    @Test
    override fun navBarLayerIsVisible() = super.navBarLayerIsVisible()

    /** {@inheritDoc} */
    @Presubmit
    @Test
    override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()

    /** {@inheritDoc} */
    @Presubmit
    @Test
    override fun entireScreenCovered() = super.entireScreenCovered()

    companion object {
        /**
         * Creates the test configurations.
+23 −9
Original line number Diff line number Diff line
@@ -25,11 +25,12 @@ import org.junit.Test
/**
 * Base class for app launch tests
 */
abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) :
    OpenAppTransition(testSpec) {
abstract class OpenAppFromLauncherTransition(
    testSpec: FlickerTestParameter
) : OpenAppTransition(testSpec) {

    /**
     * Checks that the focus changes from the launcher to [testApp]
     * Checks that the focus changes from the [ComponentMatcher.LAUNCHER] to [testApp]
     */
    @Presubmit
    @Test
@@ -44,15 +45,17 @@ abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) :
     * and is replaced by [testApp], which remains visible until the end
     */
    open fun appLayerReplacesLauncher() {
        testSpec.replacesLayer(ComponentMatcher.LAUNCHER, testApp,
        testSpec.replacesLayer(
            ComponentMatcher.LAUNCHER, testApp,
            ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true,
                ignoreSplashscreen = true)
            ignoreSplashscreen = true
        )
    }

    /**
     * Checks that [ComponentMatcher.LAUNCHER] window is visible at the start of the
     * transition, and is replaced by a snapshot or splash screen (optional), and finally, is
     * replaced by [testApp], which remains visible until the end
     * Checks that [ComponentMatcher.LAUNCHER] window is the top window at the start of the
     * transition, and is replaced by a [ComponentMatcher.SNAPSHOT] or
     * [ComponentMatcher.SPLASH_SCREEN], or [testApp], which remains visible until the end
     */
    @Presubmit
    @Test
@@ -67,4 +70,15 @@ abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) :
                )
        }
    }

    /**
     * Checks that [testApp] window is the top window at the en dof the trace
     */
    @Presubmit
    @Test
    open fun appWindowAsTopWindowAtEnd() {
        testSpec.assertWmEnd {
            this.isAppWindowOnTop(testApp)
        }
    }
}
Loading