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

Commit db8a28f2 authored by burakov's avatar burakov Committed by Danny Burakov
Browse files

[Dual Shade] Expose ShadeMode only from ShadeModeInteractor.

This achieves two things:

1. Reduces the deps pulled in by callers who are currently injecting
   ShadeInteractor only to get access to the ShadeMode.

2. Consolidates all usages of ShadeMode so they're easier to track. In
   particular, this clearly marks all places to clean up once Dual Shade
   is launched.

BONUS: Exposure the convenience shortcut `kosmos.shadeMode`.

Bug: 388793191
Test: Unit tests still pass.
Flag: com.android.systemui.scene_container
Change-Id: I463ce9e2e0d459c073daccae5f0566a7546de2ab
parent 44f195a4
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ import com.android.systemui.qs.dagger.QSComponent
import com.android.systemui.qs.dagger.QSSceneComponent
import com.android.systemui.settings.brightness.MirrorController
import com.android.systemui.shade.data.repository.fakeShadeRepository
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.domain.interactor.shadeModeInteractor
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.argumentCaptor
import com.android.systemui.util.mockito.capture
@@ -118,16 +118,14 @@ class QSSceneAdapterImplTest : SysuiTestCase() {
            }
        }

    private val shadeInteractor = kosmos.shadeInteractor
    private val displayStateInteractor = kosmos.displayStateInteractor
    private val dumpManager = mock<DumpManager>()

    private val underTest =
        QSSceneAdapterImpl(
            qsSceneComponentFactory,
            qsImplProvider,
            shadeInteractor,
            displayStateInteractor,
            kosmos.shadeModeInteractor,
            kosmos.displayStateInteractor,
            dumpManager,
            testDispatcher,
            testScope.backgroundScope,
+4 −3
Original line number Diff line number Diff line
@@ -39,13 +39,14 @@ import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.settings.brightness.ui.viewmodel.brightnessMirrorViewModelFactory
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.domain.interactor.disableDualShade
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.domain.interactor.shadeModeInteractor
import com.android.systemui.shade.ui.viewmodel.shadeHeaderViewModelFactory
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -54,6 +55,7 @@ import org.junit.runner.RunWith
import org.mockito.Mockito.times
import org.mockito.Mockito.verify

@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@RunWith(AndroidJUnit4::class)
@RunWithLooper
@@ -72,7 +74,6 @@ class QuickSettingsSceneContentViewModelTest : SysuiTestCase() {

    private val sceneContainerStartable = kosmos.sceneContainerStartable
    private val sceneInteractor by lazy { kosmos.sceneInteractor }
    private val shadeInteractor by lazy { kosmos.shadeInteractor }

    private lateinit var underTest: QuickSettingsSceneContentViewModel

@@ -89,7 +90,7 @@ class QuickSettingsSceneContentViewModelTest : SysuiTestCase() {
                footerActionsViewModelFactory = footerActionsViewModelFactory,
                footerActionsController = footerActionsController,
                mediaCarouselInteractor = kosmos.mediaCarouselInteractor,
                shadeInteractor = shadeInteractor,
                shadeModeInteractor = kosmos.shadeModeInteractor,
                sceneInteractor = sceneInteractor,
            )
        underTest.activateIn(testScope)
+2 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade
import com.android.systemui.shade.domain.interactor.enableDualShade
import com.android.systemui.shade.domain.interactor.enableSingleShade
import com.android.systemui.shade.domain.interactor.enableSplitShade
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.domain.interactor.shadeModeInteractor
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -56,7 +56,7 @@ class GoneUserActionsViewModelTest : SysuiTestCase() {

    @Before
    fun setUp() {
        underTest = GoneUserActionsViewModel(shadeInteractor = kosmos.shadeInteractor)
        underTest = GoneUserActionsViewModel(shadeModeInteractor = kosmos.shadeModeInteractor)
        underTest.activateIn(testScope)
    }

+5 −5
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ import com.android.systemui.scene.shared.model.fakeSceneDataSource
import com.android.systemui.shade.domain.interactor.enableDualShade
import com.android.systemui.shade.domain.interactor.enableSingleShade
import com.android.systemui.shade.domain.interactor.enableSplitShade
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.domain.interactor.shadeMode
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.data.repository.fakeRemoteInputRepository
import com.android.systemui.testKosmos
@@ -324,7 +324,7 @@ class SceneContainerViewModelTest : SysuiTestCase() {
    @Test
    fun edgeDetector_singleShade_usesDefaultEdgeDetector() =
        testScope.runTest {
            val shadeMode by collectLastValue(kosmos.shadeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            kosmos.enableSingleShade()

            assertThat(shadeMode).isEqualTo(ShadeMode.Single)
@@ -334,7 +334,7 @@ class SceneContainerViewModelTest : SysuiTestCase() {
    @Test
    fun edgeDetector_splitShade_usesDefaultEdgeDetector() =
        testScope.runTest {
            val shadeMode by collectLastValue(kosmos.shadeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            kosmos.enableSplitShade()

            assertThat(shadeMode).isEqualTo(ShadeMode.Split)
@@ -344,7 +344,7 @@ class SceneContainerViewModelTest : SysuiTestCase() {
    @Test
    fun edgeDetector_dualShade_narrowScreen_usesSplitEdgeDetector() =
        testScope.runTest {
            val shadeMode by collectLastValue(kosmos.shadeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            kosmos.enableDualShade(wideLayout = false)

            assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
@@ -354,7 +354,7 @@ class SceneContainerViewModelTest : SysuiTestCase() {
    @Test
    fun edgeDetector_dualShade_wideScreen_usesSplitEdgeDetector() =
        testScope.runTest {
            val shadeMode by collectLastValue(kosmos.shadeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            kosmos.enableDualShade(wideLayout = true)

            assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
+12 −12
Original line number Diff line number Diff line
@@ -597,7 +597,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun expandNotificationsShade_dualShade_opensOverlay() =
        testScope.runTest {
            kosmos.enableDualShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
@@ -614,7 +614,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun expandNotificationsShade_singleShade_switchesToShadeScene() =
        testScope.runTest {
            kosmos.enableSingleShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Single)
@@ -631,7 +631,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun expandNotificationsShade_dualShadeQuickSettingsOpen_replacesOverlay() =
        testScope.runTest {
            kosmos.enableDualShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
@@ -649,7 +649,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun expandQuickSettingsShade_dualShade_opensOverlay() =
        testScope.runTest {
            kosmos.enableDualShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
@@ -666,7 +666,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun expandQuickSettingsShade_singleShade_switchesToQuickSettingsScene() =
        testScope.runTest {
            kosmos.enableSingleShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Single)
@@ -683,7 +683,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun expandQuickSettingsShade_splitShade_switchesToShadeScene() =
        testScope.runTest {
            kosmos.enableSplitShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Split)
@@ -700,7 +700,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun expandQuickSettingsShade_dualShadeNotificationsOpen_replacesOverlay() =
        testScope.runTest {
            kosmos.enableDualShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
@@ -732,7 +732,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun collapseNotificationsShade_singleShade_switchesToLockscreen() =
        testScope.runTest {
            kosmos.enableSingleShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Single)
@@ -764,7 +764,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun collapseQuickSettingsShadeNotBypassingShade_singleShade_switchesToShade() =
        testScope.runTest {
            kosmos.enableSingleShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Single)
@@ -786,7 +786,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun collapseQuickSettingsShadeNotBypassingShade_splitShade_switchesToLockscreen() =
        testScope.runTest {
            kosmos.enableSplitShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Split)
@@ -808,7 +808,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
    fun collapseQuickSettingsShadeBypassingShade_singleShade_switchesToLockscreen() =
        testScope.runTest {
            kosmos.enableSingleShade()
            val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
            val shadeMode by collectLastValue(kosmos.shadeMode)
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(shadeMode).isEqualTo(ShadeMode.Single)
@@ -844,7 +844,7 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() {
        }

    private fun TestScope.openShade(overlay: OverlayKey) {
        val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode)
        val shadeMode by collectLastValue(kosmos.shadeMode)
        val isAnyExpanded by collectLastValue(underTest.isAnyExpanded)
        val currentScene by collectLastValue(sceneInteractor.currentScene)
        val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
Loading