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

Commit 90f7be6e authored by Nataniel Borges's avatar Nataniel Borges
Browse files

Stabilize TaskTransitionTest#transitionHasColorBackground

Is visible/invisible variable already accounts for empty color

Bug: 312180456
Test: atest FlickerTestsAppLaunch2
Change-Id: Ifa5bdea91e832339d33d8dbe27d2519574a1bd48
parent c9d81431
Loading
Loading
Loading
Loading
+21 −25
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.app.Instrumentation
import android.app.WallpaperManager
import android.content.res.Resources
import android.platform.test.annotations.Presubmit
import android.tools.common.datatypes.Region
import android.tools.common.flicker.subject.layers.LayersTraceSubject
import android.tools.common.flicker.subject.layers.LayersTraceSubject.Companion.VISIBLE_FOR_MORE_THAN_ONE_ENTRY_IGNORE_LAYERS
import android.tools.common.traces.component.ComponentNameMatcher
import android.tools.common.traces.component.ComponentNameMatcher.Companion.SPLASH_SCREEN
@@ -125,27 +127,19 @@ class TaskTransitionTest(flicker: LegacyFlickerTest) : BaseTest(flicker) {
        val backgroundColorLayer = ComponentNameMatcher("", "animation-background")
        val displayBounds = WindowUtils.getDisplayBounds(flicker.scenario.startRotation)
        flicker.assertLayers {
            this.invoke("LAUNCH_NEW_TASK_ACTIVITY coversExactly displayBounds") {
                    it.visibleRegion(launchNewTaskApp.componentMatcher).coversExactly(displayBounds)
                }
            visibleRegionCovers(launchNewTaskApp.componentMatcher, displayBounds)
                .isInvisible(backgroundColorLayer)
                .hasNoColor(backgroundColorLayer)
                .then()
                // Transitioning
                .isVisible(backgroundColorLayer)
                .hasColor(backgroundColorLayer)
                .then()
                // Fully transitioned to simple SIMPLE_ACTIVITY
                .invoke(
                    "SIMPLE_ACTIVITY's splashscreen coversExactly displayBounds",
                .visibleRegionCovers(
                    ComponentSplashScreenMatcher(simpleApp.componentMatcher),
                    displayBounds,
                    isOptional = true
                ) {
                    it.visibleRegion(ComponentSplashScreenMatcher(simpleApp.componentMatcher))
                        .coversExactly(displayBounds)
                }
                .invoke("SIMPLE_ACTIVITY coversExactly displayBounds") {
                    it.visibleRegion(simpleApp.componentMatcher).coversExactly(displayBounds)
                }
                )
                .visibleRegionCovers(simpleApp.componentMatcher, displayBounds)
                .isInvisible(backgroundColorLayer)
                .hasNoColor(backgroundColorLayer)
                .then()
@@ -154,18 +148,12 @@ class TaskTransitionTest(flicker: LegacyFlickerTest) : BaseTest(flicker) {
                .hasColor(backgroundColorLayer)
                .then()
                // Fully transitioned back to LAUNCH_NEW_TASK_ACTIVITY
                .invoke(
                    "LAUNCH_NEW_TASK_ACTIVITY's splashscreen coversExactly displayBounds",
                .visibleRegionCovers(
                    ComponentSplashScreenMatcher(launchNewTaskApp.componentMatcher),
                    displayBounds,
                    isOptional = true
                ) {
                    it.visibleRegion(
                            ComponentSplashScreenMatcher(launchNewTaskApp.componentMatcher)
                )
                        .coversExactly(displayBounds)
                }
                .invoke("LAUNCH_NEW_TASK_ACTIVITY coversExactly displayBounds") {
                    it.visibleRegion(launchNewTaskApp.componentMatcher).coversExactly(displayBounds)
                }
                .visibleRegionCovers(launchNewTaskApp.componentMatcher, displayBounds)
                .isInvisible(backgroundColorLayer)
                .hasNoColor(backgroundColorLayer)
        }
@@ -223,6 +211,14 @@ class TaskTransitionTest(flicker: LegacyFlickerTest) : BaseTest(flicker) {
            return ComponentNameMatcher(rawComponentMatcher.className)
        }

        private fun LayersTraceSubject.visibleRegionCovers(
            component: IComponentMatcher,
            expectedArea: Region,
            isOptional: Boolean = true
        ): LayersTraceSubject = invoke("$component coversExactly $expectedArea", isOptional) {
            it.visibleRegion(component).coversExactly(expectedArea)
        }

        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams() = LegacyFlickerTestFactory.nonRotationTests()