Loading packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt +15 −10 Original line number Diff line number Diff line Loading @@ -47,16 +47,20 @@ import com.android.systemui.classifier.FalsingA11yDelegate import com.android.systemui.classifier.FalsingCollector import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.flags.FakeFeatureFlags import com.android.systemui.flags.Flags import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.log.SessionTracker import com.android.systemui.plugins.ActivityStarter.OnDismissAction import com.android.systemui.plugins.FalsingManager import com.android.systemui.res.R import com.android.systemui.scene.SceneTestUtils import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags import com.android.systemui.scene.shared.model.ObservableTransitionState import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.SceneModel Loading @@ -66,6 +70,7 @@ import com.android.systemui.statusbar.policy.DevicePostureController import com.android.systemui.statusbar.policy.DeviceProvisionedController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.statusbar.policy.UserSwitcherController import com.android.systemui.testKosmos import com.android.systemui.user.domain.interactor.SelectedUserInteractor import com.android.systemui.util.kotlin.JavaAdapter import com.android.systemui.util.mockito.any Loading Loading @@ -156,7 +161,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { private lateinit var keyguardPasswordViewController: KeyguardPasswordViewController private lateinit var keyguardPasswordView: KeyguardPasswordView private lateinit var testableResources: TestableResources private lateinit var sceneTestUtils: SceneTestUtils private lateinit var kosmos: Kosmos private lateinit var sceneInteractor: SceneInteractor private lateinit var keyguardTransitionInteractor: KeyguardTransitionInteractor private lateinit var deviceEntryInteractor: DeviceEntryInteractor Loading Loading @@ -222,15 +227,15 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { mSelectedUserInteractor, ) sceneTestUtils = SceneTestUtils(this) sceneInteractor = sceneTestUtils.sceneInteractor() kosmos = testKosmos() sceneInteractor = kosmos.sceneInteractor keyguardTransitionInteractor = KeyguardTransitionInteractorFactory.create(sceneTestUtils.testScope.backgroundScope) KeyguardTransitionInteractorFactory.create(kosmos.testScope.backgroundScope) .keyguardTransitionInteractor sceneTransitionStateFlow = MutableStateFlow(ObservableTransitionState.Idle(SceneKey.Lockscreen)) sceneInteractor.setTransitionState(sceneTransitionStateFlow) deviceEntryInteractor = sceneTestUtils.deviceEntryInteractor() deviceEntryInteractor = kosmos.deviceEntryInteractor mSetFlagsRule.disableFlags(FLAG_SIDEFPS_CONTROLLER_REFACTOR) underTest = Loading @@ -249,7 +254,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { falsingManager, userSwitcherController, featureFlags, sceneTestUtils.fakeSceneContainerFlags, kosmos.fakeSceneContainerFlags, globalSettings, sessionTracker, Optional.of(sideFpsController), Loading @@ -259,7 +264,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { audioManager, faceAuthInteractor, mock(), { JavaAdapter(sceneTestUtils.testScope.backgroundScope) }, { JavaAdapter(kosmos.testScope.backgroundScope) }, mSelectedUserInteractor, deviceProvisionedController, faceAuthAccessibilityDelegate, Loading Loading @@ -786,8 +791,8 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { @Test fun dismissesKeyguard_whenSceneChangesToGone() = sceneTestUtils.testScope.runTest { sceneTestUtils.fakeSceneContainerFlags.enabled = true kosmos.testScope.runTest { kosmos.fakeSceneContainerFlags.enabled = true // Upon init, we have never dismisses the keyguard. underTest.onInit() runCurrent() Loading packages/SystemUI/multivalentTests/src/com/android/systemui/authentication/data/repository/AuthenticationRepositoryTest.kt +8 −5 Original line number Diff line number Diff line Loading @@ -29,10 +29,13 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.log.table.TableLogBuffer import com.android.systemui.scene.SceneTestUtils import com.android.systemui.scene.shared.flag.sceneContainerFlags import com.android.systemui.statusbar.pipeline.mobile.data.repository.FakeMobileConnectionsRepository import com.android.systemui.statusbar.pipeline.mobile.util.FakeMobileMappingsProxy import com.android.systemui.testKosmos import com.android.systemui.user.data.repository.FakeUserRepository import com.android.systemui.util.mockito.whenever import com.android.systemui.util.time.FakeSystemClock Loading @@ -59,8 +62,8 @@ class AuthenticationRepositoryTest : SysuiTestCase() { @Mock private lateinit var tableLogger: TableLogBuffer @Mock private lateinit var devicePolicyManager: DevicePolicyManager private val testUtils = SceneTestUtils(this) private val testScope = testUtils.testScope private val kosmos = testKosmos() private val testScope = kosmos.testScope private val clock = FakeSystemClock() private val userRepository = FakeUserRepository() private lateinit var mobileConnectionsRepository: FakeMobileConnectionsRepository Loading @@ -82,8 +85,8 @@ class AuthenticationRepositoryTest : SysuiTestCase() { underTest = AuthenticationRepositoryImpl( applicationScope = testScope.backgroundScope, backgroundDispatcher = testUtils.testDispatcher, flags = testUtils.fakeSceneContainerFlags, backgroundDispatcher = kosmos.testDispatcher, flags = kosmos.sceneContainerFlags, clock = clock, getSecurityMode = getSecurityMode, userRepository = userRepository, Loading packages/SystemUI/multivalentTests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt +50 −43 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import androidx.test.filters.SmallTest import com.android.internal.widget.LockPatternUtils import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.shared.model.AuthenticationMethodModel.None import com.android.systemui.authentication.shared.model.AuthenticationMethodModel.Password import com.android.systemui.authentication.shared.model.AuthenticationMethodModel.Pattern Loading @@ -29,7 +30,8 @@ import com.android.systemui.authentication.shared.model.AuthenticationMethodMode import com.android.systemui.authentication.shared.model.AuthenticationPatternCoordinate import com.android.systemui.authentication.shared.model.AuthenticationWipeModel import com.android.systemui.coroutines.collectLastValue import com.android.systemui.scene.SceneTestUtils import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.ExperimentalCoroutinesApi Loading @@ -45,9 +47,9 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class AuthenticationInteractorTest : SysuiTestCase() { private val utils = SceneTestUtils(this) private val testScope = utils.testScope private val underTest = utils.authenticationInteractor() private val kosmos = testKosmos() private val testScope = kosmos.testScope private val underTest = kosmos.authenticationInteractor private val onAuthenticationResult by testScope.collectLastValue(underTest.onAuthenticationResult) Loading @@ -62,7 +64,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { assertThat(authMethod).isEqualTo(Pin) assertThat(underTest.getAuthenticationMethod()).isEqualTo(Pin) utils.authenticationRepository.setAuthenticationMethod(Password) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Password) assertThat(authMethod).isEqualTo(Password) assertThat(underTest.getAuthenticationMethod()).isEqualTo(Password) Loading @@ -74,7 +76,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { val authMethod by collectLastValue(underTest.authenticationMethod) runCurrent() utils.authenticationRepository.setAuthenticationMethod(None) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(None) assertThat(authMethod).isEqualTo(None) assertThat(underTest.getAuthenticationMethod()).isEqualTo(None) Loading @@ -83,7 +85,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withCorrectPin_succeeds() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) assertSucceeded(underTest.authenticate(FakeAuthenticationRepository.DEFAULT_PIN)) } Loading @@ -91,7 +93,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withIncorrectPin_fails() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) assertFailed(underTest.authenticate(listOf(9, 8, 7, 6, 5, 4))) } Loading @@ -99,7 +101,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test(expected = IllegalArgumentException::class) fun authenticate_withEmptyPin_throwsException() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) underTest.authenticate(listOf()) } Loading @@ -107,7 +109,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun authenticate_withCorrectMaxLengthPin_succeeds() = testScope.runTest { val correctMaxLengthPin = List(16) { 9 } utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) overrideCredential(correctMaxLengthPin) } Loading @@ -124,7 +126,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { // If the policy changes, there is work to do in SysUI. assertThat(DevicePolicyManager.MAX_PASSWORD_LENGTH).isLessThan(17) utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) assertFailed(underTest.authenticate(List(17) { 9 })) } Loading @@ -132,7 +134,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withCorrectPassword_succeeds() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Password) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Password) assertSucceeded(underTest.authenticate("password".toList())) } Loading @@ -140,7 +142,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withIncorrectPassword_fails() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Password) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Password) assertFailed(underTest.authenticate("alohomora".toList())) } Loading @@ -148,7 +150,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withCorrectPattern_succeeds() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pattern) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pattern) assertSucceeded(underTest.authenticate(FakeAuthenticationRepository.PATTERN)) } Loading @@ -156,7 +158,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withIncorrectPattern_fails() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pattern) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pattern) val wrongPattern = listOf( AuthenticationPatternCoordinate(x = 2, y = 0), Loading @@ -172,7 +174,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun tryAutoConfirm_withAutoConfirmPinAndShorterPin_returnsNull() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) } Loading @@ -182,14 +184,14 @@ class AuthenticationInteractorTest : SysuiTestCase() { assertSkipped(underTest.authenticate(shorterPin, tryAutoConfirm = true)) assertThat(underTest.lockoutEndTimestamp).isNull() assertThat(utils.authenticationRepository.lockoutStartedReportCount).isEqualTo(0) assertThat(kosmos.fakeAuthenticationRepository.lockoutStartedReportCount).isEqualTo(0) } @Test fun tryAutoConfirm_withAutoConfirmWrongPinCorrectLength_returnsFalse() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) } Loading @@ -207,7 +209,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun tryAutoConfirm_withAutoConfirmLongerPin_returnsFalse() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) } Loading @@ -225,7 +227,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun tryAutoConfirm_withAutoConfirmCorrectPin_returnsTrue() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) } Loading @@ -241,7 +243,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) val hintedPinLength by collectLastValue(underTest.hintedPinLength) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) reportLockoutStarted(42) Loading @@ -258,7 +260,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun tryAutoConfirm_withoutAutoConfirmButCorrectPin_returnsNull() = testScope.runTest { utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(false) } Loading @@ -271,7 +273,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun tryAutoConfirm_withoutCorrectPassword_returnsNull() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Password) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Password) assertSkipped(underTest.authenticate("password".toList(), tryAutoConfirm = true)) } Loading @@ -280,7 +282,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun isAutoConfirmEnabled_featureDisabled_returnsFalse() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.setAutoConfirmFeatureEnabled(false) kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(false) assertThat(isAutoConfirmEnabled).isFalse() } Loading @@ -289,7 +291,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun isAutoConfirmEnabled_featureEnabled_returnsTrue() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.setAutoConfirmFeatureEnabled(true) kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true) assertThat(isAutoConfirmEnabled).isTrue() } Loading @@ -298,7 +300,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun isAutoConfirmEnabled_featureEnabledButDisabledByLockout() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.setAutoConfirmFeatureEnabled(true) kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true) // The feature is enabled. assertThat(isAutoConfirmEnabled).isTrue() Loading @@ -308,7 +310,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { assertFailed(underTest.authenticate(listOf(5, 6, 7))) // Wrong PIN } assertThat(underTest.lockoutEndTimestamp).isNotNull() assertThat(utils.authenticationRepository.lockoutStartedReportCount).isEqualTo(1) assertThat(kosmos.fakeAuthenticationRepository.lockoutStartedReportCount).isEqualTo(1) // Lockout disabled auto-confirm. assertThat(isAutoConfirmEnabled).isFalse() Loading Loading @@ -336,7 +338,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { val failedAuthenticationAttempts by collectLastValue(underTest.failedAuthenticationAttempts) utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) val correctPin = FakeAuthenticationRepository.DEFAULT_PIN assertSucceeded(underTest.authenticate(correctPin)) Loading Loading @@ -366,7 +368,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun lockoutEndTimestamp() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) val correctPin = FakeAuthenticationRepository.DEFAULT_PIN underTest.authenticate(correctPin) Loading @@ -384,7 +386,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { val expectedLockoutEndTimestamp = testScope.currentTime + FakeAuthenticationRepository.LOCKOUT_DURATION_MS assertThat(underTest.lockoutEndTimestamp).isEqualTo(expectedLockoutEndTimestamp) assertThat(utils.authenticationRepository.lockoutStartedReportCount).isEqualTo(1) assertThat(kosmos.fakeAuthenticationRepository.lockoutStartedReportCount).isEqualTo(1) // Correct PIN, but locked out, so doesn't attempt it: assertSkipped(underTest.authenticate(correctPin), assertNoResultEvents = false) Loading @@ -409,7 +411,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun upcomingWipe() = testScope.runTest { val upcomingWipe by collectLastValue(underTest.upcomingWipe) utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) val correctPin = FakeAuthenticationRepository.DEFAULT_PIN val wrongPin = FakeAuthenticationRepository.DEFAULT_PIN.map { it + 1 } Loading @@ -418,7 +420,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { var expectedFailedAttempts = 0 var remainingFailedAttempts = utils.authenticationRepository.getMaxFailedUnlockAttemptsForWipe() kosmos.fakeAuthenticationRepository.getMaxFailedUnlockAttemptsForWipe() assertThat(remainingFailedAttempts) .isGreaterThan(LockPatternUtils.FAILED_ATTEMPTS_BEFORE_WIPE_GRACE) Loading Loading @@ -458,7 +460,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun hintedPinLength_withoutAutoConfirm_isNull() = testScope.runTest { val hintedPinLength by collectLastValue(underTest.hintedPinLength) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(false) } Loading @@ -470,11 +472,13 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun hintedPinLength_withAutoConfirmPinTooShort_isNull() = testScope.runTest { val hintedPinLength by collectLastValue(underTest.hintedPinLength) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) overrideCredential( buildList { repeat(utils.authenticationRepository.hintedPinLength - 1) { add(it + 1) } repeat(kosmos.fakeAuthenticationRepository.hintedPinLength - 1) { add(it + 1) } } ) setAutoConfirmFeatureEnabled(true) Loading @@ -487,28 +491,31 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun hintedPinLength_withAutoConfirmPinAtRightLength_isSameLength() = testScope.runTest { val hintedPinLength by collectLastValue(underTest.hintedPinLength) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) overrideCredential( buildList { repeat(utils.authenticationRepository.hintedPinLength) { add(it + 1) } repeat(kosmos.fakeAuthenticationRepository.hintedPinLength) { add(it + 1) } } ) } assertThat(hintedPinLength).isEqualTo(utils.authenticationRepository.hintedPinLength) assertThat(hintedPinLength) .isEqualTo(kosmos.fakeAuthenticationRepository.hintedPinLength) } @Test fun hintedPinLength_withAutoConfirmPinTooLong_isNull() = testScope.runTest { val hintedPinLength by collectLastValue(underTest.hintedPinLength) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) overrideCredential( buildList { repeat(utils.authenticationRepository.hintedPinLength + 1) { add(it + 1) } repeat(kosmos.fakeAuthenticationRepository.hintedPinLength + 1) { add(it + 1) } } ) setAutoConfirmFeatureEnabled(true) Loading @@ -520,10 +527,10 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withTooShortPassword() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Password) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Password) val tooShortPassword = buildList { repeat(utils.authenticationRepository.minPasswordLength - 1) { time -> repeat(kosmos.fakeAuthenticationRepository.minPasswordLength - 1) { time -> add("$time") } } Loading @@ -534,7 +541,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { assertThat(authenticationResult).isEqualTo(AuthenticationResult.SUCCEEDED) assertThat(onAuthenticationResult).isTrue() assertThat(underTest.lockoutEndTimestamp).isNull() assertThat(utils.authenticationRepository.lockoutStartedReportCount).isEqualTo(0) assertThat(kosmos.fakeAuthenticationRepository.lockoutStartedReportCount).isEqualTo(0) assertThat(failedAuthenticationAttempts).isEqualTo(0) } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/data/repository/EmergencyServicesRepositoryImplTest.kt +8 −5 Original line number Diff line number Diff line Loading @@ -20,8 +20,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.R import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.configurationRepository import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.scene.SceneTestUtils import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestScope Loading @@ -36,8 +39,8 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class EmergencyServicesRepositoryImplTest : SysuiTestCase() { private val utils = SceneTestUtils(this) private val testScope = utils.testScope private val kosmos = testKosmos() private val testScope = kosmos.testScope private lateinit var underTest: EmergencyServicesRepository Loading @@ -52,7 +55,7 @@ class EmergencyServicesRepositoryImplTest : SysuiTestCase() { EmergencyServicesRepository( resources = context.resources, applicationScope = testScope.backgroundScope, configurationRepository = utils.configurationRepository, configurationRepository = kosmos.configurationRepository, ) } Loading @@ -71,7 +74,7 @@ class EmergencyServicesRepositoryImplTest : SysuiTestCase() { private fun TestScope.setEmergencyCallWhileSimLocked(isEnabled: Boolean) { overrideResource(R.bool.config_enable_emergency_call_while_sim_locked, isEnabled) utils.configurationRepository.onConfigurationChange() kosmos.fakeConfigurationRepository.onConfigurationChange() runCurrent() } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/domain/interactor/BouncerActionButtonInteractorTest.kt +45 −30 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt +15 −10 Original line number Diff line number Diff line Loading @@ -47,16 +47,20 @@ import com.android.systemui.classifier.FalsingA11yDelegate import com.android.systemui.classifier.FalsingCollector import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.flags.FakeFeatureFlags import com.android.systemui.flags.Flags import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.log.SessionTracker import com.android.systemui.plugins.ActivityStarter.OnDismissAction import com.android.systemui.plugins.FalsingManager import com.android.systemui.res.R import com.android.systemui.scene.SceneTestUtils import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags import com.android.systemui.scene.shared.model.ObservableTransitionState import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.SceneModel Loading @@ -66,6 +70,7 @@ import com.android.systemui.statusbar.policy.DevicePostureController import com.android.systemui.statusbar.policy.DeviceProvisionedController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.statusbar.policy.UserSwitcherController import com.android.systemui.testKosmos import com.android.systemui.user.domain.interactor.SelectedUserInteractor import com.android.systemui.util.kotlin.JavaAdapter import com.android.systemui.util.mockito.any Loading Loading @@ -156,7 +161,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { private lateinit var keyguardPasswordViewController: KeyguardPasswordViewController private lateinit var keyguardPasswordView: KeyguardPasswordView private lateinit var testableResources: TestableResources private lateinit var sceneTestUtils: SceneTestUtils private lateinit var kosmos: Kosmos private lateinit var sceneInteractor: SceneInteractor private lateinit var keyguardTransitionInteractor: KeyguardTransitionInteractor private lateinit var deviceEntryInteractor: DeviceEntryInteractor Loading Loading @@ -222,15 +227,15 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { mSelectedUserInteractor, ) sceneTestUtils = SceneTestUtils(this) sceneInteractor = sceneTestUtils.sceneInteractor() kosmos = testKosmos() sceneInteractor = kosmos.sceneInteractor keyguardTransitionInteractor = KeyguardTransitionInteractorFactory.create(sceneTestUtils.testScope.backgroundScope) KeyguardTransitionInteractorFactory.create(kosmos.testScope.backgroundScope) .keyguardTransitionInteractor sceneTransitionStateFlow = MutableStateFlow(ObservableTransitionState.Idle(SceneKey.Lockscreen)) sceneInteractor.setTransitionState(sceneTransitionStateFlow) deviceEntryInteractor = sceneTestUtils.deviceEntryInteractor() deviceEntryInteractor = kosmos.deviceEntryInteractor mSetFlagsRule.disableFlags(FLAG_SIDEFPS_CONTROLLER_REFACTOR) underTest = Loading @@ -249,7 +254,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { falsingManager, userSwitcherController, featureFlags, sceneTestUtils.fakeSceneContainerFlags, kosmos.fakeSceneContainerFlags, globalSettings, sessionTracker, Optional.of(sideFpsController), Loading @@ -259,7 +264,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { audioManager, faceAuthInteractor, mock(), { JavaAdapter(sceneTestUtils.testScope.backgroundScope) }, { JavaAdapter(kosmos.testScope.backgroundScope) }, mSelectedUserInteractor, deviceProvisionedController, faceAuthAccessibilityDelegate, Loading Loading @@ -786,8 +791,8 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { @Test fun dismissesKeyguard_whenSceneChangesToGone() = sceneTestUtils.testScope.runTest { sceneTestUtils.fakeSceneContainerFlags.enabled = true kosmos.testScope.runTest { kosmos.fakeSceneContainerFlags.enabled = true // Upon init, we have never dismisses the keyguard. underTest.onInit() runCurrent() Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/authentication/data/repository/AuthenticationRepositoryTest.kt +8 −5 Original line number Diff line number Diff line Loading @@ -29,10 +29,13 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testScope import com.android.systemui.log.table.TableLogBuffer import com.android.systemui.scene.SceneTestUtils import com.android.systemui.scene.shared.flag.sceneContainerFlags import com.android.systemui.statusbar.pipeline.mobile.data.repository.FakeMobileConnectionsRepository import com.android.systemui.statusbar.pipeline.mobile.util.FakeMobileMappingsProxy import com.android.systemui.testKosmos import com.android.systemui.user.data.repository.FakeUserRepository import com.android.systemui.util.mockito.whenever import com.android.systemui.util.time.FakeSystemClock Loading @@ -59,8 +62,8 @@ class AuthenticationRepositoryTest : SysuiTestCase() { @Mock private lateinit var tableLogger: TableLogBuffer @Mock private lateinit var devicePolicyManager: DevicePolicyManager private val testUtils = SceneTestUtils(this) private val testScope = testUtils.testScope private val kosmos = testKosmos() private val testScope = kosmos.testScope private val clock = FakeSystemClock() private val userRepository = FakeUserRepository() private lateinit var mobileConnectionsRepository: FakeMobileConnectionsRepository Loading @@ -82,8 +85,8 @@ class AuthenticationRepositoryTest : SysuiTestCase() { underTest = AuthenticationRepositoryImpl( applicationScope = testScope.backgroundScope, backgroundDispatcher = testUtils.testDispatcher, flags = testUtils.fakeSceneContainerFlags, backgroundDispatcher = kosmos.testDispatcher, flags = kosmos.sceneContainerFlags, clock = clock, getSecurityMode = getSecurityMode, userRepository = userRepository, Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt +50 −43 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import androidx.test.filters.SmallTest import com.android.internal.widget.LockPatternUtils import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.shared.model.AuthenticationMethodModel.None import com.android.systemui.authentication.shared.model.AuthenticationMethodModel.Password import com.android.systemui.authentication.shared.model.AuthenticationMethodModel.Pattern Loading @@ -29,7 +30,8 @@ import com.android.systemui.authentication.shared.model.AuthenticationMethodMode import com.android.systemui.authentication.shared.model.AuthenticationPatternCoordinate import com.android.systemui.authentication.shared.model.AuthenticationWipeModel import com.android.systemui.coroutines.collectLastValue import com.android.systemui.scene.SceneTestUtils import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.ExperimentalCoroutinesApi Loading @@ -45,9 +47,9 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class AuthenticationInteractorTest : SysuiTestCase() { private val utils = SceneTestUtils(this) private val testScope = utils.testScope private val underTest = utils.authenticationInteractor() private val kosmos = testKosmos() private val testScope = kosmos.testScope private val underTest = kosmos.authenticationInteractor private val onAuthenticationResult by testScope.collectLastValue(underTest.onAuthenticationResult) Loading @@ -62,7 +64,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { assertThat(authMethod).isEqualTo(Pin) assertThat(underTest.getAuthenticationMethod()).isEqualTo(Pin) utils.authenticationRepository.setAuthenticationMethod(Password) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Password) assertThat(authMethod).isEqualTo(Password) assertThat(underTest.getAuthenticationMethod()).isEqualTo(Password) Loading @@ -74,7 +76,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { val authMethod by collectLastValue(underTest.authenticationMethod) runCurrent() utils.authenticationRepository.setAuthenticationMethod(None) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(None) assertThat(authMethod).isEqualTo(None) assertThat(underTest.getAuthenticationMethod()).isEqualTo(None) Loading @@ -83,7 +85,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withCorrectPin_succeeds() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) assertSucceeded(underTest.authenticate(FakeAuthenticationRepository.DEFAULT_PIN)) } Loading @@ -91,7 +93,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withIncorrectPin_fails() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) assertFailed(underTest.authenticate(listOf(9, 8, 7, 6, 5, 4))) } Loading @@ -99,7 +101,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test(expected = IllegalArgumentException::class) fun authenticate_withEmptyPin_throwsException() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) underTest.authenticate(listOf()) } Loading @@ -107,7 +109,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun authenticate_withCorrectMaxLengthPin_succeeds() = testScope.runTest { val correctMaxLengthPin = List(16) { 9 } utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) overrideCredential(correctMaxLengthPin) } Loading @@ -124,7 +126,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { // If the policy changes, there is work to do in SysUI. assertThat(DevicePolicyManager.MAX_PASSWORD_LENGTH).isLessThan(17) utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) assertFailed(underTest.authenticate(List(17) { 9 })) } Loading @@ -132,7 +134,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withCorrectPassword_succeeds() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Password) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Password) assertSucceeded(underTest.authenticate("password".toList())) } Loading @@ -140,7 +142,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withIncorrectPassword_fails() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Password) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Password) assertFailed(underTest.authenticate("alohomora".toList())) } Loading @@ -148,7 +150,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withCorrectPattern_succeeds() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pattern) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pattern) assertSucceeded(underTest.authenticate(FakeAuthenticationRepository.PATTERN)) } Loading @@ -156,7 +158,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withIncorrectPattern_fails() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pattern) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pattern) val wrongPattern = listOf( AuthenticationPatternCoordinate(x = 2, y = 0), Loading @@ -172,7 +174,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun tryAutoConfirm_withAutoConfirmPinAndShorterPin_returnsNull() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) } Loading @@ -182,14 +184,14 @@ class AuthenticationInteractorTest : SysuiTestCase() { assertSkipped(underTest.authenticate(shorterPin, tryAutoConfirm = true)) assertThat(underTest.lockoutEndTimestamp).isNull() assertThat(utils.authenticationRepository.lockoutStartedReportCount).isEqualTo(0) assertThat(kosmos.fakeAuthenticationRepository.lockoutStartedReportCount).isEqualTo(0) } @Test fun tryAutoConfirm_withAutoConfirmWrongPinCorrectLength_returnsFalse() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) } Loading @@ -207,7 +209,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun tryAutoConfirm_withAutoConfirmLongerPin_returnsFalse() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) } Loading @@ -225,7 +227,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun tryAutoConfirm_withAutoConfirmCorrectPin_returnsTrue() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) } Loading @@ -241,7 +243,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) val hintedPinLength by collectLastValue(underTest.hintedPinLength) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) reportLockoutStarted(42) Loading @@ -258,7 +260,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun tryAutoConfirm_withoutAutoConfirmButCorrectPin_returnsNull() = testScope.runTest { utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(false) } Loading @@ -271,7 +273,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun tryAutoConfirm_withoutCorrectPassword_returnsNull() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Password) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Password) assertSkipped(underTest.authenticate("password".toList(), tryAutoConfirm = true)) } Loading @@ -280,7 +282,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun isAutoConfirmEnabled_featureDisabled_returnsFalse() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.setAutoConfirmFeatureEnabled(false) kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(false) assertThat(isAutoConfirmEnabled).isFalse() } Loading @@ -289,7 +291,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun isAutoConfirmEnabled_featureEnabled_returnsTrue() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.setAutoConfirmFeatureEnabled(true) kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true) assertThat(isAutoConfirmEnabled).isTrue() } Loading @@ -298,7 +300,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun isAutoConfirmEnabled_featureEnabledButDisabledByLockout() = testScope.runTest { val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled) utils.authenticationRepository.setAutoConfirmFeatureEnabled(true) kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true) // The feature is enabled. assertThat(isAutoConfirmEnabled).isTrue() Loading @@ -308,7 +310,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { assertFailed(underTest.authenticate(listOf(5, 6, 7))) // Wrong PIN } assertThat(underTest.lockoutEndTimestamp).isNotNull() assertThat(utils.authenticationRepository.lockoutStartedReportCount).isEqualTo(1) assertThat(kosmos.fakeAuthenticationRepository.lockoutStartedReportCount).isEqualTo(1) // Lockout disabled auto-confirm. assertThat(isAutoConfirmEnabled).isFalse() Loading Loading @@ -336,7 +338,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { val failedAuthenticationAttempts by collectLastValue(underTest.failedAuthenticationAttempts) utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) val correctPin = FakeAuthenticationRepository.DEFAULT_PIN assertSucceeded(underTest.authenticate(correctPin)) Loading Loading @@ -366,7 +368,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun lockoutEndTimestamp() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) val correctPin = FakeAuthenticationRepository.DEFAULT_PIN underTest.authenticate(correctPin) Loading @@ -384,7 +386,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { val expectedLockoutEndTimestamp = testScope.currentTime + FakeAuthenticationRepository.LOCKOUT_DURATION_MS assertThat(underTest.lockoutEndTimestamp).isEqualTo(expectedLockoutEndTimestamp) assertThat(utils.authenticationRepository.lockoutStartedReportCount).isEqualTo(1) assertThat(kosmos.fakeAuthenticationRepository.lockoutStartedReportCount).isEqualTo(1) // Correct PIN, but locked out, so doesn't attempt it: assertSkipped(underTest.authenticate(correctPin), assertNoResultEvents = false) Loading @@ -409,7 +411,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun upcomingWipe() = testScope.runTest { val upcomingWipe by collectLastValue(underTest.upcomingWipe) utils.authenticationRepository.setAuthenticationMethod(Pin) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin) val correctPin = FakeAuthenticationRepository.DEFAULT_PIN val wrongPin = FakeAuthenticationRepository.DEFAULT_PIN.map { it + 1 } Loading @@ -418,7 +420,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { var expectedFailedAttempts = 0 var remainingFailedAttempts = utils.authenticationRepository.getMaxFailedUnlockAttemptsForWipe() kosmos.fakeAuthenticationRepository.getMaxFailedUnlockAttemptsForWipe() assertThat(remainingFailedAttempts) .isGreaterThan(LockPatternUtils.FAILED_ATTEMPTS_BEFORE_WIPE_GRACE) Loading Loading @@ -458,7 +460,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun hintedPinLength_withoutAutoConfirm_isNull() = testScope.runTest { val hintedPinLength by collectLastValue(underTest.hintedPinLength) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(false) } Loading @@ -470,11 +472,13 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun hintedPinLength_withAutoConfirmPinTooShort_isNull() = testScope.runTest { val hintedPinLength by collectLastValue(underTest.hintedPinLength) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) overrideCredential( buildList { repeat(utils.authenticationRepository.hintedPinLength - 1) { add(it + 1) } repeat(kosmos.fakeAuthenticationRepository.hintedPinLength - 1) { add(it + 1) } } ) setAutoConfirmFeatureEnabled(true) Loading @@ -487,28 +491,31 @@ class AuthenticationInteractorTest : SysuiTestCase() { fun hintedPinLength_withAutoConfirmPinAtRightLength_isSameLength() = testScope.runTest { val hintedPinLength by collectLastValue(underTest.hintedPinLength) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) setAutoConfirmFeatureEnabled(true) overrideCredential( buildList { repeat(utils.authenticationRepository.hintedPinLength) { add(it + 1) } repeat(kosmos.fakeAuthenticationRepository.hintedPinLength) { add(it + 1) } } ) } assertThat(hintedPinLength).isEqualTo(utils.authenticationRepository.hintedPinLength) assertThat(hintedPinLength) .isEqualTo(kosmos.fakeAuthenticationRepository.hintedPinLength) } @Test fun hintedPinLength_withAutoConfirmPinTooLong_isNull() = testScope.runTest { val hintedPinLength by collectLastValue(underTest.hintedPinLength) utils.authenticationRepository.apply { kosmos.fakeAuthenticationRepository.apply { setAuthenticationMethod(Pin) overrideCredential( buildList { repeat(utils.authenticationRepository.hintedPinLength + 1) { add(it + 1) } repeat(kosmos.fakeAuthenticationRepository.hintedPinLength + 1) { add(it + 1) } } ) setAutoConfirmFeatureEnabled(true) Loading @@ -520,10 +527,10 @@ class AuthenticationInteractorTest : SysuiTestCase() { @Test fun authenticate_withTooShortPassword() = testScope.runTest { utils.authenticationRepository.setAuthenticationMethod(Password) kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Password) val tooShortPassword = buildList { repeat(utils.authenticationRepository.minPasswordLength - 1) { time -> repeat(kosmos.fakeAuthenticationRepository.minPasswordLength - 1) { time -> add("$time") } } Loading @@ -534,7 +541,7 @@ class AuthenticationInteractorTest : SysuiTestCase() { assertThat(authenticationResult).isEqualTo(AuthenticationResult.SUCCEEDED) assertThat(onAuthenticationResult).isTrue() assertThat(underTest.lockoutEndTimestamp).isNull() assertThat(utils.authenticationRepository.lockoutStartedReportCount).isEqualTo(0) assertThat(kosmos.fakeAuthenticationRepository.lockoutStartedReportCount).isEqualTo(0) assertThat(failedAuthenticationAttempts).isEqualTo(0) } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/data/repository/EmergencyServicesRepositoryImplTest.kt +8 −5 Original line number Diff line number Diff line Loading @@ -20,8 +20,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.R import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.configurationRepository import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.coroutines.collectLastValue import com.android.systemui.scene.SceneTestUtils import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestScope Loading @@ -36,8 +39,8 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class EmergencyServicesRepositoryImplTest : SysuiTestCase() { private val utils = SceneTestUtils(this) private val testScope = utils.testScope private val kosmos = testKosmos() private val testScope = kosmos.testScope private lateinit var underTest: EmergencyServicesRepository Loading @@ -52,7 +55,7 @@ class EmergencyServicesRepositoryImplTest : SysuiTestCase() { EmergencyServicesRepository( resources = context.resources, applicationScope = testScope.backgroundScope, configurationRepository = utils.configurationRepository, configurationRepository = kosmos.configurationRepository, ) } Loading @@ -71,7 +74,7 @@ class EmergencyServicesRepositoryImplTest : SysuiTestCase() { private fun TestScope.setEmergencyCallWhileSimLocked(isEnabled: Boolean) { overrideResource(R.bool.config_enable_emergency_call_while_sim_locked, isEnabled) utils.configurationRepository.onConfigurationChange() kosmos.fakeConfigurationRepository.onConfigurationChange() runCurrent() } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/domain/interactor/BouncerActionButtonInteractorTest.kt +45 −30 File changed.Preview size limit exceeded, changes collapsed. Show changes