Пример #1
0
  @Test
  public void showDialog_shouldReuseDialogs() {
    final DialogCreatingActivity activity = create(DialogCreatingActivity.class);
    activity.showDialog(1);
    Dialog firstDialog = ShadowDialog.getLatestDialog();
    activity.showDialog(1);

    Dialog secondDialog = ShadowDialog.getLatestDialog();
    assertSame("dialogs should be the same instance", firstDialog, secondDialog);
  }
Пример #2
0
  @Test
  public void removeDialog_shouldCreateDialogAgain() {
    final DialogCreatingActivity activity = create(DialogCreatingActivity.class);
    activity.showDialog(1);
    Dialog firstDialog = ShadowDialog.getLatestDialog();

    activity.removeDialog(1);
    assertNull(shadowOf(activity).getDialogById(1));

    activity.showDialog(1);
    Dialog secondDialog = ShadowDialog.getLatestDialog();

    assertNotSame("dialogs should not be the same instance", firstDialog, secondDialog);
  }
Пример #3
0
 @Test
 public void shouldCallOnCreateDialogFromShowDialog() {
   ActivityWithOnCreateDialog activity = create(ActivityWithOnCreateDialog.class);
   activity.showDialog(123);
   assertTrue(activity.onCreateDialogWasCalled);
   assertThat(ShadowDialog.getLatestDialog()).isNotNull();
 }
Пример #4
0
 @Test
 public void showDialog_shouldShowDialog() throws Exception {
   final DialogCreatingActivity activity = create(DialogCreatingActivity.class);
   activity.showDialog(1);
   Dialog dialog = ShadowDialog.getLatestDialog();
   assertTrue(dialog.isShowing());
 }
Пример #5
0
 @Test
 public void dismissDialog_shouldDismissPreviouslyShownDialog() throws Exception {
   final DialogCreatingActivity activity = create(DialogCreatingActivity.class);
   activity.showDialog(1);
   activity.dismissDialog(1);
   Dialog dialog = ShadowDialog.getLatestDialog();
   assertFalse(dialog.isShowing());
 }