Merge "Add 'notificaton blocked' filter to notifications"

This commit is contained in:
TreeHugger Robot
2018-09-25 22:34:37 +00:00
committed by Android (Google) Code Review
6 changed files with 78 additions and 28 deletions

View File

@@ -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<>();

View File

@@ -200,13 +200,13 @@ public class ManageApplicationsTest {
}
@Test
public void shouldUseStableItemHeight_mainType_yes() {
public void shouldUseStableItemHeight() {
assertThat(ManageApplications.ApplicationsAdapter.shouldUseStableItemHeight(
LIST_TYPE_MAIN))
.isTrue();
assertThat(ManageApplications.ApplicationsAdapter.shouldUseStableItemHeight(
LIST_TYPE_NOTIFICATION))
.isFalse();
.isTrue();
}
@Test