diff options
24 files changed, 253 insertions, 359 deletions
diff --git a/packages/SystemUI/customization/tests/utils/src/com/android/systemui/shared/settings/data/repository/FakeSecureSettingsRepository.kt b/packages/SystemUI/customization/tests/utils/src/com/android/systemui/shared/settings/data/repository/FakeSecureSettingsRepository.kt index 21d8d4648824..e11a6d049721 100644 --- a/packages/SystemUI/customization/tests/utils/src/com/android/systemui/shared/settings/data/repository/FakeSecureSettingsRepository.kt +++ b/packages/SystemUI/customization/tests/utils/src/com/android/systemui/shared/settings/data/repository/FakeSecureSettingsRepository.kt @@ -32,6 +32,11 @@ class FakeSecureSettingsRepository : SecureSettingsRepository { return intSetting(name, if (defaultValue) 1 else 0).map { it != 0 } } + fun setBool(name: String, value: Boolean) { + settings.value = + settings.value.toMutableMap().apply { this[name] = (if (value) 1 else 0).toString() } + } + override suspend fun setInt(name: String, value: Int) { settings.value = settings.value.toMutableMap().apply { this[name] = value.toString() } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/ui/viewmodel/CommunalUserActionsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/ui/viewmodel/CommunalUserActionsViewModelTest.kt index 26859b6e10f8..5510710b9b3f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/ui/viewmodel/CommunalUserActionsViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/ui/viewmodel/CommunalUserActionsViewModelTest.kt @@ -18,8 +18,6 @@ package com.android.systemui.communal.ui.viewmodel -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.animation.scene.Swipe @@ -42,9 +40,9 @@ import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.SceneFamilies import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade -import com.android.systemui.shade.data.repository.fakeShadeRepository -import com.android.systemui.shade.shared.flag.DualShade -import com.android.systemui.shade.shared.model.ShadeMode +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.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test @@ -72,33 +70,21 @@ class CommunalUserActionsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun actions_singleShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) + kosmos.enableSingleShade() - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Single, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = false) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.End)).isEqualTo(UserActionResult(SceneFamilies.Home)) assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Bouncer)) assertThat(actions?.get(Swipe.Down)).isEqualTo(UserActionResult(Scenes.Shade)) - setUpState( - isShadeTouchable = false, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Single, - ) + setUpState(isShadeTouchable = false, isDeviceUnlocked = false) assertThat(actions).isEmpty() - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = true, - shadeMode = ShadeMode.Single, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = true) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.End)).isEqualTo(UserActionResult(SceneFamilies.Home)) assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Gone)) @@ -106,34 +92,22 @@ class CommunalUserActionsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun actions_splitShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) + kosmos.enableSplitShade() - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Split, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = false) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.End)).isEqualTo(UserActionResult(SceneFamilies.Home)) assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Bouncer)) assertThat(actions?.get(Swipe.Down)) .isEqualTo(UserActionResult(Scenes.Shade, ToSplitShade)) - setUpState( - isShadeTouchable = false, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Split, - ) + setUpState(isShadeTouchable = false, isDeviceUnlocked = false) assertThat(actions).isEmpty() - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = true, - shadeMode = ShadeMode.Split, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = true) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.End)).isEqualTo(UserActionResult(SceneFamilies.Home)) assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Gone)) @@ -142,30 +116,22 @@ class CommunalUserActionsViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun actions_dualShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) + kosmos.enableDualShade() - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Dual, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = false) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.End)).isEqualTo(UserActionResult(SceneFamilies.Home)) assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Bouncer)) assertThat(actions?.get(Swipe.Down)) .isEqualTo(UserActionResult.ShowOverlay(Overlays.NotificationsShade)) - setUpState( - isShadeTouchable = false, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Dual, - ) + setUpState(isShadeTouchable = false, isDeviceUnlocked = false) assertThat(actions).isEmpty() - setUpState(isShadeTouchable = true, isDeviceUnlocked = true, shadeMode = ShadeMode.Dual) + setUpState(isShadeTouchable = true, isDeviceUnlocked = true) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.End)).isEqualTo(UserActionResult(SceneFamilies.Home)) assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Gone)) @@ -173,11 +139,7 @@ class CommunalUserActionsViewModelTest : SysuiTestCase() { .isEqualTo(UserActionResult.ShowOverlay(Overlays.NotificationsShade)) } - private fun TestScope.setUpState( - isShadeTouchable: Boolean, - isDeviceUnlocked: Boolean, - shadeMode: ShadeMode, - ) { + private fun TestScope.setUpState(isShadeTouchable: Boolean, isDeviceUnlocked: Boolean) { if (isShadeTouchable) { kosmos.powerInteractor.setAwakeForTest() } else { @@ -189,10 +151,6 @@ class CommunalUserActionsViewModelTest : SysuiTestCase() { } else { lockDevice() } - - if (shadeMode !is ShadeMode.Dual) { - kosmos.fakeShadeRepository.setShadeLayoutWide(shadeMode is ShadeMode.Split) - } runCurrent() } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/ui/viewmodel/DreamUserActionsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/ui/viewmodel/DreamUserActionsViewModelTest.kt index e19ea365fa1f..e5670627735c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/ui/viewmodel/DreamUserActionsViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/ui/viewmodel/DreamUserActionsViewModelTest.kt @@ -18,8 +18,6 @@ package com.android.systemui.dreams.ui.viewmodel -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.animation.scene.Swipe @@ -42,9 +40,9 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade -import com.android.systemui.shade.data.repository.fakeShadeRepository -import com.android.systemui.shade.shared.flag.DualShade -import com.android.systemui.shade.shared.model.ShadeMode +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.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test @@ -72,36 +70,24 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun actions_communalNotAvailable_singleShade() = testScope.runTest { + kosmos.enableSingleShade() kosmos.setCommunalAvailable(false) val actions by collectLastValue(underTest.actions) - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Single, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = false) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Bouncer)) assertThat(actions?.get(Swipe.Down)).isEqualTo(UserActionResult(Scenes.Shade)) assertThat(actions?.get(Swipe.Start)).isNull() assertThat(actions?.get(Swipe.End)).isNull() - setUpState( - isShadeTouchable = false, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Single, - ) + setUpState(isShadeTouchable = false, isDeviceUnlocked = false) assertThat(actions).isEmpty() - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = true, - shadeMode = ShadeMode.Single, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = true) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Gone)) assertThat(actions?.get(Swipe.Down)).isEqualTo(UserActionResult(Scenes.Shade)) @@ -110,18 +96,14 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun actions_communalNotAvailable_splitShade() = testScope.runTest { + kosmos.enableSplitShade() kosmos.setCommunalAvailable(false) val actions by collectLastValue(underTest.actions) - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Split, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = false) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Bouncer)) assertThat(actions?.get(Swipe.Down)) @@ -129,18 +111,10 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { assertThat(actions?.get(Swipe.Start)).isNull() assertThat(actions?.get(Swipe.End)).isNull() - setUpState( - isShadeTouchable = false, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Split, - ) + setUpState(isShadeTouchable = false, isDeviceUnlocked = false) assertThat(actions).isEmpty() - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = true, - shadeMode = ShadeMode.Split, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = true) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Gone)) assertThat(actions?.get(Swipe.Down)) @@ -150,18 +124,14 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun actions_communalNotAvailable_dualShade() = testScope.runTest { + kosmos.enableDualShade() kosmos.setCommunalAvailable(false) val actions by collectLastValue(underTest.actions) - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Dual, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = false) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Bouncer)) assertThat(actions?.get(Swipe.Down)) @@ -169,14 +139,10 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { assertThat(actions?.get(Swipe.Start)).isNull() assertThat(actions?.get(Swipe.End)).isNull() - setUpState( - isShadeTouchable = false, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Dual, - ) + setUpState(isShadeTouchable = false, isDeviceUnlocked = false) assertThat(actions).isEmpty() - setUpState(isShadeTouchable = true, isDeviceUnlocked = true, shadeMode = ShadeMode.Dual) + setUpState(isShadeTouchable = true, isDeviceUnlocked = true) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Gone)) assertThat(actions?.get(Swipe.Down)) @@ -186,36 +152,24 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun actions_communalAvailable_singleShade() = testScope.runTest { + kosmos.enableSingleShade() kosmos.setCommunalAvailable(true) val actions by collectLastValue(underTest.actions) - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Single, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = false) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Bouncer)) assertThat(actions?.get(Swipe.Down)).isEqualTo(UserActionResult(Scenes.Shade)) assertThat(actions?.get(Swipe.Start)).isEqualTo(UserActionResult(Scenes.Communal)) assertThat(actions?.get(Swipe.End)).isNull() - setUpState( - isShadeTouchable = false, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Single, - ) + setUpState(isShadeTouchable = false, isDeviceUnlocked = false) assertThat(actions).isEmpty() - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = true, - shadeMode = ShadeMode.Single, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = true) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Gone)) assertThat(actions?.get(Swipe.Down)).isEqualTo(UserActionResult(Scenes.Shade)) @@ -224,18 +178,14 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun actions_communalAvailable_splitShade() = testScope.runTest { + kosmos.enableSplitShade() kosmos.setCommunalAvailable(true) val actions by collectLastValue(underTest.actions) - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Split, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = false) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Bouncer)) assertThat(actions?.get(Swipe.Down)) @@ -243,18 +193,10 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { assertThat(actions?.get(Swipe.Start)).isEqualTo(UserActionResult(Scenes.Communal)) assertThat(actions?.get(Swipe.End)).isNull() - setUpState( - isShadeTouchable = false, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Split, - ) + setUpState(isShadeTouchable = false, isDeviceUnlocked = false) assertThat(actions).isEmpty() - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = true, - shadeMode = ShadeMode.Split, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = true) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Gone)) assertThat(actions?.get(Swipe.Down)) @@ -264,18 +206,14 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun actions_communalAvailable_dualShade() = testScope.runTest { + kosmos.enableDualShade() kosmos.setCommunalAvailable(true) val actions by collectLastValue(underTest.actions) - setUpState( - isShadeTouchable = true, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Dual, - ) + setUpState(isShadeTouchable = true, isDeviceUnlocked = false) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Bouncer)) assertThat(actions?.get(Swipe.Down)) @@ -283,14 +221,10 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { assertThat(actions?.get(Swipe.Start)).isEqualTo(UserActionResult(Scenes.Communal)) assertThat(actions?.get(Swipe.End)).isNull() - setUpState( - isShadeTouchable = false, - isDeviceUnlocked = false, - shadeMode = ShadeMode.Dual, - ) + setUpState(isShadeTouchable = false, isDeviceUnlocked = false) assertThat(actions).isEmpty() - setUpState(isShadeTouchable = true, isDeviceUnlocked = true, shadeMode = ShadeMode.Dual) + setUpState(isShadeTouchable = true, isDeviceUnlocked = true) assertThat(actions).isNotEmpty() assertThat(actions?.get(Swipe.Up)).isEqualTo(UserActionResult(Scenes.Gone)) assertThat(actions?.get(Swipe.Down)) @@ -299,11 +233,7 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { assertThat(actions?.get(Swipe.End)).isNull() } - private fun TestScope.setUpState( - isShadeTouchable: Boolean, - isDeviceUnlocked: Boolean, - shadeMode: ShadeMode, - ) { + private fun TestScope.setUpState(isShadeTouchable: Boolean, isDeviceUnlocked: Boolean) { if (isShadeTouchable) { kosmos.powerInteractor.setAwakeForTest() } else { @@ -315,10 +245,6 @@ class DreamUserActionsViewModelTest : SysuiTestCase() { } else { lockDevice() } - - if (shadeMode !is ShadeMode.Dual) { - kosmos.fakeShadeRepository.setShadeLayoutWide(shadeMode is ShadeMode.Split) - } runCurrent() } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt index e4eb55b79a23..5436d7eee00c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt @@ -18,7 +18,6 @@ package com.android.systemui.keyguard.ui.viewmodel -import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase @@ -37,7 +36,7 @@ import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.data.repository.shadeRepository -import com.android.systemui.shade.shared.flag.DualShade +import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.testKosmos import com.android.systemui.unfold.fakeUnfoldTransitionProgressProvider import com.android.systemui.util.mockito.whenever @@ -134,11 +133,11 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa } @Test - @EnableFlags(DualShade.FLAG_NAME) fun areNotificationsVisible_dualShadeWideOnLockscreen_true() = with(kosmos) { testScope.runTest { val areNotificationsVisible by collectLastValue(underTest.areNotificationsVisible()) + kosmos.enableDualShade() shadeRepository.setShadeLayoutWide(true) fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModelTest.kt index b30313e07012..675960832edc 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayContentViewModelTest.kt @@ -16,7 +16,6 @@ package com.android.systemui.notifications.ui.viewmodel -import android.platform.test.annotations.EnableFlags import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest @@ -36,8 +35,8 @@ import com.android.systemui.scene.domain.startable.sceneContainerStartable import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.data.repository.shadeRepository +import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.shade.domain.interactor.shadeInteractor -import com.android.systemui.shade.shared.flag.DualShade import com.android.systemui.shade.ui.viewmodel.notificationsShadeOverlayContentViewModel import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository import com.android.systemui.statusbar.notification.data.repository.setActiveNotifs @@ -56,7 +55,6 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @TestableLooper.RunWithLooper @EnableSceneContainer -@EnableFlags(DualShade.FLAG_NAME) class NotificationsShadeOverlayContentViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() @@ -68,6 +66,7 @@ class NotificationsShadeOverlayContentViewModelTest : SysuiTestCase() { @Before fun setUp() { kosmos.sceneContainerStartable.start() + kosmos.enableDualShade() underTest.activateIn(testScope) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/GridLayoutTypeInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/GridLayoutTypeInteractorTest.kt index b5915386b443..c775bfd75f6e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/GridLayoutTypeInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/GridLayoutTypeInteractorTest.kt @@ -16,8 +16,6 @@ package com.android.systemui.qs.panels.domain.interactor -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase @@ -26,8 +24,9 @@ import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.qs.panels.shared.model.InfiniteGridLayoutType import com.android.systemui.qs.panels.shared.model.PaginatedGridLayoutType -import com.android.systemui.shade.data.repository.fakeShadeRepository -import com.android.systemui.shade.shared.flag.DualShade +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.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test @@ -40,29 +39,27 @@ class GridLayoutTypeInteractorTest : SysuiTestCase() { val Kosmos.underTest by Kosmos.Fixture { kosmos.gridLayoutTypeInteractor } - @DisableFlags(DualShade.FLAG_NAME) @Test fun noDualShade_gridAlwaysPaginated() = kosmos.runTest { val type by collectLastValue(underTest.layout) - fakeShadeRepository.setShadeLayoutWide(false) + kosmos.enableSingleShade() assertThat(type).isEqualTo(PaginatedGridLayoutType) - fakeShadeRepository.setShadeLayoutWide(true) + kosmos.enableSplitShade() assertThat(type).isEqualTo(PaginatedGridLayoutType) } - @EnableFlags(DualShade.FLAG_NAME) @Test fun dualShade_gridAlwaysInfinite() = kosmos.runTest { val type by collectLastValue(underTest.layout) - fakeShadeRepository.setShadeLayoutWide(false) + kosmos.enableDualShade(wideLayout = false) assertThat(type).isEqualTo(InfiniteGridLayoutType) - fakeShadeRepository.setShadeLayoutWide(true) + kosmos.enableDualShade(wideLayout = true) assertThat(type).isEqualTo(InfiniteGridLayoutType) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractorTest.kt index 35f7504ead50..2e7aeb433e04 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/QSColumnsInteractorTest.kt @@ -17,8 +17,6 @@ package com.android.systemui.qs.panels.domain.interactor import android.content.res.mainResources -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase @@ -29,8 +27,9 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.qs.panels.data.repository.QSColumnsRepository import com.android.systemui.qs.panels.data.repository.qsColumnsRepository import com.android.systemui.res.R -import com.android.systemui.shade.data.repository.fakeShadeRepository -import com.android.systemui.shade.shared.flag.DualShade +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.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest @@ -65,35 +64,36 @@ class QSColumnsInteractorTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun withSingleShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { val latest by collectLastValue(underTest.columns) + kosmos.enableSingleShade() + assertThat(latest).isEqualTo(1) } } @Test - @EnableFlags(DualShade.FLAG_NAME) fun withDualShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { val latest by collectLastValue(underTest.columns) + kosmos.enableDualShade() + assertThat(latest).isEqualTo(2) } } @Test - @DisableFlags(DualShade.FLAG_NAME) fun withSplitShade_returnsCorrectValue() = with(kosmos) { testScope.runTest { val latest by collectLastValue(underTest.columns) - fakeShadeRepository.setShadeLayoutWide(true) + kosmos.enableSplitShade() assertThat(latest).isEqualTo(3) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/MediaInRowInLandscapeViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/MediaInRowInLandscapeViewModelTest.kt index 635badac04f5..e686d4dde2f1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/MediaInRowInLandscapeViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/MediaInRowInLandscapeViewModelTest.kt @@ -21,7 +21,6 @@ import android.content.res.mainResources import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository -import com.android.systemui.flags.setFlagValue import com.android.systemui.kosmos.testScope import com.android.systemui.lifecycle.activateIn import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager.Companion.LOCATION_QQS @@ -30,8 +29,9 @@ import com.android.systemui.media.controls.ui.controller.MediaLocation import com.android.systemui.media.controls.ui.controller.mediaHostStatesManager import com.android.systemui.media.controls.ui.view.MediaHost import com.android.systemui.qs.composefragment.dagger.usingMediaInComposeFragment -import com.android.systemui.shade.data.repository.shadeRepository -import com.android.systemui.shade.shared.flag.DualShade +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.shared.model.ShadeMode import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat @@ -57,7 +57,11 @@ class MediaInRowInLandscapeViewModelTest(private val testData: TestData) : Sysui @Before fun setUp() { - mSetFlagsRule.setFlagValue(DualShade.FLAG_NAME, testData.shadeMode == ShadeMode.Dual) + when (testData.shadeMode) { + ShadeMode.Single -> kosmos.enableSingleShade() + ShadeMode.Split -> kosmos.enableSplitShade() + ShadeMode.Dual -> kosmos.enableDualShade() + } } @Test @@ -66,7 +70,6 @@ class MediaInRowInLandscapeViewModelTest(private val testData: TestData) : Sysui testScope.runTest { underTest.activateIn(testScope) - shadeRepository.setShadeLayoutWide(testData.shadeMode != ShadeMode.Single) val config = Configuration(mainResources.configuration).apply { orientation = testData.orientation diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModelTest.kt index 4ae8589de87b..241cdbfbef83 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/QSColumnsViewModelTest.kt @@ -17,8 +17,6 @@ package com.android.systemui.qs.panels.ui.viewmodel import android.content.res.mainResources -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase @@ -37,7 +35,8 @@ import com.android.systemui.qs.composefragment.dagger.usingMediaInComposeFragmen import com.android.systemui.qs.panels.data.repository.QSColumnsRepository import com.android.systemui.qs.panels.data.repository.qsColumnsRepository import com.android.systemui.res.R -import com.android.systemui.shade.shared.flag.DualShade +import com.android.systemui.shade.domain.interactor.disableDualShade +import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest @@ -66,12 +65,12 @@ class QSColumnsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun mediaLocationNull_singleOrSplit_alwaysSingleShadeColumns() = with(kosmos) { testScope.runTest { val underTest = qsColumnsViewModelFactory.create(null) underTest.activateIn(testScope) + kosmos.disableDualShade() setConfigurationForMediaInRow(mediaInRow = false) @@ -89,12 +88,12 @@ class QSColumnsViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun mediaLocationNull_dualShade_alwaysDualShadeColumns() = with(kosmos) { testScope.runTest { val underTest = qsColumnsViewModelFactory.create(null) underTest.activateIn(testScope) + kosmos.enableDualShade() setConfigurationForMediaInRow(mediaInRow = false) @@ -112,12 +111,12 @@ class QSColumnsViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun mediaLocationQS_dualShade_alwaysDualShadeColumns() = with(kosmos) { testScope.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QS) underTest.activateIn(testScope) + kosmos.enableDualShade() setConfigurationForMediaInRow(mediaInRow = false) @@ -134,12 +133,12 @@ class QSColumnsViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun mediaLocationQQS_dualShade_alwaysDualShadeColumns() = with(kosmos) { testScope.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QQS) underTest.activateIn(testScope) + kosmos.enableDualShade() setConfigurationForMediaInRow(mediaInRow = false) @@ -156,12 +155,12 @@ class QSColumnsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun mediaLocationQS_singleOrSplit_halfColumnsOnCorrectConfigurationAndVisible() = with(kosmos) { testScope.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QS) underTest.activateIn(testScope) + kosmos.disableDualShade() setConfigurationForMediaInRow(mediaInRow = false) runCurrent() @@ -181,12 +180,12 @@ class QSColumnsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun mediaLocationQQS_singleOrSplit_halfColumnsOnCorrectConfigurationAndVisible() = with(kosmos) { testScope.runTest { val underTest = qsColumnsViewModelFactory.create(LOCATION_QQS) underTest.activateIn(testScope) + kosmos.disableDualShade() setConfigurationForMediaInRow(mediaInRow = false) runCurrent() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt index 7d366f65d64a..01714d7a4b87 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayContentViewModelTest.kt @@ -16,7 +16,6 @@ package com.android.systemui.qs.ui.viewmodel -import android.platform.test.annotations.EnableFlags import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest @@ -36,9 +35,8 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.domain.startable.sceneContainerStartable import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes -import com.android.systemui.shade.data.repository.shadeRepository +import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.shade.domain.interactor.shadeInteractor -import com.android.systemui.shade.shared.flag.DualShade import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimShape import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationScrollViewModel @@ -57,7 +55,6 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @TestableLooper.RunWithLooper @EnableSceneContainer -@EnableFlags(DualShade.FLAG_NAME) class QuickSettingsShadeOverlayContentViewModelTest : SysuiTestCase() { private val kosmos = @@ -72,6 +69,7 @@ class QuickSettingsShadeOverlayContentViewModelTest : SysuiTestCase() { @Before fun setUp() { kosmos.sceneContainerStartable.start() + kosmos.enableDualShade() underTest.activateIn(testScope) } @@ -131,7 +129,7 @@ class QuickSettingsShadeOverlayContentViewModelTest : SysuiTestCase() { @Test fun showHeader_showsOnNarrowScreen() = testScope.runTest { - kosmos.shadeRepository.setShadeLayoutWide(false) + kosmos.enableDualShade(wideLayout = false) runCurrent() assertThat(underTest.showHeader).isTrue() @@ -140,7 +138,7 @@ class QuickSettingsShadeOverlayContentViewModelTest : SysuiTestCase() { @Test fun showHeader_hidesOnWideScreen() = testScope.runTest { - kosmos.shadeRepository.setShadeLayoutWide(true) + kosmos.enableDualShade(wideLayout = true) runCurrent() assertThat(underTest.showHeader).isFalse() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneContainerOcclusionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneContainerOcclusionInteractorTest.kt index 959081663b56..707cd0493e36 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneContainerOcclusionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneContainerOcclusionInteractorTest.kt @@ -18,8 +18,6 @@ package com.android.systemui.scene.domain.interactor -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState @@ -36,7 +34,8 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.sceneDataSource -import com.android.systemui.shade.shared.flag.DualShade +import com.android.systemui.shade.domain.interactor.disableDualShade +import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.statusbar.domain.interactor.keyguardOcclusionInteractor import com.android.systemui.testKosmos import com.android.systemui.util.mockito.mock @@ -72,9 +71,9 @@ class SceneContainerOcclusionInteractorTest : SysuiTestCase() { private val underTest by lazy { kosmos.sceneContainerOcclusionInteractor } @Test - @DisableFlags(DualShade.FLAG_NAME) fun invisibleDueToOcclusion_dualShadeDisabled() = testScope.runTest { + kosmos.disableDualShade() val invisibleDueToOcclusion by collectLastValue(underTest.invisibleDueToOcclusion) val keyguardState by collectLastValue(keyguardTransitionInteractor.currentKeyguardState) @@ -134,9 +133,9 @@ class SceneContainerOcclusionInteractorTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun invisibleDueToOcclusion_dualShadeEnabled() = testScope.runTest { + kosmos.enableDualShade() val invisibleDueToOcclusion by collectLastValue(underTest.invisibleDueToOcclusion) val keyguardState by collectLastValue(keyguardTransitionInteractor.currentKeyguardState) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt index cb7267b2c34c..ef70305a3f47 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt @@ -103,8 +103,9 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource +import com.android.systemui.shade.domain.interactor.disableDualShade +import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.shade.domain.interactor.shadeInteractor -import com.android.systemui.shade.shared.flag.DualShade import com.android.systemui.shared.system.QuickStepContract import com.android.systemui.statusbar.VibratorHelper import com.android.systemui.statusbar.disableflags.data.repository.fakeDisableFlagsRepository @@ -187,9 +188,9 @@ class SceneContainerStartableTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun hydrateVisibility() = testScope.runTest { + kosmos.disableDualShade() val currentDesiredSceneKey by collectLastValue(sceneInteractor.currentScene) val isVisible by collectLastValue(sceneInteractor.isVisible) val transitionStateFlow = @@ -248,9 +249,9 @@ class SceneContainerStartableTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun hydrateVisibility_dualShade() = testScope.runTest { + kosmos.enableDualShade() val currentDesiredSceneKey by collectLastValue(sceneInteractor.currentScene) val currentDesiredOverlays by collectLastValue(sceneInteractor.currentOverlays) val isVisible by collectLastValue(sceneInteractor.isVisible) @@ -1739,9 +1740,9 @@ class SceneContainerStartableTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun hydrateInteractionState_whileLocked() = testScope.runTest { + kosmos.disableDualShade() val transitionStateFlow = prepareState(initialSceneKey = Scenes.Lockscreen) underTest.start() runCurrent() @@ -1826,9 +1827,9 @@ class SceneContainerStartableTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun hydrateInteractionState_whileUnlocked() = testScope.runTest { + kosmos.disableDualShade() val transitionStateFlow = prepareState( authenticationMethod = AuthenticationMethodModel.Pin, @@ -1915,9 +1916,9 @@ class SceneContainerStartableTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun hydrateInteractionState_dualShade_whileLocked() = testScope.runTest { + kosmos.enableDualShade() val currentDesiredOverlays by collectLastValue(sceneInteractor.currentOverlays) val transitionStateFlow = prepareState(initialSceneKey = Scenes.Lockscreen) underTest.start() @@ -2004,9 +2005,9 @@ class SceneContainerStartableTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun hydrateInteractionState_dualShade_whileUnlocked() = testScope.runTest { + kosmos.enableDualShade() val currentDesiredOverlays by collectLastValue(sceneInteractor.currentOverlays) val transitionStateFlow = prepareState( diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/GoneUserActionsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/GoneUserActionsViewModelTest.kt index fc915ca24d89..048dd66ae1da 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/GoneUserActionsViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/GoneUserActionsViewModelTest.kt @@ -16,8 +16,6 @@ package com.android.systemui.scene.ui.viewmodel -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest @@ -32,9 +30,10 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.lifecycle.activateIn import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade -import com.android.systemui.shade.data.repository.shadeRepository +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.shared.flag.DualShade import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -53,7 +52,6 @@ class GoneUserActionsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope - private val shadeRepository by lazy { kosmos.shadeRepository } private lateinit var underTest: GoneUserActionsViewModel @Before @@ -63,44 +61,40 @@ class GoneUserActionsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun downTransitionKey_splitShadeEnabled_isGoneToSplitShade() = testScope.runTest { val userActions by collectLastValue(underTest.actions) - shadeRepository.setShadeLayoutWide(true) + kosmos.enableSplitShade() runCurrent() assertThat(userActions?.get(Swipe.Down)?.transitionKey).isEqualTo(ToSplitShade) } @Test - @DisableFlags(DualShade.FLAG_NAME) fun downTransitionKey_splitShadeDisabled_isNull() = testScope.runTest { val userActions by collectLastValue(underTest.actions) - shadeRepository.setShadeLayoutWide(false) + kosmos.enableSingleShade() runCurrent() assertThat(userActions?.get(Swipe.Down)?.transitionKey).isNull() } @Test - @EnableFlags(DualShade.FLAG_NAME) fun downTransitionKey_dualShadeEnabled_isNull() = testScope.runTest { val userActions by collectLastValue(underTest.actions) - shadeRepository.setShadeLayoutWide(true) + kosmos.enableDualShade(wideLayout = true) runCurrent() assertThat(userActions?.get(Swipe.Down)?.transitionKey).isNull() } @Test - @DisableFlags(DualShade.FLAG_NAME) fun swipeDownWithTwoFingers_singleShade_goesToQuickSettings() = testScope.runTest { val userActions by collectLastValue(underTest.actions) - shadeRepository.setShadeLayoutWide(false) + kosmos.enableSingleShade() runCurrent() assertThat(userActions?.get(swipeDownFromTopWithTwoFingers())) @@ -108,11 +102,10 @@ class GoneUserActionsViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun swipeDownWithTwoFingers_splitShade_goesToShade() = testScope.runTest { val userActions by collectLastValue(underTest.actions) - shadeRepository.setShadeLayoutWide(true) + kosmos.enableSplitShade() runCurrent() assertThat(userActions?.get(swipeDownFromTopWithTwoFingers())) @@ -120,10 +113,10 @@ class GoneUserActionsViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun swipeDownWithTwoFingers_dualShadeEnabled_isNull() = testScope.runTest { val userActions by collectLastValue(underTest.actions) + kosmos.enableDualShade() runCurrent() assertThat(userActions?.get(swipeDownFromTopWithTwoFingers())).isNull() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt index af895c82c975..399b48fb2fb9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt @@ -18,8 +18,6 @@ package com.android.systemui.scene.ui.viewmodel -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import android.view.MotionEvent import android.view.MotionEvent.ACTION_DOWN import android.view.MotionEvent.ACTION_OUTSIDE @@ -41,9 +39,10 @@ import com.android.systemui.scene.sceneContainerViewModelFactory import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource -import com.android.systemui.shade.data.repository.fakeShadeRepository +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.shared.flag.DualShade import com.android.systemui.shade.shared.model.ShadeMode import com.android.systemui.statusbar.data.repository.fakeRemoteInputRepository import com.android.systemui.testKosmos @@ -69,7 +68,6 @@ class SceneContainerViewModelTest : SysuiTestCase() { private val testScope by lazy { kosmos.testScope } private val sceneInteractor by lazy { kosmos.sceneInteractor } private val fakeSceneDataSource by lazy { kosmos.fakeSceneDataSource } - private val fakeShadeRepository by lazy { kosmos.fakeShadeRepository } private val sceneContainerConfig by lazy { kosmos.sceneContainerConfig } private val fakeRemoteInputRepository by lazy { kosmos.fakeRemoteInputRepository } private val falsingManager by lazy { kosmos.fakeFalsingManager } @@ -324,44 +322,40 @@ class SceneContainerViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun edgeDetector_singleShade_usesDefaultEdgeDetector() = testScope.runTest { val shadeMode by collectLastValue(kosmos.shadeInteractor.shadeMode) - fakeShadeRepository.setShadeLayoutWide(false) - assertThat(shadeMode).isEqualTo(ShadeMode.Single) + kosmos.enableSingleShade() + assertThat(shadeMode).isEqualTo(ShadeMode.Single) assertThat(underTest.edgeDetector).isEqualTo(DefaultEdgeDetector) } @Test - @DisableFlags(DualShade.FLAG_NAME) fun edgeDetector_splitShade_usesDefaultEdgeDetector() = testScope.runTest { val shadeMode by collectLastValue(kosmos.shadeInteractor.shadeMode) - fakeShadeRepository.setShadeLayoutWide(true) - assertThat(shadeMode).isEqualTo(ShadeMode.Split) + kosmos.enableSplitShade() + assertThat(shadeMode).isEqualTo(ShadeMode.Split) assertThat(underTest.edgeDetector).isEqualTo(DefaultEdgeDetector) } @Test - @EnableFlags(DualShade.FLAG_NAME) fun edgeDetector_dualShade_narrowScreen_usesSplitEdgeDetector() = testScope.runTest { val shadeMode by collectLastValue(kosmos.shadeInteractor.shadeMode) - fakeShadeRepository.setShadeLayoutWide(false) + kosmos.enableDualShade(wideLayout = false) assertThat(shadeMode).isEqualTo(ShadeMode.Dual) assertThat(underTest.edgeDetector).isEqualTo(kosmos.splitEdgeDetector) } @Test - @EnableFlags(DualShade.FLAG_NAME) fun edgeDetector_dualShade_wideScreen_usesSplitEdgeDetector() = testScope.runTest { val shadeMode by collectLastValue(kosmos.shadeInteractor.shadeMode) - fakeShadeRepository.setShadeLayoutWide(true) + kosmos.enableDualShade(wideLayout = true) assertThat(shadeMode).isEqualTo(ShadeMode.Dual) assertThat(underTest.edgeDetector).isEqualTo(kosmos.splitEdgeDetector) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt index b1ec740c5564..5c9cf82574a1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt @@ -16,8 +16,6 @@ package com.android.systemui.shade.domain.interactor -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState @@ -34,7 +32,7 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.shadeTestUtil -import com.android.systemui.shade.shared.flag.DualShade +import com.android.systemui.shade.shared.model.ShadeMode import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -596,11 +594,13 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun expandNotificationsShade_dualShade_opensOverlay() = testScope.runTest { + kosmos.enableDualShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Dual) assertThat(currentScene).isEqualTo(Scenes.Lockscreen) assertThat(currentOverlays).isEmpty() @@ -611,12 +611,13 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun expandNotificationsShade_singleShade_switchesToShadeScene() = testScope.runTest { - shadeTestUtil.setSplitShade(false) + kosmos.enableSingleShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Single) assertThat(currentScene).isEqualTo(Scenes.Lockscreen) assertThat(currentOverlays).isEmpty() @@ -627,11 +628,14 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun expandNotificationsShade_dualShadeQuickSettingsOpen_replacesOverlay() = testScope.runTest { + kosmos.enableDualShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Dual) + underTest.expandQuickSettingsShade("reason") assertThat(currentScene).isEqualTo(Scenes.Lockscreen) assertThat(currentOverlays).containsExactly(Overlays.QuickSettingsShade) @@ -642,11 +646,13 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun expandQuickSettingsShade_dualShade_opensOverlay() = testScope.runTest { + kosmos.enableDualShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Dual) assertThat(currentScene).isEqualTo(Scenes.Lockscreen) assertThat(currentOverlays).isEmpty() @@ -657,12 +663,13 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun expandQuickSettingsShade_singleShade_switchesToQuickSettingsScene() = testScope.runTest { - shadeTestUtil.setSplitShade(false) + kosmos.enableSingleShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Single) assertThat(currentScene).isEqualTo(Scenes.Lockscreen) assertThat(currentOverlays).isEmpty() @@ -673,12 +680,13 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun expandQuickSettingsShade_splitShade_switchesToShadeScene() = testScope.runTest { - shadeTestUtil.setSplitShade(true) + kosmos.enableSplitShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Split) assertThat(currentScene).isEqualTo(Scenes.Lockscreen) assertThat(currentOverlays).isEmpty() @@ -689,11 +697,14 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun expandQuickSettingsShade_dualShadeNotificationsOpen_replacesOverlay() = testScope.runTest { + kosmos.enableDualShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Dual) + underTest.expandNotificationsShade("reason") assertThat(currentScene).isEqualTo(Scenes.Lockscreen) assertThat(currentOverlays).containsExactly(Overlays.NotificationsShade) @@ -704,9 +715,9 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun collapseNotificationsShade_dualShade_hidesOverlay() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) openShade(Overlays.NotificationsShade) @@ -718,26 +729,27 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun collapseNotificationsShade_singleShade_switchesToLockscreen() = testScope.runTest { - shadeTestUtil.setSplitShade(false) + kosmos.enableSingleShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Single) + sceneInteractor.changeScene(Scenes.Shade, "reason") assertThat(currentScene).isEqualTo(Scenes.Shade) assertThat(currentOverlays).isEmpty() underTest.collapseNotificationsShade("reason") - assertThat(currentScene).isEqualTo(Scenes.Lockscreen) assertThat(currentOverlays).isEmpty() } @Test - @EnableFlags(DualShade.FLAG_NAME) fun collapseQuickSettingsShade_dualShade_hidesOverlay() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) openShade(Overlays.QuickSettingsShade) @@ -749,12 +761,14 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun collapseQuickSettingsShadeNotBypassingShade_singleShade_switchesToShade() = testScope.runTest { - shadeTestUtil.setSplitShade(false) + kosmos.enableSingleShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Single) + sceneInteractor.changeScene(Scenes.QuickSettings, "reason") assertThat(currentScene).isEqualTo(Scenes.QuickSettings) assertThat(currentOverlays).isEmpty() @@ -769,12 +783,14 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun collapseQuickSettingsShadeNotBypassingShade_splitShade_switchesToLockscreen() = testScope.runTest { - shadeTestUtil.setSplitShade(true) + kosmos.enableSplitShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Split) + sceneInteractor.changeScene(Scenes.QuickSettings, "reason") assertThat(currentScene).isEqualTo(Scenes.QuickSettings) assertThat(currentOverlays).isEmpty() @@ -789,12 +805,14 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun collapseQuickSettingsShadeBypassingShade_singleShade_switchesToLockscreen() = testScope.runTest { - shadeTestUtil.setSplitShade(false) + kosmos.enableSingleShade() + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) + assertThat(shadeMode).isEqualTo(ShadeMode.Single) + sceneInteractor.changeScene(Scenes.QuickSettings, "reason") assertThat(currentScene).isEqualTo(Scenes.QuickSettings) assertThat(currentOverlays).isEmpty() @@ -809,9 +827,9 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun collapseEitherShade_dualShade_hidesBothOverlays() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) openShade(Overlays.QuickSettingsShade) @@ -826,10 +844,13 @@ class ShadeInteractorSceneContainerImplTest : SysuiTestCase() { } private fun TestScope.openShade(overlay: OverlayKey) { + val shadeMode by collectLastValue(kosmos.shadeModeInteractor.shadeMode) val isAnyExpanded by collectLastValue(underTest.isAnyExpanded) val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) val initialScene = checkNotNull(currentScene) + assertThat(shadeMode).isEqualTo(ShadeMode.Dual) + sceneInteractor.showOverlay(overlay, "reason") kosmos.setSceneTransition( ObservableTransitionState.Idle(initialScene, checkNotNull(currentOverlays)) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt index d37e0fb2f047..0406c3e69b54 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt @@ -16,8 +16,6 @@ package com.android.systemui.shade.domain.startable -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState @@ -39,8 +37,9 @@ import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.shade.ShadeExpansionChangeEvent import com.android.systemui.shade.ShadeExpansionListener +import com.android.systemui.shade.domain.interactor.disableDualShade +import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.shade.domain.interactor.shadeInteractor -import com.android.systemui.shade.shared.flag.DualShade import com.android.systemui.shade.shared.model.ShadeMode import com.android.systemui.statusbar.notification.stack.notificationStackScrollLayoutController import com.android.systemui.statusbar.phone.scrimController @@ -88,10 +87,10 @@ class ShadeStartableTest(flags: FlagsParameterization) : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun hydrateShadeMode_dualShadeDisabled() = testScope.runTest { overrideResource(R.bool.config_use_split_notification_shade, false) + kosmos.disableDualShade() val shadeMode by collectLastValue(shadeInteractor.shadeMode) underTest.start() @@ -107,10 +106,10 @@ class ShadeStartableTest(flags: FlagsParameterization) : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun hydrateShadeMode_dualShadeEnabled() = testScope.runTest { overrideResource(R.bool.config_use_split_notification_shade, false) + kosmos.enableDualShade() val shadeMode by collectLastValue(shadeInteractor.shadeMode) underTest.start() @@ -159,11 +158,7 @@ class ShadeStartableTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(latestChangeEvent) .isEqualTo( - ShadeExpansionChangeEvent( - fraction = 0f, - expanded = false, - tracking = false, - ) + ShadeExpansionChangeEvent(fraction = 0f, expanded = false, tracking = false) ) changeScene(Scenes.Shade, transitionState) { progress -> diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeHeaderViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeHeaderViewModelTest.kt index 0da1e7f11582..8ce20d2a05e9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeHeaderViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeHeaderViewModelTest.kt @@ -1,8 +1,6 @@ package com.android.systemui.shade.ui.viewmodel import android.content.Intent -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import android.provider.AlarmClock import android.provider.Settings import android.telephony.SubscriptionManager.PROFILE_CLASS_UNSET @@ -23,7 +21,8 @@ import com.android.systemui.plugins.activityStarter import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes -import com.android.systemui.shade.shared.flag.DualShade +import com.android.systemui.shade.domain.interactor.disableDualShade +import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.fakeMobileIconsInteractor import com.android.systemui.testKosmos @@ -101,9 +100,9 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun onSystemIconChipClicked_locked_collapsesShadeToLockscreen() = testScope.runTest { + kosmos.disableDualShade() setDeviceEntered(false) setScene(Scenes.Shade) @@ -114,9 +113,9 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun onSystemIconChipClicked_lockedOnQsShade_collapsesShadeToLockscreen() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) setDeviceEntered(false) @@ -132,9 +131,9 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun onSystemIconChipClicked_lockedOnNotifShade_expandsQsShade() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) setDeviceEntered(false) @@ -151,9 +150,9 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test - @DisableFlags(DualShade.FLAG_NAME) fun onSystemIconChipClicked_unlocked_collapsesShadeToGone() = testScope.runTest { + kosmos.disableDualShade() setDeviceEntered(true) setScene(Scenes.Shade) @@ -164,9 +163,9 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun onSystemIconChipClicked_unlockedOnQsShade_collapsesShadeToGone() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) setDeviceEntered(true) @@ -182,9 +181,9 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun onSystemIconChipClicked_unlockedOnNotifShade_expandsQsShade() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) setDeviceEntered(true) @@ -201,9 +200,9 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun onNotificationIconChipClicked_lockedOnNotifShade_collapsesShadeToLockscreen() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) setDeviceEntered(false) @@ -219,9 +218,9 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun onNotificationIconChipClicked_lockedOnQsShade_expandsNotifShade() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) setDeviceEntered(false) @@ -238,9 +237,9 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun onNotificationIconChipClicked_unlockedOnNotifShade_collapsesShadeToGone() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) setDeviceEntered(true) @@ -256,9 +255,9 @@ class ShadeHeaderViewModelTest : SysuiTestCase() { } @Test - @EnableFlags(DualShade.FLAG_NAME) fun onNotificationIconChipClicked_unlockedOnQsShade_expandsNotifShade() = testScope.runTest { + kosmos.enableDualShade() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) setDeviceEntered(true) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneContentViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneContentViewModelTest.kt index a9d5790d1f08..27faeb8574a8 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneContentViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneContentViewModelTest.kt @@ -17,7 +17,6 @@ package com.android.systemui.shade.ui.viewmodel import android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS -import android.platform.test.annotations.DisableFlags import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest @@ -36,12 +35,11 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.lifecycle.activateIn import com.android.systemui.media.controls.data.repository.mediaFilterRepository import com.android.systemui.media.controls.shared.model.MediaData -import com.android.systemui.qs.ui.adapter.fakeQSSceneAdapter import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.data.repository.shadeRepository -import com.android.systemui.shade.shared.flag.DualShade +import com.android.systemui.shade.domain.interactor.disableDualShade import com.android.systemui.shade.shared.model.ShadeMode import com.android.systemui.statusbar.disableflags.data.repository.fakeDisableFlagsRepository import com.android.systemui.testKosmos @@ -64,20 +62,19 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @TestableLooper.RunWithLooper @EnableSceneContainer -@DisableFlags(DualShade.FLAG_NAME) class ShadeSceneContentViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val sceneInteractor by lazy { kosmos.sceneInteractor } private val shadeRepository by lazy { kosmos.shadeRepository } - private val qsSceneAdapter by lazy { kosmos.fakeQSSceneAdapter } private val underTest: ShadeSceneContentViewModel by lazy { kosmos.shadeSceneContentViewModel } @Before fun setUp() { underTest.activateIn(testScope) + kosmos.disableDualShade() } @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActionsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActionsViewModelTest.kt index bbfc66a8d8e5..8f904f7fe132 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActionsViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActionsViewModelTest.kt @@ -16,7 +16,6 @@ package com.android.systemui.shade.ui.viewmodel -import android.platform.test.annotations.DisableFlags import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest @@ -39,16 +38,16 @@ import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticati import com.android.systemui.kosmos.testScope import com.android.systemui.lifecycle.activateIn import com.android.systemui.qs.ui.adapter.fakeQSSceneAdapter -import com.android.systemui.res.R import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.domain.resolver.homeSceneFamilyResolver import com.android.systemui.scene.domain.startable.sceneContainerStartable import com.android.systemui.scene.shared.model.SceneFamilies import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade -import com.android.systemui.shade.data.repository.shadeRepository +import com.android.systemui.shade.domain.interactor.disableDualShade +import com.android.systemui.shade.domain.interactor.enableSingleShade +import com.android.systemui.shade.domain.interactor.enableSplitShade import com.android.systemui.shade.domain.startable.shadeStartable -import com.android.systemui.shade.shared.flag.DualShade import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage @@ -66,13 +65,11 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @TestableLooper.RunWithLooper @EnableSceneContainer -@DisableFlags(DualShade.FLAG_NAME) class ShadeUserActionsViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val sceneInteractor by lazy { kosmos.sceneInteractor } - private val shadeRepository by lazy { kosmos.shadeRepository } private val qsSceneAdapter by lazy { kosmos.fakeQSSceneAdapter } private val underTest: ShadeUserActionsViewModel by lazy { kosmos.shadeUserActionsViewModel } @@ -80,6 +77,7 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() { @Before fun setUp() { kosmos.sceneContainerStartable.start() + kosmos.disableDualShade() underTest.activateIn(testScope) } @@ -164,7 +162,7 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() { fun upTransitionKey_splitShadeEnabled_isGoneToSplitShade() = testScope.runTest { val actions by collectLastValue(underTest.actions) - shadeRepository.setShadeLayoutWide(true) + kosmos.enableSplitShade() runCurrent() assertThat(actions?.get(Swipe.Up)?.transitionKey).isEqualTo(ToSplitShade) @@ -174,7 +172,7 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() { fun upTransitionKey_splitShadeDisable_isNull() = testScope.runTest { val actions by collectLastValue(underTest.actions) - shadeRepository.setShadeLayoutWide(false) + kosmos.enableSingleShade() runCurrent() assertThat(actions?.get(Swipe.Up)?.transitionKey).isNull() @@ -183,7 +181,7 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() { @Test fun downTransitionSceneKey_inSplitShade_null() = testScope.runTest { - overrideResource(R.bool.config_use_split_notification_shade, true) + kosmos.enableSplitShade() kosmos.shadeStartable.start() val actions by collectLastValue(underTest.actions) assertThat((actions?.get(Swipe.Down) as? UserActionResult.ChangeScene)?.toScene) @@ -193,7 +191,7 @@ class ShadeUserActionsViewModelTest : SysuiTestCase() { @Test fun downTransitionSceneKey_notSplitShade_quickSettings() = testScope.runTest { - overrideResource(R.bool.config_use_split_notification_shade, false) + kosmos.enableSingleShade() kosmos.shadeStartable.start() val actions by collectLastValue(underTest.actions) assertThat((actions?.get(Swipe.Down) as? UserActionResult.ChangeScene)?.toScene) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt index f8720b4fe5f8..a51e0c0add37 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt @@ -19,8 +19,6 @@ package com.android.systemui.statusbar import android.animation.ObjectAnimator -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import android.testing.TestableLooper import androidx.test.filters.SmallTest @@ -53,8 +51,9 @@ import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInter import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes +import com.android.systemui.shade.domain.interactor.disableDualShade +import com.android.systemui.shade.domain.interactor.enableDualShade import com.android.systemui.shade.domain.interactor.shadeInteractor -import com.android.systemui.shade.shared.flag.DualShade import com.android.systemui.statusbar.domain.interactor.keyguardOcclusionInteractor import com.android.systemui.testKosmos import com.android.systemui.util.kotlin.JavaAdapter @@ -246,9 +245,9 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization) : SysuiTest @Test @EnableSceneContainer - @DisableFlags(DualShade.FLAG_NAME) fun start_hydratesStatusBarState_whileLocked() = testScope.runTest { + kosmos.disableDualShade() var statusBarState = underTest.state val listener = object : StatusBarStateController.StateListener { @@ -303,9 +302,9 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization) : SysuiTest @Test @EnableSceneContainer - @DisableFlags(DualShade.FLAG_NAME) fun start_hydratesStatusBarState_withAlternateBouncer() = testScope.runTest { + kosmos.disableDualShade() var statusBarState = underTest.state val listener = object : StatusBarStateController.StateListener { @@ -349,9 +348,9 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization) : SysuiTest @Test @EnableSceneContainer - @EnableFlags(DualShade.FLAG_NAME) fun start_hydratesStatusBarState_dualShade_whileLocked() = testScope.runTest { + kosmos.enableDualShade() var statusBarState = underTest.state val listener = object : StatusBarStateController.StateListener { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt index a045b37a8119..786b3590facb 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt @@ -19,8 +19,6 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState @@ -64,9 +62,11 @@ import com.android.systemui.scene.data.repository.Idle import com.android.systemui.scene.data.repository.Transition import com.android.systemui.scene.data.repository.setTransition import com.android.systemui.scene.shared.model.Scenes +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.mockLargeScreenHeaderHelper import com.android.systemui.shade.shadeTestUtil -import com.android.systemui.shade.shared.flag.DualShade import com.android.systemui.statusbar.notification.stack.domain.interactor.sharedNotificationContainerInteractor import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel.HorizontalPosition import com.android.systemui.testKosmos @@ -143,7 +143,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S @Test fun validateMarginStartInSplitShade() = testScope.runTest { - shadeTestUtil.setSplitShade(true) + kosmos.enableSplitShade() overrideDimensionPixelSize(R.dimen.notification_panel_margin_horizontal, 20) val dimens by collectLastValue(underTest.configurationBasedDimensions) @@ -156,7 +156,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S @Test fun validateMarginStart() = testScope.runTest { - shadeTestUtil.setSplitShade(false) + kosmos.enableSingleShade() overrideDimensionPixelSize(R.dimen.notification_panel_margin_horizontal, 20) val dimens by collectLastValue(underTest.configurationBasedDimensions) @@ -169,9 +169,9 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S @Test fun validateHorizontalPositionSingleShade() = testScope.runTest { + kosmos.enableSingleShade() overrideDimensionPixelSize(R.dimen.shade_panel_width, 200) val dimens by collectLastValue(underTest.configurationBasedDimensions) - shadeTestUtil.setSplitShade(false) val horizontalPosition = checkNotNull(dimens).horizontalPosition assertIs<HorizontalPosition.EdgeToEdge>(horizontalPosition) @@ -180,9 +180,9 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S @Test fun validateHorizontalPositionSplitShade() = testScope.runTest { + kosmos.enableSplitShade() overrideDimensionPixelSize(R.dimen.shade_panel_width, 200) val dimens by collectLastValue(underTest.configurationBasedDimensions) - shadeTestUtil.setSplitShade(true) val horizontalPosition = checkNotNull(dimens).horizontalPosition assertIs<HorizontalPosition.MiddleToEdge>(horizontalPosition) @@ -191,25 +191,22 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S @Test @EnableSceneContainer - @DisableFlags(DualShade.FLAG_NAME) fun validateHorizontalPositionInSceneContainerSingleShade() = testScope.runTest { + kosmos.enableSingleShade() overrideDimensionPixelSize(R.dimen.shade_panel_width, 200) val dimens by collectLastValue(underTest.configurationBasedDimensions) - shadeTestUtil.setSplitShade(false) val horizontalPosition = checkNotNull(dimens).horizontalPosition assertIs<HorizontalPosition.EdgeToEdge>(horizontalPosition) } @Test - @EnableSceneContainer - @DisableFlags(DualShade.FLAG_NAME) fun validateHorizontalPositionInSceneContainerSplitShade() = testScope.runTest { + kosmos.enableSplitShade() overrideDimensionPixelSize(R.dimen.shade_panel_width, 200) val dimens by collectLastValue(underTest.configurationBasedDimensions) - shadeTestUtil.setSplitShade(true) val horizontalPosition = checkNotNull(dimens).horizontalPosition assertIs<HorizontalPosition.MiddleToEdge>(horizontalPosition) @@ -218,12 +215,11 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S @Test @EnableSceneContainer - @EnableFlags(DualShade.FLAG_NAME) fun validateHorizontalPositionInDualShade_narrowLayout() = testScope.runTest { + kosmos.enableDualShade(wideLayout = false) overrideDimensionPixelSize(R.dimen.shade_panel_width, 200) val dimens by collectLastValue(underTest.configurationBasedDimensions) - shadeTestUtil.setSplitShade(false) val horizontalPosition = checkNotNull(dimens).horizontalPosition assertIs<HorizontalPosition.EdgeToEdge>(horizontalPosition) @@ -231,12 +227,11 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S @Test @EnableSceneContainer - @EnableFlags(DualShade.FLAG_NAME) fun validateHorizontalPositionInDualShade_wideLayout() = testScope.runTest { + kosmos.enableDualShade(wideLayout = true) overrideDimensionPixelSize(R.dimen.shade_panel_width, 200) val dimens by collectLastValue(underTest.configurationBasedDimensions) - shadeTestUtil.setSplitShade(true) val horizontalPosition = checkNotNull(dimens).horizontalPosition assertIs<HorizontalPosition.FloatAtStart>(horizontalPosition) @@ -246,8 +241,8 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S @Test fun validatePaddingTopInSplitShade_usesLargeHeaderHelper() = testScope.runTest { + kosmos.enableSplitShade() whenever(largeScreenHeaderHelper.getLargeScreenHeaderHeight()).thenReturn(5) - shadeTestUtil.setSplitShade(true) overrideResource(R.bool.config_use_large_screen_shade_header, true) overrideDimensionPixelSize(R.dimen.large_screen_shade_header_height, 10) overrideDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin, 50) @@ -262,8 +257,8 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S @Test fun validatePaddingTopInNonSplitShade_usesLargeScreenHeader() = testScope.runTest { + kosmos.enableSingleShade() whenever(largeScreenHeaderHelper.getLargeScreenHeaderHeight()).thenReturn(10) - shadeTestUtil.setSplitShade(false) overrideResource(R.bool.config_use_large_screen_shade_header, true) overrideDimensionPixelSize(R.dimen.large_screen_shade_header_height, 10) overrideDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin, 50) @@ -278,8 +273,8 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S @Test fun validatePaddingTopInNonSplitShade_doesNotUseLargeScreenHeader() = testScope.runTest { + kosmos.enableSingleShade() whenever(largeScreenHeaderHelper.getLargeScreenHeaderHeight()).thenReturn(10) - shadeTestUtil.setSplitShade(false) overrideResource(R.bool.config_use_large_screen_shade_header, false) overrideDimensionPixelSize(R.dimen.large_screen_shade_header_height, 10) overrideDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin, 50) diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/GeneralKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/GeneralKosmos.kt index a4c2cc275e44..b255b51281af 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/GeneralKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/GeneralKosmos.kt @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:OptIn(ExperimentalCoroutinesApi::class) + package com.android.systemui.kosmos import com.android.systemui.SysuiTestCase @@ -6,9 +24,8 @@ import com.android.systemui.coroutines.FlowValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.kosmos.Kosmos.Fixture -import com.android.systemui.settings.brightness.ui.BrightnessWarningToast -import com.android.systemui.util.mockito.mock import kotlin.coroutines.CoroutineContext +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch @@ -46,8 +63,6 @@ var Kosmos.backgroundCoroutineContext: CoroutineContext by Fixture { backgroundScope.coroutineContext } var Kosmos.mainCoroutineContext: CoroutineContext by Fixture { testScope.coroutineContext } -var Kosmos.brightnessWarningToast: BrightnessWarningToast by - Kosmos.Fixture { mock<BrightnessWarningToast>() } /** * Run this test body with a [Kosmos] as receiver, and using the [testScope] currently installed in diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeTestUtil.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeTestUtil.kt index e143324baeae..eb494f714a31 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeTestUtil.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeTestUtil.kt @@ -32,7 +32,7 @@ import kotlinx.coroutines.test.runCurrent import org.junit.Assert /** Sets up shade state for tests for either value of the scene container flag. */ -class ShadeTestUtil constructor(val delegate: ShadeTestUtilDelegate) { +class ShadeTestUtil(val delegate: ShadeTestUtilDelegate) { /** Sets shade expansion to a value between 0-1. */ fun setShadeExpansion(shadeExpansion: Float) { diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorKosmos.kt index 1b50094ec0b7..a4631f17cb37 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorKosmos.kt @@ -16,57 +16,61 @@ package com.android.systemui.shade.domain.interactor +import android.content.testableContext import android.provider.Settings import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.kosmos.applicationCoroutineScope -import com.android.systemui.kosmos.testScope +import com.android.systemui.res.R import com.android.systemui.shade.data.repository.fakeShadeRepository import com.android.systemui.shade.data.repository.shadeRepository -import com.android.systemui.shared.settings.data.repository.secureSettingsRepository -import kotlinx.coroutines.launch +import com.android.systemui.shared.settings.data.repository.fakeSecureSettingsRepository val Kosmos.shadeModeInteractor by Fixture { ShadeModeInteractorImpl( applicationScope = applicationCoroutineScope, repository = shadeRepository, - secureSettingsRepository = secureSettingsRepository, + secureSettingsRepository = fakeSecureSettingsRepository, ) } // TODO(b/391578667): Make this user-aware once supported by FakeSecureSettingsRepository. /** - * Enables the Dual Shade setting, and (optionally) sets the shade layout to be wide (`true`) - * or narrow (`false`). + * Enables the Dual Shade setting, and (optionally) sets the shade layout to be wide (`true`) or + * narrow (`false`). * * In a wide layout, notifications and quick settings shades each take up only half the screen * width. In a narrow layout, they each take up the entire screen width. */ fun Kosmos.enableDualShade(wideLayout: Boolean? = null) { - testScope.launch { - secureSettingsRepository.setInt(Settings.Secure.DUAL_SHADE, 1) + fakeSecureSettingsRepository.setBool(Settings.Secure.DUAL_SHADE, true) - if (wideLayout != null) { - fakeShadeRepository.setShadeLayoutWide(wideLayout) - } + if (wideLayout != null) { + overrideLargeScreenResources(isLargeScreen = wideLayout) + fakeShadeRepository.setShadeLayoutWide(wideLayout) } } // TODO(b/391578667): Make this user-aware once supported by FakeSecureSettingsRepository. fun Kosmos.disableDualShade() { - testScope.launch { secureSettingsRepository.setInt(Settings.Secure.DUAL_SHADE, 0) } + fakeSecureSettingsRepository.setBool(Settings.Secure.DUAL_SHADE, false) } fun Kosmos.enableSingleShade() { - testScope.launch { - disableDualShade() - fakeShadeRepository.setShadeLayoutWide(false) - } + disableDualShade() + overrideLargeScreenResources(isLargeScreen = false) + fakeShadeRepository.setShadeLayoutWide(false) } fun Kosmos.enableSplitShade() { - testScope.launch { - disableDualShade() - fakeShadeRepository.setShadeLayoutWide(true) + disableDualShade() + overrideLargeScreenResources(isLargeScreen = true) + fakeShadeRepository.setShadeLayoutWide(true) +} + +private fun Kosmos.overrideLargeScreenResources(isLargeScreen: Boolean) { + with(testableContext.orCreateTestableResources) { + addOverride(R.bool.config_use_split_notification_shade, isLargeScreen) + addOverride(R.bool.config_use_large_screen_shade_header, isLargeScreen) } } |