Loading packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/data/repository/AmbientCueRepositoryTest.kt +6 −6 Original line number Diff line number Diff line Loading @@ -78,29 +78,29 @@ class AmbientCueRepositoryTest : SysuiTestCase() { ) @Test fun isVisible_whenHasActions_true() = fun isRootViewAttached_whenHasActions_true() = kosmos.runTest { val actions by collectLastValue(underTest.actions) val isVisible by collectLastValue(underTest.isVisible) val isRootViewAttached by collectLastValue(underTest.isRootViewAttached) runCurrent() verify(smartSpaceSession) .addOnTargetsAvailableListener(any(), onTargetsAvailableListenerCaptor.capture()) onTargetsAvailableListenerCaptor.firstValue.onTargetsAvailable(allTargets) advanceUntilIdle() assertThat(isVisible).isTrue() assertThat(isRootViewAttached).isTrue() } @Test fun isVisible_whenNoActions_false() = fun isRootViewAttached_whenNoActions_false() = kosmos.runTest { val actions by collectLastValue(underTest.actions) val isVisible by collectLastValue(underTest.isVisible) val isRootViewAttached by collectLastValue(underTest.isRootViewAttached) runCurrent() verify(smartSpaceSession) .addOnTargetsAvailableListener(any(), onTargetsAvailableListenerCaptor.capture()) onTargetsAvailableListenerCaptor.firstValue.onTargetsAvailable(listOf(invalidTarget1)) advanceUntilIdle() assertThat(isVisible).isFalse() assertThat(isRootViewAttached).isFalse() } @Test Loading packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/domain/interactor/AmbientCueInteractorTest.kt +10 −10 Original line number Diff line number Diff line Loading @@ -37,19 +37,19 @@ class AmbientCueInteractorTest : SysuiTestCase() { private val kosmos = testKosmos() @Test fun isVisible_setTrue_true() = fun isRootViewAttached_setTrue_true() = kosmos.runTest { val isVisible by collectLastValue(ambientCueInteractor.isVisible) ambientCueInteractor.setIsVisible(true) assertThat(isVisible).isTrue() val isRootViewAttached by collectLastValue(ambientCueInteractor.isRootViewAttached) ambientCueInteractor.setRootViewAttached(true) assertThat(isRootViewAttached).isTrue() } @Test fun isVisible_setFalse_False() = fun isRootViewAttached_setFalse_False() = kosmos.runTest { val isVisible by collectLastValue(ambientCueInteractor.isVisible) ambientCueInteractor.setIsVisible(false) assertThat(isVisible).isFalse() val isRootViewAttached by collectLastValue(ambientCueInteractor.isRootViewAttached) ambientCueInteractor.setRootViewAttached(false) assertThat(isRootViewAttached).isFalse() } @Test Loading Loading @@ -77,7 +77,7 @@ class AmbientCueInteractorTest : SysuiTestCase() { fun isImeVisible_setTrue_true() = kosmos.runTest { val isImeVisible by collectLastValue(ambientCueInteractor.isImeVisible) ambientCueInteractor.setIsImeVisible(true) ambientCueInteractor.setImeVisible(true) assertThat(isImeVisible).isTrue() } Loading @@ -85,7 +85,7 @@ class AmbientCueInteractorTest : SysuiTestCase() { fun isImeVisible_setFalse_false() = kosmos.runTest { val isImeVisible by collectLastValue(ambientCueInteractor.isImeVisible) ambientCueInteractor.setIsImeVisible(false) ambientCueInteractor.setImeVisible(false) assertThat(isImeVisible).isFalse() } } packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/ui/viewmodel/AmbientCueViewModelTest.kt +29 −3 Original line number Diff line number Diff line Loading @@ -50,7 +50,8 @@ class AmbientCueViewModelTest : SysuiTestCase() { @Test fun isVisible_timesOut() = kosmos.runTest { ambientCueInteractor.setIsVisible(true) ambientCueInteractor.setRootViewAttached(true) ambientCueInteractor.setImeVisible(false) runCurrent() assertThat(viewModel.isVisible).isTrue() Loading @@ -63,7 +64,8 @@ class AmbientCueViewModelTest : SysuiTestCase() { @Test fun isVisible_whenExpanded_doesntTimeOut() = kosmos.runTest { ambientCueInteractor.setIsVisible(true) ambientCueInteractor.setRootViewAttached(true) ambientCueInteractor.setImeVisible(false) runCurrent() assertThat(viewModel.isVisible).isTrue() Loading @@ -74,6 +76,30 @@ class AmbientCueViewModelTest : SysuiTestCase() { assertThat(viewModel.isVisible).isTrue() } @Test fun isVisible_imeNotVisible_true() = kosmos.runTest { ambientCueInteractor.setRootViewAttached(true) ambientCueInteractor.setImeVisible(false) runCurrent() assertThat(viewModel.isVisible).isTrue() } @Test fun isVisible_imeVisible_false() = kosmos.runTest { ambientCueInteractor.setRootViewAttached(true) ambientCueInteractor.setImeVisible(false) runCurrent() assertThat(viewModel.isVisible).isTrue() ambientCueInteractor.setImeVisible(true) runCurrent() assertThat(viewModel.isVisible).isFalse() } @Test fun onClick_collapses() = kosmos.runTest { Loading @@ -91,7 +117,7 @@ class AmbientCueViewModelTest : SysuiTestCase() { ) ) ambientCueRepository.fake.setActions(testActions) ambientCueInteractor.setIsVisible(true) ambientCueInteractor.setRootViewAttached(true) viewModel.expand() runCurrent() Loading packages/SystemUI/src/com/android/systemui/ambientcue/data/repository/AmbientCueRepository.kt +4 −4 Original line number Diff line number Diff line Loading @@ -51,8 +51,8 @@ interface AmbientCueRepository { /** Chips that should be visible on the UI. */ val actions: StateFlow<List<ActionModel>> /** If hint (or chips list) should be visible. */ val isVisible: MutableStateFlow<Boolean> /** If the root view is attached to the WindowManager. */ val isRootViewAttached: MutableStateFlow<Boolean> /** If IME is visible or not. */ val isImeVisible: MutableStateFlow<Boolean> Loading Loading @@ -145,14 +145,14 @@ constructor( Log.i(TAG, "SmartSpace session closed") } } .onEach { actions -> isVisible.update { actions.isNotEmpty() } } .onEach { actions -> isRootViewAttached.update { actions.isNotEmpty() } } .stateIn( scope = backgroundScope, started = SharingStarted.WhileSubscribed(), initialValue = emptyList(), ) override val isVisible: MutableStateFlow<Boolean> = MutableStateFlow(false) override val isRootViewAttached: MutableStateFlow<Boolean> = MutableStateFlow(false) override val isImeVisible: MutableStateFlow<Boolean> = MutableStateFlow(false) Loading packages/SystemUI/src/com/android/systemui/ambientcue/domain/interactor/AmbientCueInteractor.kt +5 −5 Original line number Diff line number Diff line Loading @@ -23,15 +23,15 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.update class AmbientCueInteractor @Inject constructor(private val repository: AmbientCueRepository) { val isVisible: StateFlow<Boolean> = repository.isVisible val isRootViewAttached: StateFlow<Boolean> = repository.isRootViewAttached val actions: StateFlow<List<ActionModel>> = repository.actions val isImeVisible: StateFlow<Boolean> = repository.isImeVisible fun setIsVisible(visible: Boolean) { repository.isVisible.update { visible } fun setRootViewAttached(isAttached: Boolean) { repository.isRootViewAttached.update { isAttached } } fun setIsImeVisible(visible: Boolean) { repository.isImeVisible.update { visible } fun setImeVisible(isVisible: Boolean) { repository.isImeVisible.update { isVisible } } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/data/repository/AmbientCueRepositoryTest.kt +6 −6 Original line number Diff line number Diff line Loading @@ -78,29 +78,29 @@ class AmbientCueRepositoryTest : SysuiTestCase() { ) @Test fun isVisible_whenHasActions_true() = fun isRootViewAttached_whenHasActions_true() = kosmos.runTest { val actions by collectLastValue(underTest.actions) val isVisible by collectLastValue(underTest.isVisible) val isRootViewAttached by collectLastValue(underTest.isRootViewAttached) runCurrent() verify(smartSpaceSession) .addOnTargetsAvailableListener(any(), onTargetsAvailableListenerCaptor.capture()) onTargetsAvailableListenerCaptor.firstValue.onTargetsAvailable(allTargets) advanceUntilIdle() assertThat(isVisible).isTrue() assertThat(isRootViewAttached).isTrue() } @Test fun isVisible_whenNoActions_false() = fun isRootViewAttached_whenNoActions_false() = kosmos.runTest { val actions by collectLastValue(underTest.actions) val isVisible by collectLastValue(underTest.isVisible) val isRootViewAttached by collectLastValue(underTest.isRootViewAttached) runCurrent() verify(smartSpaceSession) .addOnTargetsAvailableListener(any(), onTargetsAvailableListenerCaptor.capture()) onTargetsAvailableListenerCaptor.firstValue.onTargetsAvailable(listOf(invalidTarget1)) advanceUntilIdle() assertThat(isVisible).isFalse() assertThat(isRootViewAttached).isFalse() } @Test Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/domain/interactor/AmbientCueInteractorTest.kt +10 −10 Original line number Diff line number Diff line Loading @@ -37,19 +37,19 @@ class AmbientCueInteractorTest : SysuiTestCase() { private val kosmos = testKosmos() @Test fun isVisible_setTrue_true() = fun isRootViewAttached_setTrue_true() = kosmos.runTest { val isVisible by collectLastValue(ambientCueInteractor.isVisible) ambientCueInteractor.setIsVisible(true) assertThat(isVisible).isTrue() val isRootViewAttached by collectLastValue(ambientCueInteractor.isRootViewAttached) ambientCueInteractor.setRootViewAttached(true) assertThat(isRootViewAttached).isTrue() } @Test fun isVisible_setFalse_False() = fun isRootViewAttached_setFalse_False() = kosmos.runTest { val isVisible by collectLastValue(ambientCueInteractor.isVisible) ambientCueInteractor.setIsVisible(false) assertThat(isVisible).isFalse() val isRootViewAttached by collectLastValue(ambientCueInteractor.isRootViewAttached) ambientCueInteractor.setRootViewAttached(false) assertThat(isRootViewAttached).isFalse() } @Test Loading Loading @@ -77,7 +77,7 @@ class AmbientCueInteractorTest : SysuiTestCase() { fun isImeVisible_setTrue_true() = kosmos.runTest { val isImeVisible by collectLastValue(ambientCueInteractor.isImeVisible) ambientCueInteractor.setIsImeVisible(true) ambientCueInteractor.setImeVisible(true) assertThat(isImeVisible).isTrue() } Loading @@ -85,7 +85,7 @@ class AmbientCueInteractorTest : SysuiTestCase() { fun isImeVisible_setFalse_false() = kosmos.runTest { val isImeVisible by collectLastValue(ambientCueInteractor.isImeVisible) ambientCueInteractor.setIsImeVisible(false) ambientCueInteractor.setImeVisible(false) assertThat(isImeVisible).isFalse() } }
packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/ui/viewmodel/AmbientCueViewModelTest.kt +29 −3 Original line number Diff line number Diff line Loading @@ -50,7 +50,8 @@ class AmbientCueViewModelTest : SysuiTestCase() { @Test fun isVisible_timesOut() = kosmos.runTest { ambientCueInteractor.setIsVisible(true) ambientCueInteractor.setRootViewAttached(true) ambientCueInteractor.setImeVisible(false) runCurrent() assertThat(viewModel.isVisible).isTrue() Loading @@ -63,7 +64,8 @@ class AmbientCueViewModelTest : SysuiTestCase() { @Test fun isVisible_whenExpanded_doesntTimeOut() = kosmos.runTest { ambientCueInteractor.setIsVisible(true) ambientCueInteractor.setRootViewAttached(true) ambientCueInteractor.setImeVisible(false) runCurrent() assertThat(viewModel.isVisible).isTrue() Loading @@ -74,6 +76,30 @@ class AmbientCueViewModelTest : SysuiTestCase() { assertThat(viewModel.isVisible).isTrue() } @Test fun isVisible_imeNotVisible_true() = kosmos.runTest { ambientCueInteractor.setRootViewAttached(true) ambientCueInteractor.setImeVisible(false) runCurrent() assertThat(viewModel.isVisible).isTrue() } @Test fun isVisible_imeVisible_false() = kosmos.runTest { ambientCueInteractor.setRootViewAttached(true) ambientCueInteractor.setImeVisible(false) runCurrent() assertThat(viewModel.isVisible).isTrue() ambientCueInteractor.setImeVisible(true) runCurrent() assertThat(viewModel.isVisible).isFalse() } @Test fun onClick_collapses() = kosmos.runTest { Loading @@ -91,7 +117,7 @@ class AmbientCueViewModelTest : SysuiTestCase() { ) ) ambientCueRepository.fake.setActions(testActions) ambientCueInteractor.setIsVisible(true) ambientCueInteractor.setRootViewAttached(true) viewModel.expand() runCurrent() Loading
packages/SystemUI/src/com/android/systemui/ambientcue/data/repository/AmbientCueRepository.kt +4 −4 Original line number Diff line number Diff line Loading @@ -51,8 +51,8 @@ interface AmbientCueRepository { /** Chips that should be visible on the UI. */ val actions: StateFlow<List<ActionModel>> /** If hint (or chips list) should be visible. */ val isVisible: MutableStateFlow<Boolean> /** If the root view is attached to the WindowManager. */ val isRootViewAttached: MutableStateFlow<Boolean> /** If IME is visible or not. */ val isImeVisible: MutableStateFlow<Boolean> Loading Loading @@ -145,14 +145,14 @@ constructor( Log.i(TAG, "SmartSpace session closed") } } .onEach { actions -> isVisible.update { actions.isNotEmpty() } } .onEach { actions -> isRootViewAttached.update { actions.isNotEmpty() } } .stateIn( scope = backgroundScope, started = SharingStarted.WhileSubscribed(), initialValue = emptyList(), ) override val isVisible: MutableStateFlow<Boolean> = MutableStateFlow(false) override val isRootViewAttached: MutableStateFlow<Boolean> = MutableStateFlow(false) override val isImeVisible: MutableStateFlow<Boolean> = MutableStateFlow(false) Loading
packages/SystemUI/src/com/android/systemui/ambientcue/domain/interactor/AmbientCueInteractor.kt +5 −5 Original line number Diff line number Diff line Loading @@ -23,15 +23,15 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.update class AmbientCueInteractor @Inject constructor(private val repository: AmbientCueRepository) { val isVisible: StateFlow<Boolean> = repository.isVisible val isRootViewAttached: StateFlow<Boolean> = repository.isRootViewAttached val actions: StateFlow<List<ActionModel>> = repository.actions val isImeVisible: StateFlow<Boolean> = repository.isImeVisible fun setIsVisible(visible: Boolean) { repository.isVisible.update { visible } fun setRootViewAttached(isAttached: Boolean) { repository.isRootViewAttached.update { isAttached } } fun setIsImeVisible(visible: Boolean) { repository.isImeVisible.update { visible } fun setImeVisible(isVisible: Boolean) { repository.isImeVisible.update { isVisible } } }