Skip to content

Commit 4b804ab

Browse files
Added requested test
1 parent c04d1e2 commit 4b804ab

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,27 @@ public void testLaunchUrlSuppressTrue() throws Exception {
11801180
assertNull(shadowOf(blankActivity).getNextStartedActivity());
11811181
}
11821182

1183+
@Test
1184+
public void testLaunchUrlSuppressFalse() throws Exception {
1185+
// Add the 'com.onesignal.suppressLaunchURLs' as 'true' meta-data tag
1186+
// First init run for appId to be saved
1187+
// At least OneSignal was init once for user to be subscribed
1188+
// If this doesn't' happen, notifications will not arrive
1189+
OneSignalInit();
1190+
fastColdRestartApp();
1191+
OneSignalShadowPackageManager.addManifestMetaData("com.onesignal.suppressLaunchURLs", "false");
1192+
OneSignal.initWithContext(blankActivity);
1193+
// Removes app launch
1194+
shadowOf(blankActivity).getNextStartedActivity();
1195+
1196+
// No OneSignal init here to test case where it is located in an Activity.
1197+
OneSignal_handleNotificationOpen(blankActivity, new JSONArray("[{ \"alert\": \"Test Msg\", \"custom\": { \"i\": \"UUID\", \"u\": \"http://google.com\" } }]"), false, ONESIGNAL_NOTIFICATION_ID);
1198+
Intent intent = shadowOf(blankActivity).getNextStartedActivity();
1199+
assertEquals("android.intent.action.VIEW", intent.getAction());
1200+
assertEquals("http://google.com", intent.getData().toString());
1201+
assertNull(shadowOf(blankActivity).getNextStartedActivity());
1202+
}
1203+
11831204
private static String notificationReceivedBody;
11841205
private static int androidNotificationId;
11851206

0 commit comments

Comments
 (0)