Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e00796c authored by Alexander Hendrich's avatar Alexander Hendrich
Browse files

[flexiglass] Cleanup {Password|Pattern|Pin}BouncerViewModelTest

Cleaning up the redundant "kosmos." prefixes that I added as part of http://ag/c/platform/frameworks/base/+/33533127/comment/3e5a43b5_be781c45/.

Bug: none
Flag: EXEMPT - test refactor
Test: atest PasswordBouncerViewModelTest PatternBouncerViewModelTest PinBouncerViewModelTest
Change-Id: I10be58973ddcc2c08585a0f91bb02ab053c671ad
parent 5d2d75e0
Loading
Loading
Loading
Loading
+25 −33
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onShown() =
        kosmos.runTest {
            val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            lockDeviceAndOpenPasswordBouncer()

            assertThat(underTest.textFieldState.text.toString()).isEmpty()
@@ -104,7 +104,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onPasswordInputChanged() =
        kosmos.runTest {
            val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            lockDeviceAndOpenPasswordBouncer()

            verify(onIntentionalUserInputMock, never()).invoke()
@@ -120,8 +120,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onAuthenticateKeyPressed_whenCorrect() =
        kosmos.runTest {
            val authResult by
                collectLastValue(kosmos.authenticationInteractor.onAuthenticationResult)
            val authResult by collectLastValue(authenticationInteractor.onAuthenticationResult)
            lockDeviceAndOpenPasswordBouncer()

            underTest.textFieldState.setTextAndPlaceCursorAtEnd("password")
@@ -133,8 +132,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onAuthenticateKeyPressed_whenWrong() =
        kosmos.runTest {
            val authResult by
                collectLastValue(kosmos.authenticationInteractor.onAuthenticationResult)
            val authResult by collectLastValue(authenticationInteractor.onAuthenticationResult)
            lockDeviceAndOpenPasswordBouncer()

            underTest.textFieldState.setTextAndPlaceCursorAtEnd("wrong")
@@ -147,9 +145,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onAuthenticateKeyPressed_whenEmpty() =
        kosmos.runTest {
            kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
                AuthenticationMethodModel.Password
            )
            fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Password)
            showBouncer()

            // No input entered.
@@ -162,8 +158,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onAuthenticateKeyPressed_correctAfterWrong() =
        kosmos.runTest {
            val authResult by
                collectLastValue(kosmos.authenticationInteractor.onAuthenticationResult)
            val authResult by collectLastValue(authenticationInteractor.onAuthenticationResult)
            lockDeviceAndOpenPasswordBouncer()

            // Enter the wrong password:
@@ -183,7 +178,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onShown_againAfterSceneChange_resetsPassword() =
        kosmos.runTest {
            val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            lockDeviceAndOpenPasswordBouncer()

            // The user types a password.
@@ -204,7 +199,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onImeDismissed() =
        kosmos.runTest {
            val events by collectValues(kosmos.bouncerInteractor.onImeHiddenByUser)
            val events by collectValues(bouncerInteractor.onImeHiddenByUser)
            assertThat(events).isEmpty()

            underTest.onImeDismissed()
@@ -267,7 +262,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun isImeSwitcherButtonVisible() =
        kosmos.runTest {
            val selectedUserId by collectLastValue(kosmos.selectedUserInteractor.selectedUser)
            val selectedUserId by collectLastValue(selectedUserInteractor.selectedUser)
            selectUser(USER_INFOS.first())

            enableInputMethodsForUser(checkNotNull(selectedUserId))
@@ -283,7 +278,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
            selectUser(USER_INFOS.last())

            assertThat(
                    kosmos.inputMethodInteractor.hasMultipleEnabledImesOrSubtypes(
                    inputMethodInteractor.hasMultipleEnabledImesOrSubtypes(
                        checkNotNull(selectedUserId)
                    )
                )
@@ -300,21 +295,20 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    fun onImeSwitcherButtonClicked() =
        kosmos.runTest {
            val displayId = 7
            assertThat(kosmos.fakeInputMethodRepository.inputMethodPickerShownDisplayId)
            assertThat(fakeInputMethodRepository.inputMethodPickerShownDisplayId)
                .isNotEqualTo(displayId)

            underTest.onImeSwitcherButtonClicked(displayId)
            runCurrent()

            assertThat(kosmos.fakeInputMethodRepository.inputMethodPickerShownDisplayId)
            assertThat(fakeInputMethodRepository.inputMethodPickerShownDisplayId)
                .isEqualTo(displayId)
        }

    @Test
    fun afterSuccessfulAuthentication_focusIsNotRequested() =
        kosmos.runTest {
            val authResult by
                collectLastValue(kosmos.authenticationInteractor.onAuthenticationResult)
            val authResult by collectLastValue(authenticationInteractor.onAuthenticationResult)
            val textInputFocusRequested by collectLastValue(underTest.isTextFieldFocusRequested)
            lockDeviceAndOpenPasswordBouncer()

@@ -347,16 +341,16 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
        }

    private fun Kosmos.showBouncer() {
        val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
        kosmos.sceneInteractor.showOverlay(Overlays.Bouncer, "reason")
        val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
        sceneInteractor.showOverlay(Overlays.Bouncer, "reason")
        runCurrent()

        assertThat(currentOverlays).contains(Overlays.Bouncer)
    }

    private fun Kosmos.hideBouncer() {
        val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
        kosmos.sceneInteractor.hideOverlay(Overlays.Bouncer, "reason")
        val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
        sceneInteractor.hideOverlay(Overlays.Bouncer, "reason")
        underTest.onHidden()
        runCurrent()

@@ -364,22 +358,20 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    }

    private fun Kosmos.lockDeviceAndOpenPasswordBouncer() {
        kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
            AuthenticationMethodModel.Password
        )
        fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Password)
        showBouncer()
    }

    private suspend fun Kosmos.setLockout(isLockedOut: Boolean, failedAttemptCount: Int = 5) {
        if (isLockedOut) {
            repeat(failedAttemptCount) {
                kosmos.fakeAuthenticationRepository.reportAuthenticationAttempt(false)
                fakeAuthenticationRepository.reportAuthenticationAttempt(false)
            }
            kosmos.fakeAuthenticationRepository.reportLockoutStarted(
            fakeAuthenticationRepository.reportLockoutStarted(
                30.seconds.inWholeMilliseconds.toInt()
            )
        } else {
            kosmos.fakeAuthenticationRepository.reportAuthenticationAttempt(true)
            fakeAuthenticationRepository.reportAuthenticationAttempt(true)
        }
        isInputEnabled.value = !isLockedOut

@@ -387,7 +379,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
    }

    private fun Kosmos.selectUser(userInfo: UserInfo) {
        kosmos.fakeUserRepository.selectedUser.value =
        fakeUserRepository.selectedUser.value =
            SelectedUserModel(
                userInfo = userInfo,
                selectionStatus = SelectionStatus.SELECTION_COMPLETE,
@@ -395,13 +387,13 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
        advanceTimeBy(PasswordBouncerViewModel.DELAY_TO_FETCH_IMES)
    }

    private suspend fun enableInputMethodsForUser(userId: Int) {
        kosmos.fakeInputMethodRepository.setEnabledInputMethods(
    private suspend fun Kosmos.enableInputMethodsForUser(userId: Int) {
        fakeInputMethodRepository.setEnabledInputMethods(
            userId,
            createInputMethodWithSubtypes(auxiliarySubtypes = 0, nonAuxiliarySubtypes = 0),
            createInputMethodWithSubtypes(auxiliarySubtypes = 0, nonAuxiliarySubtypes = 1),
        )
        assertThat(kosmos.inputMethodInteractor.hasMultipleEnabledImesOrSubtypes(userId)).isTrue()
        assertThat(inputMethodInteractor.hasMultipleEnabledImesOrSubtypes(userId)).isTrue()
    }

    private fun createInputMethodWithSubtypes(
+19 −24
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onShown() =
        kosmos.runTest {
            val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            val selectedDots by collectLastValue(underTest.selectedDots)
            val currentDot by collectLastValue(underTest.currentDot)
            lockDeviceAndOpenPatternBouncer()
@@ -93,7 +93,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onDragStart() =
        kosmos.runTest {
            val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            val selectedDots by collectLastValue(underTest.selectedDots)
            val currentDot by collectLastValue(underTest.currentDot)
            lockDeviceAndOpenPatternBouncer()
@@ -111,8 +111,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onDragEnd_whenCorrect() =
        kosmos.runTest {
            val authResult by
                collectLastValue(kosmos.authenticationInteractor.onAuthenticationResult)
            val authResult by collectLastValue(authenticationInteractor.onAuthenticationResult)
            val selectedDots by collectLastValue(underTest.selectedDots)
            val currentDot by collectLastValue(underTest.currentDot)
            lockDeviceAndOpenPatternBouncer()
@@ -145,7 +144,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onDragEnd_whenWrong() =
        kosmos.runTest {
            val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            val selectedDots by collectLastValue(underTest.selectedDots)
            val currentDot by collectLastValue(underTest.currentDot)
            lockDeviceAndOpenPatternBouncer()
@@ -298,8 +297,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onDragEnd_whenPatternTooShort() =
        kosmos.runTest {
            val dialogViewModel by
                collectLastValue(kosmos.bouncerOverlayContentViewModel.dialogViewModel)
            val dialogViewModel by collectLastValue(bouncerOverlayContentViewModel.dialogViewModel)
            lockDeviceAndOpenPatternBouncer()

            // Enter a pattern that's too short more than enough times that would normally trigger
@@ -307,8 +305,8 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
            val attempts = FakeAuthenticationRepository.MAX_FAILED_AUTH_TRIES_BEFORE_LOCKOUT + 1
            repeat(attempts) { attempt ->
                underTest.onDragStart()
                CORRECT_PATTERN.subList(0, kosmos.authenticationRepository.minPatternLength - 1)
                    .forEach { coordinate ->
                CORRECT_PATTERN.subList(0, authenticationRepository.minPatternLength - 1).forEach {
                    coordinate ->
                    underTest.onDrag(
                        xPx = 30f * coordinate.x + 15,
                        yPx = 30f * coordinate.y + 15,
@@ -325,8 +323,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onDragEnd_correctAfterWrong() =
        kosmos.runTest {
            val authResult by
                collectLastValue(kosmos.authenticationInteractor.onAuthenticationResult)
            val authResult by collectLastValue(authenticationInteractor.onAuthenticationResult)
            val selectedDots by collectLastValue(underTest.selectedDots)
            val currentDot by collectLastValue(underTest.currentDot)
            lockDeviceAndOpenPatternBouncer()
@@ -352,9 +349,9 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
        kosmos.runTest {
            underTest.performDotFeedback(null)

            assertThat(kosmos.fakeMSDLPlayer.latestTokenPlayed)
            assertThat(fakeMSDLPlayer.latestTokenPlayed)
                .isEqualTo(MSDLToken.DRAG_INDICATOR_DISCRETE)
            assertThat(kosmos.fakeMSDLPlayer.latestPropertiesPlayed).isNull()
            assertThat(fakeMSDLPlayer.latestPropertiesPlayed).isNull()
        }

    private fun dragOverCoordinates(vararg coordinatesDragged: Point) {
@@ -371,12 +368,10 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
    }

    private fun Kosmos.lockDeviceAndOpenPatternBouncer() {
        val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
        kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
            AuthenticationMethodModel.Pattern
        )
        val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
        fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pattern)

        kosmos.sceneInteractor.showOverlay(Overlays.Bouncer, "reason")
        sceneInteractor.showOverlay(Overlays.Bouncer, "reason")
        runCurrent()

        assertThat(currentOverlays).contains(Overlays.Bouncer)
+37 −51
Original line number Diff line number Diff line
@@ -95,11 +95,11 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    fun simBouncerViewModel_simAreaIsVisible() =
        kosmos.runTest {
            val underTest =
                kosmos.pinBouncerViewModelFactory.create(
                pinBouncerViewModelFactory.create(
                    isInputEnabled = MutableStateFlow(true),
                    onIntentionalUserInput = {},
                    authenticationMethod = AuthenticationMethodModel.Sim,
                    bouncerHapticPlayer = kosmos.bouncerHapticPlayer,
                    bouncerHapticPlayer = bouncerHapticPlayer,
                )

            assertThat(underTest.isSimAreaVisible).isTrue()
@@ -109,7 +109,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    fun onErrorDialogDismissed_clearsDialogMessage() =
        kosmos.runTest {
            val dialogMessage by collectLastValue(underTest.errorDialogMessage)
            kosmos.fakeSimBouncerRepository.setSimVerificationErrorMessage("abc")
            fakeSimBouncerRepository.setSimVerificationErrorMessage("abc")
            assertThat(dialogMessage).isEqualTo("abc")

            underTest.onErrorDialogDismissed()
@@ -121,13 +121,13 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    fun simBouncerViewModel_autoConfirmEnabled_hintedPinLengthIsNull() =
        kosmos.runTest {
            val underTest =
                kosmos.pinBouncerViewModelFactory.create(
                pinBouncerViewModelFactory.create(
                    isInputEnabled = MutableStateFlow(true),
                    onIntentionalUserInput = {},
                    authenticationMethod = AuthenticationMethodModel.Pin,
                    bouncerHapticPlayer = kosmos.bouncerHapticPlayer,
                    bouncerHapticPlayer = bouncerHapticPlayer,
                )
            kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)
            fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)
            val hintedPinLength by collectLastValue(underTest.hintedPinLength)

            assertThat(hintedPinLength).isNull()
@@ -181,7 +181,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onBackspaceButtonLongPressed() =
        kosmos.runTest {
            val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
            lockDeviceAndOpenPinBouncer()

@@ -200,8 +200,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onAuthenticateButtonClicked_whenCorrect() =
        kosmos.runTest {
            val authResult by
                collectLastValue(kosmos.authenticationInteractor.onAuthenticationResult)
            val authResult by collectLastValue(authenticationInteractor.onAuthenticationResult)
            lockDeviceAndOpenPinBouncer()

            FakeAuthenticationRepository.DEFAULT_PIN.forEach(underTest::onPinButtonClicked)
@@ -214,7 +213,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onAuthenticateButtonClicked_whenWrong() =
        kosmos.runTest {
            val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
            lockDeviceAndOpenPinBouncer()

@@ -233,8 +232,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    @Test
    fun onAuthenticateButtonClicked_correctAfterWrong() =
        kosmos.runTest {
            val authResult by
                collectLastValue(kosmos.authenticationInteractor.onAuthenticationResult)
            val authResult by collectLastValue(authenticationInteractor.onAuthenticationResult)
            val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
            lockDeviceAndOpenPinBouncer()

@@ -262,12 +260,11 @@ class PinBouncerViewModelTest : SysuiTestCase() {
            // Collect the flow so that it is hot, in the real application this is done by using a
            // refreshingFlow that relies on the UI to make this flow hot.
            val autoConfirmEnabled by
                collectLastValue(kosmos.authenticationInteractor.isAutoConfirmEnabled)
            kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)
                collectLastValue(authenticationInteractor.isAutoConfirmEnabled)
            fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)

            assertThat(autoConfirmEnabled).isTrue()
            val authResult by
                collectLastValue(kosmos.authenticationInteractor.onAuthenticationResult)
            val authResult by collectLastValue(authenticationInteractor.onAuthenticationResult)
            lockDeviceAndOpenPinBouncer()

            FakeAuthenticationRepository.DEFAULT_PIN.forEach(underTest::onPinButtonClicked)
@@ -282,11 +279,11 @@ class PinBouncerViewModelTest : SysuiTestCase() {
            // Collect the flow so that it is hot, in the real application this is done by using a
            // refreshingFlow that relies on the UI to make this flow hot.
            val autoConfirmEnabled by
                collectLastValue(kosmos.authenticationInteractor.isAutoConfirmEnabled)
                collectLastValue(authenticationInteractor.isAutoConfirmEnabled)

            val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
            kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)
            fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)

            assertThat(autoConfirmEnabled).isTrue()
            lockDeviceAndOpenPinBouncer()
@@ -327,9 +324,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
        kosmos.runTest {
            val backspaceButtonAppearance by collectLastValue(underTest.backspaceButtonAppearance)

            kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
                AuthenticationMethodModel.Pin
            )
            fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)

            assertThat(backspaceButtonAppearance).isEqualTo(ActionButtonAppearance.Shown)
        }
@@ -338,10 +333,8 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    fun backspaceButtonAppearance_withAutoConfirmButNoInput_isHidden() =
        kosmos.runTest {
            val backspaceButtonAppearance by collectLastValue(underTest.backspaceButtonAppearance)
            kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
                AuthenticationMethodModel.Pin
            )
            kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)
            fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
            fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)

            assertThat(backspaceButtonAppearance).isEqualTo(ActionButtonAppearance.Hidden)
        }
@@ -350,10 +343,8 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    fun backspaceButtonAppearance_withAutoConfirmAndInput_isShownQuiet() =
        kosmos.runTest {
            val backspaceButtonAppearance by collectLastValue(underTest.backspaceButtonAppearance)
            kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
                AuthenticationMethodModel.Pin
            )
            kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)
            fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
            fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)
            runCurrent()

            underTest.onPinButtonClicked(1)
@@ -366,9 +357,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
        kosmos.runTest {
            val confirmButtonAppearance by collectLastValue(underTest.confirmButtonAppearance)

            kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
                AuthenticationMethodModel.Pin
            )
            fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)

            assertThat(confirmButtonAppearance).isEqualTo(ActionButtonAppearance.Shown)
        }
@@ -377,10 +366,8 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    fun confirmButtonAppearance_withAutoConfirm_isHidden() =
        kosmos.runTest {
            val confirmButtonAppearance by collectLastValue(underTest.confirmButtonAppearance)
            kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
                AuthenticationMethodModel.Pin
            )
            kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)
            fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
            fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)

            assertThat(confirmButtonAppearance).isEqualTo(ActionButtonAppearance.Hidden)
        }
@@ -390,10 +377,10 @@ class PinBouncerViewModelTest : SysuiTestCase() {
        kosmos.runTest {
            val isAnimationEnabled by collectLastValue(underTest.isDigitButtonAnimationEnabled)

            kosmos.fakeAuthenticationRepository.setPinEnhancedPrivacyEnabled(true)
            fakeAuthenticationRepository.setPinEnhancedPrivacyEnabled(true)
            assertThat(isAnimationEnabled).isFalse()

            kosmos.fakeAuthenticationRepository.setPinEnhancedPrivacyEnabled(false)
            fakeAuthenticationRepository.setPinEnhancedPrivacyEnabled(false)
            assertThat(isAnimationEnabled).isTrue()
        }

@@ -401,7 +388,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    fun onPinButtonClicked_whenInputSameLengthAsHintedPin_ignoresClick() =
        kosmos.runTest {
            val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
            kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)
            fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(true)
            val hintedPinLength by collectLastValue(underTest.hintedPinLength)
            assertThat(hintedPinLength).isEqualTo(FakeAuthenticationRepository.HINTING_PIN_LENGTH)
            lockDeviceAndOpenPinBouncer()
@@ -410,7 +397,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
                underTest.onPinButtonClicked(repetition + 1)
                runCurrent()
            }
            kosmos.fakeAuthenticationRepository.pauseCredentialChecking()
            fakeAuthenticationRepository.pauseCredentialChecking()
            // If credential checking were not paused, this would check the credentials and succeed.
            underTest.onPinButtonClicked(FakeAuthenticationRepository.HINTING_PIN_LENGTH)
            runCurrent()
@@ -430,7 +417,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
                    }
                )

            kosmos.fakeAuthenticationRepository.unpauseCredentialChecking()
            fakeAuthenticationRepository.unpauseCredentialChecking()
            runCurrent()
            assertThat(pin).isEmpty()
        }
@@ -439,7 +426,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    fun onPinButtonClicked_whenPinNotHinted_doesNotIgnoreClick() =
        kosmos.runTest {
            val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
            kosmos.fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(false)
            fakeAuthenticationRepository.setAutoConfirmFeatureEnabled(false)
            val hintedPinLength by collectLastValue(underTest.hintedPinLength)
            assertThat(hintedPinLength).isNull()
            lockDeviceAndOpenPinBouncer()
@@ -496,9 +483,8 @@ class PinBouncerViewModelTest : SysuiTestCase() {
        kosmos.runTest {
            underTest.onDigitButtonDown(null)

            assertThat(kosmos.fakeMSDLPlayer.latestTokenPlayed)
                .isEqualTo(MSDLToken.KEYPRESS_STANDARD)
            assertThat(kosmos.fakeMSDLPlayer.latestPropertiesPlayed).isNull()
            assertThat(fakeMSDLPlayer.latestTokenPlayed).isEqualTo(MSDLToken.KEYPRESS_STANDARD)
            assertThat(fakeMSDLPlayer.latestPropertiesPlayed).isNull()
        }

    @Test
@@ -520,16 +506,16 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    }

    private fun Kosmos.showBouncer() {
        val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
        kosmos.sceneInteractor.showOverlay(Overlays.Bouncer, "reason")
        val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
        sceneInteractor.showOverlay(Overlays.Bouncer, "reason")
        runCurrent()

        assertThat(currentOverlays).contains(Overlays.Bouncer)
    }

    private fun Kosmos.hideBouncer() {
        val currentOverlays by collectLastValue(kosmos.sceneInteractor.currentOverlays)
        kosmos.sceneInteractor.hideOverlay(Overlays.Bouncer, "reason")
        val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
        sceneInteractor.hideOverlay(Overlays.Bouncer, "reason")
        underTest.onHidden()
        runCurrent()

@@ -537,7 +523,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
    }

    private fun Kosmos.lockDeviceAndOpenPinBouncer() {
        kosmos.fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
        fakeAuthenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
        showBouncer()
    }