Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractorTest.kt +3 −1 Original line number Diff line number Diff line Loading @@ -58,7 +58,9 @@ class ModesTileDataInteractorTest : SysuiTestCase() { private val dispatcher = kosmos.testDispatcher private val zenModeRepository = kosmos.fakeZenModeRepository private val underTest = ModesTileDataInteractor(context, kosmos.zenModeInteractor, dispatcher) private val underTest by lazy { ModesTileDataInteractor(context, kosmos.zenModeInteractor, dispatcher) } @Before fun setUp() { Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/emptyshade/ui/viewmodel/EmptyShadeViewModelTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ class EmptyShadeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val activeNotificationListRepository = kosmos.activeNotificationListRepository private val fakeSecureSettingsRepository = kosmos.fakeSecureSettingsRepository private val underTest = kosmos.emptyShadeViewModel private val underTest by lazy { kosmos.emptyShadeViewModel } companion object { @JvmStatic Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/domain/interactor/ZenModeInteractorTest.kt +4 −4 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ class ZenModeInteractorTest : SysuiTestCase() { private val settingsRepository = kosmos.secureSettingsRepository private val deviceProvisioningRepository = kosmos.fakeDeviceProvisioningRepository private val underTest = kosmos.zenModeInteractor private val underTest by lazy { kosmos.zenModeInteractor } @Test fun isZenAvailable_off() = Loading Loading @@ -176,13 +176,13 @@ class ZenModeInteractorTest : SysuiTestCase() { @Test fun shouldAskForZenDuration_changesWithSetting() = kosmos.runTest { val manualDnd = TestModeBuilder().makeManualDnd().setActive(true).build() val manualDnd by collectLastValue(underTest.dndMode) settingsRepository.setInt(ZEN_DURATION, ZEN_DURATION_FOREVER) assertThat(underTest.shouldAskForZenDuration(manualDnd)).isFalse() assertThat(underTest.shouldAskForZenDuration(manualDnd!!)).isFalse() settingsRepository.setInt(ZEN_DURATION, ZEN_DURATION_PROMPT) assertThat(underTest.shouldAskForZenDuration(manualDnd)).isTrue() assertThat(underTest.shouldAskForZenDuration(manualDnd!!)).isTrue() } @Test Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/domain/interactor/ZenModeInteractor.kt +15 −6 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine Loading Loading @@ -123,11 +124,19 @@ constructor( * explicitly wants a shortcut to DND). Please prefer using [modes] or [activeModes] in all * other scenarios. */ val dndMode: StateFlow<ZenMode?> by lazy { ModesUi.assertInNewMode() val dndMode: StateFlow<ZenMode?> = if (ModesUi.isEnabled) zenModeRepository.modes .map { modes -> modes.singleOrNull { it.isManualDnd } } .stateIn(scope = backgroundScope, started = SharingStarted.Eagerly, initialValue = null) .stateIn( scope = backgroundScope, started = SharingStarted.Eagerly, initialValue = null, ) else MutableStateFlow<ZenMode?>(null) get() { ModesUi.assertInNewMode() return field } /** Flow returning the currently active mode(s), if any. */ Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractorTest.kt +3 −1 Original line number Diff line number Diff line Loading @@ -58,7 +58,9 @@ class ModesTileDataInteractorTest : SysuiTestCase() { private val dispatcher = kosmos.testDispatcher private val zenModeRepository = kosmos.fakeZenModeRepository private val underTest = ModesTileDataInteractor(context, kosmos.zenModeInteractor, dispatcher) private val underTest by lazy { ModesTileDataInteractor(context, kosmos.zenModeInteractor, dispatcher) } @Before fun setUp() { Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/emptyshade/ui/viewmodel/EmptyShadeViewModelTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ class EmptyShadeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val activeNotificationListRepository = kosmos.activeNotificationListRepository private val fakeSecureSettingsRepository = kosmos.fakeSecureSettingsRepository private val underTest = kosmos.emptyShadeViewModel private val underTest by lazy { kosmos.emptyShadeViewModel } companion object { @JvmStatic Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/domain/interactor/ZenModeInteractorTest.kt +4 −4 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ class ZenModeInteractorTest : SysuiTestCase() { private val settingsRepository = kosmos.secureSettingsRepository private val deviceProvisioningRepository = kosmos.fakeDeviceProvisioningRepository private val underTest = kosmos.zenModeInteractor private val underTest by lazy { kosmos.zenModeInteractor } @Test fun isZenAvailable_off() = Loading Loading @@ -176,13 +176,13 @@ class ZenModeInteractorTest : SysuiTestCase() { @Test fun shouldAskForZenDuration_changesWithSetting() = kosmos.runTest { val manualDnd = TestModeBuilder().makeManualDnd().setActive(true).build() val manualDnd by collectLastValue(underTest.dndMode) settingsRepository.setInt(ZEN_DURATION, ZEN_DURATION_FOREVER) assertThat(underTest.shouldAskForZenDuration(manualDnd)).isFalse() assertThat(underTest.shouldAskForZenDuration(manualDnd!!)).isFalse() settingsRepository.setInt(ZEN_DURATION, ZEN_DURATION_PROMPT) assertThat(underTest.shouldAskForZenDuration(manualDnd)).isTrue() assertThat(underTest.shouldAskForZenDuration(manualDnd!!)).isTrue() } @Test Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/domain/interactor/ZenModeInteractor.kt +15 −6 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine Loading Loading @@ -123,11 +124,19 @@ constructor( * explicitly wants a shortcut to DND). Please prefer using [modes] or [activeModes] in all * other scenarios. */ val dndMode: StateFlow<ZenMode?> by lazy { ModesUi.assertInNewMode() val dndMode: StateFlow<ZenMode?> = if (ModesUi.isEnabled) zenModeRepository.modes .map { modes -> modes.singleOrNull { it.isManualDnd } } .stateIn(scope = backgroundScope, started = SharingStarted.Eagerly, initialValue = null) .stateIn( scope = backgroundScope, started = SharingStarted.Eagerly, initialValue = null, ) else MutableStateFlow<ZenMode?>(null) get() { ModesUi.assertInNewMode() return field } /** Flow returning the currently active mode(s), if any. */ Loading