diff --git a/packages/SystemUI/res/layout/status_bar_notification_footer.xml b/packages/SystemUI/res/layout/status_bar_notification_footer.xml index bbb8df1c5a4aa..db94c92738f27 100644 --- a/packages/SystemUI/res/layout/status_bar_notification_footer.xml +++ b/packages/SystemUI/res/layout/status_bar_notification_footer.xml @@ -26,6 +26,17 @@ android:id="@+id/content" android:layout_width="match_parent" android:layout_height="wrap_content"> + mStateListenerArgumentCaptor; + private final SeenNotificationsProviderImpl mSeenNotificationsProvider = + new SeenNotificationsProviderImpl(); + private NotificationStackScrollLayoutController mController; @Before @@ -180,7 +185,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { mUiEventLogger, mRemoteInputManager, mVisibilityLocationProviderDelegator, - new SeenNotificationsProviderImpl(), + mSeenNotificationsProvider, mShadeController, mJankMonitor, mStackLogger, @@ -233,16 +238,14 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ true, - /* notifVisibleInShade= */ true, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ true); setupShowEmptyShadeViewState(false); reset(mNotificationStackScrollLayout); mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ false, - /* notifVisibleInShade= */ true, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ true); } @Test @@ -255,16 +258,14 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ true, - /* notifVisibleInShade= */ false, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ false); setupShowEmptyShadeViewState(false); reset(mNotificationStackScrollLayout); mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ false, - /* notifVisibleInShade= */ false, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ false); } @Test @@ -283,16 +284,14 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ true, - /* notifVisibleInShade= */ false, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ false); mController.setQsFullScreen(true); reset(mNotificationStackScrollLayout); mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ true, - /* notifVisibleInShade= */ false, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ false); } @Test @@ -400,6 +399,17 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { verify(mNotificationStackScrollLayout).setIsRemoteInputActive(true); } + @Test + public void testSetNotifStats_updatesHasFilteredOutSeenNotifications() { + when(mNotifPipelineFlags.getShouldFilterUnseenNotifsOnKeyguard()).thenReturn(true); + mSeenNotificationsProvider.setHasFilteredOutSeenNotifications(true); + mController.attach(mNotificationStackScrollLayout); + mController.getNotifStackController().setNotifStats(NotifStats.getEmpty()); + verify(mNotificationStackScrollLayout).setHasFilteredOutSeenNotifications(true); + verify(mNotificationStackScrollLayout).updateFooter(); + verify(mNotificationStackScrollLayout).updateEmptyShadeView(anyBoolean(), anyBoolean()); + } + private LogMaker logMatcher(int category, int type) { return argThat(new LogMatcher(category, type)); } 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 7622549d29dee..dd7143ae7e169 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 @@ -30,6 +30,7 @@ import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertFalse; +import static org.mockito.AdditionalMatchers.not; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; @@ -53,6 +54,7 @@ import android.util.MathUtils; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import androidx.test.annotation.UiThreadTest; import androidx.test.filters.SmallTest; @@ -328,7 +330,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { public void updateEmptyView_dndSuppressing() { when(mEmptyShadeView.willBeGone()).thenReturn(true); - mStackScroller.updateEmptyShadeView(true, true, false); + mStackScroller.updateEmptyShadeView(true, true); verify(mEmptyShadeView).setText(R.string.dnd_suppressing_shade_text); } @@ -338,7 +340,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { mStackScroller.setEmptyShadeView(mEmptyShadeView); when(mEmptyShadeView.willBeGone()).thenReturn(true); - mStackScroller.updateEmptyShadeView(true, false, false); + mStackScroller.updateEmptyShadeView(true, false); verify(mEmptyShadeView).setText(R.string.empty_shade_text); } @@ -347,10 +349,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { public void updateEmptyView_noNotificationsToDndSuppressing() { mStackScroller.setEmptyShadeView(mEmptyShadeView); when(mEmptyShadeView.willBeGone()).thenReturn(true); - mStackScroller.updateEmptyShadeView(true, false, false); + mStackScroller.updateEmptyShadeView(true, false); verify(mEmptyShadeView).setText(R.string.empty_shade_text); - mStackScroller.updateEmptyShadeView(true, true, false); + mStackScroller.updateEmptyShadeView(true, true); verify(mEmptyShadeView).setText(R.string.dnd_suppressing_shade_text); } @@ -818,6 +820,29 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { assertEquals(0f, mAmbientState.getStackY()); } + @Test + public void hasFilteredOutSeenNotifs_updateFooter() { + mStackScroller.setCurrentUserSetup(true); + + // add footer + mStackScroller.inflateFooterView(); + TextView footerLabel = + mStackScroller.mFooterView.requireViewById(R.id.unlock_prompt_footer); + + mStackScroller.setHasFilteredOutSeenNotifications(true); + mStackScroller.updateFooter(); + + assertThat(footerLabel.getVisibility()).isEqualTo(View.VISIBLE); + } + + @Test + public void hasFilteredOutSeenNotifs_updateEmptyShadeView() { + mStackScroller.setHasFilteredOutSeenNotifications(true); + mStackScroller.updateEmptyShadeView(true, false); + + verify(mEmptyShadeView).setFooterText(not(0)); + } + private void setBarStateForTest(int state) { // Can't inject this through the listener or we end up on the actual implementation // rather than the mock because the spy just coppied the anonymous inner /shruggie.