Add 'notificaton blocked' filter to notifications
Test: robotests Change-Id: I5c0cd9a2f73b6a22d66df7669e944bbe1473539c Fixes: 112576746
This commit is contained in:
@@ -18,6 +18,8 @@ package com.android.settings.applications;
|
||||
|
||||
import static android.text.format.DateUtils.DAY_IN_MILLIS;
|
||||
|
||||
import static com.android.settings.applications.AppStateNotificationBridge
|
||||
.FILTER_APP_NOTIFICATION_BLOCKED;
|
||||
import static com.android.settings.applications.AppStateNotificationBridge
|
||||
.FILTER_APP_NOTIFICATION_FREQUENCY;
|
||||
import static com.android.settings.applications.AppStateNotificationBridge
|
||||
@@ -379,10 +381,11 @@ public class AppStateNotificationBridgeTest {
|
||||
NotificationsSentState sent = new NotificationsSentState();
|
||||
sent.lastSent = System.currentTimeMillis() - (2 * DAY_IN_MILLIS);
|
||||
|
||||
assertThat(AppStateNotificationBridge.getSummary(mContext, neverSent, true)).isEqualTo(
|
||||
mContext.getString(R.string.notifications_sent_never));
|
||||
assertThat(AppStateNotificationBridge.getSummary(mContext, sent, true).toString())
|
||||
.contains("2");
|
||||
assertThat(AppStateNotificationBridge.getSummary(
|
||||
mContext, neverSent, R.id.sort_order_recent_notification)).isEqualTo(
|
||||
mContext.getString(R.string.notifications_sent_never));
|
||||
assertThat(AppStateNotificationBridge.getSummary(
|
||||
mContext, sent, R.id.sort_order_recent_notification).toString()).contains("2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -392,12 +395,23 @@ public class AppStateNotificationBridgeTest {
|
||||
NotificationsSentState sentOften = new NotificationsSentState();
|
||||
sentOften.avgSentDaily = 8;
|
||||
|
||||
assertThat(AppStateNotificationBridge.getSummary(mContext, sentRarely, false).toString())
|
||||
assertThat(AppStateNotificationBridge.getSummary(
|
||||
mContext, sentRarely, R.id.sort_order_frequent_notification).toString())
|
||||
.contains("1");
|
||||
assertThat(AppStateNotificationBridge.getSummary(mContext, sentOften, false).toString())
|
||||
assertThat(AppStateNotificationBridge.getSummary(
|
||||
mContext, sentOften, R.id.sort_order_frequent_notification).toString())
|
||||
.contains("8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSummary_alpha() {
|
||||
NotificationsSentState sentRarely = new NotificationsSentState();
|
||||
sentRarely.avgSentWeekly = 1;
|
||||
assertThat(AppStateNotificationBridge.getSummary(
|
||||
mContext, sentRarely, R.id.sort_order_alpha).toString())
|
||||
.isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterRecency() {
|
||||
NotificationsSentState allowState = new NotificationsSentState();
|
||||
@@ -432,6 +446,23 @@ public class AppStateNotificationBridgeTest {
|
||||
assertFalse(FILTER_APP_NOTIFICATION_FREQUENCY.filterApp(deny));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterBlocked() {
|
||||
NotificationsSentState allowState = new NotificationsSentState();
|
||||
allowState.blocked = true;
|
||||
AppEntry allow = mock(AppEntry.class);
|
||||
allow.extraInfo = allowState;
|
||||
|
||||
assertTrue(FILTER_APP_NOTIFICATION_BLOCKED.filterApp(allow));
|
||||
|
||||
NotificationsSentState denyState = new NotificationsSentState();
|
||||
denyState.blocked = false;
|
||||
AppEntry deny = mock(AppEntry.class);
|
||||
deny.extraInfo = denyState;
|
||||
|
||||
assertFalse(FILTER_APP_NOTIFICATION_BLOCKED.filterApp(deny));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComparators_nullsNoCrash() {
|
||||
List<AppEntry> entries = new ArrayList<>();
|
||||
|
Reference in New Issue
Block a user