diff options
Diffstat (limited to 'packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java')
-rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index f5fe6f3a1a5f..b83743c90623 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -39,6 +39,7 @@ import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -122,12 +123,12 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { allowTestableLooperAsMainThread(); // Interact with real instance of AmbientState. - mAmbientState = new AmbientState( + mAmbientState = spy(new AmbientState( mContext, mDumpManager, mNotificationSectionsManager, mBypassController, - mStatusBarKeyguardViewManager); + mStatusBarKeyguardViewManager)); // Inject dependencies before initializing the layout mDependency.injectTestDependency(SysuiStatusBarStateController.class, mBarState); @@ -190,7 +191,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { endHeight, dozeAmount); mStackScroller.updateStackHeight(endHeight, expansionFraction); - assertTrue(mAmbientState.getStackHeight() == expected); + assertThat(mAmbientState.getStackHeight()).isEqualTo(expected); } @Test @@ -205,7 +206,74 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { endHeight, expansionFraction); mStackScroller.updateStackHeight(endHeight, expansionFraction); - assertTrue(mAmbientState.getStackHeight() == expected); + assertThat(mAmbientState.getStackHeight()).isEqualTo(expected); + } + + @Test + public void updateStackEndHeightAndStackHeight_normallyUpdatesBoth() { + final float expansionFraction = 0.5f; + mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); + + // Validate that by default we update everything + clearInvocations(mAmbientState); + mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); + verify(mAmbientState).setStackEndHeight(anyFloat()); + verify(mAmbientState).setStackHeight(anyFloat()); + } + + @Test + public void updateStackEndHeightAndStackHeight_onlyUpdatesStackHeightDuringSwipeUp() { + final float expansionFraction = 0.5f; + mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); + mAmbientState.setSwipingUp(true); + + // Validate that when the gesture is in progress, we update only the stackHeight + clearInvocations(mAmbientState); + mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); + verify(mAmbientState, never()).setStackEndHeight(anyFloat()); + verify(mAmbientState).setStackHeight(anyFloat()); + } + + @Test + public void setPanelFlinging_updatesStackEndHeightOnlyOnFinish() { + final float expansionFraction = 0.5f; + mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); + mAmbientState.setSwipingUp(true); + mStackScroller.setPanelFlinging(true); + mAmbientState.setSwipingUp(false); + + // Validate that when the animation is running, we update only the stackHeight + clearInvocations(mAmbientState); + mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); + verify(mAmbientState, never()).setStackEndHeight(anyFloat()); + verify(mAmbientState).setStackHeight(anyFloat()); + + // Validate that when the animation ends the stackEndHeight is recalculated immediately + clearInvocations(mAmbientState); + mStackScroller.setPanelFlinging(false); + verify(mAmbientState).setIsFlinging(eq(false)); + verify(mAmbientState).setStackEndHeight(anyFloat()); + verify(mAmbientState).setStackHeight(anyFloat()); + } + + @Test + public void setUnlockHintRunning_updatesStackEndHeightOnlyOnFinish() { + final float expansionFraction = 0.5f; + mAmbientState.setStatusBarState(StatusBarState.KEYGUARD); + mStackScroller.setUnlockHintRunning(true); + + // Validate that when the animation is running, we update only the stackHeight + clearInvocations(mAmbientState); + mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); + verify(mAmbientState, never()).setStackEndHeight(anyFloat()); + verify(mAmbientState).setStackHeight(anyFloat()); + + // Validate that when the animation ends the stackEndHeight is recalculated immediately + clearInvocations(mAmbientState); + mStackScroller.setUnlockHintRunning(false); + verify(mAmbientState).setUnlockHintRunning(eq(false)); + verify(mAmbientState).setStackEndHeight(anyFloat()); + verify(mAmbientState).setStackHeight(anyFloat()); } @Test |