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

Commit 5d0dacde authored by Nataniel Borges's avatar Nataniel Borges
Browse files

Check only the display where the app layer is supposed to be, not all visible displays

Fixes: 321148772
Test: atest ChangeAppRotationTest
Change-Id: I0e05d32237c9266641bbc3be49caeafa0b0f9da0
parent 2ed1c1d7
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() {