diff options
28 files changed, 304 insertions, 619 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt index c82688c2772a..5f932f452751 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt @@ -52,7 +52,7 @@ 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.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.log.SessionTracker @@ -236,9 +236,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { kosmos = testKosmos() sceneInteractor = kosmos.sceneInteractor - keyguardTransitionInteractor = - KeyguardTransitionInteractorFactory.create(kosmos.testScope.backgroundScope) - .keyguardTransitionInteractor + keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor sceneTransitionStateFlow = MutableStateFlow(ObservableTransitionState.Idle(SceneKey.Lockscreen)) sceneInteractor.setTransitionState(sceneTransitionStateFlow) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsKeyguardViewLegacyControllerWithCoroutinesTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsKeyguardViewLegacyControllerWithCoroutinesTest.kt index 0e257bcfecc3..55cfcc2c6d5b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsKeyguardViewLegacyControllerWithCoroutinesTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsKeyguardViewLegacyControllerWithCoroutinesTest.kt @@ -16,44 +16,27 @@ package com.android.systemui.biometrics -import android.os.Handler import android.testing.TestableLooper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.keyguard.KeyguardSecurityModel import com.android.systemui.biometrics.UdfpsKeyguardViewLegacy.ANIMATE_APPEAR_ON_SCREEN_OFF import com.android.systemui.biometrics.UdfpsKeyguardViewLegacy.ANIMATION_BETWEEN_AOD_AND_LOCKSCREEN -import com.android.systemui.biometrics.data.repository.FakeFingerprintPropertyRepository -import com.android.systemui.biometrics.domain.interactor.UdfpsOverlayInteractor -import com.android.systemui.bouncer.data.repository.KeyguardBouncerRepository -import com.android.systemui.bouncer.data.repository.KeyguardBouncerRepositoryImpl -import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor -import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor -import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor +import com.android.systemui.biometrics.domain.interactor.udfpsOverlayInteractor +import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository +import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor +import com.android.systemui.bouncer.domain.interactor.primaryBouncerInteractor import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants -import com.android.systemui.bouncer.ui.BouncerView -import com.android.systemui.classifier.FalsingCollector import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor -import com.android.systemui.keyguard.DismissCallbackRegistry -import com.android.systemui.keyguard.data.repository.BiometricSettingsRepository -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository -import com.android.systemui.keyguard.data.repository.FakeTrustRepository -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory +import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository +import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep -import com.android.systemui.log.table.TableLogBuffer -import com.android.systemui.plugins.statusbar.StatusBarStateController +import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.StatusBarState -import com.android.systemui.statusbar.policy.KeyguardStateController -import com.android.systemui.user.domain.interactor.SelectedUserInteractor +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever -import com.android.systemui.util.time.FakeSystemClock -import com.android.systemui.util.time.SystemClock import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.test.StandardTestDispatcher -import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Assert.assertFalse @@ -64,9 +47,7 @@ import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.any import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.eq -import org.mockito.Mock import org.mockito.Mockito -import org.mockito.Mockito.mock import org.mockito.Mockito.never import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations @@ -77,70 +58,24 @@ import org.mockito.MockitoAnnotations @kotlinx.coroutines.ExperimentalCoroutinesApi class UdfpsKeyguardViewLegacyControllerWithCoroutinesTest : UdfpsKeyguardViewLegacyControllerBaseTest() { - private val testDispatcher = StandardTestDispatcher() - private val testScope = TestScope(testDispatcher) + private val kosmos = testKosmos() + private val testScope = kosmos.testScope - private lateinit var keyguardBouncerRepository: KeyguardBouncerRepository - private lateinit var transitionRepository: FakeKeyguardTransitionRepository - - @Mock private lateinit var bouncerLogger: TableLogBuffer + private val keyguardBouncerRepository = kosmos.fakeKeyguardBouncerRepository + private val transitionRepository = kosmos.fakeKeyguardTransitionRepository @Before override fun setUp() { allowTestableLooperAsMainThread() // repeatWhenAttached requires the main thread MockitoAnnotations.initMocks(this) - keyguardBouncerRepository = - KeyguardBouncerRepositoryImpl( - FakeSystemClock(), - testScope.backgroundScope, - bouncerLogger, - ) - transitionRepository = FakeKeyguardTransitionRepository() super.setUp() } override fun createUdfpsKeyguardViewController(): UdfpsKeyguardViewControllerLegacy { - mPrimaryBouncerInteractor = - PrimaryBouncerInteractor( - keyguardBouncerRepository, - mock(BouncerView::class.java), - mock(Handler::class.java), - mKeyguardStateController, - mock(KeyguardSecurityModel::class.java), - mock(PrimaryBouncerCallbackInteractor::class.java), - mock(FalsingCollector::class.java), - mock(DismissCallbackRegistry::class.java), - context, - mKeyguardUpdateMonitor, - FakeTrustRepository(), - testScope.backgroundScope, - mSelectedUserInteractor, - mock(DeviceEntryFaceAuthInteractor::class.java), - ) - mAlternateBouncerInteractor = - AlternateBouncerInteractor( - mock(StatusBarStateController::class.java), - mock(KeyguardStateController::class.java), - keyguardBouncerRepository, - FakeFingerprintPropertyRepository(), - mock(BiometricSettingsRepository::class.java), - mock(SystemClock::class.java), - mKeyguardUpdateMonitor, - testScope.backgroundScope, - ) - mKeyguardTransitionInteractor = - KeyguardTransitionInteractorFactory.create( - scope = testScope.backgroundScope, - repository = transitionRepository, - ) - .keyguardTransitionInteractor - mUdfpsOverlayInteractor = - UdfpsOverlayInteractor( - context, - mock(AuthController::class.java), - mock(SelectedUserInteractor::class.java), - testScope.backgroundScope, - ) + mPrimaryBouncerInteractor = kosmos.primaryBouncerInteractor + mAlternateBouncerInteractor = kosmos.alternateBouncerInteractor + mKeyguardTransitionInteractor = kosmos.keyguardTransitionInteractor + mUdfpsOverlayInteractor = kosmos.udfpsOverlayInteractor return createUdfpsKeyguardViewController(/* useModernBouncer */ true) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt index 6808f5d643a9..b611e0aafa2f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt @@ -37,16 +37,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.logging.InstanceId.fakeInstanceId import com.android.internal.logging.UiEventLogger -import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.Flags as AConfigFlags import com.android.systemui.SysuiTestCase -import com.android.systemui.biometrics.data.repository.FakeDisplayStateRepository -import com.android.systemui.biometrics.data.repository.FakeFacePropertyRepository -import com.android.systemui.biometrics.data.repository.FakeFingerprintPropertyRepository -import com.android.systemui.biometrics.domain.interactor.DisplayStateInteractor -import com.android.systemui.biometrics.domain.interactor.DisplayStateInteractorImpl -import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository -import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor +import com.android.systemui.biometrics.domain.interactor.displayStateInteractor +import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository +import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor import com.android.systemui.coroutines.FlowValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues @@ -59,52 +54,46 @@ import com.android.systemui.deviceentry.shared.model.FaceAuthenticationStatus import com.android.systemui.deviceentry.shared.model.FaceDetectionStatus import com.android.systemui.deviceentry.shared.model.HelpFaceAuthenticationStatus import com.android.systemui.deviceentry.shared.model.SuccessFaceAuthenticationStatus -import com.android.systemui.display.data.repository.FakeDisplayRepository import com.android.systemui.display.data.repository.display +import com.android.systemui.display.data.repository.displayRepository import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FakeFeatureFlags import com.android.systemui.keyguard.data.repository.BiometricType -import com.android.systemui.keyguard.data.repository.FakeBiometricSettingsRepository -import com.android.systemui.keyguard.data.repository.FakeCommandQueue -import com.android.systemui.keyguard.data.repository.FakeDeviceEntryFingerprintAuthRepository -import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository -import com.android.systemui.keyguard.data.repository.FakeTrustRepository -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory +import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository +import com.android.systemui.keyguard.data.repository.fakeCommandQueue +import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFingerprintAuthRepository +import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository +import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository +import com.android.systemui.keyguard.data.repository.fakeTrustRepository +import com.android.systemui.keyguard.domain.interactor.keyguardInteractor +import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep +import com.android.systemui.kosmos.testDispatcher +import com.android.systemui.kosmos.testScope import com.android.systemui.log.FaceAuthenticationLogger import com.android.systemui.log.SessionTracker import com.android.systemui.log.logcatLogBuffer import com.android.systemui.log.table.TableLogBuffer -import com.android.systemui.plugins.statusbar.StatusBarStateController -import com.android.systemui.power.data.repository.FakePowerRepository -import com.android.systemui.power.domain.interactor.PowerInteractor 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.PowerInteractorFactory +import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.res.R -import com.android.systemui.statusbar.phone.FakeKeyguardStateController +import com.android.systemui.statusbar.commandQueue import com.android.systemui.statusbar.phone.KeyguardBypassController +import com.android.systemui.testKosmos import com.android.systemui.user.data.model.SelectionStatus -import com.android.systemui.user.data.repository.FakeUserRepository -import com.android.systemui.util.concurrency.FakeExecutor +import com.android.systemui.user.data.repository.fakeUserRepository import com.android.systemui.util.mockito.KotlinArgumentCaptor import com.android.systemui.util.mockito.captureMany import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever import com.android.systemui.util.time.FakeSystemClock -import com.android.systemui.util.time.SystemClock import com.google.common.truth.Truth.assertThat import java.io.PrintWriter import java.io.StringWriter import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.StandardTestDispatcher -import kotlinx.coroutines.test.TestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runCurrent @@ -129,6 +118,7 @@ import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { + private val kosmos = testKosmos().apply { this.commandQueue = this.fakeCommandQueue } private lateinit var underTest: DeviceEntryFaceAuthRepositoryImpl @Mock private lateinit var faceManager: FaceManager @@ -136,7 +126,6 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { @Mock private lateinit var sessionTracker: SessionTracker @Mock private lateinit var uiEventLogger: UiEventLogger @Mock private lateinit var dumpManager: DumpManager - @Mock private lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor @Captor private lateinit var authenticationCallback: ArgumentCaptor<FaceManager.AuthenticationCallback> @@ -151,11 +140,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { @Captor private lateinit var faceLockoutResetCallback: ArgumentCaptor<FaceManager.LockoutResetCallback> - private lateinit var testDispatcher: TestDispatcher + private val testDispatcher = kosmos.testDispatcher - private lateinit var keyguardTransitionRepository: FakeKeyguardTransitionRepository - private lateinit var testScope: TestScope - private lateinit var fakeUserRepository: FakeUserRepository + private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository + private val testScope = kosmos.testScope + private val fakeUserRepository = kosmos.fakeUserRepository private lateinit var authStatus: FlowValue<FaceAuthenticationStatus?> private lateinit var detectStatus: FlowValue<FaceDetectionStatus?> private lateinit var authRunning: FlowValue<Boolean?> @@ -163,88 +152,30 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { private lateinit var lockedOut: FlowValue<Boolean?> private lateinit var canFaceAuthRun: FlowValue<Boolean?> private lateinit var authenticated: FlowValue<Boolean?> - private lateinit var biometricSettingsRepository: FakeBiometricSettingsRepository - private lateinit var deviceEntryFingerprintAuthRepository: - FakeDeviceEntryFingerprintAuthRepository - private lateinit var trustRepository: FakeTrustRepository - private lateinit var keyguardRepository: FakeKeyguardRepository - private lateinit var powerRepository: FakePowerRepository - private lateinit var powerInteractor: PowerInteractor - private lateinit var keyguardInteractor: KeyguardInteractor - private lateinit var alternateBouncerInteractor: AlternateBouncerInteractor - private lateinit var displayStateInteractor: DisplayStateInteractor - private lateinit var bouncerRepository: FakeKeyguardBouncerRepository - private lateinit var displayRepository: FakeDisplayRepository - private lateinit var fakeCommandQueue: FakeCommandQueue + private val biometricSettingsRepository = kosmos.fakeBiometricSettingsRepository + private val deviceEntryFingerprintAuthRepository = + kosmos.fakeDeviceEntryFingerprintAuthRepository + private val trustRepository = kosmos.fakeTrustRepository + private val keyguardRepository = kosmos.fakeKeyguardRepository + private val powerInteractor = kosmos.powerInteractor + private val keyguardInteractor = kosmos.keyguardInteractor + private val alternateBouncerInteractor = kosmos.alternateBouncerInteractor + private val displayStateInteractor = kosmos.displayStateInteractor + private val bouncerRepository = kosmos.fakeKeyguardBouncerRepository + private val displayRepository = kosmos.displayRepository + private val fakeCommandQueue = kosmos.fakeCommandQueue + private val keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor private lateinit var featureFlags: FakeFeatureFlags - private lateinit var fakeFacePropertyRepository: FakeFacePropertyRepository private var wasAuthCancelled = false private var wasDetectCancelled = false - private lateinit var keyguardTransitionInteractor: KeyguardTransitionInteractor - @Before fun setup() { MockitoAnnotations.initMocks(this) - testDispatcher = StandardTestDispatcher() - testScope = TestScope(testDispatcher) - fakeUserRepository = FakeUserRepository() fakeUserRepository.setUserInfos(listOf(primaryUser, secondaryUser)) - biometricSettingsRepository = FakeBiometricSettingsRepository() - deviceEntryFingerprintAuthRepository = FakeDeviceEntryFingerprintAuthRepository() - trustRepository = FakeTrustRepository() featureFlags = FakeFeatureFlags() - powerRepository = FakePowerRepository() - powerInteractor = - PowerInteractorFactory.create( - repository = powerRepository, - ) - .powerInteractor - - val withDeps = - KeyguardInteractorFactory.create( - featureFlags = featureFlags, - powerInteractor = powerInteractor, - ) - keyguardInteractor = withDeps.keyguardInteractor - keyguardRepository = withDeps.repository - bouncerRepository = withDeps.bouncerRepository - - keyguardTransitionRepository = FakeKeyguardTransitionRepository() - keyguardTransitionInteractor = - KeyguardTransitionInteractorFactory.create( - scope = testScope.backgroundScope, - repository = keyguardTransitionRepository, - keyguardInteractor = keyguardInteractor, - ) - .keyguardTransitionInteractor - - fakeCommandQueue = withDeps.commandQueue - - alternateBouncerInteractor = - AlternateBouncerInteractor( - bouncerRepository = bouncerRepository, - fingerprintPropertyRepository = FakeFingerprintPropertyRepository(), - biometricSettingsRepository = biometricSettingsRepository, - systemClock = mock(SystemClock::class.java), - keyguardStateController = FakeKeyguardStateController(), - statusBarStateController = mock(StatusBarStateController::class.java), - keyguardUpdateMonitor = keyguardUpdateMonitor, - scope = testScope.backgroundScope, - ) - - displayRepository = FakeDisplayRepository() - displayStateInteractor = - DisplayStateInteractorImpl( - applicationScope = testScope.backgroundScope, - context = context, - mainExecutor = FakeExecutor(FakeSystemClock()), - displayStateRepository = FakeDisplayStateRepository(), - displayRepository = displayRepository, - ) - bypassStateChangedListener = KotlinArgumentCaptor(KeyguardBypassController.OnBypassStateChangedListener::class.java) whenever(sessionTracker.getSessionId(SESSION_KEYGUARD)).thenReturn(keyguardSessionId) @@ -282,7 +213,6 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { testScope.backgroundScope ) - fakeFacePropertyRepository = FakeFacePropertyRepository() return DeviceEntryFaceAuthRepositoryImpl( mContext, fmOverride, diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorTest.kt index 98f0211587ea..9d34903d544d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorTest.kt @@ -18,23 +18,27 @@ package com.android.systemui.keyguard.domain.interactor import android.content.Intent +import android.view.accessibility.accessibilityManagerWrapper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.internal.logging.UiEventLogger +import com.android.internal.logging.testing.UiEventLoggerFake +import com.android.internal.logging.uiEventLogger import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.flags.FakeFeatureFlags import com.android.systemui.flags.Flags -import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository +import com.android.systemui.flags.fakeFeatureFlagsClassic +import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository +import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState +import com.android.systemui.kosmos.testScope import com.android.systemui.res.R import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper +import com.android.systemui.testKosmos +import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.advanceTimeBy import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -43,7 +47,6 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyInt -import org.mockito.Mock import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations @@ -51,27 +54,25 @@ import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) class KeyguardLongPressInteractorTest : SysuiTestCase() { - - @Mock private lateinit var logger: UiEventLogger - @Mock private lateinit var accessibilityManager: AccessibilityManagerWrapper + private val kosmos = + testKosmos().apply { + this.accessibilityManagerWrapper = mock<AccessibilityManagerWrapper>() + this.uiEventLogger = mock<UiEventLoggerFake>() + } private lateinit var underTest: KeyguardLongPressInteractor - private lateinit var testScope: TestScope - private lateinit var keyguardRepository: FakeKeyguardRepository - private lateinit var keyguardTransitionRepository: FakeKeyguardTransitionRepository + private val logger = kosmos.uiEventLogger + private val testScope = kosmos.testScope + private val keyguardRepository = kosmos.fakeKeyguardRepository + private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository @Before fun setUp() { MockitoAnnotations.initMocks(this) overrideResource(R.bool.long_press_keyguard_customize_lockscreen_enabled, true) - whenever(accessibilityManager.getRecommendedTimeoutMillis(anyInt(), anyInt())).thenAnswer { - it.arguments[0] - } - - testScope = TestScope() - keyguardRepository = FakeKeyguardRepository() - keyguardTransitionRepository = FakeKeyguardTransitionRepository() + whenever(kosmos.accessibilityManagerWrapper.getRecommendedTimeoutMillis(anyInt(), anyInt())) + .thenAnswer { it.arguments[0] } runBlocking { createUnderTest() } } @@ -284,25 +285,22 @@ class KeyguardLongPressInteractorTest : SysuiTestCase() { isRevampedWppFeatureEnabled: Boolean = true, isOpenWppDirectlyEnabled: Boolean = false, ) { + // This needs to be re-created for each test outside of kosmos since the flag values are + // read during initialization to set up flows. Maybe there is a better way to handle that. underTest = KeyguardLongPressInteractor( appContext = mContext, scope = testScope.backgroundScope, - transitionInteractor = - KeyguardTransitionInteractorFactory.create( - scope = testScope.backgroundScope, - repository = keyguardTransitionRepository, - ) - .keyguardTransitionInteractor, + transitionInteractor = kosmos.keyguardTransitionInteractor, repository = keyguardRepository, logger = logger, featureFlags = - FakeFeatureFlags().apply { + kosmos.fakeFeatureFlagsClassic.apply { set(Flags.LOCK_SCREEN_LONG_PRESS_ENABLED, isLongPressFeatureEnabled) set(Flags.LOCK_SCREEN_LONG_PRESS_DIRECT_TO_WPP, isOpenWppDirectlyEnabled) }, broadcastDispatcher = fakeBroadcastDispatcher, - accessibilityManager = accessibilityManager + accessibilityManager = kosmos.accessibilityManagerWrapper ) setUpState() } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractorTest.kt index ce43d4e14cc1..9b302ae60e21 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractorTest.kt @@ -19,23 +19,23 @@ package com.android.systemui.keyguard.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository +import com.android.systemui.keyguard.data.fakeLightRevealScrimRepository import com.android.systemui.keyguard.data.repository.FakeLightRevealScrimRepository +import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState 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.statusbar.LightRevealEffect import com.android.systemui.statusbar.LightRevealScrim -import com.android.systemui.util.mockito.mock +import com.android.systemui.testKosmos import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Assert.assertEquals -import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito @@ -43,29 +43,22 @@ import org.mockito.Mockito.anyBoolean import org.mockito.Mockito.never import org.mockito.Mockito.reset import org.mockito.Mockito.verify -import org.mockito.MockitoAnnotations @SmallTest @OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) class LightRevealScrimInteractorTest : SysuiTestCase() { - private val fakeKeyguardTransitionRepository = FakeKeyguardTransitionRepository() - - private val fakeLightRevealScrimRepository by lazy { - Mockito.spy(FakeLightRevealScrimRepository()) - } + val kosmos = + testKosmos().apply { + this.fakeLightRevealScrimRepository = Mockito.spy(FakeLightRevealScrimRepository()) + } - private val testScope = TestScope() + private val fakeLightRevealScrimRepository = kosmos.fakeLightRevealScrimRepository - private val keyguardTransitionInteractor by lazy { - KeyguardTransitionInteractorFactory.create( - scope = testScope.backgroundScope, - repository = fakeKeyguardTransitionRepository, - ) - .keyguardTransitionInteractor - } + private val fakeKeyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository + private val testScope = kosmos.testScope - private lateinit var underTest: LightRevealScrimInteractor + private val underTest = kosmos.lightRevealScrimInteractor private val reveal1 = object : LightRevealEffect { @@ -77,19 +70,6 @@ class LightRevealScrimInteractorTest : SysuiTestCase() { override fun setRevealAmountOnScrim(amount: Float, scrim: LightRevealScrim) {} } - @Before - fun setUp() { - MockitoAnnotations.initMocks(this) - underTest = - LightRevealScrimInteractor( - keyguardTransitionInteractor, - fakeLightRevealScrimRepository, - testScope.backgroundScope, - mock(), - mock() - ) - } - @Test fun lightRevealEffect_doesNotChangeDuringKeyguardTransition() = runTest(UnconfinedTestDispatcher()) { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt index 53c81e537708..e18e4637f676 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt @@ -109,7 +109,7 @@ const val UNLOCK_ANIMATION_DURATION_MS = 167L * This animation will take place entirely within the Launcher window. We can safely unlock the * device, end remote animations, etc. even if this is still running. */ -const val LAUNCHER_ICONS_ANIMATION_DURATION_MS = 633L +const val LAUNCHER_ICONS_ANIMATION_DURATION_MS = 1633L /** * How long to wait for the shade to get out of the way before starting the canned unlock animation. diff --git a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java index da6bfe84eee7..d742da743a12 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java @@ -47,7 +47,6 @@ import com.android.systemui.doze.util.BurnInHelperKt; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FakeFeatureFlags; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory; -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory; import com.android.systemui.kosmos.KosmosJavaAdapter; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; @@ -167,9 +166,7 @@ public class LockIconViewControllerBaseTest extends SysuiTestCase { mVibrator, mAuthRippleController, mResources, - KeyguardTransitionInteractorFactory.create( - TestScopeProvider.getTestScope().getBackgroundScope()) - .getKeyguardTransitionInteractor(), + mKosmos.getKeyguardTransitionInteractor(), KeyguardInteractorFactory.create(mFeatureFlags).getKeyguardInteractor(), mFeatureFlags, mPrimaryBouncerInteractor, diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractorImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractorImplTest.kt index fc3425567919..3f83ce371ffe 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractorImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/LogContextInteractorImplTest.kt @@ -26,7 +26,7 @@ import com.android.systemui.display.data.repository.DeviceStateRepository import com.android.systemui.display.data.repository.fakeDeviceStateRepository import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory +import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep @@ -47,7 +47,6 @@ import org.mockito.junit.MockitoJUnit @SmallTest @RunWith(JUnit4::class) class LogContextInteractorImplTest : SysuiTestCase() { - @JvmField @Rule var mockitoRule = MockitoJUnit.rule() private val kosmos = testKosmos() @@ -64,11 +63,7 @@ class LogContextInteractorImplTest : SysuiTestCase() { LogContextInteractorImpl( testScope.backgroundScope, deviceStateRepository, - KeyguardTransitionInteractorFactory.create( - repository = keyguardTransitionRepository, - scope = testScope.backgroundScope, - ) - .keyguardTransitionInteractor, + kosmos.keyguardTransitionInteractor, udfpsOverlayInteractor, ) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryFaceAuthInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryFaceAuthInteractorTest.kt index 368d1d983879..b28d0c802c18 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryFaceAuthInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryFaceAuthInteractorTest.kt @@ -16,71 +16,56 @@ package com.android.systemui.deviceentry.domain.interactor -import android.app.trust.TrustManager import android.content.pm.UserInfo import android.hardware.biometrics.BiometricFaceConstants import android.hardware.biometrics.BiometricSourceType -import android.os.Handler import android.os.PowerManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.keyguard.KeyguardSecurityModel -import com.android.keyguard.KeyguardUpdateMonitor +import com.android.keyguard.keyguardUpdateMonitor +import com.android.keyguard.trustManager import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.data.repository.FaceSensorInfo -import com.android.systemui.biometrics.data.repository.FakeFacePropertyRepository -import com.android.systemui.biometrics.data.repository.FakeFingerprintPropertyRepository +import com.android.systemui.biometrics.data.repository.facePropertyRepository import com.android.systemui.biometrics.shared.model.LockoutMode import com.android.systemui.biometrics.shared.model.SensorStrength -import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository -import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor -import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor -import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor -import com.android.systemui.bouncer.ui.BouncerView -import com.android.systemui.classifier.FalsingCollector +import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository +import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor +import com.android.systemui.bouncer.domain.interactor.primaryBouncerInteractor import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.data.repository.FaceWakeUpTriggersConfig +import com.android.systemui.deviceentry.data.repository.faceWakeUpTriggersConfig import com.android.systemui.deviceentry.shared.FaceAuthUiEvent import com.android.systemui.deviceentry.shared.model.ErrorFaceAuthenticationStatus -import com.android.systemui.keyguard.DismissCallbackRegistry -import com.android.systemui.keyguard.data.repository.FakeBiometricSettingsRepository -import com.android.systemui.keyguard.data.repository.FakeDeviceEntryFaceAuthRepository -import com.android.systemui.keyguard.data.repository.FakeDeviceEntryFingerprintAuthRepository -import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository -import com.android.systemui.keyguard.data.repository.FakeTrustRepository -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory +import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository +import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFaceAuthRepository +import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFingerprintAuthRepository +import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository +import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep +import com.android.systemui.kosmos.testDispatcher +import com.android.systemui.kosmos.testScope import com.android.systemui.log.FaceAuthenticationLogger import com.android.systemui.log.logcatLogBuffer -import com.android.systemui.plugins.statusbar.StatusBarStateController -import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest -import com.android.systemui.power.domain.interactor.PowerInteractorFactory +import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.power.shared.model.WakeSleepReason -import com.android.systemui.statusbar.policy.KeyguardStateController +import com.android.systemui.testKosmos import com.android.systemui.user.data.model.SelectionStatus -import com.android.systemui.user.data.repository.FakeUserRepository -import com.android.systemui.user.domain.interactor.SelectedUserInteractor +import com.android.systemui.user.data.repository.fakeUserRepository import com.android.systemui.util.mockito.eq +import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever -import com.android.systemui.util.time.FakeSystemClock import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.StandardTestDispatcher -import kotlinx.coroutines.test.TestCoroutineScheduler -import kotlinx.coroutines.test.TestScope 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.ArgumentMatchers.anyInt -import org.mockito.Mock -import org.mockito.Mockito.mock import org.mockito.Mockito.never import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations @@ -89,84 +74,39 @@ import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) class DeviceEntryFaceAuthInteractorTest : SysuiTestCase() { + val kosmos = + testKosmos().apply { this.faceWakeUpTriggersConfig = mock<FaceWakeUpTriggersConfig>() } private lateinit var underTest: SystemUIDeviceEntryFaceAuthInteractor - private lateinit var testScope: TestScope - private lateinit var bouncerRepository: FakeKeyguardBouncerRepository - private lateinit var keyguardTransitionRepository: FakeKeyguardTransitionRepository - private lateinit var keyguardTransitionInteractor: KeyguardTransitionInteractor - private lateinit var faceAuthRepository: FakeDeviceEntryFaceAuthRepository - private lateinit var fakeUserRepository: FakeUserRepository - private lateinit var facePropertyRepository: FakeFacePropertyRepository - private lateinit var fakeDeviceEntryFingerprintAuthRepository: - FakeDeviceEntryFingerprintAuthRepository - private lateinit var fakeKeyguardRepository: FakeKeyguardRepository - private lateinit var powerInteractor: PowerInteractor - private lateinit var fakeBiometricSettingsRepository: FakeBiometricSettingsRepository - - @Mock private lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor - @Mock private lateinit var faceWakeUpTriggersConfig: FaceWakeUpTriggersConfig - @Mock private lateinit var selectedUserInteractor: SelectedUserInteractor - @Mock private lateinit var trustManager: TrustManager + private val testScope = kosmos.testScope + private val bouncerRepository = kosmos.fakeKeyguardBouncerRepository + private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository + private val keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor + private val faceAuthRepository = kosmos.fakeDeviceEntryFaceAuthRepository + private val fakeUserRepository = kosmos.fakeUserRepository + private val facePropertyRepository = kosmos.facePropertyRepository + private val fakeDeviceEntryFingerprintAuthRepository = + kosmos.fakeDeviceEntryFingerprintAuthRepository + private val powerInteractor = kosmos.powerInteractor + private val fakeBiometricSettingsRepository = kosmos.fakeBiometricSettingsRepository + + private val keyguardUpdateMonitor = kosmos.keyguardUpdateMonitor + private val faceWakeUpTriggersConfig = kosmos.faceWakeUpTriggersConfig + private val trustManager = kosmos.trustManager @Before fun setup() { MockitoAnnotations.initMocks(this) - val scheduler = TestCoroutineScheduler() - val dispatcher = StandardTestDispatcher(scheduler) - testScope = TestScope(dispatcher) - bouncerRepository = FakeKeyguardBouncerRepository() - faceAuthRepository = FakeDeviceEntryFaceAuthRepository() - keyguardTransitionRepository = FakeKeyguardTransitionRepository() - keyguardTransitionInteractor = - KeyguardTransitionInteractorFactory.create( - scope = TestScope().backgroundScope, - repository = keyguardTransitionRepository, - ) - .keyguardTransitionInteractor - - fakeDeviceEntryFingerprintAuthRepository = FakeDeviceEntryFingerprintAuthRepository() - fakeUserRepository = FakeUserRepository() fakeUserRepository.setUserInfos(listOf(primaryUser, secondaryUser)) - facePropertyRepository = FakeFacePropertyRepository() - fakeKeyguardRepository = FakeKeyguardRepository() - powerInteractor = PowerInteractorFactory.create().powerInteractor - fakeBiometricSettingsRepository = FakeBiometricSettingsRepository() underTest = SystemUIDeviceEntryFaceAuthInteractor( mContext, testScope.backgroundScope, - dispatcher, + kosmos.testDispatcher, faceAuthRepository, - { - PrimaryBouncerInteractor( - bouncerRepository, - mock(BouncerView::class.java), - mock(Handler::class.java), - mock(KeyguardStateController::class.java), - mock(KeyguardSecurityModel::class.java), - mock(PrimaryBouncerCallbackInteractor::class.java), - mock(FalsingCollector::class.java), - mock(DismissCallbackRegistry::class.java), - context, - keyguardUpdateMonitor, - FakeTrustRepository(), - testScope.backgroundScope, - selectedUserInteractor, - underTest, - ) - }, - AlternateBouncerInteractor( - mock(StatusBarStateController::class.java), - mock(KeyguardStateController::class.java), - bouncerRepository, - FakeFingerprintPropertyRepository(), - fakeBiometricSettingsRepository, - FakeSystemClock(), - keyguardUpdateMonitor, - testScope.backgroundScope, - ), + { kosmos.primaryBouncerInteractor }, + kosmos.alternateBouncerInteractor, keyguardTransitionInteractor, FaceAuthenticationLogger(logcatLogBuffer("faceAuthBuffer")), keyguardUpdateMonitor, diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ResourceTrimmerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ResourceTrimmerTest.kt index 852f9a540221..cf8fe79f70f0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ResourceTrimmerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ResourceTrimmerTest.kt @@ -5,16 +5,16 @@ import android.graphics.HardwareRenderer import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.flags.FakeFeatureFlags import com.android.systemui.flags.Flags -import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository +import com.android.systemui.flags.fakeFeatureFlagsClassic +import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository +import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory +import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState -import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest -import com.android.systemui.power.domain.interactor.PowerInteractorFactory +import com.android.systemui.power.domain.interactor.powerInteractor +import com.android.systemui.testKosmos import com.android.systemui.util.mockito.any import com.android.systemui.utils.GlobalWindowManager import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -36,13 +36,14 @@ import org.mockito.MockitoAnnotations @RunWith(AndroidTestingRunner::class) @SmallTest class ResourceTrimmerTest : SysuiTestCase() { + val kosmos = testKosmos() private val testDispatcher = UnconfinedTestDispatcher() private val testScope = TestScope(testDispatcher) - private val keyguardRepository = FakeKeyguardRepository() - private val featureFlags = FakeFeatureFlags() - private val keyguardTransitionRepository = FakeKeyguardTransitionRepository() - private lateinit var powerInteractor: PowerInteractor + private val keyguardRepository = kosmos.fakeKeyguardRepository + private val featureFlags = kosmos.fakeFeatureFlagsClassic + private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository + private val powerInteractor = kosmos.powerInteractor @Mock private lateinit var globalWindowManager: GlobalWindowManager private lateinit var resourceTrimmer: ResourceTrimmer @@ -52,7 +53,6 @@ class ResourceTrimmerTest : SysuiTestCase() { MockitoAnnotations.initMocks(this) featureFlags.set(Flags.TRIM_RESOURCES_WITH_BACKGROUND_TRIM_AT_LOCK, true) featureFlags.set(Flags.TRIM_FONT_CACHES_AT_UNLOCK, true) - powerInteractor = PowerInteractorFactory.create().powerInteractor keyguardRepository.setDozeAmount(0f) keyguardRepository.setKeyguardGoingAway(false) @@ -66,11 +66,7 @@ class ResourceTrimmerTest : SysuiTestCase() { ResourceTrimmer( keyguardInteractor, powerInteractor, - KeyguardTransitionInteractorFactory.create( - scope = TestScope().backgroundScope, - repository = keyguardTransitionRepository, - ) - .keyguardTransitionInteractor, + kosmos.keyguardTransitionInteractor, globalWindowManager, testScope.backgroundScope, testDispatcher, diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorTest.kt index e75f5570248e..62855d79c052 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorTest.kt @@ -21,16 +21,15 @@ 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.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository +import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository +import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.DismissAction import com.android.systemui.keyguard.shared.model.KeyguardDone import com.android.systemui.keyguard.shared.model.KeyguardState +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.StandardTestDispatcher -import kotlinx.coroutines.test.TestDispatcher -import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before @@ -42,11 +41,12 @@ import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) class KeyguardDismissActionInteractorTest : SysuiTestCase() { - private lateinit var keyguardRepository: FakeKeyguardRepository - private lateinit var transitionRepository: FakeKeyguardTransitionRepository + val kosmos = testKosmos() - private lateinit var dispatcher: TestDispatcher - private lateinit var testScope: TestScope + private val keyguardRepository = kosmos.fakeKeyguardRepository + private val transitionRepository = kosmos.fakeKeyguardTransitionRepository + + private val testScope = kosmos.testScope private lateinit var dismissInteractorWithDependencies: KeyguardDismissInteractorFactory.WithDependencies @@ -55,25 +55,18 @@ class KeyguardDismissActionInteractorTest : SysuiTestCase() { @Before fun setUp() { MockitoAnnotations.initMocks(this) - dispatcher = StandardTestDispatcher() - testScope = TestScope(dispatcher) dismissInteractorWithDependencies = KeyguardDismissInteractorFactory.create( context = context, testScope = testScope, + keyguardRepository = keyguardRepository, ) - keyguardRepository = dismissInteractorWithDependencies.keyguardRepository - transitionRepository = FakeKeyguardTransitionRepository() underTest = KeyguardDismissActionInteractor( keyguardRepository, - KeyguardTransitionInteractorFactory.create( - scope = testScope.backgroundScope, - repository = transitionRepository, - ) - .keyguardTransitionInteractor, + kosmos.keyguardTransitionInteractor, dismissInteractorWithDependencies.interactor, testScope.backgroundScope, ) @@ -180,7 +173,7 @@ class KeyguardDismissActionInteractorTest : SysuiTestCase() { transitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE, - testScope + testScope, ) assertThat(executeDismissAction).isNotNull() } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractorTestCase.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractorTestCase.kt deleted file mode 100644 index a03aed04432b..000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractorTestCase.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2023 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.keyguard.domain.interactor - -import com.android.systemui.SysuiTestCase -import com.android.systemui.communal.domain.interactor.CommunalInteractor -import com.android.systemui.communal.domain.interactor.communalInteractor -import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository -import com.android.systemui.testKosmos -import com.android.systemui.util.mockito.mock -import dagger.Lazy -import kotlinx.coroutines.test.StandardTestDispatcher -import kotlinx.coroutines.test.TestScope - -open class KeyguardTransitionInteractorTestCase : SysuiTestCase() { - private val kosmos = testKosmos() - val testDispatcher = StandardTestDispatcher() - var testScope = TestScope(testDispatcher) - - lateinit var keyguardRepository: FakeKeyguardRepository - lateinit var transitionRepository: FakeKeyguardTransitionRepository - - lateinit var keyguardInteractor: KeyguardInteractor - lateinit var communalInteractor: CommunalInteractor - lateinit var transitionInteractor: KeyguardTransitionInteractor - - /** - * Replace these lazy providers with non-null ones if you want test dependencies to use a real - * instance of the interactor for the test. - */ - open var fromLockscreenTransitionInteractorLazy: Lazy<FromLockscreenTransitionInteractor>? = - null - open var fromPrimaryBouncerTransitionInteractorLazy: - Lazy<FromPrimaryBouncerTransitionInteractor>? = - null - - open fun setUp() { - keyguardRepository = FakeKeyguardRepository() - transitionRepository = FakeKeyguardTransitionRepository() - - keyguardInteractor = - KeyguardInteractorFactory.create(repository = keyguardRepository).keyguardInteractor - - communalInteractor = kosmos.communalInteractor - - transitionInteractor = - KeyguardTransitionInteractorFactory.create( - repository = transitionRepository, - keyguardInteractor = keyguardInteractor, - scope = testScope.backgroundScope, - fromLockscreenTransitionInteractor = fromLockscreenTransitionInteractorLazy - ?: Lazy { mock() }, - fromPrimaryBouncerTransitionInteractor = - fromPrimaryBouncerTransitionInteractorLazy ?: Lazy { mock() }, - ) - .also { - fromLockscreenTransitionInteractorLazy = it.fromLockscreenTransitionInteractor - fromPrimaryBouncerTransitionInteractorLazy = - it.fromPrimaryBouncerTransitionInteractor - } - .keyguardTransitionInteractor - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt index 6eed427e9297..a4483bdac467 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt @@ -20,76 +20,46 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectValues -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository +import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState 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.testKosmos +import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever import junit.framework.Assert.assertEquals import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.test.TestScope 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.initMocks @SmallTest @RunWith(AndroidJUnit4::class) @kotlinx.coroutines.ExperimentalCoroutinesApi class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { - - private lateinit var underTest: WindowManagerLockscreenVisibilityInteractor - - @Mock private lateinit var surfaceBehindInteractor: KeyguardSurfaceBehindInteractor - @Mock - private lateinit var fromLockscreenTransitionInteractor: FromLockscreenTransitionInteractor - @Mock - private lateinit var fromPrimaryBouncerTransitionInteractor: - FromPrimaryBouncerTransitionInteractor - private val lockscreenSurfaceVisibilityFlow = MutableStateFlow<Boolean?>(false) private val primaryBouncerSurfaceVisibilityFlow = MutableStateFlow<Boolean?>(false) private val surfaceBehindIsAnimatingFlow = MutableStateFlow(false) - private val testScope = TestScope() - - private lateinit var keyguardInteractor: KeyguardInteractor - private lateinit var transitionRepository: FakeKeyguardTransitionRepository - private lateinit var transitionInteractor: KeyguardTransitionInteractor - - @Before - fun setUp() { - initMocks(this) - - whenever(fromLockscreenTransitionInteractor.surfaceBehindVisibility) - .thenReturn(lockscreenSurfaceVisibilityFlow) - whenever(fromPrimaryBouncerTransitionInteractor.surfaceBehindVisibility) - .thenReturn(primaryBouncerSurfaceVisibilityFlow) - whenever(surfaceBehindInteractor.isAnimatingSurface) - .thenReturn(surfaceBehindIsAnimatingFlow) - - transitionRepository = FakeKeyguardTransitionRepository() + private val kosmos = + testKosmos().apply { + fromLockscreenTransitionInteractor = mock<FromLockscreenTransitionInteractor>() + fromPrimaryBouncerTransitionInteractor = mock<FromPrimaryBouncerTransitionInteractor>() + keyguardSurfaceBehindInteractor = mock<KeyguardSurfaceBehindInteractor>() + + whenever(fromLockscreenTransitionInteractor.surfaceBehindVisibility) + .thenReturn(lockscreenSurfaceVisibilityFlow) + whenever(fromPrimaryBouncerTransitionInteractor.surfaceBehindVisibility) + .thenReturn(primaryBouncerSurfaceVisibilityFlow) + whenever(keyguardSurfaceBehindInteractor.isAnimatingSurface) + .thenReturn(surfaceBehindIsAnimatingFlow) + } - transitionInteractor = - KeyguardTransitionInteractorFactory.create( - scope = testScope.backgroundScope, - repository = transitionRepository, - ) - .also { keyguardInteractor = it.keyguardInteractor } - .keyguardTransitionInteractor - - underTest = - WindowManagerLockscreenVisibilityInteractor( - keyguardInteractor = keyguardInteractor, - transitionInteractor = transitionInteractor, - surfaceBehindInteractor = surfaceBehindInteractor, - fromLockscreenTransitionInteractor, - fromPrimaryBouncerTransitionInteractor, - ) - } + private val underTest = kosmos.windowManagerLockscreenVisibilityInteractor + private val testScope = kosmos.testScope + private val transitionRepository = kosmos.fakeKeyguardTransitionRepository @Test fun surfaceBehindVisibility_switchesToCorrectFlow() = 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 af38523c2fd3..90943de4c973 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 @@ -46,7 +46,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInterac import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory import com.android.systemui.keyguard.domain.interactor.KeyguardLongPressInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory +import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.quickaffordance.ActivationState import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancesMetricsLogger @@ -67,7 +67,6 @@ import com.android.systemui.util.settings.FakeSettings import com.google.common.truth.Truth.assertThat import kotlin.math.max import kotlin.math.min -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.map import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope @@ -83,7 +82,6 @@ import org.mockito.Mockito import org.mockito.Mockito.verifyZeroInteractions import org.mockito.MockitoAnnotations -@OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(JUnit4::class) class KeyguardBottomAreaViewModelTest : SysuiTestCase() { @@ -208,11 +206,7 @@ class KeyguardBottomAreaViewModelTest : SysuiTestCase() { KeyguardLongPressInteractor( appContext = mContext, scope = testScope.backgroundScope, - transitionInteractor = - KeyguardTransitionInteractorFactory.create( - scope = TestScope().backgroundScope, - ) - .keyguardTransitionInteractor, + transitionInteractor = kosmos.keyguardTransitionInteractor, repository = repository, logger = UiEventLoggerFake(), featureFlags = featureFlags, diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaCarouselControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaCarouselControllerTest.kt index 310e0b8e7ac3..f3b9102da780 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaCarouselControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaCarouselControllerTest.kt @@ -30,13 +30,12 @@ import androidx.test.filters.SmallTest import com.android.internal.logging.InstanceId import com.android.keyguard.KeyguardUpdateMonitor import com.android.keyguard.KeyguardUpdateMonitorCallback -import com.android.keyguard.TestScopeProvider import com.android.systemui.SysuiTestCase import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dump.DumpManager -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository +import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory +import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.media.controls.MediaTestUtils import com.android.systemui.media.controls.models.player.MediaData @@ -53,6 +52,7 @@ import com.android.systemui.res.R import com.android.systemui.statusbar.notification.collection.provider.OnReorderingAllowedListener import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider import com.android.systemui.statusbar.policy.ConfigurationController +import com.android.systemui.testKosmos import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.concurrency.FakeExecutor import com.android.systemui.util.mockito.any @@ -93,6 +93,7 @@ private const val PLAYING_LOCAL = "playing local" @TestableLooper.RunWithLooper(setAsMainLooper = true) @RunWith(AndroidTestingRunner::class) class MediaCarouselControllerTest : SysuiTestCase() { + val kosmos = testKosmos() @Mock lateinit var mediaControlPanelFactory: Provider<MediaControlPanel> @Mock lateinit var panel: MediaControlPanel @@ -115,7 +116,7 @@ class MediaCarouselControllerTest : SysuiTestCase() { @Mock lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor @Mock lateinit var keyguardTransitionInteractor: KeyguardTransitionInteractor @Mock lateinit var globalSettings: GlobalSettings - private lateinit var transitionRepository: FakeKeyguardTransitionRepository + private val transitionRepository = kosmos.fakeKeyguardTransitionRepository @Captor lateinit var listener: ArgumentCaptor<MediaDataManager.Listener> @Captor lateinit var configListener: ArgumentCaptor<ConfigurationController.ConfigurationListener> @@ -132,7 +133,6 @@ class MediaCarouselControllerTest : SysuiTestCase() { fun setup() { MockitoAnnotations.initMocks(this) context.resources.configuration.setLocales(LocaleList(Locale.US, Locale.UK)) - transitionRepository = FakeKeyguardTransitionRepository() bgExecutor = FakeExecutor(clock) mediaCarouselController = MediaCarouselController( @@ -152,11 +152,7 @@ class MediaCarouselControllerTest : SysuiTestCase() { debugLogger, mediaFlags, keyguardUpdateMonitor, - KeyguardTransitionInteractorFactory.create( - scope = TestScopeProvider.getTestScope().backgroundScope, - repository = transitionRepository, - ) - .keyguardTransitionInteractor, + kosmos.keyguardTransitionInteractor, globalSettings ) verify(configurationController).addCallback(capture(configListener)) diff --git a/packages/SystemUI/tests/utils/src/com/android/internal/logging/UiEventLoggerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/internal/logging/UiEventLoggerKosmos.kt index 9059da2259b1..20b9e8445780 100644 --- a/packages/SystemUI/tests/utils/src/com/android/internal/logging/UiEventLoggerKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/internal/logging/UiEventLoggerKosmos.kt @@ -20,4 +20,4 @@ import com.android.internal.logging.testing.UiEventLoggerFake import com.android.systemui.kosmos.Kosmos var Kosmos.uiEventLogger: UiEventLogger by Kosmos.Fixture { uiEventLoggerFake } -val Kosmos.uiEventLoggerFake by Kosmos.Fixture { UiEventLoggerFake() } +var Kosmos.uiEventLoggerFake by Kosmos.Fixture { UiEventLoggerFake() } diff --git a/packages/SystemUI/tests/utils/src/com/android/keyguard/logging/ScrimLoggerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/keyguard/logging/ScrimLoggerKosmos.kt new file mode 100644 index 000000000000..901bdcc156dd --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/keyguard/logging/ScrimLoggerKosmos.kt @@ -0,0 +1,22 @@ +/* + * 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.keyguard.logging + +import com.android.systemui.kosmos.Kosmos +import com.android.systemui.util.mockito.mock + +val Kosmos.scrimLogger by Kosmos.Fixture { mock<ScrimLogger>() } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/flags/FeatureFlagsClassicKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/flags/FeatureFlagsClassicKosmos.kt index 7b36a29ad607..365d97f3ac15 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/flags/FeatureFlagsClassicKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/flags/FeatureFlagsClassicKosmos.kt @@ -35,6 +35,7 @@ val Kosmos.fakeFeatureFlagsClassic by FakeFeatureFlagsClassic().apply { set(Flags.FULL_SCREEN_USER_SWITCHER, false) set(Flags.NSSL_DEBUG_LINES, false) + set(Flags.LOCK_SCREEN_LONG_PRESS_ENABLED, false) } } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/LightRevealScrimRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/LightRevealScrimRepositoryKosmos.kt new file mode 100644 index 000000000000..046946e05fe4 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/LightRevealScrimRepositoryKosmos.kt @@ -0,0 +1,24 @@ +/* + * 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.keyguard.data + +import com.android.systemui.keyguard.data.repository.FakeLightRevealScrimRepository +import com.android.systemui.kosmos.Kosmos + +val Kosmos.lightRevealScrimRepository by Kosmos.Fixture { fakeLightRevealScrimRepository } + +var Kosmos.fakeLightRevealScrimRepository by Kosmos.Fixture { FakeLightRevealScrimRepository() } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromLockscreenTransitionInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromLockscreenTransitionInteractorKosmos.kt index d9882fc2c140..3b52676fc0ef 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromLockscreenTransitionInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromLockscreenTransitionInteractorKosmos.kt @@ -24,7 +24,7 @@ import com.android.systemui.kosmos.testDispatcher import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.shade.data.repository.shadeRepository -val Kosmos.fromLockscreenTransitionInteractor by +var Kosmos.fromLockscreenTransitionInteractor by Kosmos.Fixture { FromLockscreenTransitionInteractor( transitionRepository = keyguardTransitionRepository, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractorKosmos.kt index 719686e3d862..6b764491f32a 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromPrimaryBouncerTransitionInteractorKosmos.kt @@ -26,7 +26,7 @@ import com.android.systemui.kosmos.testDispatcher import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.user.domain.interactor.selectedUserInteractor -val Kosmos.fromPrimaryBouncerTransitionInteractor by +var Kosmos.fromPrimaryBouncerTransitionInteractor by Kosmos.Fixture { FromPrimaryBouncerTransitionInteractor( transitionRepository = keyguardTransitionRepository, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorKosmos.kt index 638a6a38595c..c06f833c9e96 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorKosmos.kt @@ -18,12 +18,12 @@ package com.android.systemui.keyguard.domain.interactor import android.content.applicationContext import android.view.accessibility.accessibilityManagerWrapper +import com.android.internal.logging.uiEventLogger import com.android.systemui.broadcast.broadcastDispatcher import com.android.systemui.flags.featureFlagsClassic import com.android.systemui.keyguard.data.repository.keyguardRepository import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope -import com.android.systemui.qs.uiEventLogger val Kosmos.keyguardLongPressInteractor by Kosmos.Fixture { diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardSurfaceBehindInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardSurfaceBehindInteractorKosmos.kt index d756f9a61c31..a646bc6fec44 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardSurfaceBehindInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardSurfaceBehindInteractorKosmos.kt @@ -20,7 +20,7 @@ import android.content.applicationContext import com.android.systemui.keyguard.data.repository.keyguardSurfaceBehindRepository import com.android.systemui.kosmos.Kosmos -val Kosmos.keyguardSurfaceBehindInteractor by +var Kosmos.keyguardSurfaceBehindInteractor by Kosmos.Fixture { KeyguardSurfaceBehindInteractor( repository = keyguardSurfaceBehindRepository, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractorFactory.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractorFactory.kt deleted file mode 100644 index 5cf656ceedaa..000000000000 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionInteractorFactory.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2023 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.keyguard.domain.interactor - -import com.android.systemui.flags.FakeFeatureFlags -import com.android.systemui.flags.FakeFeatureFlagsClassic -import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository -import com.android.systemui.util.mockito.mock -import dagger.Lazy -import kotlinx.coroutines.CoroutineScope - -/** - * Helper to create a new KeyguardTransitionInteractor in a way that doesn't require modifying 20+ - * tests whenever we add a constructor param. - */ -object KeyguardTransitionInteractorFactory { - @JvmOverloads - @JvmStatic - fun create( - scope: CoroutineScope, - repository: FakeKeyguardTransitionRepository = FakeKeyguardTransitionRepository(), - featureFlags: FakeFeatureFlags = FakeFeatureFlagsClassic(), - keyguardInteractor: KeyguardInteractor = - KeyguardInteractorFactory.create(featureFlags = featureFlags).keyguardInteractor, - fromLockscreenTransitionInteractor: Lazy<FromLockscreenTransitionInteractor> = Lazy { - mock<FromLockscreenTransitionInteractor>() - }, - fromPrimaryBouncerTransitionInteractor: Lazy<FromPrimaryBouncerTransitionInteractor> = - Lazy { - mock<FromPrimaryBouncerTransitionInteractor>() - }, - ): WithDependencies { - return WithDependencies( - repository = repository, - keyguardInteractor = keyguardInteractor, - fromLockscreenTransitionInteractor = fromLockscreenTransitionInteractor, - fromPrimaryBouncerTransitionInteractor = fromPrimaryBouncerTransitionInteractor, - KeyguardTransitionInteractor( - scope = scope, - repository = repository, - keyguardInteractor = { keyguardInteractor }, - fromLockscreenTransitionInteractor = fromLockscreenTransitionInteractor, - fromPrimaryBouncerTransitionInteractor = fromPrimaryBouncerTransitionInteractor, - ) - ) - } - - data class WithDependencies( - val repository: FakeKeyguardTransitionRepository, - val keyguardInteractor: KeyguardInteractor, - val fromLockscreenTransitionInteractor: Lazy<FromLockscreenTransitionInteractor>, - val fromPrimaryBouncerTransitionInteractor: Lazy<FromPrimaryBouncerTransitionInteractor>, - val keyguardTransitionInteractor: KeyguardTransitionInteractor, - ) -} diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractorKosmos.kt new file mode 100644 index 000000000000..58e0a3b32f78 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/LightRevealScrimInteractorKosmos.kt @@ -0,0 +1,34 @@ +/* + * 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.keyguard.domain.interactor + +import com.android.keyguard.logging.scrimLogger +import com.android.systemui.keyguard.data.lightRevealScrimRepository +import com.android.systemui.kosmos.Kosmos +import com.android.systemui.kosmos.applicationCoroutineScope +import com.android.systemui.power.domain.interactor.powerInteractor + +val Kosmos.lightRevealScrimInteractor by + Kosmos.Fixture { + LightRevealScrimInteractor( + keyguardTransitionInteractor, + lightRevealScrimRepository, + applicationCoroutineScope, + scrimLogger, + powerInteractor, + ) + } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorKosmos.kt new file mode 100644 index 000000000000..0207280dd30c --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorKosmos.kt @@ -0,0 +1,30 @@ +/* + * 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.keyguard.domain.interactor + +import com.android.systemui.kosmos.Kosmos + +val Kosmos.windowManagerLockscreenVisibilityInteractor by + Kosmos.Fixture { + WindowManagerLockscreenVisibilityInteractor( + keyguardInteractor = keyguardInteractor, + transitionInteractor = keyguardTransitionInteractor, + surfaceBehindInteractor = keyguardSurfaceBehindInteractor, + fromLockscreenInteractor = fromLockscreenTransitionInteractor, + fromBouncerInteractor = fromPrimaryBouncerTransitionInteractor, + ) + } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt index 73b7c50eb8be..be559efc7946 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt @@ -16,9 +16,9 @@ package com.android.systemui.plugins.statusbar +import com.android.internal.logging.uiEventLogger import com.android.systemui.jank.interactionJankMonitor import com.android.systemui.kosmos.Kosmos -import com.android.systemui.qs.uiEventLogger import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.statusbar.StatusBarStateControllerImpl import com.android.systemui.util.mockito.mock diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/QuickSettingsKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/QuickSettingsKosmos.kt index 6332c1a8010d..23d657d0abca 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/QuickSettingsKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/QuickSettingsKosmos.kt @@ -16,7 +16,7 @@ package com.android.systemui.qs -import com.android.internal.logging.testing.UiEventLoggerFake +import com.android.internal.logging.uiEventLoggerFake import com.android.systemui.InstanceIdSequenceFake import com.android.systemui.kosmos.Kosmos import com.android.systemui.plugins.qs.QSFactory @@ -24,9 +24,8 @@ import com.android.systemui.qs.tiles.di.NewQSTileFactory val Kosmos.instanceIdSequenceFake: InstanceIdSequenceFake by Kosmos.Fixture { InstanceIdSequenceFake(0) } -val Kosmos.uiEventLogger: UiEventLoggerFake by Kosmos.Fixture { UiEventLoggerFake() } val Kosmos.qsEventLogger: QsEventLoggerFake by - Kosmos.Fixture { QsEventLoggerFake(uiEventLogger, instanceIdSequenceFake) } + Kosmos.Fixture { QsEventLoggerFake(uiEventLoggerFake, instanceIdSequenceFake) } var Kosmos.newQSTileFactory by Kosmos.Fixture<NewQSTileFactory>() var Kosmos.qsTileFactory by Kosmos.Fixture<QSFactory>() |