use of org.robolectric.shadows.ShadowPendingIntent in project sms-backup-plus by jberkel.
the class AlarmManagerDriverTest method assertAlarmScheduled.
private Intent assertAlarmScheduled(String ofExpectedType) {
AlarmManager alarmManager = (AlarmManager) RuntimeEnvironment.application.getSystemService(Context.ALARM_SERVICE);
ShadowAlarmManager shadow = shadowOf(alarmManager);
ShadowAlarmManager.ScheduledAlarm nextScheduledAlarm = shadow.getNextScheduledAlarm();
assertThat(nextScheduledAlarm.type).isEqualTo(AlarmManager.RTC_WAKEUP);
assertThat(nextScheduledAlarm.triggerAtTime).isGreaterThan(0L);
PendingIntent pendingIntent = nextScheduledAlarm.operation;
ShadowPendingIntent shadowPendingIntent = shadowOf(pendingIntent);
ComponentName component = shadowPendingIntent.getSavedIntent().getComponent();
assertThat(component.getPackageName()).isEqualTo("com.zegoggles.smssync");
assertThat(component.getClassName()).isEqualTo("com.zegoggles.smssync.service.SmsBackupService");
assertThat(shadowPendingIntent.getFlags()).isEqualTo(FLAG_UPDATE_CURRENT);
assertThat(shadowPendingIntent.getSavedIntent().getAction()).isNotEmpty();
assertThat(shadowPendingIntent.getSavedIntent().getAction()).isEqualTo(ofExpectedType);
return shadowPendingIntent.getSavedIntent();
}
use of org.robolectric.shadows.ShadowPendingIntent in project iterable-android-sdk by Iterable.
the class IterableNotificationTest method testNoAction.
@Test
public void testNoAction() throws Exception {
Bundle notif = new Bundle();
notif.putString(IterableConstants.ITERABLE_DATA_KEY, getResourceString("push_payload_no_action.json"));
IterableNotificationBuilder iterableNotification = postNotification(notif);
StatusBarNotification statusBarNotification = mNotificationManager.getActiveNotifications()[0];
Notification notification = statusBarNotification.getNotification();
assertEquals(1, notification.actions.length);
assertEquals("No action", notification.actions[0].title);
ShadowPendingIntent shadowPendingIntent = shadowOf(notification.actions[0].actionIntent);
Intent savedIntent = shadowPendingIntent.getSavedIntent();
assertEquals(IterableConstants.ACTION_PUSH_ACTION, savedIntent.getAction());
assertEquals("button1", savedIntent.getStringExtra(IterableConstants.ACTION_IDENTIFIER));
}
Aggregations