Skip to content

Commit 8652290

Browse files
committed
Test ensuring correct Activity is used for API
Add test to ensure correct Activity is for Notification opens when device is running Android API 23 (Android 6) or newer.
1 parent 00f1367 commit 8652290

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,21 @@ public void shouldSetButtonsCorrectly() throws Exception {
11301130
assertEquals("id1", new JSONObject(json_data).optString(BUNDLE_KEY_ACTION_ID));
11311131
}
11321132

1133+
@Test
1134+
@Config(sdk = 23, shadows = { ShadowGenerateNotification.class })
1135+
public void shouldUseCorrectActivityForAndroid23Plus() throws Exception {
1136+
NotificationBundleProcessor_ProcessFromFCMIntentService(blankActivity, getBaseNotifBundle());
1137+
threadAndTaskWait();
1138+
1139+
Intent[] intents = lastNotificationIntents();
1140+
assertEquals("android.intent.action.MAIN", intents[0].getAction());
1141+
assertEquals(
1142+
com.onesignal.NotificationOpenedReceiver.class.getName(),
1143+
intents[1].getComponent().getClassName()
1144+
);
1145+
assertEquals(2, intents.length);
1146+
}
1147+
11331148
@Test
11341149
@Config(shadows = { ShadowGenerateNotification.class })
11351150
public void shouldSetContentIntentForLaunchURL() throws Exception {

0 commit comments

Comments
 (0)