Loading packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImpl.kt +3 −1 Original line number Diff line number Diff line Loading @@ -188,7 +188,9 @@ constructor( if (animationState.value == ANIMATING_OUT) { coroutineScope.launch { withTimeout(DISAPPEAR_ANIMATION_DURATION) { animationState.first { it == SHOWING_PERSISTENT_DOT || it == ANIMATION_QUEUED } animationState.first { it == SHOWING_PERSISTENT_DOT || it == IDLE || it == ANIMATION_QUEUED } notifyHidePersistentDot() } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImplTest.kt +30 −0 Original line number Diff line number Diff line Loading @@ -60,9 +60,13 @@ import org.mockito.MockitoAnnotations class SystemStatusAnimationSchedulerImplTest : SysuiTestCase() { @Mock private lateinit var systemEventCoordinator: SystemEventCoordinator @Mock private lateinit var statusBarWindowController: StatusBarWindowController @Mock private lateinit var statusBarContentInsetProvider: StatusBarContentInsetsProvider @Mock private lateinit var dumpManager: DumpManager @Mock private lateinit var listener: SystemStatusAnimationCallback private lateinit var systemClock: FakeSystemClock Loading Loading @@ -379,6 +383,32 @@ class SystemStatusAnimationSchedulerImplTest : SysuiTestCase() { verify(listener, never()).onHidePersistentDot() } @Test fun testPrivacyDot_isRemovedDuringChipDisappearAnimation() = runTest { // Instantiate class under test with TestScope from runTest initializeSystemStatusAnimationScheduler(testScope = this) // create and schedule high priority event createAndScheduleFakePrivacyEvent() // fast forward to ANIMATING_OUT state fastForwardAnimationToState(ANIMATING_OUT) assertEquals(ANIMATING_OUT, systemStatusAnimationScheduler.getAnimationState()) verify(listener, times(1)).onSystemStatusAnimationTransitionToPersistentDot(any()) // remove persistent dot systemStatusAnimationScheduler.removePersistentDot() testScheduler.runCurrent() // skip disappear animation animatorTestRule.advanceTimeBy(DISAPPEAR_ANIMATION_DURATION) testScheduler.runCurrent() // verify that animationState changes to IDLE and onHidePersistentDot callback is invoked assertEquals(IDLE, systemStatusAnimationScheduler.getAnimationState()) verify(listener, times(1)).onHidePersistentDot() } @Test fun testPrivacyEvent_forceVisibleIsUpdated_whenRescheduledDuringQueuedState() = runTest { // Instantiate class under test with TestScope from runTest Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImpl.kt +3 −1 Original line number Diff line number Diff line Loading @@ -188,7 +188,9 @@ constructor( if (animationState.value == ANIMATING_OUT) { coroutineScope.launch { withTimeout(DISAPPEAR_ANIMATION_DURATION) { animationState.first { it == SHOWING_PERSISTENT_DOT || it == ANIMATION_QUEUED } animationState.first { it == SHOWING_PERSISTENT_DOT || it == IDLE || it == ANIMATION_QUEUED } notifyHidePersistentDot() } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImplTest.kt +30 −0 Original line number Diff line number Diff line Loading @@ -60,9 +60,13 @@ import org.mockito.MockitoAnnotations class SystemStatusAnimationSchedulerImplTest : SysuiTestCase() { @Mock private lateinit var systemEventCoordinator: SystemEventCoordinator @Mock private lateinit var statusBarWindowController: StatusBarWindowController @Mock private lateinit var statusBarContentInsetProvider: StatusBarContentInsetsProvider @Mock private lateinit var dumpManager: DumpManager @Mock private lateinit var listener: SystemStatusAnimationCallback private lateinit var systemClock: FakeSystemClock Loading Loading @@ -379,6 +383,32 @@ class SystemStatusAnimationSchedulerImplTest : SysuiTestCase() { verify(listener, never()).onHidePersistentDot() } @Test fun testPrivacyDot_isRemovedDuringChipDisappearAnimation() = runTest { // Instantiate class under test with TestScope from runTest initializeSystemStatusAnimationScheduler(testScope = this) // create and schedule high priority event createAndScheduleFakePrivacyEvent() // fast forward to ANIMATING_OUT state fastForwardAnimationToState(ANIMATING_OUT) assertEquals(ANIMATING_OUT, systemStatusAnimationScheduler.getAnimationState()) verify(listener, times(1)).onSystemStatusAnimationTransitionToPersistentDot(any()) // remove persistent dot systemStatusAnimationScheduler.removePersistentDot() testScheduler.runCurrent() // skip disappear animation animatorTestRule.advanceTimeBy(DISAPPEAR_ANIMATION_DURATION) testScheduler.runCurrent() // verify that animationState changes to IDLE and onHidePersistentDot callback is invoked assertEquals(IDLE, systemStatusAnimationScheduler.getAnimationState()) verify(listener, times(1)).onHidePersistentDot() } @Test fun testPrivacyEvent_forceVisibleIsUpdated_whenRescheduledDuringQueuedState() = runTest { // Instantiate class under test with TestScope from runTest Loading