Rename method and val.

This commit is contained in:
Benoit Marty 2024-06-17 14:56:56 +02:00
parent 7322c75a67
commit 2b062f217b

View file

@ -44,9 +44,9 @@ class DefaultFtueServiceTest {
givenVerifiedStatus(SessionVerifiedStatus.Unknown) givenVerifiedStatus(SessionVerifiedStatus.Unknown)
} }
val coroutineScope = CoroutineScope(coroutineContext + SupervisorJob()) val coroutineScope = CoroutineScope(coroutineContext + SupervisorJob())
val state = createState(coroutineScope, sessionVerificationService) val service = createDefaultFtueService(coroutineScope, sessionVerificationService)
state.state.test { service.state.test {
// Verification state is unknown, we don't display the flow yet // Verification state is unknown, we don't display the flow yet
assertThat(awaitItem()).isEqualTo(FtueState.Unknown) assertThat(awaitItem()).isEqualTo(FtueState.Unknown)
@ -67,7 +67,7 @@ class DefaultFtueServiceTest {
val lockScreenService = FakeLockScreenService() val lockScreenService = FakeLockScreenService()
val coroutineScope = CoroutineScope(coroutineContext + SupervisorJob()) val coroutineScope = CoroutineScope(coroutineContext + SupervisorJob())
val state = createState( val service = createDefaultFtueService(
coroutineScope = coroutineScope, coroutineScope = coroutineScope,
sessionVerificationService = sessionVerificationService, sessionVerificationService = sessionVerificationService,
analyticsService = analyticsService, analyticsService = analyticsService,
@ -79,9 +79,9 @@ class DefaultFtueServiceTest {
analyticsService.setDidAskUserConsent() analyticsService.setDidAskUserConsent()
permissionStateProvider.setPermissionGranted() permissionStateProvider.setPermissionGranted()
lockScreenService.setIsPinSetup(true) lockScreenService.setIsPinSetup(true)
state.updateState() service.updateState()
assertThat(state.state.value).isEqualTo(FtueState.Complete) assertThat(service.state.value).isEqualTo(FtueState.Complete)
// Cleanup // Cleanup
coroutineScope.cancel() coroutineScope.cancel()
@ -97,7 +97,7 @@ class DefaultFtueServiceTest {
val lockScreenService = FakeLockScreenService() val lockScreenService = FakeLockScreenService()
val coroutineScope = CoroutineScope(coroutineContext + SupervisorJob()) val coroutineScope = CoroutineScope(coroutineContext + SupervisorJob())
val state = createState( val service = createDefaultFtueService(
coroutineScope = coroutineScope, coroutineScope = coroutineScope,
sessionVerificationService = sessionVerificationService, sessionVerificationService = sessionVerificationService,
analyticsService = analyticsService, analyticsService = analyticsService,
@ -107,23 +107,23 @@ class DefaultFtueServiceTest {
val steps = mutableListOf<FtueStep?>() val steps = mutableListOf<FtueStep?>()
// Session verification // Session verification
steps.add(state.getNextStep(steps.lastOrNull())) steps.add(service.getNextStep(steps.lastOrNull()))
sessionVerificationService.givenVerifiedStatus(SessionVerifiedStatus.NotVerified) sessionVerificationService.givenVerifiedStatus(SessionVerifiedStatus.NotVerified)
// Notifications opt in // Notifications opt in
steps.add(state.getNextStep(steps.lastOrNull())) steps.add(service.getNextStep(steps.lastOrNull()))
permissionStateProvider.setPermissionGranted() permissionStateProvider.setPermissionGranted()
// Entering PIN code // Entering PIN code
steps.add(state.getNextStep(steps.lastOrNull())) steps.add(service.getNextStep(steps.lastOrNull()))
lockScreenService.setIsPinSetup(true) lockScreenService.setIsPinSetup(true)
// Analytics opt in // Analytics opt in
steps.add(state.getNextStep(steps.lastOrNull())) steps.add(service.getNextStep(steps.lastOrNull()))
analyticsService.setDidAskUserConsent() analyticsService.setDidAskUserConsent()
// Final step (null) // Final step (null)
steps.add(state.getNextStep(steps.lastOrNull())) steps.add(service.getNextStep(steps.lastOrNull()))
assertThat(steps).containsExactly( assertThat(steps).containsExactly(
FtueStep.SessionVerification, FtueStep.SessionVerification,
@ -145,7 +145,7 @@ class DefaultFtueServiceTest {
val analyticsService = FakeAnalyticsService() val analyticsService = FakeAnalyticsService()
val permissionStateProvider = FakePermissionStateProvider(permissionGranted = false) val permissionStateProvider = FakePermissionStateProvider(permissionGranted = false)
val lockScreenService = FakeLockScreenService() val lockScreenService = FakeLockScreenService()
val state = createState( val service = createDefaultFtueService(
coroutineScope = coroutineScope, coroutineScope = coroutineScope,
sessionVerificationService = sessionVerificationService, sessionVerificationService = sessionVerificationService,
analyticsService = analyticsService, analyticsService = analyticsService,
@ -158,10 +158,10 @@ class DefaultFtueServiceTest {
permissionStateProvider.setPermissionGranted() permissionStateProvider.setPermissionGranted()
lockScreenService.setIsPinSetup(true) lockScreenService.setIsPinSetup(true)
assertThat(state.getNextStep()).isEqualTo(FtueStep.AnalyticsOptIn) assertThat(service.getNextStep()).isEqualTo(FtueStep.AnalyticsOptIn)
analyticsService.setDidAskUserConsent() analyticsService.setDidAskUserConsent()
assertThat(state.getNextStep(null)).isNull() assertThat(service.getNextStep(null)).isNull()
// Cleanup // Cleanup
coroutineScope.cancel() coroutineScope.cancel()
@ -174,7 +174,7 @@ class DefaultFtueServiceTest {
val analyticsService = FakeAnalyticsService() val analyticsService = FakeAnalyticsService()
val lockScreenService = FakeLockScreenService() val lockScreenService = FakeLockScreenService()
val state = createState( val service = createDefaultFtueService(
sdkIntVersion = Build.VERSION_CODES.M, sdkIntVersion = Build.VERSION_CODES.M,
sessionVerificationService = sessionVerificationService, sessionVerificationService = sessionVerificationService,
coroutineScope = coroutineScope, coroutineScope = coroutineScope,
@ -185,16 +185,16 @@ class DefaultFtueServiceTest {
sessionVerificationService.givenVerifiedStatus(SessionVerifiedStatus.Verified) sessionVerificationService.givenVerifiedStatus(SessionVerifiedStatus.Verified)
lockScreenService.setIsPinSetup(true) lockScreenService.setIsPinSetup(true)
assertThat(state.getNextStep()).isEqualTo(FtueStep.AnalyticsOptIn) assertThat(service.getNextStep()).isEqualTo(FtueStep.AnalyticsOptIn)
analyticsService.setDidAskUserConsent() analyticsService.setDidAskUserConsent()
assertThat(state.getNextStep(null)).isNull() assertThat(service.getNextStep(null)).isNull()
// Cleanup // Cleanup
coroutineScope.cancel() coroutineScope.cancel()
} }
private fun createState( private fun createDefaultFtueService(
coroutineScope: CoroutineScope, coroutineScope: CoroutineScope,
sessionVerificationService: FakeSessionVerificationService = FakeSessionVerificationService(), sessionVerificationService: FakeSessionVerificationService = FakeSessionVerificationService(),
analyticsService: AnalyticsService = FakeAnalyticsService(), analyticsService: AnalyticsService = FakeAnalyticsService(),