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

Commit 95947889 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Set initial value of enabledDisplay to DEFAULT_DISPLAY" into main

parents 817431b4 2a2e0d1b
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -178,7 +178,15 @@ constructor(
                .mapElementsLazily { displayId -> getDisplay(displayId) }
                .mapElementsLazily { displayId -> getDisplay(displayId) }
                .flowOn(backgroundCoroutineDispatcher)
                .flowOn(backgroundCoroutineDispatcher)
                .debugLog("enabledDisplays")
                .debugLog("enabledDisplays")
                .stateIn(bgApplicationScope, SharingStarted.WhileSubscribed(), emptySet())
                .stateIn(
                    bgApplicationScope,
                    started = SharingStarted.WhileSubscribed(),
                    initialValue =
                        setOf(
                            getDisplay(Display.DEFAULT_DISPLAY)
                                ?: error("Unable to get default display.")
                        )
                )
        } else {
        } else {
            oldEnabledDisplays
            oldEnabledDisplays
        }
        }
+11 −0
Original line number Original line Diff line number Diff line
@@ -126,6 +126,7 @@ class DisplayRepositoryTest : SysuiTestCase() {
        // All subscribers are done, unregister should have been called.
        // All subscribers are done, unregister should have been called.
        verify(displayManager).unregisterDisplayListener(any())
        verify(displayManager).unregisterDisplayListener(any())
    }
    }

    @Test
    @Test
    fun onDisplayAdded_propagated() =
    fun onDisplayAdded_propagated() =
        testScope.runTest {
        testScope.runTest {
@@ -457,6 +458,16 @@ class DisplayRepositoryTest : SysuiTestCase() {
            assertThat(defaultDisplayOff).isFalse()
            assertThat(defaultDisplayOff).isFalse()
        }
        }


    @Test
    fun displayFlow_startsWithDefaultDisplayBeforeAnyEvent() =
        testScope.runTest {
            setDisplays(Display.DEFAULT_DISPLAY)

            val value by latestDisplayFlowValue()

            assertThat(value?.ids()).containsExactly(Display.DEFAULT_DISPLAY)
        }

    private fun Iterable<Display>.ids(): List<Int> = map { it.displayId }
    private fun Iterable<Display>.ids(): List<Int> = map { it.displayId }


    // Wrapper to capture the displayListener.
    // Wrapper to capture the displayListener.