use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project android_packages_apps_Settings by omnirom.
the class AppStateNotificationBridgeTest method testLoadAllExtraInfo_multipleEventsAgg.
@Test
public void testLoadAllExtraInfo_multipleEventsAgg() throws RemoteException {
List<Event> events = new ArrayList<>();
for (int i = 0; i < 7; i++) {
Event good = new Event();
good.mEventType = Event.NOTIFICATION_INTERRUPTION;
good.mPackage = PKG1;
good.mTimeStamp = i;
events.add(good);
}
UsageEvents usageEvents = getUsageEvents(events);
when(mUsageStats.queryEventsForUser(anyLong(), anyLong(), anyInt(), anyString())).thenReturn(usageEvents);
ArrayList<AppEntry> apps = new ArrayList<>();
apps.add(getMockAppEntry(PKG1));
when(mSession.getAllApps()).thenReturn(apps);
mBridge.loadAllExtraInfo();
assertThat(((NotificationsSentState) apps.get(0).extraInfo).sentCount).isEqualTo(7);
assertThat(((NotificationsSentState) apps.get(0).extraInfo).lastSent).isEqualTo(6);
assertThat(((NotificationsSentState) apps.get(0).extraInfo).avgSentDaily).isEqualTo(1);
assertThat(((NotificationsSentState) apps.get(0).extraInfo).avgSentWeekly).isEqualTo(0);
assertThat(((NotificationsSentState) apps.get(0).extraInfo).blocked).isTrue();
assertThat(((NotificationsSentState) apps.get(0).extraInfo).systemApp).isTrue();
assertThat(((NotificationsSentState) apps.get(0).extraInfo).blockable).isTrue();
}
use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project android_packages_apps_Settings by omnirom.
the class AppStateNotificationBridgeTest method testFilterRecency.
@Test
public void testFilterRecency() {
NotificationsSentState allowState = new NotificationsSentState();
allowState.lastSent = 1;
AppEntry allow = mock(AppEntry.class);
allow.extraInfo = allowState;
assertTrue(FILTER_APP_NOTIFICATION_RECENCY.filterApp(allow));
NotificationsSentState denyState = new NotificationsSentState();
denyState.lastSent = 0;
AppEntry deny = mock(AppEntry.class);
deny.extraInfo = denyState;
assertFalse(FILTER_APP_NOTIFICATION_RECENCY.filterApp(deny));
}
use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project android_packages_apps_Settings by omnirom.
the class AppStateNotificationBridgeTest method testLoadAllExtraInfo_multiplePkgs.
@Test
public void testLoadAllExtraInfo_multiplePkgs() throws RemoteException {
List<Event> events = new ArrayList<>();
for (int i = 0; i < 8; i++) {
Event good = new Event();
good.mEventType = Event.NOTIFICATION_INTERRUPTION;
good.mPackage = PKG1;
good.mTimeStamp = i;
events.add(good);
}
Event good1 = new Event();
good1.mEventType = Event.NOTIFICATION_INTERRUPTION;
good1.mPackage = PKG2;
good1.mTimeStamp = 1;
events.add(good1);
UsageEvents usageEvents = getUsageEvents(events);
when(mUsageStats.queryEventsForUser(anyLong(), anyLong(), anyInt(), anyString())).thenReturn(usageEvents);
ArrayList<AppEntry> apps = new ArrayList<>();
apps.add(getMockAppEntry(PKG1));
apps.add(getMockAppEntry(PKG2));
when(mSession.getAllApps()).thenReturn(apps);
mBridge.loadAllExtraInfo();
assertThat(((NotificationsSentState) apps.get(0).extraInfo).sentCount).isEqualTo(8);
assertThat(((NotificationsSentState) apps.get(0).extraInfo).lastSent).isEqualTo(7);
assertThat(((NotificationsSentState) apps.get(0).extraInfo).avgSentWeekly).isEqualTo(0);
assertThat(((NotificationsSentState) apps.get(0).extraInfo).avgSentDaily).isEqualTo(1);
assertThat(((NotificationsSentState) apps.get(1).extraInfo).sentCount).isEqualTo(1);
assertThat(((NotificationsSentState) apps.get(1).extraInfo).lastSent).isEqualTo(1);
assertThat(((NotificationsSentState) apps.get(1).extraInfo).avgSentWeekly).isEqualTo(1);
assertThat(((NotificationsSentState) apps.get(1).extraInfo).avgSentDaily).isEqualTo(0);
}
use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project android_packages_apps_Settings by omnirom.
the class AppStateNotificationBridgeTest method testSummary_recency.
@Test
public void testSummary_recency() {
NotificationsSentState neverSent = new NotificationsSentState();
NotificationsSentState sent = new NotificationsSentState();
sent.lastSent = System.currentTimeMillis() - (2 * DAY_IN_MILLIS);
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");
}
use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppStateNotificationBridgeTest method testGetAggregatedUsageEvents_onlyNotificationEvents.
@Test
public void testGetAggregatedUsageEvents_onlyNotificationEvents() throws Exception {
List<Event> events = new ArrayList<>();
Event good = new Event();
good.mEventType = Event.NOTIFICATION_INTERRUPTION;
good.mPackage = PKG1;
good.mTimeStamp = 1;
events.add(good);
Event bad = new Event();
bad.mEventType = Event.CHOOSER_ACTION;
bad.mPackage = PKG1;
bad.mTimeStamp = 2;
events.add(bad);
UsageEvents usageEvents = getUsageEvents(events);
when(mUsageStats.queryEventsForUser(anyLong(), anyLong(), anyInt(), anyString())).thenReturn(usageEvents);
Map<String, NotificationsSentState> map = mBridge.getAggregatedUsageEvents();
assertThat(map.get(AppStateNotificationBridge.getKey(0, PKG1)).sentCount).isEqualTo(1);
}
Aggregations