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

Commit c9f75fda authored by Pablo Gamito's avatar Pablo Gamito Committed by Android (Google) Code Review
Browse files

Merge "Update colorLayerIsVisibleDuringTransition test to match new spec"

parents 44af4ad1 69ddd9f7
Loading
Loading
Loading
Loading
+60 −72
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Instrumentation
import android.app.WallpaperManager
import android.platform.test.annotations.FlakyTest
import android.platform.test.annotations.Postsubmit
import android.platform.test.annotations.Presubmit
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.BaseTest
import com.android.server.wm.flicker.FlickerBuilder
@@ -29,11 +30,15 @@ import com.android.server.wm.flicker.helpers.NewTasksAppHelper
import com.android.server.wm.flicker.helpers.SimpleAppHelper
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.junit.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled
import com.android.server.wm.traces.common.ComponentNameMatcher
import com.android.server.wm.traces.common.ComponentNameMatcher.Companion.DEFAULT_TASK_DISPLAY_AREA
import com.android.server.wm.traces.common.ComponentNameMatcher.Companion.SPLASH_SCREEN
import com.android.server.wm.traces.common.ComponentNameMatcher.Companion.WALLPAPER_BBQ_WRAPPER
import com.android.server.wm.traces.common.ComponentSplashScreenMatcher
import com.android.server.wm.traces.common.IComponentMatcher
import com.android.server.wm.traces.parser.toFlickerComponent
import org.junit.Assume
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
@@ -43,7 +48,7 @@ import org.junit.runners.Parameterized
/**
 * Test the back and forward transition between 2 activities.
 *
 * To run this test: `atest FlickerTests:ActivitiesTransitionTest`
 * To run this test: `atest FlickerTests:TaskTransitionTest`
 *
 * Actions:
 * ```
@@ -57,7 +62,7 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class TaskTransitionTest(flicker: FlickerTest) : BaseTest(flicker) {
    private val testApp = NewTasksAppHelper(instrumentation)
    private val launchNewTaskApp = NewTasksAppHelper(instrumentation)
    private val simpleApp = SimpleAppHelper(instrumentation)
    private val wallpaper by lazy {
        getWallpaperPackage(instrumentation) ?: error("Unable to obtain wallpaper")
@@ -65,10 +70,10 @@ class TaskTransitionTest(flicker: FlickerTest) : BaseTest(flicker) {

    /** {@inheritDoc} */
    override val transition: FlickerBuilder.() -> Unit = {
        setup { testApp.launchViaIntent(wmHelper) }
        teardown { testApp.exit(wmHelper) }
        setup { launchNewTaskApp.launchViaIntent(wmHelper) }
        teardown { launchNewTaskApp.exit(wmHelper) }
        transitions {
            testApp.openNewTask(device, wmHelper)
            launchNewTaskApp.openNewTask(device, wmHelper)
            tapl.pressBack()
            wmHelper.StateSyncBuilder().withAppTransitionIdle().waitForAndVerify()
        }
@@ -101,7 +106,7 @@ class TaskTransitionTest(flicker: FlickerTest) : BaseTest(flicker) {
     * Check that the [ComponentNameMatcher.LAUNCHER] window is never visible when performing task
     * transitions. A solid color background should be shown above it.
     */
    @Postsubmit
    @Presubmit
    @Test
    fun launcherWindowIsNeverVisible() {
        flicker.assertWm { this.isAppWindowInvisible(ComponentNameMatcher.LAUNCHER) }
@@ -111,42 +116,76 @@ class TaskTransitionTest(flicker: FlickerTest) : BaseTest(flicker) {
     * Checks that the [ComponentNameMatcher.LAUNCHER] layer is never visible when performing task
     * transitions. A solid color background should be shown above it.
     */
    @Postsubmit
    @Presubmit
    @Test
    fun launcherLayerIsNeverVisible() {
        flicker.assertLayers { this.isInvisible(ComponentNameMatcher.LAUNCHER) }
    }

    /** Checks that a color background is visible while the task transition is occurring. */
    @FlakyTest(bugId = 240570652)
    @Presubmit
    @Test
    fun colorLayerIsVisibleDuringTransition() {
        val bgColorLayer = ComponentNameMatcher("", "colorBackgroundLayer")
        val displayBounds = WindowUtils.getDisplayBounds(flicker.scenario.startRotation)
    fun transitionHasColorBackground_legacy() {
        Assume.assumeFalse(isShellTransitionsEnabled)
        transitionHasColorBackground(DEFAULT_TASK_DISPLAY_AREA)
    }

    /** Checks that a color background is visible while the task transition is occurring. */
    @Presubmit
    @Test
    fun transitionHasColorBackground_shellTransit() {
        Assume.assumeTrue(isShellTransitionsEnabled)
        transitionHasColorBackground(ComponentNameMatcher("", "Animation Background"))
    }

    private fun transitionHasColorBackground(backgroundColorLayer: IComponentMatcher) {
        Assume.assumeTrue(isShellTransitionsEnabled)

        val displayBounds = WindowUtils.getDisplayBounds(flicker.scenario.startRotation)
        flicker.assertLayers {
            this.invoke("LAUNCH_NEW_TASK_ACTIVITY coversExactly displayBounds") {
                    it.visibleRegion(testApp.componentMatcher).coversExactly(displayBounds)
            this
                .invoke("LAUNCH_NEW_TASK_ACTIVITY coversExactly displayBounds") {
                    it.visibleRegion(launchNewTaskApp.componentMatcher).coversExactly(displayBounds)
                }
                .isInvisible(bgColorLayer)
                .isInvisible(backgroundColorLayer)
                .hasNoColor(backgroundColorLayer)
                .then()
                // Transitioning
                .isVisible(bgColorLayer)
                .isVisible(backgroundColorLayer)
                .hasColor(backgroundColorLayer)
                .then()
                // Fully transitioned to simple SIMPLE_ACTIVITY
                .invoke(
                    "SIMPLE_ACTIVITY's splashscreen coversExactly displayBounds",
                    isOptional = true
                ) {
                    it.visibleRegion(ComponentSplashScreenMatcher( simpleApp.componentMatcher))
                        .coversExactly(displayBounds)
                }
                .invoke("SIMPLE_ACTIVITY coversExactly displayBounds") {
                    it.visibleRegion(simpleApp.componentMatcher).coversExactly(displayBounds)
                }
                .isInvisible(bgColorLayer)
                .isInvisible(backgroundColorLayer)
                .hasNoColor(backgroundColorLayer)
                .then()
                // Transitioning back
                .isVisible(bgColorLayer)
                .isVisible(backgroundColorLayer)
                .hasColor(backgroundColorLayer)
                .then()
                // Fully transitioned back to LAUNCH_NEW_TASK_ACTIVITY
                .invoke(
                    "LAUNCH_NEW_TASK_ACTIVITY's splashscreen coversExactly displayBounds",
                    isOptional = true
                ) {
                    it.visibleRegion(
                            ComponentSplashScreenMatcher(launchNewTaskApp.componentMatcher))
                        .coversExactly(displayBounds)
                }
                .invoke("LAUNCH_NEW_TASK_ACTIVITY coversExactly displayBounds") {
                    it.visibleRegion(testApp.componentMatcher).coversExactly(displayBounds)
                    it.visibleRegion(launchNewTaskApp.componentMatcher).coversExactly(displayBounds)
                }
                .isInvisible(bgColorLayer)
                .isInvisible(backgroundColorLayer)
                .hasNoColor(backgroundColorLayer)
        }
    }

@@ -158,7 +197,7 @@ class TaskTransitionTest(flicker: FlickerTest) : BaseTest(flicker) {
    @Test
    fun newTaskOpensOnTopAndThenCloses() {
        flicker.assertWm {
            this.isAppWindowOnTop(testApp.componentMatcher)
            this.isAppWindowOnTop(launchNewTaskApp.componentMatcher)
                .then()
                .isAppWindowOnTop(SPLASH_SCREEN, isOptional = true)
                .then()
@@ -166,66 +205,15 @@ class TaskTransitionTest(flicker: FlickerTest) : BaseTest(flicker) {
                .then()
                .isAppWindowOnTop(SPLASH_SCREEN, isOptional = true)
                .then()
                .isAppWindowOnTop(testApp.componentMatcher)
                .isAppWindowOnTop(launchNewTaskApp.componentMatcher)
        }
    }

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

    /** {@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()

    companion object {
        private fun getWallpaperPackage(instrumentation: Instrumentation): IComponentMatcher? {
            val wallpaperManager = WallpaperManager.getInstance(instrumentation.targetContext)