Search in sources :

Example 31 with NotificationsSentState

use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project android_packages_apps_Settings by omnirom.

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);
}
Also used : NotificationsSentState(com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState) ArrayList(java.util.ArrayList) Event(android.app.usage.UsageEvents.Event) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) UsageEvents(android.app.usage.UsageEvents) Test(org.junit.Test)

Example 32 with NotificationsSentState

use of com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState in project android_packages_apps_Settings by omnirom.

the class AppStateNotificationBridgeTest method testFilterFrequency.

@Test
public void testFilterFrequency() {
    NotificationsSentState allowState = new NotificationsSentState();
    allowState.sentCount = 1;
    AppEntry allow = mock(AppEntry.class);
    allow.extraInfo = allowState;
    assertTrue(FILTER_APP_NOTIFICATION_FREQUENCY.filterApp(allow));
    NotificationsSentState denyState = new NotificationsSentState();
    denyState.sentCount = 0;
    AppEntry deny = mock(AppEntry.class);
    deny.extraInfo = denyState;
    assertFalse(FILTER_APP_NOTIFICATION_FREQUENCY.filterApp(deny));
}
Also used : NotificationsSentState(com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState) AppEntry(com.android.settingslib.applications.ApplicationsState.AppEntry) Test(org.junit.Test)

Aggregations

NotificationsSentState (com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState)32 Test (org.junit.Test)32 AppEntry (com.android.settingslib.applications.ApplicationsState.AppEntry)20 ArrayList (java.util.ArrayList)18 UsageEvents (android.app.usage.UsageEvents)14 Event (android.app.usage.UsageEvents.Event)14 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 ApplicationInfo (android.content.pm.ApplicationInfo)2 Switch (android.widget.Switch)2 ViewGroup (android.view.ViewGroup)1 CompoundButton (android.widget.CompoundButton)1