diff options
| author | 2024-05-10 10:45:20 +0000 | |
|---|---|---|
| committer | 2024-05-10 10:45:20 +0000 | |
| commit | afa3ba5227bf7bd356a40770190e8d973ade514d (patch) | |
| tree | 05d57977385e971a683f47d6dc339167b2d0159d | |
| parent | cdb2d3ae712e2a1ef5021357ba35099a55937d38 (diff) | |
| parent | 845eed584be8508ca7c46a510dc44b936c77a4ce (diff) | |
Merge changes Ice414d9d,I08c347c0,I35083685 into main
* changes:
Parameterize Lockscreen tests for scene container flag
Remove unnecessary nullability
Parameterize NotificationListViewModelTest for scene container flag
26 files changed, 285 insertions, 163 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt index 9d6a66de367f..1f8cb8a2fc9b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt @@ -90,7 +90,7 @@ import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class CommunalViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class CommunalViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { @Mock private lateinit var mediaHost: MediaHost @Mock private lateinit var user: UserInfo @Mock private lateinit var providerInfo: AppWidgetProviderInfo @@ -111,7 +111,7 @@ class CommunalViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { private lateinit var underTest: CommunalViewModel init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/UdfpsKeyguardInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/UdfpsKeyguardInteractorTest.kt index 3b6f6a2d5e1a..f31eb7f50405 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/UdfpsKeyguardInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/UdfpsKeyguardInteractorTest.kt @@ -58,7 +58,7 @@ import platform.test.runner.parameterized.Parameters @ExperimentalCoroutinesApi @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class UdfpsKeyguardInteractorTest(flags: FlagsParameterization?) : SysuiTestCase() { +class UdfpsKeyguardInteractorTest(flags: FlagsParameterization) : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val keyguardRepository = kosmos.fakeKeyguardRepository @@ -88,7 +88,7 @@ class UdfpsKeyguardInteractorTest(flags: FlagsParameterization?) : SysuiTestCase } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/AodToLockscreenTransitionViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/AodToLockscreenTransitionViewModelTest.kt index f52c66e24907..cde703b70fe6 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/AodToLockscreenTransitionViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/AodToLockscreenTransitionViewModelTest.kt @@ -43,7 +43,7 @@ import platform.test.runner.parameterized.Parameters @ExperimentalCoroutinesApi @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class AodToLockscreenTransitionViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class AodToLockscreenTransitionViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val repository = kosmos.fakeKeyguardTransitionRepository @@ -60,7 +60,7 @@ class AodToLockscreenTransitionViewModelTest(flags: FlagsParameterization?) : Sy } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/BouncerToGoneFlowsTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/BouncerToGoneFlowsTest.kt index fee18dd94a91..d63293675034 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/BouncerToGoneFlowsTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/BouncerToGoneFlowsTest.kt @@ -16,13 +16,15 @@ package com.android.systemui.keyguard.ui.viewmodel -import androidx.test.ext.junit.runners.AndroidJUnit4 +import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.bouncer.domain.interactor.mockPrimaryBouncerInteractor import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues +import com.android.systemui.flags.BrokenWithSceneContainer import com.android.systemui.flags.Flags +import com.android.systemui.flags.andSceneContainer import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState @@ -31,29 +33,25 @@ import com.android.systemui.keyguard.shared.model.ScrimAlpha import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.testScope -import com.android.systemui.shade.data.repository.shadeRepository -import com.android.systemui.shade.domain.interactor.ShadeInteractor +import com.android.systemui.shade.shadeTestUtil import com.android.systemui.statusbar.sysuiStatusBarStateController import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever import com.google.common.collect.Range import com.google.common.truth.Truth.assertThat import kotlin.time.Duration.Companion.milliseconds -import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.mockito.Mock import org.mockito.MockitoAnnotations +import platform.test.runner.parameterized.ParameterizedAndroidJunit4 +import platform.test.runner.parameterized.Parameters @SmallTest -@RunWith(AndroidJUnit4::class) -class BouncerToGoneFlowsTest : SysuiTestCase() { - @Mock private lateinit var shadeInteractor: ShadeInteractor - - private val shadeExpansionStateFlow = MutableStateFlow(0.1f) +@RunWith(ParameterizedAndroidJunit4::class) +class BouncerToGoneFlowsTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos().apply { @@ -61,16 +59,31 @@ class BouncerToGoneFlowsTest : SysuiTestCase() { } private val testScope = kosmos.testScope private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository - private val shadeRepository = kosmos.shadeRepository private val sysuiStatusBarStateController = kosmos.sysuiStatusBarStateController private val primaryBouncerInteractor = kosmos.mockPrimaryBouncerInteractor - private val underTest = kosmos.bouncerToGoneFlows + + private val shadeTestUtil by lazy { kosmos.shadeTestUtil } + + private lateinit var underTest: BouncerToGoneFlows + + companion object { + @JvmStatic + @Parameters(name = "{0}") + fun getParams(): List<FlagsParameterization> { + return FlagsParameterization.allCombinationsOf().andSceneContainer() + } + } + + init { + mSetFlagsRule.setFlagsParameterization(flags) + } @Before fun setUp() { MockitoAnnotations.initMocks(this) whenever(primaryBouncerInteractor.willRunDismissFromKeyguard()).thenReturn(false) sysuiStatusBarStateController.setLeaveOpenOnKeyguardHide(false) + underTest = kosmos.bouncerToGoneFlows } @Test @@ -79,7 +92,7 @@ class BouncerToGoneFlowsTest : SysuiTestCase() { val values by collectValues(underTest.scrimAlpha(500.milliseconds, PRIMARY_BOUNCER)) runCurrent() - shadeRepository.setLockscreenShadeExpansion(1f) + shadeTestUtil.setLockscreenShadeExpansion(1f) whenever(primaryBouncerInteractor.willRunDismissFromKeyguard()).thenReturn(true) keyguardTransitionRepository.sendTransitionSteps( @@ -99,12 +112,13 @@ class BouncerToGoneFlowsTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun scrimAlpha_runDimissFromKeyguard_shadeNotExpanded() = testScope.runTest { val values by collectValues(underTest.scrimAlpha(500.milliseconds, PRIMARY_BOUNCER)) runCurrent() - shadeRepository.setLockscreenShadeExpansion(0f) + shadeTestUtil.setLockscreenShadeExpansion(0f) whenever(primaryBouncerInteractor.willRunDismissFromKeyguard()).thenReturn(true) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt index 2e1765a641b8..838b2a79adff 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt @@ -60,7 +60,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class KeyguardRootViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class KeyguardRootViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val keyguardTransitionRepository by lazy { kosmos.fakeKeyguardTransitionRepository } @@ -75,7 +75,6 @@ class KeyguardRootViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() private val viewState = ViewStateAccessor() - // add to init block companion object { @JvmStatic @Parameters(name = "{0}") @@ -85,7 +84,7 @@ class KeyguardRootViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt index ec2cb049836f..de4b999b3899 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt @@ -47,7 +47,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class LockscreenContentViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos: Kosmos = testKosmos() @@ -62,7 +62,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization?) : SysuiTestC } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToAodTransitionViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToAodTransitionViewModelTest.kt index e3ae3ba4cedd..bc381f2abc6d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToAodTransitionViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToAodTransitionViewModelTest.kt @@ -49,7 +49,7 @@ import platform.test.runner.parameterized.Parameters @ExperimentalCoroutinesApi @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class LockscreenToAodTransitionViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class LockscreenToAodTransitionViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos().apply { fakeFeatureFlagsClassic.apply { set(FULL_SCREEN_USER_SWITCHER, false) } @@ -73,7 +73,7 @@ class LockscreenToAodTransitionViewModelTest(flags: FlagsParameterization?) : Sy } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToDreamingTransitionViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToDreamingTransitionViewModelTest.kt index adeb395fc142..933779312df5 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToDreamingTransitionViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToDreamingTransitionViewModelTest.kt @@ -51,7 +51,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class LockscreenToDreamingTransitionViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class LockscreenToDreamingTransitionViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos().apply { @@ -73,7 +73,7 @@ class LockscreenToDreamingTransitionViewModelTest(flags: FlagsParameterization?) } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToOccludedTransitionViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToOccludedTransitionViewModelTest.kt index f8da74fdd742..6ce7e88edc2b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToOccludedTransitionViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToOccludedTransitionViewModelTest.kt @@ -54,7 +54,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class LockscreenToOccludedTransitionViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class LockscreenToOccludedTransitionViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos().apply { fakeFeatureFlagsClassic.apply { set(Flags.FULL_SCREEN_USER_SWITCHER, false) } @@ -76,7 +76,7 @@ class LockscreenToOccludedTransitionViewModelTest(flags: FlagsParameterization?) } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToPrimaryBouncerTransitionViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToPrimaryBouncerTransitionViewModelTest.kt index d5df159d6d1e..58c6817c4270 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToPrimaryBouncerTransitionViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToPrimaryBouncerTransitionViewModelTest.kt @@ -46,7 +46,7 @@ import platform.test.runner.parameterized.Parameters @ExperimentalCoroutinesApi @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class LockscreenToPrimaryBouncerTransitionViewModelTest(flags: FlagsParameterization?) : +class LockscreenToPrimaryBouncerTransitionViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos().apply { @@ -67,7 +67,7 @@ class LockscreenToPrimaryBouncerTransitionViewModelTest(flags: FlagsParameteriza } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImplTest.kt index aa0ca186c1ee..78c4def5689b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImplTest.kt @@ -60,7 +60,7 @@ import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class ShadeInteractorImplTest(flags: FlagsParameterization?) : SysuiTestCase() { +class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val configurationRepository by lazy { kosmos.fakeConfigurationRepository } @@ -85,7 +85,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization?) : SysuiTestCase() { } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt index 44c9695d8b03..cecc70cae60d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt @@ -60,7 +60,7 @@ import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class ShadeStartableTest(flags: FlagsParameterization?) : SysuiTestCase() { +class ShadeStartableTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val shadeInteractor by lazy { kosmos.shadeInteractor } @@ -80,7 +80,7 @@ class ShadeStartableTest(flags: FlagsParameterization?) : SysuiTestCase() { } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt index d353a625b890..21dc953e79d1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt @@ -65,7 +65,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) @TestableLooper.RunWithLooper -class StatusBarStateControllerImplTest(flags: FlagsParameterization?) : SysuiTestCase() { +class StatusBarStateControllerImplTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope @@ -84,7 +84,7 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization?) : SysuiTes } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/icon/ui/viewmodel/NotificationIconContainerStatusBarViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/icon/ui/viewmodel/NotificationIconContainerStatusBarViewModelTest.kt index cbbc4d897048..9367a93a2890 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/icon/ui/viewmodel/NotificationIconContainerStatusBarViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/icon/ui/viewmodel/NotificationIconContainerStatusBarViewModelTest.kt @@ -59,7 +59,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterization?) : +class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { companion object { @@ -71,7 +71,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } private val kosmos = testKosmos() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationListViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationListViewModelTest.kt index 7ac549a7b551..cc5df74e5e6e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationListViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationListViewModelTest.kt @@ -20,12 +20,13 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel import android.app.NotificationManager.Policy import android.platform.test.annotations.EnableFlags +import android.platform.test.flag.junit.FlagsParameterization import android.provider.Settings -import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.Flags +import com.android.systemui.flags.andSceneContainer import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.shared.model.StatusBarState @@ -33,7 +34,7 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.power.data.repository.fakePowerRepository import com.android.systemui.power.shared.model.WakefulnessState import com.android.systemui.res.R -import com.android.systemui.shade.data.repository.fakeShadeRepository +import com.android.systemui.shade.shadeTestUtil import com.android.systemui.statusbar.data.repository.fakeRemoteInputRepository import com.android.systemui.statusbar.notification.data.repository.FakeHeadsUpRowRepository import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository @@ -56,11 +57,13 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.MockitoAnnotations +import platform.test.runner.parameterized.ParameterizedAndroidJunit4 +import platform.test.runner.parameterized.Parameters @SmallTest -@RunWith(AndroidJUnit4::class) +@RunWith(ParameterizedAndroidJunit4::class) @EnableFlags(FooterViewRefactor.FLAG_NAME) -class NotificationListViewModelTest : SysuiTestCase() { +class NotificationListViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos().apply { fakeFeatureFlagsClassic.apply { set(Flags.FULL_SCREEN_USER_SWITCHER, false) } @@ -72,16 +75,30 @@ class NotificationListViewModelTest : SysuiTestCase() { private val fakeKeyguardRepository = kosmos.fakeKeyguardRepository private val fakePowerRepository = kosmos.fakePowerRepository private val fakeRemoteInputRepository = kosmos.fakeRemoteInputRepository - private val fakeShadeRepository = kosmos.fakeShadeRepository private val fakeUserSetupRepository = kosmos.fakeUserSetupRepository private val headsUpRepository = kosmos.headsUpNotificationRepository private val zenModeRepository = kosmos.zenModeRepository - val underTest = kosmos.notificationListViewModel + private val shadeTestUtil by lazy { kosmos.shadeTestUtil } + + private lateinit var underTest: NotificationListViewModel + + companion object { + @JvmStatic + @Parameters(name = "{0}") + fun getParams(): List<FlagsParameterization> { + return FlagsParameterization.allCombinationsOf().andSceneContainer() + } + } + + init { + mSetFlagsRule.setFlagsParameterization(flags) + } @Before fun setUp() { MockitoAnnotations.initMocks(this) + underTest = kosmos.notificationListViewModel } @Test @@ -163,7 +180,7 @@ class NotificationListViewModelTest : SysuiTestCase() { // WHEN has no notifs activeNotificationListRepository.setActiveNotifs(count = 0) // AND quick settings are expanded - fakeShadeRepository.legacyQsFullscreen.value = true + shadeTestUtil.setQsFullscreen(true) runCurrent() // THEN empty shade is not visible @@ -178,9 +195,10 @@ class NotificationListViewModelTest : SysuiTestCase() { // WHEN has no notifs activeNotificationListRepository.setActiveNotifs(count = 0) // AND quick settings are expanded - fakeShadeRepository.setQsExpansion(1f) - // AND split shade is enabled + shadeTestUtil.setQsExpansion(1f) + // AND split shade is expanded overrideResource(R.bool.config_use_split_notification_shade, true) + shadeTestUtil.setShadeExpansion(1f) fakeConfigurationController.notifyConfigurationChanged() runCurrent() @@ -290,7 +308,7 @@ class NotificationListViewModelTest : SysuiTestCase() { activeNotificationListRepository.setActiveNotifs(count = 2) // AND shade is open fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE) - fakeShadeRepository.setLegacyShadeExpansion(1f) + shadeTestUtil.setShadeExpansion(1f) runCurrent() // THEN footer is visible @@ -306,7 +324,7 @@ class NotificationListViewModelTest : SysuiTestCase() { activeNotificationListRepository.setActiveNotifs(count = 2) // AND shade is open on lockscreen fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE_LOCKED) - fakeShadeRepository.setLegacyShadeExpansion(1f) + shadeTestUtil.setShadeExpansion(1f) runCurrent() // THEN footer is visible @@ -337,7 +355,7 @@ class NotificationListViewModelTest : SysuiTestCase() { activeNotificationListRepository.setActiveNotifs(count = 2) // AND shade is open fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE) - fakeShadeRepository.setLegacyShadeExpansion(1f) + shadeTestUtil.setShadeExpansion(1f) // AND user is not set up fakeUserSetupRepository.setUserSetUp(false) runCurrent() @@ -355,7 +373,7 @@ class NotificationListViewModelTest : SysuiTestCase() { activeNotificationListRepository.setActiveNotifs(count = 2) // AND shade is open fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE) - fakeShadeRepository.setLegacyShadeExpansion(1f) + shadeTestUtil.setShadeExpansion(1f) // AND device is starting to go to sleep fakePowerRepository.updateWakefulness(WakefulnessState.STARTING_TO_SLEEP) runCurrent() @@ -373,10 +391,10 @@ class NotificationListViewModelTest : SysuiTestCase() { activeNotificationListRepository.setActiveNotifs(count = 2) // AND shade is open fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE) - fakeShadeRepository.setLegacyShadeExpansion(1f) + shadeTestUtil.setShadeExpansion(1f) // AND quick settings are expanded - fakeShadeRepository.setQsExpansion(1f) - fakeShadeRepository.legacyQsFullscreen.value = true + shadeTestUtil.setQsExpansion(1f) + shadeTestUtil.setQsFullscreen(true) runCurrent() // THEN footer is not visible @@ -390,11 +408,11 @@ class NotificationListViewModelTest : SysuiTestCase() { // WHEN has notifs activeNotificationListRepository.setActiveNotifs(count = 2) + // AND quick settings are expanded + shadeTestUtil.setQsExpansion(1f) // AND shade is open fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE) - fakeShadeRepository.setLegacyShadeExpansion(1f) - // AND quick settings are expanded - fakeShadeRepository.setQsExpansion(1f) + shadeTestUtil.setShadeExpansion(1f) // AND split shade is enabled overrideResource(R.bool.config_use_split_notification_shade, true) fakeConfigurationController.notifyConfigurationChanged() @@ -413,7 +431,7 @@ class NotificationListViewModelTest : SysuiTestCase() { activeNotificationListRepository.setActiveNotifs(count = 2) // AND shade is open fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE) - fakeShadeRepository.setLegacyShadeExpansion(1f) + shadeTestUtil.setShadeExpansion(1f) // AND remote input is active fakeRemoteInputRepository.isRemoteInputActive.value = true runCurrent() @@ -431,7 +449,7 @@ class NotificationListViewModelTest : SysuiTestCase() { activeNotificationListRepository.setActiveNotifs(count = 2) // AND shade is open and fully expanded fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE) - fakeShadeRepository.setLegacyShadeExpansion(1f) + shadeTestUtil.setShadeExpansion(1f) runCurrent() // THEN footer visibility animates @@ -447,7 +465,7 @@ class NotificationListViewModelTest : SysuiTestCase() { activeNotificationListRepository.setActiveNotifs(count = 2) // AND we are on the keyguard fakeKeyguardRepository.setStatusBarState(StatusBarState.KEYGUARD) - fakeShadeRepository.setLegacyShadeExpansion(1f) + shadeTestUtil.setShadeExpansion(1f) runCurrent() // THEN footer visibility does not animate @@ -461,7 +479,7 @@ class NotificationListViewModelTest : SysuiTestCase() { // WHEN shade is closed fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE) - fakeShadeRepository.setLegacyShadeExpansion(0f) + shadeTestUtil.setShadeExpansion(0f) runCurrent() // THEN footer is hidden @@ -475,7 +493,7 @@ class NotificationListViewModelTest : SysuiTestCase() { // WHEN shade is open fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE) - fakeShadeRepository.setLegacyShadeExpansion(1f) + shadeTestUtil.setShadeExpansion(1f) runCurrent() // THEN footer is hidden @@ -489,8 +507,8 @@ class NotificationListViewModelTest : SysuiTestCase() { // WHEN QS partially open fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE) - fakeShadeRepository.setQsExpansion(0.5f) - fakeShadeRepository.setLegacyShadeExpansion(0.5f) + shadeTestUtil.setQsExpansion(0.5f) + shadeTestUtil.setShadeExpansion(0.5f) runCurrent() // THEN footer is hidden @@ -588,7 +606,7 @@ class NotificationListViewModelTest : SysuiTestCase() { testScope.runTest { val animationsEnabled by collectLastValue(underTest.headsUpAnimationsEnabled) - fakeShadeRepository.setQsExpansion(0.0f) + shadeTestUtil.setQsExpansion(0.0f) fakeKeyguardRepository.setKeyguardShowing(false) runCurrent() @@ -601,7 +619,7 @@ class NotificationListViewModelTest : SysuiTestCase() { testScope.runTest { val animationsEnabled by collectLastValue(underTest.headsUpAnimationsEnabled) - fakeShadeRepository.setQsExpansion(0.0f) + shadeTestUtil.setQsExpansion(0.0f) fakeKeyguardRepository.setKeyguardShowing(true) runCurrent() diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt index 2cd295c6045d..f2ce745ed293 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt @@ -75,7 +75,7 @@ import platform.test.runner.parameterized.Parameters @RunWith(ParameterizedAndroidJunit4::class) // SharedNotificationContainerViewModel is only bound when FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT is on @EnableFlags(FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) -class SharedNotificationContainerViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { companion object { @JvmStatic @@ -89,7 +89,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization?) : } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } val aodBurnInViewModel = mock(AodBurnInViewModel::class.java) diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/DefaultUdfpsTouchOverlayViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/DefaultUdfpsTouchOverlayViewModelTest.kt index 5caa146f6351..0d01472b45c7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/DefaultUdfpsTouchOverlayViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/DefaultUdfpsTouchOverlayViewModelTest.kt @@ -16,97 +16,95 @@ package com.android.systemui.biometrics.ui.viewmodel +import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest -import com.android.systemui.SysUITestComponent -import com.android.systemui.SysUITestModule import com.android.systemui.SysuiTestCase -import com.android.systemui.TestMocksModule -import com.android.systemui.biometrics.domain.BiometricsDomainLayerModule -import com.android.systemui.collectLastValue -import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.flags.FakeFeatureFlagsClassicModule +import com.android.systemui.coroutines.collectLastValue +import com.android.systemui.flags.BrokenWithSceneContainer import com.android.systemui.flags.Flags -import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository +import com.android.systemui.flags.fakeFeatureFlagsClassic +import com.android.systemui.flags.parameterizeSceneContainerFlag +import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.shared.model.StatusBarState -import com.android.systemui.runCurrent -import com.android.systemui.runTest -import com.android.systemui.shade.data.repository.FakeShadeRepository +import com.android.systemui.kosmos.testScope +import com.android.systemui.shade.domain.interactor.shadeInteractor +import com.android.systemui.shade.shadeTestUtil import com.android.systemui.statusbar.phone.SystemUIDialogManager -import com.android.systemui.user.domain.UserDomainLayerModule -import com.android.systemui.util.mockito.mock +import com.android.systemui.statusbar.phone.systemUIDialogManager +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat -import dagger.BindsInstance -import dagger.Component 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 -import org.junit.runners.JUnit4 import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations +import platform.test.runner.parameterized.ParameterizedAndroidJunit4 +import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalCoroutinesApi::class) @SmallTest -@RunWith(JUnit4::class) -class DefaultUdfpsTouchOverlayViewModelTest : SysuiTestCase() { +@RunWith(ParameterizedAndroidJunit4::class) +class DefaultUdfpsTouchOverlayViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { + + private val kosmos = + testKosmos().apply { + fakeFeatureFlagsClassic.apply { set(Flags.FULL_SCREEN_USER_SWITCHER, true) } + } + private val testScope = kosmos.testScope + @Captor private lateinit var sysuiDialogListenerCaptor: ArgumentCaptor<SystemUIDialogManager.Listener> - private var systemUIDialogManager: SystemUIDialogManager = mock() + private var systemUIDialogManager = kosmos.systemUIDialogManager + private val keyguardRepository = kosmos.fakeKeyguardRepository + + private val shadeTestUtil by lazy { kosmos.shadeTestUtil } + + private lateinit var underTest: DefaultUdfpsTouchOverlayViewModel + + companion object { + @JvmStatic + @Parameters(name = "{0}") + fun getParams(): List<FlagsParameterization> { + return parameterizeSceneContainerFlag() + } + } + + init { + mSetFlagsRule.setFlagsParameterization(flags) + } @Before fun setUp() { MockitoAnnotations.initMocks(this) + underTest = + DefaultUdfpsTouchOverlayViewModel( + kosmos.shadeInteractor, + systemUIDialogManager, + ) } - @SysUISingleton - @Component( - modules = - [ - SysUITestModule::class, - UserDomainLayerModule::class, - BiometricsDomainLayerModule::class, - ] - ) - interface TestComponent : SysUITestComponent<DefaultUdfpsTouchOverlayViewModel> { - val keyguardRepository: FakeKeyguardRepository - val shadeRepository: FakeShadeRepository - @Component.Factory - interface Factory { - fun create( - @BindsInstance test: SysuiTestCase, - featureFlags: FakeFeatureFlagsClassicModule, - mocks: TestMocksModule, - ): TestComponent - } - } - - private fun TestComponent.shadeExpanded(expanded: Boolean) { + private fun shadeExpanded(expanded: Boolean) { if (expanded) { - shadeRepository.setLegacyShadeExpansion(1f) - shadeRepository.setLegacyShadeTracking(false) - shadeRepository.setLegacyExpandedOrAwaitingInputTransfer(true) + shadeTestUtil.setShadeExpansion(1f) + shadeTestUtil.setTracking(false) + shadeTestUtil.setLegacyExpandedOrAwaitingInputTransfer(true) } else { keyguardRepository.setStatusBarState(StatusBarState.SHADE) - shadeRepository.setLegacyShadeExpansion(0f) - shadeRepository.setLegacyShadeTracking(false) - shadeRepository.setLegacyExpandedOrAwaitingInputTransfer(false) + shadeTestUtil.setShadeExpansion(0f) + shadeTestUtil.setTracking(false) + shadeTestUtil.setLegacyExpandedOrAwaitingInputTransfer(false) } } - private val testComponent: TestComponent = - DaggerDefaultUdfpsTouchOverlayViewModelTest_TestComponent.factory() - .create( - test = this, - featureFlags = - FakeFeatureFlagsClassicModule { set(Flags.FULL_SCREEN_USER_SWITCHER, true) }, - mocks = TestMocksModule(systemUIDialogManager = systemUIDialogManager), - ) - @Test + @BrokenWithSceneContainer(339465026) fun shadeNotExpanded_noDialogShowing_shouldHandleTouchesTrue() = - testComponent.runTest { + testScope.runTest { val shouldHandleTouches by collectLastValue(underTest.shouldHandleTouches) runCurrent() @@ -120,7 +118,7 @@ class DefaultUdfpsTouchOverlayViewModelTest : SysuiTestCase() { @Test fun shadeNotExpanded_dialogShowing_shouldHandleTouchesFalse() = - testComponent.runTest { + testScope.runTest { val shouldHandleTouches by collectLastValue(underTest.shouldHandleTouches) runCurrent() @@ -134,7 +132,7 @@ class DefaultUdfpsTouchOverlayViewModelTest : SysuiTestCase() { @Test fun shadeExpanded_noDialogShowing_shouldHandleTouchesFalse() = - testComponent.runTest { + testScope.runTest { val shouldHandleTouches by collectLastValue(underTest.shouldHandleTouches) runCurrent() diff --git a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt index 6a0462b72544..c39c3fe5f527 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/ui/viewmodel/UdfpsAccessibilityOverlayViewModelTest.kt @@ -16,7 +16,7 @@ package com.android.systemui.deviceentry.domain.ui.viewmodel -import androidx.test.ext.junit.runners.AndroidJUnit4 +import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.accessibility.data.repository.fakeAccessibilityRepository @@ -24,7 +24,9 @@ import com.android.systemui.biometrics.data.repository.fingerprintPropertyReposi import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.deviceentry.data.ui.viewmodel.deviceEntryUdfpsAccessibilityOverlayViewModel +import com.android.systemui.deviceentry.ui.viewmodel.DeviceEntryUdfpsAccessibilityOverlayViewModel import com.android.systemui.flags.Flags.FULL_SCREEN_USER_SWITCHER +import com.android.systemui.flags.andSceneContainer import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.deviceEntryFingerprintAuthRepository import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository @@ -34,19 +36,22 @@ import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.keyguard.ui.viewmodel.fakeDeviceEntryIconViewModelTransition import com.android.systemui.kosmos.testScope -import com.android.systemui.shade.data.repository.fakeShadeRepository +import com.android.systemui.shade.shadeTestUtil import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest +import org.junit.Before import org.junit.runner.RunWith +import platform.test.runner.parameterized.ParameterizedAndroidJunit4 +import platform.test.runner.parameterized.Parameters @ExperimentalCoroutinesApi @SmallTest -@RunWith(AndroidJUnit4::class) -class UdfpsAccessibilityOverlayViewModelTest : SysuiTestCase() { +@RunWith(ParameterizedAndroidJunit4::class) +class UdfpsAccessibilityOverlayViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos().apply { fakeFeatureFlagsClassic.apply { set(FULL_SCREEN_USER_SWITCHER, false) } @@ -59,8 +64,27 @@ class UdfpsAccessibilityOverlayViewModelTest : SysuiTestCase() { private val fingerprintPropertyRepository = kosmos.fingerprintPropertyRepository private val deviceEntryFingerprintAuthRepository = kosmos.deviceEntryFingerprintAuthRepository private val deviceEntryRepository = kosmos.fakeDeviceEntryRepository - private val shadeRepository = kosmos.fakeShadeRepository - private val underTest = kosmos.deviceEntryUdfpsAccessibilityOverlayViewModel + + private val shadeTestUtil by lazy { kosmos.shadeTestUtil } + + private lateinit var underTest: DeviceEntryUdfpsAccessibilityOverlayViewModel + + companion object { + @JvmStatic + @Parameters(name = "{0}") + fun getParams(): List<FlagsParameterization> { + return FlagsParameterization.allCombinationsOf().andSceneContainer() + } + } + + init { + mSetFlagsRule.setFlagsParameterization(flags) + } + + @Before + fun setup() { + underTest = kosmos.deviceEntryUdfpsAccessibilityOverlayViewModel + } @Test fun visible() = @@ -142,7 +166,7 @@ class UdfpsAccessibilityOverlayViewModelTest : SysuiTestCase() { ) // Shade not expanded - shadeRepository.qsExpansion.value = 0f - shadeRepository.lockscreenShadeExpansion.value = 0f + shadeTestUtil.setQsExpansion(0f) + shadeTestUtil.setLockscreenShadeExpansion(0f) } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt index 1dc58d1784d7..687e91ad0b81 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt @@ -17,6 +17,7 @@ package com.android.systemui.keyguard.domain.interactor import android.app.StatusBarManager +import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.keyguard.KeyguardSecurityModel @@ -29,7 +30,9 @@ import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.communal.shared.model.CommunalScenes import com.android.systemui.dock.fakeDockManager +import com.android.systemui.flags.BrokenWithSceneContainer import com.android.systemui.flags.FakeFeatureFlags +import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeCommandQueue import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository @@ -46,7 +49,8 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest import com.android.systemui.power.domain.interactor.powerInteractor -import com.android.systemui.shade.data.repository.fakeShadeRepository +import com.android.systemui.scene.shared.flag.SceneContainerFlag +import com.android.systemui.shade.shadeTestUtil import com.android.systemui.statusbar.commandQueue import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever @@ -61,13 +65,14 @@ import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.junit.runners.JUnit4 import org.mockito.ArgumentMatchers.anyInt import org.mockito.Mock import org.mockito.Mockito.clearInvocations import org.mockito.Mockito.reset import org.mockito.Mockito.spy import org.mockito.MockitoAnnotations +import platform.test.runner.parameterized.ParameterizedAndroidJunit4 +import platform.test.runner.parameterized.Parameters /** * Class for testing user journeys through the interactors. They will all be activated during setup, @@ -75,8 +80,8 @@ import org.mockito.MockitoAnnotations */ @ExperimentalCoroutinesApi @SmallTest -@RunWith(JUnit4::class) -class KeyguardTransitionScenariosTest : SysuiTestCase() { +@RunWith(ParameterizedAndroidJunit4::class) +class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTestCase() { private val kosmos = testKosmos().apply { fakeKeyguardTransitionRepository = spy(FakeKeyguardTransitionRepository()) @@ -87,7 +92,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { private val keyguardRepository = kosmos.fakeKeyguardRepository private val bouncerRepository = kosmos.fakeKeyguardBouncerRepository private var commandQueue = kosmos.fakeCommandQueue - private val shadeRepository = kosmos.fakeShadeRepository + private val shadeTestUtil by lazy { kosmos.shadeTestUtil } private val transitionRepository = kosmos.fakeKeyguardTransitionRepository private lateinit var featureFlags: FakeFeatureFlags @@ -112,6 +117,18 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { private val communalInteractor = kosmos.communalInteractor private val dockManager = kosmos.fakeDockManager + companion object { + @JvmStatic + @Parameters(name = "{0}") + fun getParams(): List<FlagsParameterization> { + return FlagsParameterization.allCombinationsOf().andSceneContainer() + } + } + + init { + mSetFlagsRule.setFlagsParameterization(flags!!) + } + @Before fun setUp() { MockitoAnnotations.initMocks(this) @@ -119,9 +136,11 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { whenever(keyguardSecurityModel.getSecurityMode(anyInt())).thenReturn(PIN) mSetFlagsRule.enableFlags(FLAG_COMMUNAL_HUB) - mSetFlagsRule.disableFlags( - Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR, - ) + if (!SceneContainerFlag.isEnabled) { + mSetFlagsRule.disableFlags( + Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR, + ) + } featureFlags = FakeFeatureFlags() fromLockscreenTransitionInteractor.start() @@ -210,6 +229,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun lockscreenToDreaming() = testScope.runTest { // GIVEN a device that is not dreaming or dozing @@ -238,6 +258,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun lockscreenToDreamingLockscreenHosted() = testScope.runTest { // GIVEN a device that is not dreaming or dozing @@ -527,6 +548,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun dozingToGoneWithUnlock() = testScope.runTest { // GIVEN a prior transition has run to DOZING @@ -706,6 +728,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun goneToLockscreen() = testScope.runTest { // GIVEN a prior transition has run to GONE @@ -755,6 +778,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun goneToGlanceableHub() = testScope.runTest { // GIVEN a prior transition has run to GONE @@ -897,6 +921,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun alternateBouncerToGone() = testScope.runTest { // GIVEN a prior transition has run to ALTERNATE_BOUNCER @@ -1135,6 +1160,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun occludedToGone() = testScope.runTest { // GIVEN a device on lockscreen @@ -1165,6 +1191,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun occludedToLockscreen() = testScope.runTest { // GIVEN a device on lockscreen @@ -1193,6 +1220,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun occludedToGlanceableHub() = testScope.runTest { // GIVEN a device on lockscreen @@ -1229,6 +1257,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun occludedToGlanceableHubWhenInitiallyOnHub() = testScope.runTest { // GIVEN a device on lockscreen and communal is available @@ -1314,6 +1343,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun primaryBouncerToOccluded() = testScope.runTest { // GIVEN a prior transition has run to PRIMARY_BOUNCER @@ -1339,6 +1369,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun dozingToOccluded() = testScope.runTest { // GIVEN a prior transition has run to DOZING @@ -1364,6 +1395,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun dreamingToOccluded() = testScope.runTest { // GIVEN a prior transition has run to DREAMING @@ -1484,6 +1516,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun lockscreenToOccluded() = testScope.runTest { // GIVEN a prior transition has run to LOCKSCREEN @@ -1507,6 +1540,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun aodToOccluded() = testScope.runTest { // GIVEN a prior transition has run to AOD @@ -1553,6 +1587,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun lockscreenToOccluded_fromCameraGesture() = testScope.runTest { // GIVEN a prior transition has run to LOCKSCREEN @@ -1586,6 +1621,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun lockscreenToPrimaryBouncerDragging() = testScope.runTest { // GIVEN a prior transition has run to LOCKSCREEN @@ -1595,8 +1631,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { // GIVEN the keyguard is showing locked keyguardRepository.setStatusBarState(StatusBarState.KEYGUARD) runCurrent() - shadeRepository.setLegacyShadeTracking(true) - shadeRepository.setLegacyShadeExpansion(.9f) + shadeTestUtil.setTracking(true) + shadeTestUtil.setShadeExpansion(.9f) runCurrent() // THEN a transition from LOCKSCREEN => PRIMARY_BOUNCER should occur @@ -1613,8 +1649,8 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { // WHEN the user stops dragging and shade is back to expanded clearInvocations(transitionRepository) runTransitionAndSetWakefulness(KeyguardState.LOCKSCREEN, KeyguardState.PRIMARY_BOUNCER) - shadeRepository.setLegacyShadeTracking(false) - shadeRepository.setLegacyShadeExpansion(1f) + shadeTestUtil.setTracking(false) + shadeTestUtil.setShadeExpansion(1f) runCurrent() // THEN a transition from LOCKSCREEN => PRIMARY_BOUNCER should occur @@ -1803,6 +1839,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() { } @Test + @BrokenWithSceneContainer(339465026) fun glanceableHubToOccluded() = testScope.runTest { // GIVEN a prior transition has run to GLANCEABLE_HUB diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt index 1881a9e0c205..16421a0f83b4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt @@ -88,7 +88,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class KeyguardBottomAreaViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class KeyguardBottomAreaViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { @Mock private lateinit var expandable: Expandable @Mock private lateinit var burnInHelperWrapper: BurnInHelperWrapper @@ -115,7 +115,7 @@ class KeyguardBottomAreaViewModelTest(flags: FlagsParameterization?) : SysuiTest private val kosmos = testKosmos() init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt index 0c98cff89ee2..768d4468de4f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt @@ -53,7 +53,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -class KeyguardClockViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class KeyguardClockViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val underTest = kosmos.keyguardClockViewModel @@ -67,7 +67,7 @@ class KeyguardClockViewModelTest(flags: FlagsParameterization?) : SysuiTestCase( var faceConfig = ClockFaceConfig() init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt index a867b0f7df00..45d0102f2dd1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt @@ -102,7 +102,7 @@ import org.mockito.Mockito.`when` as whenever @SmallTest @RunWith(ParameterizedAndroidJunit4::class) @RunWithLooper(setAsMainLooper = true) -class NotificationShadeWindowViewControllerTest(flags: FlagsParameterization?) : SysuiTestCase() { +class NotificationShadeWindowViewControllerTest(flags: FlagsParameterization) : SysuiTestCase() { @Mock private lateinit var view: NotificationShadeWindowView @Mock private lateinit var sysuiStatusBarStateController: SysuiStatusBarStateController @@ -160,7 +160,7 @@ class NotificationShadeWindowViewControllerTest(flags: FlagsParameterization?) : private lateinit var featureFlagsClassic: FakeFeatureFlagsClassic init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/footer/ui/viewmodel/FooterViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/footer/ui/viewmodel/FooterViewModelTest.kt index 347620a1631a..83ad18b6468b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/footer/ui/viewmodel/FooterViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/footer/ui/viewmodel/FooterViewModelTest.kt @@ -55,7 +55,7 @@ import platform.test.runner.parameterized.Parameters @RunWith(ParameterizedAndroidJunit4::class) @SmallTest @EnableFlags(FooterViewRefactor.FLAG_NAME) -class FooterViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos().apply { fakeFeatureFlagsClassic.apply { set(Flags.FULL_SCREEN_USER_SWITCHER, false) } @@ -79,7 +79,7 @@ class FooterViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBypassControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBypassControllerTest.kt index 9b4f9312a7ba..cb40f72ff1af 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBypassControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBypassControllerTest.kt @@ -66,7 +66,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) @TestableLooper.RunWithLooper -class KeyguardBypassControllerTest(flags: FlagsParameterization?) : SysuiTestCase() { +class KeyguardBypassControllerTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val featureFlags = FakeFeatureFlags() @@ -92,7 +92,7 @@ class KeyguardBypassControllerTest(flags: FlagsParameterization?) : SysuiTestCas } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Captor diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModelTest.kt index cfa734a14811..ab10bc4a4acc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModelTest.kt @@ -47,7 +47,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @OptIn(ExperimentalCoroutinesApi::class) @RunWith(ParameterizedAndroidJunit4::class) -class KeyguardStatusBarViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { +class KeyguardStatusBarViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private val keyguardRepository by lazy { kosmos.fakeKeyguardRepository } @@ -66,7 +66,7 @@ class KeyguardStatusBarViewModelTest(flags: FlagsParameterization?) : SysuiTestC } init { - mSetFlagsRule.setFlagsParameterization(flags!!) + mSetFlagsRule.setFlagsParameterization(flags) } @Before diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeTestUtil.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeTestUtil.kt index 38ede44efef6..ea02d0c7ac9a 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeTestUtil.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeTestUtil.kt @@ -76,6 +76,16 @@ class ShadeTestUtil constructor(val delegate: ShadeTestUtilDelegate) { delegate.assertFlagValid() delegate.programmaticCollapseShade() } + + fun setQsFullscreen(qsFullscreen: Boolean) { + delegate.assertFlagValid() + delegate.setQsFullscreen(qsFullscreen) + } + + fun setLegacyExpandedOrAwaitingInputTransfer(legacyExpandedOrAwaitingInputTransfer: Boolean) { + delegate.assertFlagValid() + delegate.setLegacyExpandedOrAwaitingInputTransfer(legacyExpandedOrAwaitingInputTransfer) + } } /** Sets up shade state for tests for a specific value of the scene container flag. */ @@ -103,6 +113,10 @@ interface ShadeTestUtilDelegate { /** Sets the shade to half collapsed with no touch input. */ fun programmaticCollapseShade() + + fun setQsFullscreen(qsFullscreen: Boolean) + + fun setLegacyExpandedOrAwaitingInputTransfer(legacyExpandedOrAwaitingInputTransfer: Boolean) } /** Sets up shade state for tests when the scene container flag is disabled. */ @@ -146,6 +160,14 @@ class ShadeTestUtilLegacyImpl(val testScope: TestScope, val shadeRepository: Fak shadeRepository.setLegacyShadeExpansion(.5f) testScope.runCurrent() } + + override fun setQsFullscreen(qsFullscreen: Boolean) { + shadeRepository.legacyQsFullscreen.value = true + } + + override fun setLegacyExpandedOrAwaitingInputTransfer(expanded: Boolean) { + shadeRepository.setLegacyExpandedOrAwaitingInputTransfer(expanded) + } } /** Sets up shade state for tests when the scene container flag is enabled. */ @@ -183,6 +205,16 @@ class ShadeTestUtilSceneImpl(val testScope: TestScope, val sceneInteractor: Scen setTransitionProgress(Scenes.Shade, Scenes.Lockscreen, .5f, false) } + override fun setQsFullscreen(qsFullscreen: Boolean) { + setQsExpansion(1f) + } + + override fun setLegacyExpandedOrAwaitingInputTransfer( + legacyExpandedOrAwaitingInputTransfer: Boolean + ) { + setShadeExpansion(.1f) + } + override fun setLockscreenShadeExpansion(lockscreenShadeExpansion: Float) { if (lockscreenShadeExpansion == 0f) { setIdleScene(Scenes.Lockscreen) |