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

Commit 15c84c9f authored by AI test gen's avatar AI test gen Committed by Ang Li
Browse files

Add test for multi-display cutout handling in SysUICutoutProvider

Adds a unit test to verify that `SysUICutoutProviderImpl` correctly uses the display associated with its injected `@DisplayAware` context.

The test simulates a multi-display scenario by creating two instances of the provider: one for a display with a cutout and one for a display without. It then asserts that each provider returns the correct cutout information for its respective display, confirming that the behavior is dependent on the injected context.



Please help fill out the survey for feedback: https://docs.google.com/forms/d/e/1FAIpQLSeKFKpHImCAqZIa_OR801cw72HQUreM2oGM25C3mKKT2tBFnw/viewform?usp=pp_url&entry.1586624956=ag/35397076

Original Change: ag/35058391
Test: ATP tests passed http://go/forrest-run/L00900030017378414
Bug: 431235865
Flag: TEST_ONLY

Change-Id: I5c1d0eb36be8ee3ac07c33dd824907735995669c
parent 04721557
Loading
Loading
Loading
Loading
+25 −0
Original line number Original line Diff line number Diff line
@@ -49,6 +49,31 @@ class SysUICutoutProviderTest : SysuiTestCase() {
        assertThat(sysUICutout).isNull()
        assertThat(sysUICutout).isNull()
    }
    }


    @Test
    fun cutoutInfo_dependsOnInjectedDisplayContext() {
        // This test verifies that the provider's output depends on the display from the
        // injected context. This is critical for multi-display scenarios, where different
        // displays can have different cutout properties.

        // GIVEN a provider for an external display with NO cutout
        val externalDisplay = createDisplay(uniqueId = "external", cutout = null)
        val externalContext = context.createDisplayContext(externalDisplay)
        val externalProvider = SysUICutoutProviderImpl(externalContext, fakeProtectionLoader)

        // THEN it returns no cutout info
        assertThat(externalProvider.cutoutInfoForCurrentDisplayAndRotation()).isNull()

        // GIVEN a provider for an internal display WITH a cutout
        val internalDisplay = createDisplay(uniqueId = "internal", cutout = mock())
        val internalContext = context.createDisplayContext(internalDisplay)
        val internalProvider = SysUICutoutProviderImpl(internalContext, fakeProtectionLoader)

        // THEN it returns the correct cutout info
        val internalCutoutInfo = internalProvider.cutoutInfoForCurrentDisplayAndRotation()
        assertThat(internalCutoutInfo).isNotNull()
        assertThat(internalCutoutInfo!!.cutout).isEqualTo(internalDisplay.cutout)
    }

    @Test
    @Test
    fun cutoutInfoForCurrentDisplay_returnsCutout() {
    fun cutoutInfoForCurrentDisplay_returnsCutout() {
        val cutoutDisplay = createDisplay()
        val cutoutDisplay = createDisplay()