Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationStackAppearanceIntegrationTest.kt +40 −49 Original line number Diff line number Diff line Loading @@ -21,13 +21,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource Loading @@ -43,8 +43,6 @@ import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith Loading @@ -61,24 +59,20 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { set(Flags.NSSL_DEBUG_LINES, false) } } private val testScope = kosmos.testScope private val placeholderViewModel by lazy { kosmos.notificationsPlaceholderViewModel } private val scrollViewModel by lazy { kosmos.notificationScrollViewModel } private val sceneInteractor by lazy { kosmos.sceneInteractor } private val fakeKeyguardRepository by lazy { kosmos.fakeKeyguardRepository } private val fakeSceneDataSource by lazy { kosmos.fakeSceneDataSource } @Test fun updateBounds() = testScope.runTest { kosmos.enableSingleShade() kosmos.runTest { enableSingleShade() val radius = MutableStateFlow(32) val leftOffset = MutableStateFlow(0) val shape by collectLastValue(scrollViewModel.notificationScrimShape(radius, leftOffset)) collectLastValue( notificationScrollViewModel.notificationScrimShape(radius, leftOffset) ) // When: receive scrim bounds placeholderViewModel.onScrimBoundsChanged( notificationsPlaceholderViewModel.onScrimBoundsChanged( ShadeScrimBounds(left = 0f, top = 200f, right = 100f, bottom = 550f) ) // Then: shape is updated Loading @@ -95,7 +89,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { // When: receive new scrim bounds leftOffset.value = 200 radius.value = 24 placeholderViewModel.onScrimBoundsChanged( notificationsPlaceholderViewModel.onScrimBoundsChanged( ShadeScrimBounds(left = 210f, top = 200f, right = 300f, bottom = 550f) ) // Then: shape is updated Loading @@ -120,36 +114,37 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { assertThat(shape).isNull() // Same scenario on Dual Shade, shape should have clipping bounds kosmos.enableDualShade() enableDualShade() assertThat(shape).isNull() } @Test fun brightnessMirrorAlpha_updatesViewModel() = testScope.runTest { val maxAlpha by collectLastValue(scrollViewModel.maxAlpha) kosmos.runTest { val maxAlpha by collectLastValue(notificationScrollViewModel.maxAlpha) assertThat(maxAlpha).isEqualTo(1f) placeholderViewModel.setAlphaForBrightnessMirror(0.33f) notificationsPlaceholderViewModel.setAlphaForBrightnessMirror(0.33f) assertThat(maxAlpha).isEqualTo(0.33f) placeholderViewModel.setAlphaForBrightnessMirror(0f) notificationsPlaceholderViewModel.setAlphaForBrightnessMirror(0f) assertThat(maxAlpha).isEqualTo(0f) placeholderViewModel.setAlphaForBrightnessMirror(1f) notificationsPlaceholderViewModel.setAlphaForBrightnessMirror(1f) assertThat(maxAlpha).isEqualTo(1f) } @Test fun shadeExpansion_goneToShade() = testScope.runTest { kosmos.runTest { enableSingleShade() val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(currentScene = Scenes.Gone) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(scrollViewModel.expandFraction) val expandFraction by collectLastValue(notificationScrollViewModel.expandFraction) assertThat(expandFraction).isEqualTo(0f) fakeSceneDataSource.changeScene(toScene = Scenes.Gone) val isScrollable by collectLastValue(scrollViewModel.isScrollable) val isScrollable by collectLastValue(notificationScrollViewModel.isScrollable) assertThat(isScrollable).isFalse() fakeSceneDataSource.pause() Loading @@ -169,7 +164,6 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { repeat(steps) { repetition -> val progress = (1f / steps) * (repetition + 1) transitionProgress.value = progress runCurrent() assertThat(expandFraction).isWithin(0.01f).of(progress) } Loading @@ -180,49 +174,47 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { @Test fun shadeExpansion_idleOnLockscreen() = testScope.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(currentScene = Scenes.Lockscreen) kosmos.runTest { sceneInteractor.setTransitionState( flowOf(ObservableTransitionState.Idle(currentScene = Scenes.Lockscreen)) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(scrollViewModel.expandFraction) val expandFraction by collectLastValue(notificationScrollViewModel.expandFraction) assertThat(expandFraction).isEqualTo(1f) fakeSceneDataSource.changeScene(toScene = Scenes.Lockscreen) val isScrollable by collectLastValue(scrollViewModel.isScrollable) val isScrollable by collectLastValue(notificationScrollViewModel.isScrollable) assertThat(isScrollable).isFalse() } @Test fun shadeExpansion_idleOnQs() = testScope.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(currentScene = Scenes.QuickSettings) kosmos.runTest { enableSingleShade() sceneInteractor.setTransitionState( flowOf(ObservableTransitionState.Idle(currentScene = Scenes.QuickSettings)) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(scrollViewModel.expandFraction) val expandFraction by collectLastValue(notificationScrollViewModel.expandFraction) assertThat(expandFraction).isEqualTo(1f) fakeSceneDataSource.changeScene(toScene = Scenes.QuickSettings) val isScrollable by collectLastValue(scrollViewModel.isScrollable) val isScrollable by collectLastValue(notificationScrollViewModel.isScrollable) assertThat(isScrollable).isFalse() } @Test fun shadeExpansion_shadeToQs() = testScope.runTest { kosmos.runTest { enableSingleShade() val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(currentScene = Scenes.Shade) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(scrollViewModel.expandFraction) val expandFraction by collectLastValue(notificationScrollViewModel.expandFraction) assertThat(expandFraction).isEqualTo(1f) fakeSceneDataSource.changeScene(toScene = Scenes.Shade) val isScrollable by collectLastValue(scrollViewModel.isScrollable) val isScrollable by collectLastValue(notificationScrollViewModel.isScrollable) assertThat(isScrollable).isTrue() fakeSceneDataSource.pause() Loading @@ -242,7 +234,6 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { repeat(steps) { repetition -> val progress = (1f / steps) * (repetition + 1) transitionProgress.value = progress runCurrent() assertThat(expandFraction).isEqualTo(1f) } Loading @@ -253,17 +244,18 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { @Test fun shadeExpansion_goneToQs() = testScope.runTest { kosmos.runTest { enableSingleShade() val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(currentScene = Scenes.Gone) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(scrollViewModel.expandFraction) val expandFraction by collectLastValue(notificationScrollViewModel.expandFraction) assertThat(expandFraction).isEqualTo(0f) fakeSceneDataSource.changeScene(toScene = Scenes.Gone) val isScrollable by collectLastValue(scrollViewModel.isScrollable) val isScrollable by collectLastValue(notificationScrollViewModel.isScrollable) assertThat(isScrollable).isFalse() fakeSceneDataSource.pause() Loading @@ -283,7 +275,6 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { repeat(steps) { repetition -> val progress = (1f / steps) * (repetition + 1) transitionProgress.value = progress runCurrent() assertThat(expandFraction) .isEqualTo( (progress / EXPANSION_FOR_MAX_SCRIM_ALPHA - Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationStackAppearanceIntegrationTest.kt +40 −49 Original line number Diff line number Diff line Loading @@ -21,13 +21,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource Loading @@ -43,8 +43,6 @@ import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith Loading @@ -61,24 +59,20 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { set(Flags.NSSL_DEBUG_LINES, false) } } private val testScope = kosmos.testScope private val placeholderViewModel by lazy { kosmos.notificationsPlaceholderViewModel } private val scrollViewModel by lazy { kosmos.notificationScrollViewModel } private val sceneInteractor by lazy { kosmos.sceneInteractor } private val fakeKeyguardRepository by lazy { kosmos.fakeKeyguardRepository } private val fakeSceneDataSource by lazy { kosmos.fakeSceneDataSource } @Test fun updateBounds() = testScope.runTest { kosmos.enableSingleShade() kosmos.runTest { enableSingleShade() val radius = MutableStateFlow(32) val leftOffset = MutableStateFlow(0) val shape by collectLastValue(scrollViewModel.notificationScrimShape(radius, leftOffset)) collectLastValue( notificationScrollViewModel.notificationScrimShape(radius, leftOffset) ) // When: receive scrim bounds placeholderViewModel.onScrimBoundsChanged( notificationsPlaceholderViewModel.onScrimBoundsChanged( ShadeScrimBounds(left = 0f, top = 200f, right = 100f, bottom = 550f) ) // Then: shape is updated Loading @@ -95,7 +89,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { // When: receive new scrim bounds leftOffset.value = 200 radius.value = 24 placeholderViewModel.onScrimBoundsChanged( notificationsPlaceholderViewModel.onScrimBoundsChanged( ShadeScrimBounds(left = 210f, top = 200f, right = 300f, bottom = 550f) ) // Then: shape is updated Loading @@ -120,36 +114,37 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { assertThat(shape).isNull() // Same scenario on Dual Shade, shape should have clipping bounds kosmos.enableDualShade() enableDualShade() assertThat(shape).isNull() } @Test fun brightnessMirrorAlpha_updatesViewModel() = testScope.runTest { val maxAlpha by collectLastValue(scrollViewModel.maxAlpha) kosmos.runTest { val maxAlpha by collectLastValue(notificationScrollViewModel.maxAlpha) assertThat(maxAlpha).isEqualTo(1f) placeholderViewModel.setAlphaForBrightnessMirror(0.33f) notificationsPlaceholderViewModel.setAlphaForBrightnessMirror(0.33f) assertThat(maxAlpha).isEqualTo(0.33f) placeholderViewModel.setAlphaForBrightnessMirror(0f) notificationsPlaceholderViewModel.setAlphaForBrightnessMirror(0f) assertThat(maxAlpha).isEqualTo(0f) placeholderViewModel.setAlphaForBrightnessMirror(1f) notificationsPlaceholderViewModel.setAlphaForBrightnessMirror(1f) assertThat(maxAlpha).isEqualTo(1f) } @Test fun shadeExpansion_goneToShade() = testScope.runTest { kosmos.runTest { enableSingleShade() val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(currentScene = Scenes.Gone) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(scrollViewModel.expandFraction) val expandFraction by collectLastValue(notificationScrollViewModel.expandFraction) assertThat(expandFraction).isEqualTo(0f) fakeSceneDataSource.changeScene(toScene = Scenes.Gone) val isScrollable by collectLastValue(scrollViewModel.isScrollable) val isScrollable by collectLastValue(notificationScrollViewModel.isScrollable) assertThat(isScrollable).isFalse() fakeSceneDataSource.pause() Loading @@ -169,7 +164,6 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { repeat(steps) { repetition -> val progress = (1f / steps) * (repetition + 1) transitionProgress.value = progress runCurrent() assertThat(expandFraction).isWithin(0.01f).of(progress) } Loading @@ -180,49 +174,47 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { @Test fun shadeExpansion_idleOnLockscreen() = testScope.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(currentScene = Scenes.Lockscreen) kosmos.runTest { sceneInteractor.setTransitionState( flowOf(ObservableTransitionState.Idle(currentScene = Scenes.Lockscreen)) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(scrollViewModel.expandFraction) val expandFraction by collectLastValue(notificationScrollViewModel.expandFraction) assertThat(expandFraction).isEqualTo(1f) fakeSceneDataSource.changeScene(toScene = Scenes.Lockscreen) val isScrollable by collectLastValue(scrollViewModel.isScrollable) val isScrollable by collectLastValue(notificationScrollViewModel.isScrollable) assertThat(isScrollable).isFalse() } @Test fun shadeExpansion_idleOnQs() = testScope.runTest { val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(currentScene = Scenes.QuickSettings) kosmos.runTest { enableSingleShade() sceneInteractor.setTransitionState( flowOf(ObservableTransitionState.Idle(currentScene = Scenes.QuickSettings)) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(scrollViewModel.expandFraction) val expandFraction by collectLastValue(notificationScrollViewModel.expandFraction) assertThat(expandFraction).isEqualTo(1f) fakeSceneDataSource.changeScene(toScene = Scenes.QuickSettings) val isScrollable by collectLastValue(scrollViewModel.isScrollable) val isScrollable by collectLastValue(notificationScrollViewModel.isScrollable) assertThat(isScrollable).isFalse() } @Test fun shadeExpansion_shadeToQs() = testScope.runTest { kosmos.runTest { enableSingleShade() val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(currentScene = Scenes.Shade) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(scrollViewModel.expandFraction) val expandFraction by collectLastValue(notificationScrollViewModel.expandFraction) assertThat(expandFraction).isEqualTo(1f) fakeSceneDataSource.changeScene(toScene = Scenes.Shade) val isScrollable by collectLastValue(scrollViewModel.isScrollable) val isScrollable by collectLastValue(notificationScrollViewModel.isScrollable) assertThat(isScrollable).isTrue() fakeSceneDataSource.pause() Loading @@ -242,7 +234,6 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { repeat(steps) { repetition -> val progress = (1f / steps) * (repetition + 1) transitionProgress.value = progress runCurrent() assertThat(expandFraction).isEqualTo(1f) } Loading @@ -253,17 +244,18 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { @Test fun shadeExpansion_goneToQs() = testScope.runTest { kosmos.runTest { enableSingleShade() val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(currentScene = Scenes.Gone) ) sceneInteractor.setTransitionState(transitionState) val expandFraction by collectLastValue(scrollViewModel.expandFraction) val expandFraction by collectLastValue(notificationScrollViewModel.expandFraction) assertThat(expandFraction).isEqualTo(0f) fakeSceneDataSource.changeScene(toScene = Scenes.Gone) val isScrollable by collectLastValue(scrollViewModel.isScrollable) val isScrollable by collectLastValue(notificationScrollViewModel.isScrollable) assertThat(isScrollable).isFalse() fakeSceneDataSource.pause() Loading @@ -283,7 +275,6 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { repeat(steps) { repetition -> val progress = (1f / steps) * (repetition + 1) transitionProgress.value = progress runCurrent() assertThat(expandFraction) .isEqualTo( (progress / EXPANSION_FOR_MAX_SCRIM_ALPHA - Loading