Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt +25 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteract import com.android.systemui.keyguard.domain.interactor.KeyguardSmartspaceInteractor import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel import com.android.systemui.res.R import com.android.systemui.shared.R as sharedR import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import com.android.systemui.util.mockito.any Loading Loading @@ -68,6 +69,7 @@ class SmartspaceSectionTest : SysuiTestCase() { private val clockShouldBeCentered = MutableStateFlow(false) private val hasCustomWeatherDataDisplay = MutableStateFlow(false) private val isWeatherVisibleFlow = MutableStateFlow(false) private val isShadeLayoutWide = MutableStateFlow(false) @Before fun setup() { Loading @@ -80,7 +82,7 @@ class SmartspaceSectionTest : SysuiTestCase() { keyguardSmartspaceInteractor, lockscreenSmartspaceController, keyguardUnlockAnimationController, blueprintInteractor blueprintInteractor, ) constraintLayout = ConstraintLayout(mContext) whenever(lockscreenSmartspaceController.buildAndConnectView(any())) Loading @@ -93,6 +95,7 @@ class SmartspaceSectionTest : SysuiTestCase() { whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered) whenever(keyguardSmartspaceViewModel.isSmartspaceEnabled).thenReturn(true) whenever(keyguardSmartspaceViewModel.isWeatherVisible).thenReturn(isWeatherVisibleFlow) whenever(keyguardSmartspaceViewModel.isShadeLayoutWide).thenReturn(isShadeLayoutWide) constraintSet = ConstraintSet() } Loading Loading @@ -124,6 +127,26 @@ class SmartspaceSectionTest : SysuiTestCase() { assert(dateView.parent == null) } @Test fun testConstraintsWhenShadeLayoutIsNotWide() { underTest.addViews(constraintLayout) underTest.applyConstraints(constraintSet) val smartspaceConstraints = constraintSet.getConstraint(smartspaceView.id) assertThat(smartspaceConstraints.layout.endToEnd).isEqualTo(ConstraintSet.PARENT_ID) } @Test fun testConstraintsWhenShadeLayoutIsWide() { isShadeLayoutWide.value = true underTest.addViews(constraintLayout) underTest.applyConstraints(constraintSet) val smartspaceConstraints = constraintSet.getConstraint(smartspaceView.id) assertThat(smartspaceConstraints.layout.endToEnd).isEqualTo(R.id.split_shade_guideline) } @Test fun testConstraintsWhenNotHasCustomWeatherDataDisplay() { whenever(keyguardSmartspaceViewModel.isDateWeatherDecoupled).thenReturn(true) Loading Loading @@ -160,6 +183,7 @@ class SmartspaceSectionTest : SysuiTestCase() { assertThat(constraintSet.getVisibility(weatherView.id)).isEqualTo(GONE) assertThat(constraintSet.getVisibility(dateView.id)).isEqualTo(VISIBLE) } @Test fun testCustomDateWeatherVisibility() { hasCustomWeatherDataDisplay.value = true Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt +23 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.systemui.keyguard.data.repository.keyguardSmartspaceRepositor import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.shade.data.repository.shadeRepository import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat Loading Loading @@ -96,4 +97,26 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isWeatherVisible).isEqualTo(false) } @Test fun isShadeLayoutWide_withConfigTrue_true() = with(kosmos) { testScope.runTest { val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide) shadeRepository.setShadeLayoutWide(true) assertThat(isShadeLayoutWide).isTrue() } } @Test fun isShadeLayoutWide_withConfigFalse_false() = with(kosmos) { testScope.runTest { val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide) shadeRepository.setShadeLayoutWide(false) assertThat(isShadeLayoutWide).isFalse() } } } packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt +11 −14 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ constructor( ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, horizontalPaddingStart horizontalPaddingStart, ) // migrate addSmartspaceView from KeyguardClockSwitchController Loading @@ -135,15 +135,15 @@ constructor( ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, horizontalPaddingStart horizontalPaddingStart, ) connect( sharedR.id.bc_smartspace_view, ConstraintSet.END, if (keyguardClockViewModel.clockShouldBeCentered.value) ConstraintSet.PARENT_ID else R.id.split_shade_guideline, if (keyguardSmartspaceViewModel.isShadeLayoutWide.value) R.id.split_shade_guideline else ConstraintSet.PARENT_ID, ConstraintSet.END, horizontalPaddingEnd horizontalPaddingEnd, ) if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) { Loading @@ -152,7 +152,7 @@ constructor( sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM, sharedR.id.bc_smartspace_view, ConstraintSet.TOP ConstraintSet.TOP, ) } else { clear(sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM) Loading @@ -160,13 +160,13 @@ constructor( sharedR.id.date_smartspace_view, ConstraintSet.TOP, customR.id.lockscreen_clock_view, ConstraintSet.BOTTOM ConstraintSet.BOTTOM, ) connect( sharedR.id.bc_smartspace_view, ConstraintSet.TOP, sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM ConstraintSet.BOTTOM, ) } Loading @@ -174,10 +174,7 @@ constructor( R.id.smart_space_barrier_bottom, Barrier.BOTTOM, 0, *intArrayOf( sharedR.id.bc_smartspace_view, sharedR.id.date_smartspace_view, ) *intArrayOf(sharedR.id.bc_smartspace_view, sharedR.id.date_smartspace_view), ) } updateVisibility(constraintSet) Loading Loading @@ -212,7 +209,7 @@ constructor( setVisibility(sharedR.id.weather_smartspace_view, weatherVisibility) setAlpha( sharedR.id.weather_smartspace_view, if (weatherVisibility == View.VISIBLE) 1f else 0f if (weatherVisibility == View.VISIBLE) 1f else 0f, ) val dateVisibility = if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) ConstraintSet.GONE Loading @@ -220,7 +217,7 @@ constructor( setVisibility(sharedR.id.date_smartspace_view, dateVisibility) setAlpha( sharedR.id.date_smartspace_view, if (dateVisibility == ConstraintSet.VISIBLE) 1f else 0f if (dateVisibility == ConstraintSet.VISIBLE) 1f else 0f, ) } } Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt +4 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyguard.domain.interactor.KeyguardSmartspaceInteractor import com.android.systemui.res.R import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import javax.inject.Inject import kotlinx.coroutines.CoroutineScope Loading @@ -39,6 +40,7 @@ constructor( smartspaceController: LockscreenSmartspaceController, keyguardClockViewModel: KeyguardClockViewModel, smartspaceInteractor: KeyguardSmartspaceInteractor, shadeInteractor: ShadeInteractor, ) { /** Whether the smartspace section is available in the build. */ val isSmartspaceEnabled: Boolean = smartspaceController.isEnabled Loading Loading @@ -89,6 +91,8 @@ constructor( /* trigger clock and smartspace constraints change when smartspace appears */ val bcSmartspaceVisibility: StateFlow<Int> = smartspaceInteractor.bcSmartspaceVisibility val isShadeLayoutWide: StateFlow<Boolean> = shadeInteractor.isShadeLayoutWide companion object { fun getSmartspaceStartMargin(context: Context): Int { return context.resources.getDimensionPixelSize(R.dimen.below_clock_padding_start) + Loading packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelKosmos.kt +2 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.viewmodel import com.android.systemui.keyguard.domain.interactor.keyguardSmartspaceInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.util.mockito.mock val Kosmos.keyguardSmartspaceViewModel by Loading @@ -28,5 +29,6 @@ val Kosmos.keyguardSmartspaceViewModel by smartspaceController = mock(), keyguardClockViewModel = keyguardClockViewModel, smartspaceInteractor = keyguardSmartspaceInteractor, shadeInteractor = shadeInteractor, ) } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt +25 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteract import com.android.systemui.keyguard.domain.interactor.KeyguardSmartspaceInteractor import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel import com.android.systemui.res.R import com.android.systemui.shared.R as sharedR import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import com.android.systemui.util.mockito.any Loading Loading @@ -68,6 +69,7 @@ class SmartspaceSectionTest : SysuiTestCase() { private val clockShouldBeCentered = MutableStateFlow(false) private val hasCustomWeatherDataDisplay = MutableStateFlow(false) private val isWeatherVisibleFlow = MutableStateFlow(false) private val isShadeLayoutWide = MutableStateFlow(false) @Before fun setup() { Loading @@ -80,7 +82,7 @@ class SmartspaceSectionTest : SysuiTestCase() { keyguardSmartspaceInteractor, lockscreenSmartspaceController, keyguardUnlockAnimationController, blueprintInteractor blueprintInteractor, ) constraintLayout = ConstraintLayout(mContext) whenever(lockscreenSmartspaceController.buildAndConnectView(any())) Loading @@ -93,6 +95,7 @@ class SmartspaceSectionTest : SysuiTestCase() { whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered) whenever(keyguardSmartspaceViewModel.isSmartspaceEnabled).thenReturn(true) whenever(keyguardSmartspaceViewModel.isWeatherVisible).thenReturn(isWeatherVisibleFlow) whenever(keyguardSmartspaceViewModel.isShadeLayoutWide).thenReturn(isShadeLayoutWide) constraintSet = ConstraintSet() } Loading Loading @@ -124,6 +127,26 @@ class SmartspaceSectionTest : SysuiTestCase() { assert(dateView.parent == null) } @Test fun testConstraintsWhenShadeLayoutIsNotWide() { underTest.addViews(constraintLayout) underTest.applyConstraints(constraintSet) val smartspaceConstraints = constraintSet.getConstraint(smartspaceView.id) assertThat(smartspaceConstraints.layout.endToEnd).isEqualTo(ConstraintSet.PARENT_ID) } @Test fun testConstraintsWhenShadeLayoutIsWide() { isShadeLayoutWide.value = true underTest.addViews(constraintLayout) underTest.applyConstraints(constraintSet) val smartspaceConstraints = constraintSet.getConstraint(smartspaceView.id) assertThat(smartspaceConstraints.layout.endToEnd).isEqualTo(R.id.split_shade_guideline) } @Test fun testConstraintsWhenNotHasCustomWeatherDataDisplay() { whenever(keyguardSmartspaceViewModel.isDateWeatherDecoupled).thenReturn(true) Loading Loading @@ -160,6 +183,7 @@ class SmartspaceSectionTest : SysuiTestCase() { assertThat(constraintSet.getVisibility(weatherView.id)).isEqualTo(GONE) assertThat(constraintSet.getVisibility(dateView.id)).isEqualTo(VISIBLE) } @Test fun testCustomDateWeatherVisibility() { hasCustomWeatherDataDisplay.value = true Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt +23 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.systemui.keyguard.data.repository.keyguardSmartspaceRepositor import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.shade.data.repository.shadeRepository import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat Loading Loading @@ -96,4 +97,26 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isWeatherVisible).isEqualTo(false) } @Test fun isShadeLayoutWide_withConfigTrue_true() = with(kosmos) { testScope.runTest { val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide) shadeRepository.setShadeLayoutWide(true) assertThat(isShadeLayoutWide).isTrue() } } @Test fun isShadeLayoutWide_withConfigFalse_false() = with(kosmos) { testScope.runTest { val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide) shadeRepository.setShadeLayoutWide(false) assertThat(isShadeLayoutWide).isFalse() } } }
packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt +11 −14 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ constructor( ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, horizontalPaddingStart horizontalPaddingStart, ) // migrate addSmartspaceView from KeyguardClockSwitchController Loading @@ -135,15 +135,15 @@ constructor( ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, horizontalPaddingStart horizontalPaddingStart, ) connect( sharedR.id.bc_smartspace_view, ConstraintSet.END, if (keyguardClockViewModel.clockShouldBeCentered.value) ConstraintSet.PARENT_ID else R.id.split_shade_guideline, if (keyguardSmartspaceViewModel.isShadeLayoutWide.value) R.id.split_shade_guideline else ConstraintSet.PARENT_ID, ConstraintSet.END, horizontalPaddingEnd horizontalPaddingEnd, ) if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) { Loading @@ -152,7 +152,7 @@ constructor( sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM, sharedR.id.bc_smartspace_view, ConstraintSet.TOP ConstraintSet.TOP, ) } else { clear(sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM) Loading @@ -160,13 +160,13 @@ constructor( sharedR.id.date_smartspace_view, ConstraintSet.TOP, customR.id.lockscreen_clock_view, ConstraintSet.BOTTOM ConstraintSet.BOTTOM, ) connect( sharedR.id.bc_smartspace_view, ConstraintSet.TOP, sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM ConstraintSet.BOTTOM, ) } Loading @@ -174,10 +174,7 @@ constructor( R.id.smart_space_barrier_bottom, Barrier.BOTTOM, 0, *intArrayOf( sharedR.id.bc_smartspace_view, sharedR.id.date_smartspace_view, ) *intArrayOf(sharedR.id.bc_smartspace_view, sharedR.id.date_smartspace_view), ) } updateVisibility(constraintSet) Loading Loading @@ -212,7 +209,7 @@ constructor( setVisibility(sharedR.id.weather_smartspace_view, weatherVisibility) setAlpha( sharedR.id.weather_smartspace_view, if (weatherVisibility == View.VISIBLE) 1f else 0f if (weatherVisibility == View.VISIBLE) 1f else 0f, ) val dateVisibility = if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) ConstraintSet.GONE Loading @@ -220,7 +217,7 @@ constructor( setVisibility(sharedR.id.date_smartspace_view, dateVisibility) setAlpha( sharedR.id.date_smartspace_view, if (dateVisibility == ConstraintSet.VISIBLE) 1f else 0f if (dateVisibility == ConstraintSet.VISIBLE) 1f else 0f, ) } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt +4 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyguard.domain.interactor.KeyguardSmartspaceInteractor import com.android.systemui.res.R import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import javax.inject.Inject import kotlinx.coroutines.CoroutineScope Loading @@ -39,6 +40,7 @@ constructor( smartspaceController: LockscreenSmartspaceController, keyguardClockViewModel: KeyguardClockViewModel, smartspaceInteractor: KeyguardSmartspaceInteractor, shadeInteractor: ShadeInteractor, ) { /** Whether the smartspace section is available in the build. */ val isSmartspaceEnabled: Boolean = smartspaceController.isEnabled Loading Loading @@ -89,6 +91,8 @@ constructor( /* trigger clock and smartspace constraints change when smartspace appears */ val bcSmartspaceVisibility: StateFlow<Int> = smartspaceInteractor.bcSmartspaceVisibility val isShadeLayoutWide: StateFlow<Boolean> = shadeInteractor.isShadeLayoutWide companion object { fun getSmartspaceStartMargin(context: Context): Int { return context.resources.getDimensionPixelSize(R.dimen.below_clock_padding_start) + Loading
packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelKosmos.kt +2 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.viewmodel import com.android.systemui.keyguard.domain.interactor.keyguardSmartspaceInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.util.mockito.mock val Kosmos.keyguardSmartspaceViewModel by Loading @@ -28,5 +29,6 @@ val Kosmos.keyguardSmartspaceViewModel by smartspaceController = mock(), keyguardClockViewModel = keyguardClockViewModel, smartspaceInteractor = keyguardSmartspaceInteractor, shadeInteractor = shadeInteractor, ) }