use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppStateNotificationBridgeTest method testGetAggregatedUsageEvents_multiplePkgs.
@Test
public void testGetAggregatedUsageEvents_multiplePkgs() throws Exception {
List<Event> events = new ArrayList<>();
Event good = new Event();
good.mEventType = Event.NOTIFICATION_INTERRUPTION;
good.mPackage = PKG1;
good.mTimeStamp = 6;
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);
Map<String, NotificationsSentState> map = mBridge.getAggregatedUsageEvents();
assertThat(map.get(AppStateNotificationBridge.getKey(0, PKG1)).sentCount).isEqualTo(1);
assertThat(map.get(AppStateNotificationBridge.getKey(0, PKG2)).sentCount).isEqualTo(1);
assertThat(map.get(AppStateNotificationBridge.getKey(0, PKG1)).lastSent).isEqualTo(6);
assertThat(map.get(AppStateNotificationBridge.getKey(0, PKG2)).lastSent).isEqualTo(1);
}
use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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 Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppStateNotificationBridgeTest method testSummary_frequency.
@Test
public void testSummary_frequency() {
NotificationsSentState sentRarely = new NotificationsSentState();
sentRarely.avgSentWeekly = 1;
NotificationsSentState sentOften = new NotificationsSentState();
sentOften.avgSentDaily = 8;
assertThat(AppStateNotificationBridge.getSummary(mContext, sentRarely, R.id.sort_order_frequent_notification).toString()).contains("1");
assertThat(AppStateNotificationBridge.getSummary(mContext, sentRarely, R.id.sort_order_frequent_notification).toString()).contains("notification ");
assertThat(AppStateNotificationBridge.getSummary(mContext, sentRarely, R.id.sort_order_frequent_notification).toString()).contains("week");
assertThat(AppStateNotificationBridge.getSummary(mContext, sentOften, R.id.sort_order_frequent_notification).toString()).contains("8");
assertThat(AppStateNotificationBridge.getSummary(mContext, sentOften, R.id.sort_order_frequent_notification).toString()).contains("notifications");
assertThat(AppStateNotificationBridge.getSummary(mContext, sentOften, R.id.sort_order_frequent_notification).toString()).contains("day");
}
use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppStateNotificationBridgeTest method testSummary_alpha.
@Test
public void testSummary_alpha() {
NotificationsSentState sentRarely = new NotificationsSentState();
sentRarely.avgSentWeekly = 1;
assertThat(AppStateNotificationBridge.getSummary(mContext, sentRarely, R.id.sort_order_alpha).toString()).isEqualTo("");
}
use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppStateNotificationBridgeTest method testRecencyComparator.
@Test
public void testRecencyComparator() {
List<AppEntry> entries = new ArrayList<>();
NotificationsSentState earlier = new NotificationsSentState();
earlier.lastSent = 1;
AppEntry earlyEntry = mock(AppEntry.class);
earlyEntry.extraInfo = earlier;
entries.add(earlyEntry);
NotificationsSentState later = new NotificationsSentState();
later.lastSent = 8;
AppEntry lateEntry = mock(AppEntry.class);
lateEntry.extraInfo = later;
entries.add(lateEntry);
entries.sort(RECENT_NOTIFICATION_COMPARATOR);
assertThat(entries).containsExactly(lateEntry, earlyEntry);
}
Aggregations