Skip to content

Commit f0a10a4

Browse files
committed
adding unit test for clearing groupless summary notification
1 parent eff59c9 commit f0a10a4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

OneSignalSDK/unittest/src/test/java/com/test/onesignal/GenerateNotificationRunner.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,26 @@ public void testFourGrouplessNotificationsUseDefaultGroup() throws Exception {
430430
assertEquals(4, getNotificationsInGroup("os_group_undefined").size());
431431
}
432432

433+
@Test
434+
@Config(sdk = Build.VERSION_CODES.N, shadows = { ShadowGenerateNotification.class })
435+
public void testGrouplessSummaryNotificationIsDismissedOnClear() throws Exception {
436+
OneSignal.setAppId("b2f7f966-d8cc-11e4-bed1-df8f05be55ba");
437+
OneSignal.initWithContext(blankActivity.getApplicationContext());
438+
threadAndTaskWait();
439+
440+
// Add 4 groupless notifications
441+
postNotificationWithOptionalGroup(4, null);
442+
threadAndTaskWait();
443+
444+
// Obtain the posted notifications
445+
Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
446+
assertEquals(5, postedNotifs.size());
447+
// Clear OneSignal Notifications
448+
OneSignal.clearOneSignalNotifications();
449+
threadAndTaskWait();
450+
assertEquals(0, postedNotifs.size());
451+
}
452+
433453
@Test
434454
@Config(sdk = Build.VERSION_CODES.LOLLIPOP, shadows = { ShadowGenerateNotification.class })
435455
public void testNotifDismissAllOnGroupSummaryClickForAndroidUnderM() throws Exception {

0 commit comments

Comments
 (0)