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


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


import android.app.Instrumentation
import android.platform.test.annotations.Postsubmit
import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.Presubmit
import androidx.test.filters.RequiresDevice
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import com.android.server.wm.flicker.BaseTest
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.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameterFactory
import com.android.server.wm.flicker.FlickerTestParameterFactory
import com.android.server.wm.flicker.annotation.Group4
import com.android.server.wm.flicker.annotation.Group4
import com.android.server.wm.flicker.dsl.FlickerBuilder
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.helpers.TwoActivitiesAppHelper
import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.traces.common.ComponentMatcher
import com.android.server.wm.traces.common.ComponentMatcher
@@ -59,18 +56,11 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group4
@Group4
class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
class ActivitiesTransitionTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) {
    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val testApp: TwoActivitiesAppHelper = TwoActivitiesAppHelper(instrumentation)
    private val testApp: TwoActivitiesAppHelper = TwoActivitiesAppHelper(instrumentation)
    private val tapl = LauncherInstrumentation()


    /**
    /** {@inheritDoc} */
     * Entry point for the test runner. It will use this method to initialize and cache
    override val transition: FlickerBuilder.() -> Unit = {
     * flicker executions
     */
    @FlickerBuilderProvider
    fun buildFlicker(): FlickerBuilder {
        return FlickerBuilder(instrumentation).apply {
        setup {
        setup {
            test {
            test {
                tapl.setExpectedRotation(testSpec.startRotation)
                tapl.setExpectedRotation(testSpec.startRotation)
@@ -90,7 +80,60 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
                .waitForAndVerify()
                .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
     * 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
     * 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,
     * asserted with `isAppWindowVisible` because it contains 2 windows with the exact same name,
+50 −29
Original line number Original line Diff line number Diff line
@@ -54,11 +54,10 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
@Group1
class OpenAppColdFromIcon(testSpec: FlickerTestParameter) :
class OpenAppColdFromIcon(
    OpenAppFromLauncherTransition(testSpec) {
    testSpec: FlickerTestParameter
    /**
) : OpenAppFromLauncherTransition(testSpec) {
     * Defines the transition used to run the test
    /** {@inheritDoc} */
     */
    override val transition: FlickerBuilder.() -> Unit
    override val transition: FlickerBuilder.() -> Unit
        get() = {
        get() = {
            super.transition(this)
            super.transition(this)
@@ -82,85 +81,107 @@ class OpenAppColdFromIcon(testSpec: FlickerTestParameter) :
            }
            }
        }
        }


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

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


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


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

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

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


    /** {@inheritDoc} */
    /** {@inheritDoc} */
@@ -95,27 +95,6 @@ open class OpenAppColdTest(testSpec: FlickerTestParameter) :
    @Test
    @Test
    override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher()
    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 {
    companion object {
        /**
        /**
         * Creates the test configurations.
         * Creates the test configurations.
+23 −9
Original line number Original line Diff line number Diff line
@@ -25,11 +25,12 @@ import org.junit.Test
/**
/**
 * Base class for app launch tests
 * Base class for app launch tests
 */
 */
abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) :
abstract class OpenAppFromLauncherTransition(
    OpenAppTransition(testSpec) {
    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
    @Presubmit
    @Test
    @Test
@@ -44,15 +45,17 @@ abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) :
     * and is replaced by [testApp], which remains visible until the end
     * and is replaced by [testApp], which remains visible until the end
     */
     */
    open fun appLayerReplacesLauncher() {
    open fun appLayerReplacesLauncher() {
        testSpec.replacesLayer(ComponentMatcher.LAUNCHER, testApp,
        testSpec.replacesLayer(
            ComponentMatcher.LAUNCHER, testApp,
            ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true,
            ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true,
                ignoreSplashscreen = true)
            ignoreSplashscreen = true
        )
    }
    }


    /**
    /**
     * Checks that [ComponentMatcher.LAUNCHER] window is visible at the start of the
     * Checks that [ComponentMatcher.LAUNCHER] window is the top window at the start of the
     * transition, and is replaced by a snapshot or splash screen (optional), and finally, is
     * transition, and is replaced by a [ComponentMatcher.SNAPSHOT] or
     * replaced by [testApp], which remains visible until the end
     * [ComponentMatcher.SPLASH_SCREEN], or [testApp], which remains visible until the end
     */
     */
    @Presubmit
    @Presubmit
    @Test
    @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