Loading packages/SystemUI/multivalentTests/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogCallbacksInteractorTest.kt +30 −0 Original line number Diff line number Diff line Loading @@ -16,12 +16,16 @@ package com.android.systemui.volume.dialog.domain.interactor import android.media.AudioManager.RINGER_MODE_NORMAL import android.media.AudioManager.RINGER_MODE_SILENT import android.media.AudioManager.RINGER_MODE_VIBRATE import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.plugins.fakeVolumeDialogController import com.android.systemui.testKosmos import com.android.systemui.volume.dialog.domain.model.VolumeDialogEventModel import com.google.common.truth.Truth.assertThat Loading @@ -44,4 +48,30 @@ class VolumeDialogCallbacksInteractorTest : SysuiTestCase() { val event by collectLastValue(underTest.event) assertThat(event).isInstanceOf(VolumeDialogEventModel.SubscribedToEvents::class.java) } @Test fun showSilentHint_setsRingerModeToNormal() = kosmos.runTest { fakeVolumeDialogController.setRingerMode(RINGER_MODE_VIBRATE, false) underTest // It should eagerly collect the values and update the controller fakeVolumeDialogController.onShowSilentHint() fakeVolumeDialogController.getState() assertThat(fakeVolumeDialogController.state.ringerModeInternal) .isEqualTo(RINGER_MODE_NORMAL) } @Test fun showVibrateHint_setsRingerModeToSilent() = kosmos.runTest { fakeVolumeDialogController.setRingerMode(RINGER_MODE_VIBRATE, false) underTest // It should eagerly collect the values and update the controller fakeVolumeDialogController.onShowVibrateHint() fakeVolumeDialogController.getState() assertThat(fakeVolumeDialogController.state.ringerModeInternal) .isEqualTo(RINGER_MODE_SILENT) } } packages/SystemUI/multivalentTests/src/com/android/systemui/volume/dialog/ringer/domain/VolumeDialogRingerInteractorTest.kt +7 −15 Original line number Diff line number Diff line Loading @@ -25,14 +25,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.settingslib.volume.shared.model.RingerMode import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.plugins.fakeVolumeDialogController import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -43,8 +42,7 @@ import org.junit.runner.RunWith @TestableLooper.RunWithLooper class VolumeDialogRingerInteractorTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val controller = kosmos.fakeVolumeDialogController private lateinit var underTest: VolumeDialogRingerInteractor Loading @@ -57,13 +55,11 @@ class VolumeDialogRingerInteractorTest : SysuiTestCase() { @Test fun setRingerMode_normal() = testScope.runTest { runCurrent() kosmos.runTest { val ringerModel by collectLastValue(underTest.ringerModel) underTest.setRingerMode(RingerMode(RINGER_MODE_NORMAL)) controller.getState() runCurrent() assertThat(ringerModel).isNotNull() assertThat(ringerModel?.currentRingerMode).isEqualTo(RingerMode(RINGER_MODE_NORMAL)) Loading @@ -71,13 +67,11 @@ class VolumeDialogRingerInteractorTest : SysuiTestCase() { @Test fun setRingerMode_silent() = testScope.runTest { runCurrent() kosmos.runTest { val ringerModel by collectLastValue(underTest.ringerModel) underTest.setRingerMode(RingerMode(RINGER_MODE_SILENT)) controller.getState() runCurrent() assertThat(ringerModel).isNotNull() assertThat(ringerModel?.currentRingerMode).isEqualTo(RingerMode(RINGER_MODE_SILENT)) Loading @@ -85,13 +79,11 @@ class VolumeDialogRingerInteractorTest : SysuiTestCase() { @Test fun setRingerMode_vibrate() = testScope.runTest { runCurrent() kosmos.runTest { val ringerModel by collectLastValue(underTest.ringerModel) underTest.setRingerMode(RingerMode(RINGER_MODE_VIBRATE)) controller.getState() runCurrent() assertThat(ringerModel).isNotNull() assertThat(ringerModel?.currentRingerMode).isEqualTo(RingerMode(RINGER_MODE_VIBRATE)) Loading packages/SystemUI/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogCallbacksInteractor.kt +24 −20 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.systemui.volume.dialog.domain.interactor import android.annotation.SuppressLint import android.media.AudioManager.RINGER_MODE_NORMAL import android.media.AudioManager.RINGER_MODE_SILENT import android.os.Handler import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.plugins.VolumeDialogController Loading Loading @@ -60,10 +62,10 @@ constructor( awaitClose { volumeDialogController.removeCallback(producer) } } .buffer(capacity = BUFFER_CAPACITY, onBufferOverflow = BufferOverflow.DROP_OLDEST) .shareIn(replay = 0, scope = coroutineScope, started = SharingStarted.WhileSubscribed()) .shareIn(replay = 0, scope = coroutineScope, started = SharingStarted.Eagerly) .onStart { emit(VolumeDialogEventModel.SubscribedToEvents) } private class VolumeDialogEventModelProducer( private inner class VolumeDialogEventModelProducer( private val scope: ProducerScope<VolumeDialogEventModel> ) : VolumeDialogController.Callbacks { override fun onShowRequested(reason: Int, keyguardLocked: Boolean, lockTaskModeState: Int) { Loading Loading @@ -93,14 +95,6 @@ constructor( // Configuration change is never emitted by the VolumeDialogControllerImpl now. override fun onConfigurationChanged() = Unit override fun onShowVibrateHint() { scope.trySend(VolumeDialogEventModel.ShowVibrateHint) } override fun onShowSilentHint() { scope.trySend(VolumeDialogEventModel.ShowSilentHint) } override fun onScreenOff() { scope.trySend(VolumeDialogEventModel.ScreenOff) } Loading @@ -113,16 +107,6 @@ constructor( scope.trySend(VolumeDialogEventModel.AccessibilityModeChanged(showA11yStream == true)) } // Captions button is remove from the Volume Dialog override fun onCaptionComponentStateChanged( isComponentEnabled: Boolean, fromTooltip: Boolean, ) = Unit // Captions button is remove from the Volume Dialog override fun onCaptionEnabledStateChanged(isEnabled: Boolean, checkBeforeSwitch: Boolean) = Unit override fun onShowCsdWarning(csdWarning: Int, durationMs: Int) { scope.trySend( VolumeDialogEventModel.ShowCsdWarning( Loading @@ -135,5 +119,25 @@ constructor( override fun onVolumeChangedFromKey() { scope.trySend(VolumeDialogEventModel.VolumeChangedFromKey) } // This should've been handled in side the controller itself. override fun onShowVibrateHint() { volumeDialogController.setRingerMode(RINGER_MODE_SILENT, false) } // This should've been handled in side the controller itself. override fun onShowSilentHint() { volumeDialogController.setRingerMode(RINGER_MODE_NORMAL, false) } // Captions button is remove from the Volume Dialog override fun onCaptionComponentStateChanged( isComponentEnabled: Boolean, fromTooltip: Boolean, ) = Unit // Captions button is remove from the Volume Dialog override fun onCaptionEnabledStateChanged(isEnabled: Boolean, checkBeforeSwitch: Boolean) = Unit } } packages/SystemUI/src/com/android/systemui/volume/dialog/domain/model/VolumeDialogEventModel.kt +0 −4 Original line number Diff line number Diff line Loading @@ -38,10 +38,6 @@ sealed interface VolumeDialogEventModel { data class LayoutDirectionChanged(val layoutDirection: Int) : VolumeDialogEventModel data object ShowVibrateHint : VolumeDialogEventModel data object ShowSilentHint : VolumeDialogEventModel data object ScreenOff : VolumeDialogEventModel data class ShowSafetyWarning(val flags: Int) : VolumeDialogEventModel Loading packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/domain/VolumeDialogRingerInteractor.kt +0 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,6 @@ constructor( private val audioSystemRepository: AudioSystemRepository, private val ringerFeedbackRepository: VolumeDialogRingerFeedbackRepository, ) { val ringerModel: Flow<VolumeDialogRingerModel> = volumeDialogStateInteractor.volumeDialogState .mapNotNull { toRingerModel(it) } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogCallbacksInteractorTest.kt +30 −0 Original line number Diff line number Diff line Loading @@ -16,12 +16,16 @@ package com.android.systemui.volume.dialog.domain.interactor import android.media.AudioManager.RINGER_MODE_NORMAL import android.media.AudioManager.RINGER_MODE_SILENT import android.media.AudioManager.RINGER_MODE_VIBRATE import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.plugins.fakeVolumeDialogController import com.android.systemui.testKosmos import com.android.systemui.volume.dialog.domain.model.VolumeDialogEventModel import com.google.common.truth.Truth.assertThat Loading @@ -44,4 +48,30 @@ class VolumeDialogCallbacksInteractorTest : SysuiTestCase() { val event by collectLastValue(underTest.event) assertThat(event).isInstanceOf(VolumeDialogEventModel.SubscribedToEvents::class.java) } @Test fun showSilentHint_setsRingerModeToNormal() = kosmos.runTest { fakeVolumeDialogController.setRingerMode(RINGER_MODE_VIBRATE, false) underTest // It should eagerly collect the values and update the controller fakeVolumeDialogController.onShowSilentHint() fakeVolumeDialogController.getState() assertThat(fakeVolumeDialogController.state.ringerModeInternal) .isEqualTo(RINGER_MODE_NORMAL) } @Test fun showVibrateHint_setsRingerModeToSilent() = kosmos.runTest { fakeVolumeDialogController.setRingerMode(RINGER_MODE_VIBRATE, false) underTest // It should eagerly collect the values and update the controller fakeVolumeDialogController.onShowVibrateHint() fakeVolumeDialogController.getState() assertThat(fakeVolumeDialogController.state.ringerModeInternal) .isEqualTo(RINGER_MODE_SILENT) } }
packages/SystemUI/multivalentTests/src/com/android/systemui/volume/dialog/ringer/domain/VolumeDialogRingerInteractorTest.kt +7 −15 Original line number Diff line number Diff line Loading @@ -25,14 +25,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.settingslib.volume.shared.model.RingerMode import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.plugins.fakeVolumeDialogController import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading @@ -43,8 +42,7 @@ import org.junit.runner.RunWith @TestableLooper.RunWithLooper class VolumeDialogRingerInteractorTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val kosmos = testKosmos().useUnconfinedTestDispatcher() private val controller = kosmos.fakeVolumeDialogController private lateinit var underTest: VolumeDialogRingerInteractor Loading @@ -57,13 +55,11 @@ class VolumeDialogRingerInteractorTest : SysuiTestCase() { @Test fun setRingerMode_normal() = testScope.runTest { runCurrent() kosmos.runTest { val ringerModel by collectLastValue(underTest.ringerModel) underTest.setRingerMode(RingerMode(RINGER_MODE_NORMAL)) controller.getState() runCurrent() assertThat(ringerModel).isNotNull() assertThat(ringerModel?.currentRingerMode).isEqualTo(RingerMode(RINGER_MODE_NORMAL)) Loading @@ -71,13 +67,11 @@ class VolumeDialogRingerInteractorTest : SysuiTestCase() { @Test fun setRingerMode_silent() = testScope.runTest { runCurrent() kosmos.runTest { val ringerModel by collectLastValue(underTest.ringerModel) underTest.setRingerMode(RingerMode(RINGER_MODE_SILENT)) controller.getState() runCurrent() assertThat(ringerModel).isNotNull() assertThat(ringerModel?.currentRingerMode).isEqualTo(RingerMode(RINGER_MODE_SILENT)) Loading @@ -85,13 +79,11 @@ class VolumeDialogRingerInteractorTest : SysuiTestCase() { @Test fun setRingerMode_vibrate() = testScope.runTest { runCurrent() kosmos.runTest { val ringerModel by collectLastValue(underTest.ringerModel) underTest.setRingerMode(RingerMode(RINGER_MODE_VIBRATE)) controller.getState() runCurrent() assertThat(ringerModel).isNotNull() assertThat(ringerModel?.currentRingerMode).isEqualTo(RingerMode(RINGER_MODE_VIBRATE)) Loading
packages/SystemUI/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogCallbacksInteractor.kt +24 −20 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.systemui.volume.dialog.domain.interactor import android.annotation.SuppressLint import android.media.AudioManager.RINGER_MODE_NORMAL import android.media.AudioManager.RINGER_MODE_SILENT import android.os.Handler import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.plugins.VolumeDialogController Loading Loading @@ -60,10 +62,10 @@ constructor( awaitClose { volumeDialogController.removeCallback(producer) } } .buffer(capacity = BUFFER_CAPACITY, onBufferOverflow = BufferOverflow.DROP_OLDEST) .shareIn(replay = 0, scope = coroutineScope, started = SharingStarted.WhileSubscribed()) .shareIn(replay = 0, scope = coroutineScope, started = SharingStarted.Eagerly) .onStart { emit(VolumeDialogEventModel.SubscribedToEvents) } private class VolumeDialogEventModelProducer( private inner class VolumeDialogEventModelProducer( private val scope: ProducerScope<VolumeDialogEventModel> ) : VolumeDialogController.Callbacks { override fun onShowRequested(reason: Int, keyguardLocked: Boolean, lockTaskModeState: Int) { Loading Loading @@ -93,14 +95,6 @@ constructor( // Configuration change is never emitted by the VolumeDialogControllerImpl now. override fun onConfigurationChanged() = Unit override fun onShowVibrateHint() { scope.trySend(VolumeDialogEventModel.ShowVibrateHint) } override fun onShowSilentHint() { scope.trySend(VolumeDialogEventModel.ShowSilentHint) } override fun onScreenOff() { scope.trySend(VolumeDialogEventModel.ScreenOff) } Loading @@ -113,16 +107,6 @@ constructor( scope.trySend(VolumeDialogEventModel.AccessibilityModeChanged(showA11yStream == true)) } // Captions button is remove from the Volume Dialog override fun onCaptionComponentStateChanged( isComponentEnabled: Boolean, fromTooltip: Boolean, ) = Unit // Captions button is remove from the Volume Dialog override fun onCaptionEnabledStateChanged(isEnabled: Boolean, checkBeforeSwitch: Boolean) = Unit override fun onShowCsdWarning(csdWarning: Int, durationMs: Int) { scope.trySend( VolumeDialogEventModel.ShowCsdWarning( Loading @@ -135,5 +119,25 @@ constructor( override fun onVolumeChangedFromKey() { scope.trySend(VolumeDialogEventModel.VolumeChangedFromKey) } // This should've been handled in side the controller itself. override fun onShowVibrateHint() { volumeDialogController.setRingerMode(RINGER_MODE_SILENT, false) } // This should've been handled in side the controller itself. override fun onShowSilentHint() { volumeDialogController.setRingerMode(RINGER_MODE_NORMAL, false) } // Captions button is remove from the Volume Dialog override fun onCaptionComponentStateChanged( isComponentEnabled: Boolean, fromTooltip: Boolean, ) = Unit // Captions button is remove from the Volume Dialog override fun onCaptionEnabledStateChanged(isEnabled: Boolean, checkBeforeSwitch: Boolean) = Unit } }
packages/SystemUI/src/com/android/systemui/volume/dialog/domain/model/VolumeDialogEventModel.kt +0 −4 Original line number Diff line number Diff line Loading @@ -38,10 +38,6 @@ sealed interface VolumeDialogEventModel { data class LayoutDirectionChanged(val layoutDirection: Int) : VolumeDialogEventModel data object ShowVibrateHint : VolumeDialogEventModel data object ShowSilentHint : VolumeDialogEventModel data object ScreenOff : VolumeDialogEventModel data class ShowSafetyWarning(val flags: Int) : VolumeDialogEventModel Loading
packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/domain/VolumeDialogRingerInteractor.kt +0 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,6 @@ constructor( private val audioSystemRepository: AudioSystemRepository, private val ringerFeedbackRepository: VolumeDialogRingerFeedbackRepository, ) { val ringerModel: Flow<VolumeDialogRingerModel> = volumeDialogStateInteractor.volumeDialogState .mapNotNull { toRingerModel(it) } Loading