diff options
| author | 2024-05-01 07:52:46 -0400 | |
|---|---|---|
| committer | 2024-05-01 07:53:35 -0400 | |
| commit | db160d6cf9f6c68ffa77d77cdad1fe04633d34f3 (patch) | |
| tree | cbcfd375d9f45d02adc396517c187baf245a3d0f | |
| parent | ef4d94eb2ac89cce00fbc8383c1fbbab86fd9786 (diff) | |
Parameterize some keyguard tests for scene container flag
Bug: 334874076
Test: yes
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: I7b77e86c2aa4fe49fc5b2b332abd187cb03334d4
6 files changed, 135 insertions, 52 deletions
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 49073595af0c..ec2cb049836f 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 @@ -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.biometrics.authController import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.coroutines.collectLastValue +import com.android.systemui.flags.DisableSceneContainer 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.fakeKeyguardClockRepository import com.android.systemui.keyguard.shared.model.ClockSize @@ -40,15 +42,29 @@ import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import platform.test.runner.parameterized.ParameterizedAndroidJunit4 +import platform.test.runner.parameterized.Parameters @SmallTest -@RunWith(AndroidJUnit4::class) -class LockscreenContentViewModelTest : SysuiTestCase() { +@RunWith(ParameterizedAndroidJunit4::class) +class LockscreenContentViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { private val kosmos: Kosmos = testKosmos() lateinit var underTest: LockscreenContentViewModel + companion object { + @JvmStatic + @Parameters(name = "{0}") + fun getParams(): List<FlagsParameterization> { + return FlagsParameterization.allCombinationsOf().andSceneContainer() + } + } + + init { + mSetFlagsRule.setFlagsParameterization(flags!!) + } + @Before fun setup() { with(kosmos) { @@ -77,6 +93,7 @@ class LockscreenContentViewModelTest : SysuiTestCase() { } @Test + @DisableSceneContainer fun clockSize_withLargeClock_true() = with(kosmos) { testScope.runTest { @@ -87,6 +104,7 @@ class LockscreenContentViewModelTest : SysuiTestCase() { } @Test + @DisableSceneContainer fun clockSize_withSmallClock_false() = with(kosmos) { testScope.runTest { @@ -109,6 +127,7 @@ class LockscreenContentViewModelTest : SysuiTestCase() { } @Test + @DisableSceneContainer fun areNotificationsVisible_withSmallClock_true() = with(kosmos) { testScope.runTest { @@ -119,6 +138,7 @@ class LockscreenContentViewModelTest : SysuiTestCase() { } @Test + @DisableSceneContainer fun areNotificationsVisible_withLargeClock_false() = with(kosmos) { testScope.runTest { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt index 776f1a55fdcb..bc9d257b3836 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt @@ -33,6 +33,7 @@ import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor +import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.testScope import com.android.systemui.power.data.repository.fakePowerRepository import com.android.systemui.power.shared.model.WakefulnessState @@ -57,6 +58,7 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) +@EnableSceneContainer class LockscreenSceneViewModelTest : SysuiTestCase() { companion object { 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 1d98dc3a8f47..0c98cff89ee2 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 @@ -18,11 +18,12 @@ package com.android.systemui.keyguard.ui.viewmodel import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags +import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.flags.DisableSceneContainer +import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.data.repository.fakeKeyguardClockRepository import com.android.systemui.keyguard.data.repository.keyguardClockRepository import com.android.systemui.keyguard.data.repository.keyguardRepository @@ -45,14 +46,14 @@ import kotlin.test.Test import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.runner.RunWith -import org.junit.runners.JUnit4 import org.mockito.Mock import org.mockito.MockitoAnnotations +import platform.test.runner.parameterized.ParameterizedAndroidJunit4 +import platform.test.runner.parameterized.Parameters @SmallTest -@RunWith(JUnit4::class) -@DisableSceneContainer -class KeyguardClockViewModelTest : SysuiTestCase() { +@RunWith(ParameterizedAndroidJunit4::class) +class KeyguardClockViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val underTest = kosmos.keyguardClockViewModel @@ -65,6 +66,10 @@ class KeyguardClockViewModelTest : SysuiTestCase() { var config = ClockConfig("TEST", "Test", "") var faceConfig = ClockFaceConfig() + init { + mSetFlagsRule.setFlagsParameterization(flags!!) + } + @Before fun setup() { MockitoAnnotations.initMocks(this) @@ -276,5 +281,11 @@ class KeyguardClockViewModelTest : SysuiTestCase() { companion object { private const val KEYGUARD_STATUS_BAR_HEIGHT = 20 + + @JvmStatic + @Parameters(name = "{0}") + fun getParams(): List<FlagsParameterization> { + return FlagsParameterization.allCombinationsOf().andSceneContainer() + } } } 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 bdd3d188ad91..cfa734a14811 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 @@ -16,71 +16,69 @@ package com.android.systemui.statusbar.ui.viewmodel +import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository -import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository -import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor -import com.android.systemui.keyguard.domain.interactor.fromGoneTransitionInteractor -import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor +import com.android.systemui.flags.andSceneContainer +import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository +import com.android.systemui.keyguard.data.repository.keyguardRepository +import com.android.systemui.keyguard.domain.interactor.keyguardInteractor import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.kosmos.testScope -import com.android.systemui.power.domain.interactor.PowerInteractorFactory -import com.android.systemui.scene.domain.interactor.sceneInteractor -import com.android.systemui.shade.data.repository.FakeShadeRepository -import com.android.systemui.statusbar.CommandQueue -import com.android.systemui.statusbar.data.repository.FakeKeyguardStatusBarRepository -import com.android.systemui.statusbar.domain.interactor.KeyguardStatusBarInteractor -import com.android.systemui.statusbar.notification.stack.domain.interactor.sharedNotificationContainerInteractor +import com.android.systemui.statusbar.domain.interactor.keyguardStatusBarInteractor import com.android.systemui.statusbar.policy.BatteryController +import com.android.systemui.statusbar.policy.batteryController import com.android.systemui.testKosmos import com.android.systemui.util.mockito.argumentCaptor import com.android.systemui.util.mockito.capture -import com.android.systemui.util.mockito.mock import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.launchIn 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.Mockito.verify +import platform.test.runner.parameterized.ParameterizedAndroidJunit4 +import platform.test.runner.parameterized.Parameters @SmallTest @OptIn(ExperimentalCoroutinesApi::class) -class KeyguardStatusBarViewModelTest : SysuiTestCase() { +@RunWith(ParameterizedAndroidJunit4::class) +class KeyguardStatusBarViewModelTest(flags: FlagsParameterization?) : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope - private val keyguardRepository = FakeKeyguardRepository() - private val keyguardInteractor = - KeyguardInteractor( - keyguardRepository, - mock<CommandQueue>(), - PowerInteractorFactory.create().powerInteractor, - FakeKeyguardBouncerRepository(), - ConfigurationInteractor(FakeConfigurationRepository()), - FakeShadeRepository(), - kosmos.keyguardTransitionInteractor, - { kosmos.sceneInteractor }, - { kosmos.fromGoneTransitionInteractor }, - { kosmos.sharedNotificationContainerInteractor }, - testScope, - ) - private val keyguardStatusBarInteractor = - KeyguardStatusBarInteractor( - FakeKeyguardStatusBarRepository(), - ) - private val batteryController = mock<BatteryController>() - - private val underTest = - KeyguardStatusBarViewModel( - testScope.backgroundScope, - keyguardInteractor, - keyguardStatusBarInteractor, - batteryController, - ) + private val keyguardRepository by lazy { kosmos.fakeKeyguardRepository } + private val keyguardInteractor by lazy { kosmos.keyguardInteractor } + private val keyguardStatusBarInteractor by lazy { kosmos.keyguardStatusBarInteractor } + private val batteryController = kosmos.batteryController + + lateinit var underTest: KeyguardStatusBarViewModel + + companion object { + @JvmStatic + @Parameters(name = "{0}") + fun getParams(): List<FlagsParameterization> { + return FlagsParameterization.allCombinationsOf().andSceneContainer() + } + } + + init { + mSetFlagsRule.setFlagsParameterization(flags!!) + } + + @Before + fun setup() { + underTest = + KeyguardStatusBarViewModel( + testScope.backgroundScope, + keyguardInteractor, + keyguardStatusBarInteractor, + batteryController, + ) + } @Test fun isVisible_dozing_false() = diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/data/repository/KeyguardStatusBarRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/data/repository/KeyguardStatusBarRepositoryKosmos.kt new file mode 100644 index 000000000000..da95ee90dade --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/data/repository/KeyguardStatusBarRepositoryKosmos.kt @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.data.repository + +import com.android.systemui.kosmos.Kosmos + +val Kosmos.keyguardStatusBarRepository: FakeKeyguardStatusBarRepository by + Kosmos.Fixture { fakeKeyguardStatusBarRepository } + +val Kosmos.fakeKeyguardStatusBarRepository: FakeKeyguardStatusBarRepository by + Kosmos.Fixture { FakeKeyguardStatusBarRepository() } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/domain/interactor/KeyguardStatusBarInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/domain/interactor/KeyguardStatusBarInteractorKosmos.kt new file mode 100644 index 000000000000..71ed5f696906 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/domain/interactor/KeyguardStatusBarInteractorKosmos.kt @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.domain.interactor + +import com.android.systemui.kosmos.Kosmos +import com.android.systemui.statusbar.data.repository.keyguardStatusBarRepository + +val Kosmos.keyguardStatusBarInteractor: KeyguardStatusBarInteractor by + Kosmos.Fixture { + KeyguardStatusBarInteractor( + keyguardStatusBarRepository, + ) + } |