|
74 | 74 | import android.net.Uri;
|
75 | 75 | import android.os.Build;
|
76 | 76 | import android.os.Bundle;
|
77 |
| -import android.os.SystemClock; |
78 | 77 | import android.util.Log;
|
79 | 78 |
|
80 | 79 | import androidx.annotation.NonNull;
|
@@ -450,6 +449,34 @@ public void testGrouplessSummaryNotificationIsDismissedOnClear() throws Exceptio
|
450 | 449 | assertEquals(0, postedNotifs.size());
|
451 | 450 | }
|
452 | 451 |
|
| 452 | + @Test |
| 453 | + @Config(sdk = Build.VERSION_CODES.N, shadows = { ShadowGenerateNotification.class }) |
| 454 | + public void testIndividualGrouplessSummaryNotificationDismissal() throws Exception { |
| 455 | + OneSignal.setAppId("b2f7f966-d8cc-11e4-bed1-df8f05be55ba"); |
| 456 | + OneSignal.initWithContext(blankActivity.getApplicationContext()); |
| 457 | + threadAndTaskWait(); |
| 458 | + |
| 459 | + // Add 4 groupless notifications |
| 460 | + postNotificationWithOptionalGroup(4, null); |
| 461 | + threadAndTaskWait(); |
| 462 | + |
| 463 | + // Obtain the posted notifications |
| 464 | + Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications; |
| 465 | + Iterator<Map.Entry<Integer, PostedNotification>> iterator = postedNotifs.entrySet().iterator(); |
| 466 | + Map.Entry<Integer, PostedNotification> entry = iterator.next(); |
| 467 | + Map.Entry<Integer, PostedNotification> entry2 = iterator.next(); |
| 468 | + Map.Entry<Integer, PostedNotification> entry3 = iterator.next(); |
| 469 | + Map.Entry<Integer, PostedNotification> entry4 = iterator.next(); |
| 470 | + Integer id4 = entry4.getKey(); |
| 471 | + assertNotNull(id4); |
| 472 | + |
| 473 | + assertEquals(5, postedNotifs.size()); |
| 474 | + // Clear a OneSignal Notification |
| 475 | + OneSignal.removeNotification(id4); |
| 476 | + threadAndTaskWait(); |
| 477 | + assertEquals(4, postedNotifs.size()); |
| 478 | + } |
| 479 | + |
453 | 480 | @Test
|
454 | 481 | @Config(sdk = Build.VERSION_CODES.LOLLIPOP, shadows = { ShadowGenerateNotification.class })
|
455 | 482 | public void testNotifDismissAllOnGroupSummaryClickForAndroidUnderM() throws Exception {
|
|
0 commit comments