Search in sources :

Example 31 with Event

use of android.app.usage.UsageEvents.Event 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)

Aggregations

Event (android.app.usage.UsageEvents.Event)31 UsageEvents (android.app.usage.UsageEvents)28 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)18 NotificationsSentState (com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState)14 AppEntry (com.android.settingslib.applications.ApplicationsState.AppEntry)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 ConfigurationStats (android.app.usage.ConfigurationStats)4 UsageStats (android.app.usage.UsageStats)4 Configuration (android.content.res.Configuration)4 ResolveInfo (android.content.pm.ResolveInfo)3 Intent (android.content.Intent)2 Preference (androidx.preference.Preference)2 Config (org.robolectric.annotation.Config)2 ApplicationInfo (android.content.pm.ApplicationInfo)1 Parcel (android.os.Parcel)1 NotifyingApp (android.service.notification.NotifyingApp)1 ArraySet (android.util.ArraySet)1 ApplicationsState (com.android.settingslib.applications.ApplicationsState)1 ImmutableList (com.google.common.collect.ImmutableList)1