예제 #1
0
  @Test
  public void
      shouldNotComplainIfActivityIsDestroyedWhileAnotherActivityHasRegisteredBroadcastReceivers()
          throws Exception {
    activity = create(DialogLifeCycleActivity.class);

    DialogLifeCycleActivity activity2 = new DialogLifeCycleActivity();
    activity2.registerReceiver(new AppWidgetProvider(), new IntentFilter());

    destroy(activity); // should not throw exception
  }
예제 #2
0
  @Test
  public void showDialog_shouldCreatePrepareAndShowDialogWithBundle() {
    final DialogLifeCycleActivity activity = create(DialogLifeCycleActivity.class);
    final AtomicBoolean dialogWasShown = new AtomicBoolean(false);

    new Dialog(activity) {
      {
        activity.dialog = this;
      }

      @Override
      public void show() {
        dialogWasShown.set(true);
      }
    };

    activity.showDialog(1, new Bundle());

    assertTrue(activity.createdDialog);
    assertTrue(activity.preparedDialogWithBundle);
    assertTrue(dialogWasShown.get());
  }