SmsBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (LOCAL_LOGV) Log.v(TAG, "onReceive(" + context + "," + intent + ")"); if (SMS_RECEIVED.equals(intent.getAction())) { incomingSMS(context); } else { Log.w(TAG, "unhandled intent: "+intent); } }  @Override void onReceive(Context context, Intent intent);  }
@Test public void shouldScheduleIncomingBackupAfterIncomingMessage() throws Exception { mockScheduled(); receiver.onReceive(context, new Intent().setAction("android.provider.Telephony.SMS_RECEIVED")); verify(backupJobs, times(1)).scheduleIncoming(); }
@Test public void shouldNotScheduleIfAutoBackupIsDisabled() throws Exception { mockScheduled(); when(preferences.isAutoBackupEnabled()).thenReturn(false); receiver.onReceive(context, new Intent().setAction("android.provider.Telephony.SMS_RECEIVED")); verifyZeroInteractions(backupJobs); }
@Test public void shouldNotScheduleIfLoginInformationIsNotSet() throws Exception { mockScheduled(); when(authPreferences.isLoginInformationSet()).thenReturn(false); receiver.onReceive(context, new Intent().setAction("android.provider.Telephony.SMS_RECEIVED")); verifyZeroInteractions(backupJobs); }
@Test public void shouldNotScheduleIfFirstBackupHasNotBeenRun() throws Exception { mockScheduled(); when(preferences.isFirstBackup()).thenReturn(true); receiver.onReceive(context, new Intent().setAction("android.provider.Telephony.SMS_RECEIVED")); verifyZeroInteractions(backupJobs); }