From 0636ffb7467b6437fd6a72810d3bf93d38966b72 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Tue, 25 Jul 2023 15:08:50 -0700 Subject: [PATCH] [flexiglass] Fixes failing test after coroutine lib upgrade. The changed test case started failing after the coroutines library has been upgraded; not sure why. This fixes it by toggling the isUnlocked state to trigger the flow under test to update (since updating getAuthenticationMethod() or isLockscreenEnabled does not trigger this flow to update). Bug: 292807808 Test: N/A Change-Id: Ie26c407931e52a98235c575adf9ba12186caa3a2 Merged-In: Ie26c407931e52a98235c575adf9ba12186caa3a2 (cherry picked from commit cd2676756650066861218b03b3a0200640cfecc4) --- .../interactor/AuthenticationInteractorTest.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/SystemUI/tests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt index 1990c8f644b41..18ace162696a4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt @@ -86,6 +86,22 @@ class AuthenticationInteractorTest : SysuiTestCase() { underTest.biometricUnlock() runCurrent() + // Toggle isUnlocked, twice. + // + // This is done because the underTest.isUnlocked flow doesn't receive values from + // just changing the state above; the actual isUnlocked state needs to change to + // cause the logic under test to "pick up" the current state again. + // + // It is done twice to make sure that we don't actually change the isUnlocked + // state from what it originally was. + utils.authenticationRepository().setUnlocked( + !utils.authenticationRepository().isUnlocked.value + ) + runCurrent() + utils.authenticationRepository().setUnlocked( + !utils.authenticationRepository().isUnlocked.value + ) + runCurrent() assertThat(isUnlocked).isTrue() }