Skip to content

Commit

Permalink
Add unit test for dismissing individual groupless summary notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
jennantilla committed Dec 30, 2022
1 parent ba9c717 commit 7c199a6
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -450,6 +449,34 @@ public void testGrouplessSummaryNotificationIsDismissedOnClear() throws Exceptio
assertEquals(0, postedNotifs.size());
}

@Test
@Config(sdk = Build.VERSION_CODES.N, shadows = { ShadowGenerateNotification.class })
public void testIndividualGrouplessSummaryNotificationDismissal() throws Exception {
OneSignal.setAppId("b2f7f966-d8cc-11e4-bed1-df8f05be55ba");
OneSignal.initWithContext(blankActivity.getApplicationContext());
threadAndTaskWait();

// Add 4 groupless notifications
postNotificationWithOptionalGroup(4, null);
threadAndTaskWait();

// Obtain the posted notifications
Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
Iterator<Map.Entry<Integer, PostedNotification>> iterator = postedNotifs.entrySet().iterator();
Map.Entry<Integer, PostedNotification> entry = iterator.next();
Map.Entry<Integer, PostedNotification> entry2 = iterator.next();
Map.Entry<Integer, PostedNotification> entry3 = iterator.next();
Map.Entry<Integer, PostedNotification> entry4 = iterator.next();
Integer id4 = entry4.getKey();
assertNotNull(id4);

assertEquals(5, postedNotifs.size());
// Clear a OneSignal Notification
OneSignal.removeNotification(id4);
threadAndTaskWait();
assertEquals(4, postedNotifs.size());
}

@Test
@Config(sdk = Build.VERSION_CODES.LOLLIPOP, shadows = { ShadowGenerateNotification.class })
public void testNotifDismissAllOnGroupSummaryClickForAndroidUnderM() throws Exception {
Expand Down

0 comments on commit 7c199a6

Please sign in to comment.