Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix individually clearing notifications #1711

Merged
merged 2 commits into from
Jan 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add unit test for dismissing individual groupless summary notifications
  • Loading branch information
jennantilla committed Dec 30, 2022
commit 7c199a63d8938891246eb7b5bba1bf3f251d7274
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