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

Commit f812c0c4 authored by Nataniel Borges's avatar Nataniel Borges Committed by Android (Google) Code Review
Browse files

Merge "Check only the display where the app layer is supposed to be, not all...

Merge "Check only the display where the app layer is supposed to be, not all visible displays" into main
parents 12ea5d32 5d0dacde
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -17,7 +17,10 @@
package com.android.server.wm.flicker.rotation

import android.platform.test.annotations.Presubmit
import android.tools.common.flicker.subject.layers.LayerTraceEntrySubject
import android.tools.common.traces.component.ComponentNameMatcher
import android.tools.common.traces.component.IComponentMatcher
import android.tools.common.traces.surfaceflinger.Display
import android.tools.device.apphelpers.StandardAppHelper
import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest
@@ -57,9 +60,8 @@ abstract class RotationTransition(flicker: LegacyFlickerTest) : BaseTest(flicker
    @Test
    open fun appLayerRotates_StartingPos() {
        flicker.assertLayersStart {
            this.entry.displays.map { display ->
                this.visibleRegion(testApp).coversExactly(display.layerStackSpace)
            }
            val display = getDisplay(testApp)
            this.visibleRegion(testApp).coversAtLeast(display.layerStackSpace)
        }
    }

@@ -68,10 +70,18 @@ abstract class RotationTransition(flicker: LegacyFlickerTest) : BaseTest(flicker
    @Test
    open fun appLayerRotates_EndingPos() {
        flicker.assertLayersEnd {
            this.entry.displays.map { display ->
                this.visibleRegion(testApp).coversExactly(display.layerStackSpace)
            val display = getDisplay(testApp)
            this.visibleRegion(testApp).coversAtLeast(display.layerStackSpace)
        }
    }

    private fun LayerTraceEntrySubject.getDisplay(componentMatcher: IComponentMatcher): Display {
        val stackId = this.layer {
            componentMatcher.layerMatchesAnyOf(it) && it.isVisible
        }?.layer?.stackId ?: -1

        return this.entry.displays.firstOrNull { it.layerStackId == stackId }
            ?: error("Unable to find visible layer for $componentMatcher")
    }

    override fun cujCompleted() {