Loading packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt +0 −2 Original line number Original line Diff line number Diff line Loading @@ -85,7 +85,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Before Loading Loading @@ -182,7 +181,6 @@ class SceneContainerStartableTest : SysuiTestCase() { kosmos.headsUpNotificationRepository.activeHeadsUpRows.value = kosmos.headsUpNotificationRepository.activeHeadsUpRows.value = buildNotificationRows(isPinned = false) buildNotificationRows(isPinned = false) advanceTimeBy(50L) // account for HeadsUpNotificationInteractor debounce assertThat(isVisible).isFalse() assertThat(isVisible).isFalse() } } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractorTest.kt +0 −59 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFaceAuthRepository import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFaceAuthRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository Loading Loading @@ -279,64 +278,6 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).containsExactly(rows[0]) assertThat(pinnedHeadsUpRows).containsExactly(rows[0]) } } @Test fun isHeadsUpOrAnimatingAway_falseOnStart() = testScope.runTest { val isHeadsUpOrAnimatingAway by collectLastValue(underTest.isHeadsUpOrAnimatingAway) runCurrent() assertThat(isHeadsUpOrAnimatingAway).isFalse() } @Test fun isHeadsUpOrAnimatingAway_hasPinnedRows() = testScope.runTest { val isHeadsUpOrAnimatingAway by collectLastValue(underTest.isHeadsUpOrAnimatingAway) // WHEN a row is pinned headsUpRepository.setNotifications(fakeHeadsUpRowRepository("key 0", isPinned = true)) runCurrent() assertThat(isHeadsUpOrAnimatingAway).isTrue() } @Test fun isHeadsUpOrAnimatingAway_headsUpAnimatingAway() = testScope.runTest { val isHeadsUpOrAnimatingAway by collectLastValue(underTest.isHeadsUpOrAnimatingAway) // WHEN the last row is animating away headsUpRepository.setHeadsUpAnimatingAway(true) runCurrent() assertThat(isHeadsUpOrAnimatingAway).isTrue() } @Test fun isHeadsUpOrAnimatingAway_headsUpAnimatingAwayDebounced() = testScope.runTest { val values by collectValues(underTest.isHeadsUpOrAnimatingAway) // GIVEN a row is pinned headsUpRepository.setNotifications(fakeHeadsUpRowRepository("key 0", isPinned = true)) runCurrent() assertThat(values.size).isEqualTo(2) assertThat(values.first()).isFalse() // initial value assertThat(values.last()).isTrue() // WHEN the last row is removed headsUpRepository.setNotifications(emptyList()) runCurrent() // AND starts to animate away headsUpRepository.setHeadsUpAnimatingAway(true) runCurrent() // THEN isHeadsUpOrAnimatingAway remained true assertThat(values.size).isEqualTo(2) assertThat(values.last()).isTrue() } @Test @Test fun showHeadsUpStatusBar_true() = fun showHeadsUpStatusBar_true() = testScope.runTest { testScope.runTest { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt +1 −16 Original line number Original line Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. * limitations under the License. */ */ @file:OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class) @file:OptIn(ExperimentalCoroutinesApi::class) package com.android.systemui.statusbar.notification.domain.interactor package com.android.systemui.statusbar.notification.domain.interactor Loading @@ -28,15 +28,11 @@ import com.android.systemui.statusbar.notification.shared.HeadsUpRowKey import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor import javax.inject.Inject import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart class HeadsUpNotificationInteractor class HeadsUpNotificationInteractor @Inject @Inject Loading Loading @@ -97,17 +93,6 @@ constructor( animatingAway -> animatingAway -> hasPinnedRows || animatingAway hasPinnedRows || animatingAway } } .debounce { isHeadsUpOrAnimatingAway -> if (isHeadsUpOrAnimatingAway) { 0 } else { // When the last pinned entry is removed from the [HeadsUpRepository], // there might be a delay before the View starts animating. 50L } } .onStart { emit(false) } // emit false, so we don't wait for the initial update .distinctUntilChanged() } } } } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt +0 −2 Original line number Original line Diff line number Diff line Loading @@ -85,7 +85,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Before Loading Loading @@ -182,7 +181,6 @@ class SceneContainerStartableTest : SysuiTestCase() { kosmos.headsUpNotificationRepository.activeHeadsUpRows.value = kosmos.headsUpNotificationRepository.activeHeadsUpRows.value = buildNotificationRows(isPinned = false) buildNotificationRows(isPinned = false) advanceTimeBy(50L) // account for HeadsUpNotificationInteractor debounce assertThat(isVisible).isFalse() assertThat(isVisible).isFalse() } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractorTest.kt +0 −59 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFaceAuthRepository import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFaceAuthRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository Loading Loading @@ -279,64 +278,6 @@ class HeadsUpNotificationInteractorTest : SysuiTestCase() { assertThat(pinnedHeadsUpRows).containsExactly(rows[0]) assertThat(pinnedHeadsUpRows).containsExactly(rows[0]) } } @Test fun isHeadsUpOrAnimatingAway_falseOnStart() = testScope.runTest { val isHeadsUpOrAnimatingAway by collectLastValue(underTest.isHeadsUpOrAnimatingAway) runCurrent() assertThat(isHeadsUpOrAnimatingAway).isFalse() } @Test fun isHeadsUpOrAnimatingAway_hasPinnedRows() = testScope.runTest { val isHeadsUpOrAnimatingAway by collectLastValue(underTest.isHeadsUpOrAnimatingAway) // WHEN a row is pinned headsUpRepository.setNotifications(fakeHeadsUpRowRepository("key 0", isPinned = true)) runCurrent() assertThat(isHeadsUpOrAnimatingAway).isTrue() } @Test fun isHeadsUpOrAnimatingAway_headsUpAnimatingAway() = testScope.runTest { val isHeadsUpOrAnimatingAway by collectLastValue(underTest.isHeadsUpOrAnimatingAway) // WHEN the last row is animating away headsUpRepository.setHeadsUpAnimatingAway(true) runCurrent() assertThat(isHeadsUpOrAnimatingAway).isTrue() } @Test fun isHeadsUpOrAnimatingAway_headsUpAnimatingAwayDebounced() = testScope.runTest { val values by collectValues(underTest.isHeadsUpOrAnimatingAway) // GIVEN a row is pinned headsUpRepository.setNotifications(fakeHeadsUpRowRepository("key 0", isPinned = true)) runCurrent() assertThat(values.size).isEqualTo(2) assertThat(values.first()).isFalse() // initial value assertThat(values.last()).isTrue() // WHEN the last row is removed headsUpRepository.setNotifications(emptyList()) runCurrent() // AND starts to animate away headsUpRepository.setHeadsUpAnimatingAway(true) runCurrent() // THEN isHeadsUpOrAnimatingAway remained true assertThat(values.size).isEqualTo(2) assertThat(values.last()).isTrue() } @Test @Test fun showHeadsUpStatusBar_true() = fun showHeadsUpStatusBar_true() = testScope.runTest { testScope.runTest { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt +1 −16 Original line number Original line Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. * limitations under the License. */ */ @file:OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class) @file:OptIn(ExperimentalCoroutinesApi::class) package com.android.systemui.statusbar.notification.domain.interactor package com.android.systemui.statusbar.notification.domain.interactor Loading @@ -28,15 +28,11 @@ import com.android.systemui.statusbar.notification.shared.HeadsUpRowKey import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor import javax.inject.Inject import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart class HeadsUpNotificationInteractor class HeadsUpNotificationInteractor @Inject @Inject Loading Loading @@ -97,17 +93,6 @@ constructor( animatingAway -> animatingAway -> hasPinnedRows || animatingAway hasPinnedRows || animatingAway } } .debounce { isHeadsUpOrAnimatingAway -> if (isHeadsUpOrAnimatingAway) { 0 } else { // When the last pinned entry is removed from the [HeadsUpRepository], // there might be a delay before the View starts animating. 50L } } .onStart { emit(false) } // emit false, so we don't wait for the initial update .distinctUntilChanged() } } } } Loading