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

Commit 042a9a86 authored by Andre Le's avatar Andre Le
Browse files

Flexiglass: Fix QSPanelControllerTest when flexiglass is enabled

onInit_setsMediaAsExpanded is failing when flexiglass is enabled because
mediaCarouselInteractor is now used in the init step. Thus we need to
set it up correctly.

Also, certain code now needs to run on the main thread so that
JavaAdapterDisposableHandle can run properly.

Bug: 416716751
Test: QSPanelControllerTest
Flag: TEST_ONLY
Change-Id: Idc0da13aabb57cbd2ece1c34fe1b3b9bb402d637
parent 679115af
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import android.testing.TestableResources
import android.view.ContextThemeWrapper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.platform.app.InstrumentationRegistry
import com.android.internal.logging.MetricsLogger
import com.android.internal.logging.UiEventLogger
import com.android.systemui.SysuiTestCase
@@ -27,6 +28,7 @@ import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController
import com.android.systemui.tuner.TunerService
import com.google.common.truth.Truth.assertThat
import javax.inject.Provider
import kotlinx.coroutines.flow.MutableStateFlow
import org.junit.After
import org.junit.Before
import org.junit.Test
@@ -116,12 +118,23 @@ class QSPanelControllerTest : SysuiTestCase() {

    @After
    fun tearDown() {
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            // Ensure destroy() is called on the main thread for `mJavaAdapterDisposableHandle` to
            // run properly.
            controller.destroy()
        }
        reset(mediaHost)
    }

    @Test
    fun onInit_setsMediaAsExpanded() {
    fun onInit_setsMediaAsExpanded() =
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            // Set up media carousel interactor
            if (SceneContainerFlag.isEnabled) {
                val mockStateFlow = MutableStateFlow(false)
                whenever(mediaCarouselInteractor.hasAnyMedia).thenReturn(mockStateFlow)
            }

            controller.onInit()

            verify(mediaHost).expansion = MediaHostState.EXPANDED