Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt +4 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,10 @@ constructor( /** Tell the bouncer to start the pre hide animation. */ fun startDisappearAnimation(runnable: Runnable) { if (willRunDismissFromKeyguard()) { runnable.run() return } val finishRunnable = Runnable { runnable.run() repository.setPrimaryStartDisappearAnimation(null) Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt +1 −3 Original line number Diff line number Diff line Loading @@ -81,9 +81,7 @@ constructor( ) .map { if (willRunDismissFromKeyguard) { ScrimAlpha( notificationsAlpha = 1f, ) ScrimAlpha() } else if (leaveShadeOpen) { ScrimAlpha( behindAlpha = 1f, Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractorTest.kt +44 −29 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import com.android.systemui.plugins.ActivityStarter import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.whenever import com.android.systemui.utils.os.FakeHandler import com.google.common.truth.Truth.assertThat import org.junit.Before Loading @@ -50,7 +51,6 @@ import org.mockito.Mock import org.mockito.Mockito.mock import org.mockito.Mockito.never import org.mockito.Mockito.verify import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @SmallTest Loading Loading @@ -90,9 +90,9 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { keyguardUpdateMonitor, keyguardBypassController, ) `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) `when`(repository.primaryBouncerShow.value).thenReturn(false) `when`(bouncerView.delegate).thenReturn(bouncerViewDelegate) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) whenever(repository.primaryBouncerShow.value).thenReturn(false) whenever(bouncerView.delegate).thenReturn(bouncerViewDelegate) resources = context.orCreateTestableResources } Loading @@ -118,7 +118,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testShow_keyguardIsDone() { `when`(bouncerView.delegate?.showNextSecurityScreenOrFinish()).thenReturn(true) whenever(bouncerView.delegate?.showNextSecurityScreenOrFinish()).thenReturn(true) verify(keyguardStateController, never()).notifyPrimaryBouncerShowing(true) verify(mPrimaryBouncerCallbackInteractor, never()).dispatchStartingToShow() } Loading @@ -135,7 +135,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testExpansion() { `when`(repository.panelExpansionAmount.value).thenReturn(0.5f) whenever(repository.panelExpansionAmount.value).thenReturn(0.5f) underTest.setPanelExpansion(0.6f) verify(repository).setPanelExpansion(0.6f) verify(mPrimaryBouncerCallbackInteractor).dispatchExpansionChanged(0.6f) Loading @@ -143,8 +143,8 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testExpansion_fullyShown() { `when`(repository.panelExpansionAmount.value).thenReturn(0.5f) `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) whenever(repository.panelExpansionAmount.value).thenReturn(0.5f) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) underTest.setPanelExpansion(EXPANSION_VISIBLE) verify(falsingCollector).onBouncerShown() verify(mPrimaryBouncerCallbackInteractor).dispatchFullyShown() Loading @@ -152,8 +152,8 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testExpansion_fullyHidden() { `when`(repository.panelExpansionAmount.value).thenReturn(0.5f) `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) whenever(repository.panelExpansionAmount.value).thenReturn(0.5f) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) underTest.setPanelExpansion(EXPANSION_HIDDEN) verify(repository).setPrimaryShow(false) verify(falsingCollector).onBouncerHidden() Loading @@ -163,7 +163,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testExpansion_startingToHide() { `when`(repository.panelExpansionAmount.value).thenReturn(EXPANSION_VISIBLE) whenever(repository.panelExpansionAmount.value).thenReturn(EXPANSION_VISIBLE) underTest.setPanelExpansion(0.1f) verify(repository).setPrimaryStartingToHide(true) verify(mPrimaryBouncerCallbackInteractor).dispatchStartingToHide() Loading Loading @@ -228,7 +228,21 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { } @Test fun testStartDisappearAnimation() { fun testStartDisappearAnimation_willRunDismissFromKeyguard() { whenever(bouncerViewDelegate.willRunDismissFromKeyguard()).thenReturn(true) val runnable = mock(Runnable::class.java) underTest.startDisappearAnimation(runnable) // End runnable should run immediately verify(runnable).run() // ... while the disappear animation should never be run verify(repository, never()).setPrimaryStartDisappearAnimation(any(Runnable::class.java)) } @Test fun testStartDisappearAnimation_willNotRunDismissFromKeyguard_() { whenever(bouncerViewDelegate.willRunDismissFromKeyguard()).thenReturn(false) val runnable = mock(Runnable::class.java) underTest.startDisappearAnimation(runnable) verify(repository).setPrimaryStartDisappearAnimation(any(Runnable::class.java)) Loading @@ -236,45 +250,45 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testIsFullShowing() { `when`(repository.primaryBouncerShow.value).thenReturn(true) `when`(repository.panelExpansionAmount.value).thenReturn(EXPANSION_VISIBLE) `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) whenever(repository.primaryBouncerShow.value).thenReturn(true) whenever(repository.panelExpansionAmount.value).thenReturn(EXPANSION_VISIBLE) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) assertThat(underTest.isFullyShowing()).isTrue() `when`(repository.primaryBouncerShow.value).thenReturn(false) whenever(repository.primaryBouncerShow.value).thenReturn(false) assertThat(underTest.isFullyShowing()).isFalse() } @Test fun testIsScrimmed() { `when`(repository.primaryBouncerScrimmed.value).thenReturn(true) whenever(repository.primaryBouncerScrimmed.value).thenReturn(true) assertThat(underTest.isScrimmed()).isTrue() `when`(repository.primaryBouncerScrimmed.value).thenReturn(false) whenever(repository.primaryBouncerScrimmed.value).thenReturn(false) assertThat(underTest.isScrimmed()).isFalse() } @Test fun testIsInTransit() { `when`(repository.primaryBouncerShowingSoon.value).thenReturn(true) whenever(repository.primaryBouncerShowingSoon.value).thenReturn(true) assertThat(underTest.isInTransit()).isTrue() `when`(repository.primaryBouncerShowingSoon.value).thenReturn(false) whenever(repository.primaryBouncerShowingSoon.value).thenReturn(false) assertThat(underTest.isInTransit()).isFalse() `when`(repository.panelExpansionAmount.value).thenReturn(0.5f) whenever(repository.panelExpansionAmount.value).thenReturn(0.5f) assertThat(underTest.isInTransit()).isTrue() } @Test fun testIsAnimatingAway() { `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(Runnable {}) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(Runnable {}) assertThat(underTest.isAnimatingAway()).isTrue() `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) assertThat(underTest.isAnimatingAway()).isFalse() } @Test fun testWillDismissWithAction() { `when`(bouncerViewDelegate.willDismissWithActions()).thenReturn(true) whenever(bouncerViewDelegate.willDismissWithActions()).thenReturn(true) assertThat(underTest.willDismissWithAction()).isTrue() `when`(bouncerViewDelegate.willDismissWithActions()).thenReturn(false) whenever(bouncerViewDelegate.willDismissWithActions()).thenReturn(false) assertThat(underTest.willDismissWithAction()).isFalse() } Loading Loading @@ -363,12 +377,13 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { isUnlockingWithFpAllowed: Boolean, isAnimatingAway: Boolean ) { `when`(repository.primaryBouncerShow.value).thenReturn(isVisible) whenever(repository.primaryBouncerShow.value).thenReturn(isVisible) resources.addOverride(R.bool.config_show_sidefps_hint_on_bouncer, sfpsEnabled) `when`(keyguardUpdateMonitor.isFingerprintDetectionRunning).thenReturn(fpsDetectionRunning) `when`(keyguardUpdateMonitor.isUnlockingWithFingerprintAllowed) whenever(keyguardUpdateMonitor.isFingerprintDetectionRunning) .thenReturn(fpsDetectionRunning) whenever(keyguardUpdateMonitor.isUnlockingWithFingerprintAllowed) .thenReturn(isUnlockingWithFpAllowed) `when`(repository.primaryBouncerStartingDisappearAnimation.value) whenever(repository.primaryBouncerStartingDisappearAnimation.value) .thenReturn(if (isAnimatingAway) Runnable {} else null) } } packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ class PrimaryBouncerToGoneTransitionViewModelTest : SysuiTestCase() { repository.sendTransitionStep(step(1f)) assertThat(values.size).isEqualTo(4) values.forEach { assertThat(it).isEqualTo(ScrimAlpha(notificationsAlpha = 1f)) } values.forEach { assertThat(it).isEqualTo(ScrimAlpha()) } job.cancel() } Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt +4 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,10 @@ constructor( /** Tell the bouncer to start the pre hide animation. */ fun startDisappearAnimation(runnable: Runnable) { if (willRunDismissFromKeyguard()) { runnable.run() return } val finishRunnable = Runnable { runnable.run() repository.setPrimaryStartDisappearAnimation(null) Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt +1 −3 Original line number Diff line number Diff line Loading @@ -81,9 +81,7 @@ constructor( ) .map { if (willRunDismissFromKeyguard) { ScrimAlpha( notificationsAlpha = 1f, ) ScrimAlpha() } else if (leaveShadeOpen) { ScrimAlpha( behindAlpha = 1f, Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractorTest.kt +44 −29 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import com.android.systemui.plugins.ActivityStarter import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.whenever import com.android.systemui.utils.os.FakeHandler import com.google.common.truth.Truth.assertThat import org.junit.Before Loading @@ -50,7 +51,6 @@ import org.mockito.Mock import org.mockito.Mockito.mock import org.mockito.Mockito.never import org.mockito.Mockito.verify import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @SmallTest Loading Loading @@ -90,9 +90,9 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { keyguardUpdateMonitor, keyguardBypassController, ) `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) `when`(repository.primaryBouncerShow.value).thenReturn(false) `when`(bouncerView.delegate).thenReturn(bouncerViewDelegate) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) whenever(repository.primaryBouncerShow.value).thenReturn(false) whenever(bouncerView.delegate).thenReturn(bouncerViewDelegate) resources = context.orCreateTestableResources } Loading @@ -118,7 +118,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testShow_keyguardIsDone() { `when`(bouncerView.delegate?.showNextSecurityScreenOrFinish()).thenReturn(true) whenever(bouncerView.delegate?.showNextSecurityScreenOrFinish()).thenReturn(true) verify(keyguardStateController, never()).notifyPrimaryBouncerShowing(true) verify(mPrimaryBouncerCallbackInteractor, never()).dispatchStartingToShow() } Loading @@ -135,7 +135,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testExpansion() { `when`(repository.panelExpansionAmount.value).thenReturn(0.5f) whenever(repository.panelExpansionAmount.value).thenReturn(0.5f) underTest.setPanelExpansion(0.6f) verify(repository).setPanelExpansion(0.6f) verify(mPrimaryBouncerCallbackInteractor).dispatchExpansionChanged(0.6f) Loading @@ -143,8 +143,8 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testExpansion_fullyShown() { `when`(repository.panelExpansionAmount.value).thenReturn(0.5f) `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) whenever(repository.panelExpansionAmount.value).thenReturn(0.5f) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) underTest.setPanelExpansion(EXPANSION_VISIBLE) verify(falsingCollector).onBouncerShown() verify(mPrimaryBouncerCallbackInteractor).dispatchFullyShown() Loading @@ -152,8 +152,8 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testExpansion_fullyHidden() { `when`(repository.panelExpansionAmount.value).thenReturn(0.5f) `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) whenever(repository.panelExpansionAmount.value).thenReturn(0.5f) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) underTest.setPanelExpansion(EXPANSION_HIDDEN) verify(repository).setPrimaryShow(false) verify(falsingCollector).onBouncerHidden() Loading @@ -163,7 +163,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testExpansion_startingToHide() { `when`(repository.panelExpansionAmount.value).thenReturn(EXPANSION_VISIBLE) whenever(repository.panelExpansionAmount.value).thenReturn(EXPANSION_VISIBLE) underTest.setPanelExpansion(0.1f) verify(repository).setPrimaryStartingToHide(true) verify(mPrimaryBouncerCallbackInteractor).dispatchStartingToHide() Loading Loading @@ -228,7 +228,21 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { } @Test fun testStartDisappearAnimation() { fun testStartDisappearAnimation_willRunDismissFromKeyguard() { whenever(bouncerViewDelegate.willRunDismissFromKeyguard()).thenReturn(true) val runnable = mock(Runnable::class.java) underTest.startDisappearAnimation(runnable) // End runnable should run immediately verify(runnable).run() // ... while the disappear animation should never be run verify(repository, never()).setPrimaryStartDisappearAnimation(any(Runnable::class.java)) } @Test fun testStartDisappearAnimation_willNotRunDismissFromKeyguard_() { whenever(bouncerViewDelegate.willRunDismissFromKeyguard()).thenReturn(false) val runnable = mock(Runnable::class.java) underTest.startDisappearAnimation(runnable) verify(repository).setPrimaryStartDisappearAnimation(any(Runnable::class.java)) Loading @@ -236,45 +250,45 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { @Test fun testIsFullShowing() { `when`(repository.primaryBouncerShow.value).thenReturn(true) `when`(repository.panelExpansionAmount.value).thenReturn(EXPANSION_VISIBLE) `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) whenever(repository.primaryBouncerShow.value).thenReturn(true) whenever(repository.panelExpansionAmount.value).thenReturn(EXPANSION_VISIBLE) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) assertThat(underTest.isFullyShowing()).isTrue() `when`(repository.primaryBouncerShow.value).thenReturn(false) whenever(repository.primaryBouncerShow.value).thenReturn(false) assertThat(underTest.isFullyShowing()).isFalse() } @Test fun testIsScrimmed() { `when`(repository.primaryBouncerScrimmed.value).thenReturn(true) whenever(repository.primaryBouncerScrimmed.value).thenReturn(true) assertThat(underTest.isScrimmed()).isTrue() `when`(repository.primaryBouncerScrimmed.value).thenReturn(false) whenever(repository.primaryBouncerScrimmed.value).thenReturn(false) assertThat(underTest.isScrimmed()).isFalse() } @Test fun testIsInTransit() { `when`(repository.primaryBouncerShowingSoon.value).thenReturn(true) whenever(repository.primaryBouncerShowingSoon.value).thenReturn(true) assertThat(underTest.isInTransit()).isTrue() `when`(repository.primaryBouncerShowingSoon.value).thenReturn(false) whenever(repository.primaryBouncerShowingSoon.value).thenReturn(false) assertThat(underTest.isInTransit()).isFalse() `when`(repository.panelExpansionAmount.value).thenReturn(0.5f) whenever(repository.panelExpansionAmount.value).thenReturn(0.5f) assertThat(underTest.isInTransit()).isTrue() } @Test fun testIsAnimatingAway() { `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(Runnable {}) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(Runnable {}) assertThat(underTest.isAnimatingAway()).isTrue() `when`(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) whenever(repository.primaryBouncerStartingDisappearAnimation.value).thenReturn(null) assertThat(underTest.isAnimatingAway()).isFalse() } @Test fun testWillDismissWithAction() { `when`(bouncerViewDelegate.willDismissWithActions()).thenReturn(true) whenever(bouncerViewDelegate.willDismissWithActions()).thenReturn(true) assertThat(underTest.willDismissWithAction()).isTrue() `when`(bouncerViewDelegate.willDismissWithActions()).thenReturn(false) whenever(bouncerViewDelegate.willDismissWithActions()).thenReturn(false) assertThat(underTest.willDismissWithAction()).isFalse() } Loading Loading @@ -363,12 +377,13 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() { isUnlockingWithFpAllowed: Boolean, isAnimatingAway: Boolean ) { `when`(repository.primaryBouncerShow.value).thenReturn(isVisible) whenever(repository.primaryBouncerShow.value).thenReturn(isVisible) resources.addOverride(R.bool.config_show_sidefps_hint_on_bouncer, sfpsEnabled) `when`(keyguardUpdateMonitor.isFingerprintDetectionRunning).thenReturn(fpsDetectionRunning) `when`(keyguardUpdateMonitor.isUnlockingWithFingerprintAllowed) whenever(keyguardUpdateMonitor.isFingerprintDetectionRunning) .thenReturn(fpsDetectionRunning) whenever(keyguardUpdateMonitor.isUnlockingWithFingerprintAllowed) .thenReturn(isUnlockingWithFpAllowed) `when`(repository.primaryBouncerStartingDisappearAnimation.value) whenever(repository.primaryBouncerStartingDisappearAnimation.value) .thenReturn(if (isAnimatingAway) Runnable {} else null) } }
packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ class PrimaryBouncerToGoneTransitionViewModelTest : SysuiTestCase() { repository.sendTransitionStep(step(1f)) assertThat(values.size).isEqualTo(4) values.forEach { assertThat(it).isEqualTo(ScrimAlpha(notificationsAlpha = 1f)) } values.forEach { assertThat(it).isEqualTo(ScrimAlpha()) } job.cancel() } Loading