use of com.onesignal.OneSignalPackagePrivateHelper.FCMBroadcastReceiver_onReceived_withIntent in project OneSignal-Android-SDK by OneSignal.
the class GenerateNotificationRunner method shouldSetButtonsCorrectly.
@Test
@Config(shadows = { ShadowFCMBroadcastReceiver.class, ShadowGenerateNotification.class })
public void shouldSetButtonsCorrectly() throws Exception {
final Intent intent = new Intent();
intent.setAction("com.google.android.c2dm.intent.RECEIVE");
intent.putExtra("message_type", "gcm");
Bundle bundle = getBaseNotifBundle();
addButtonsToReceivedPayload(bundle);
intent.putExtras(bundle);
FCMBroadcastReceiver_onReceived_withIntent(blankActivity, intent);
threadAndTaskWait();
// Normal notifications should be generated right from the BroadcastReceiver
// without creating a service.
assertNull(Shadows.shadowOf(blankActivity).getNextStartedService());
Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
Iterator<Map.Entry<Integer, PostedNotification>> postedNotifsIterator = postedNotifs.entrySet().iterator();
PostedNotification lastNotification = postedNotifsIterator.next().getValue();
assertEquals(1, lastNotification.notif.actions.length);
String json_data = shadowOf(lastNotification.notif.actions[0].actionIntent).getSavedIntent().getStringExtra(BUNDLE_KEY_ONESIGNAL_DATA);
assertEquals("id1", new JSONObject(json_data).optString(BUNDLE_KEY_ACTION_ID));
}
Aggregations