Beispiel #1
0
 @Test
 public void onResume_shouldRegisterFindMeReceiver() {
   Intent expectedIntent = new Intent(COM_MAPZEN_FIND_ME);
   List<BroadcastReceiver> findMeReceivers =
       Robolectric.getShadowApplication().getReceiversForIntent(expectedIntent);
   assertThat(findMeReceivers).hasSize(1);
 }
Beispiel #2
0
 @Test
 public void onPause_shouldUnregisterFindMeReceiver() {
   mapFragment.onPause();
   Intent expectedIntent = new Intent(COM_MAPZEN_FIND_ME);
   List<BroadcastReceiver> findMeReceivers =
       Robolectric.getShadowApplication().getReceiversForIntent(expectedIntent);
   assertThat(findMeReceivers).isEmpty();
 }
 /*
  * Create an intent with an outfit
  */
 public Intent createIntentWithOutfit() throws FileNotFoundException {
   Intent intent =
       new Intent(Robolectric.getShadowApplication().getApplicationContext(), ActivityMail.class);
   Bundle bundle = new Bundle();
   bundle.putSerializable("outfit", this.generateOutfit());
   intent.putExtras(bundle);
   return intent;
 }
  @Test
  public void shouldStartHardwareTriggerServiceOnBootWhenHomeReady() {
    bootReceiver.onReceive(Robolectric.application, bootIntent);

    Intent startedIntent = Robolectric.getShadowApplication().getNextStartedService();
    ShadowIntent shadowIntent = shadowOf(startedIntent);
    assertNotNull(startedIntent);
    assertEquals(HardwareTriggerService.class, shadowIntent.getIntentClass());
  }
  @Test
  public void handleShouldOverrideUrl_smsUrl_clicked_shouldStartActivity() {
    subjectBanner.setClicked(true);
    reset(mockBannerWebView);
    when(mockBannerWebView.getContext()).thenReturn(activity);

    boolean result = subjectBanner.handleShouldOverrideUrl("sms://123456789");

    Intent startedIntent = Robolectric.getShadowApplication().getNextStartedActivity();
    assertThat(startedIntent).isNotNull();
    assertThat(startedIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK).isNotEqualTo(0);
    assertThat(startedIntent.getComponent()).isNull();
    assertThat(result).isTrue();
  }
 @Before
 public void setUpTest() {
   context = Robolectric.getShadowApplication().getApplicationContext();
   observer = new DataObserver();
 }
 /**
  * Non-Android accessor retrieves the most recent wakelock registered by the application
  *
  * @return
  */
 public static PowerManager.WakeLock getLatestWakeLock() {
   return Robolectric.getShadowApplication().getLatestWakeLock();
 }
 /** Non-Android accessor that discards the most recent {@code PowerManager.WakeLock}s */
 public static void reset() {
   ShadowApplication shadowApplication = Robolectric.getShadowApplication();
   if (shadowApplication != null) {
     shadowApplication.clearWakeLocks();
   }
 }
 @Implementation
 public PowerManager.WakeLock newWakeLock(int flags, String tag) {
   PowerManager.WakeLock wl = Robolectric.newInstanceOf(PowerManager.WakeLock.class);
   Robolectric.getShadowApplication().addWakeLock(wl);
   return wl;
 }
 @Test
 public void shouldNotProcessOtherIntents() {
   bootReceiver.onReceive(Robolectric.application, new Intent(Intent.ACTION_SCREEN_ON));
   assertNull(Robolectric.getShadowApplication().getNextStartedService());
 }
Beispiel #11
0
 public static void setLatestDialog(ShadowDialog latestDialog) {
   ShadowApplication shadowApplication = Robolectric.getShadowApplication();
   if (shadowApplication != null) shadowApplication.setLatestDialog(latestDialog);
 }
Beispiel #12
0
 public static Dialog getLatestDialog() {
   ShadowDialog dialog = Robolectric.getShadowApplication().getLatestDialog();
   return dialog == null ? null : dialog.realDialog;
 }