use of com.onesignal.OneSignalPackagePrivateHelper.FCMBroadcastReceiver_processBundle in project OneSignal-Android-SDK by OneSignal.
the class GenerateNotificationRunner method testNotificationProcessing_completeNotCalled.
@Test
@Config(shadows = { ShadowGenerateNotification.class, ShadowTimeoutHandler.class })
public void testNotificationProcessing_completeNotCalled() throws Exception {
// 1. Setup correct notification extension service class
startRemoteNotificationReceivedHandlerService("com.test.onesignal.GenerateNotificationRunner$" + "RemoteNotificationReceivedHandler_notificationReceivedCompleteNotCalled");
// 2. Add app context and setup the established notification extension service
OneSignal.initWithContext(ApplicationProvider.getApplicationContext());
OneSignal_setupNotificationServiceExtension();
// Mock timeout to 1, given that we are not calling complete inside RemoteNotificationReceivedHandler we depend on the timeout complete
ShadowTimeoutHandler.setMockDelayMillis(1);
// 3. Receive a notification
Bundle bundle = getBaseNotifBundle();
FCMBroadcastReceiver_processBundle(blankActivity, bundle);
threadAndTaskWait();
// 4. Make sure service was called
assertNotNull(lastServiceNotificationReceivedEvent);
// Notification save is done on the OSTimeoutHandler, we wait until the notification is saved
Awaitility.await().atMost(new Duration(3, TimeUnit.SECONDS)).pollInterval(new Duration(100, TimeUnit.MILLISECONDS)).untilAsserted(() -> {
// 5. Make sure 1 notification exists in DB
assertNotificationDbRecords(1);
});
}
use of com.onesignal.OneSignalPackagePrivateHelper.FCMBroadcastReceiver_processBundle in project OneSignal-Android-SDK by OneSignal.
the class GenerateNotificationRunner method testNotificationProcessing_silentNotification.
@Test
@Config(shadows = { ShadowGenerateNotification.class })
public void testNotificationProcessing_silentNotification() throws Exception {
// 1. Setup correct notification extension service class
startRemoteNotificationReceivedHandlerService("com.test.onesignal.GenerateNotificationRunner$" + "RemoteNotificationReceivedHandler_notificationReceivedDisplayNotCalled");
// 2. Add app context and setup the established notification extension service
OneSignal.initWithContext(ApplicationProvider.getApplicationContext());
OneSignal_setupNotificationServiceExtension();
// 3. Receive a notification
Bundle bundle = getBaseNotifBundle();
FCMBroadcastReceiver_processBundle(blankActivity, bundle);
threadAndTaskWait();
// 4. Make sure service was called
assertNotNull(lastServiceNotificationReceivedEvent);
// 5. Make sure running on main thread check was not called, this is only called for showing the notification
assertFalse(ShadowGenerateNotification.isRunningOnMainThreadCheckCalled());
// 6. Make sure 1 notification exists in DB
assertNotificationDbRecords(1);
}
use of com.onesignal.OneSignalPackagePrivateHelper.FCMBroadcastReceiver_processBundle in project OneSignal-Android-SDK by OneSignal.
the class GenerateNotificationRunner method testNotificationProcessing_whenAlertIsNull.
@Test
public // No MainThread mock since notification is not being display
void testNotificationProcessing_whenAlertIsNull() throws Exception {
// 1. Setup correct notification extension service class
startRemoteNotificationReceivedHandlerService("com.test.onesignal.GenerateNotificationRunner$" + "RemoteNotificationReceivedHandler_notificationReceivedDisplayAndComplete");
// 2. Add app context and setup the established notification extension service
OneSignal.initWithContext(ApplicationProvider.getApplicationContext());
OneSignal_setupNotificationServiceExtension();
// 3. Receive a notification
Bundle bundle = getBaseNotifBundle();
bundle.remove("alert");
FCMBroadcastReceiver_processBundle(blankActivity, bundle);
threadAndTaskWait();
// 4. Make sure service was called
assertNotNull(lastServiceNotificationReceivedEvent);
// 5. Make sure 1 notification exists in DB
assertNotificationDbRecords(1);
}
Aggregations