use of android.app.Dialog in project robolectric by robolectric.
the class ShadowDialogFragmentTest method removeUsingTransaction_shouldDismissTheDialog.
@Test
public void removeUsingTransaction_shouldDismissTheDialog() throws Exception {
dialogFragment.show(fragmentManager, null);
FragmentTransaction t = fragmentManager.beginTransaction();
t.remove(dialogFragment);
t.commit();
Dialog dialog = ShadowDialog.getLatestDialog();
assertFalse(dialog.isShowing());
assertTrue(shadowOf(dialog).hasBeenDismissed());
}
use of android.app.Dialog in project robolectric by robolectric.
the class ShadowGoogleApiAvailabilityTest method setErrorDialog__OnCancelListenerMethod.
@Test
public void setErrorDialog__OnCancelListenerMethod() {
final ShadowGoogleApiAvailability shadowGoogleApiAvailability = Shadows.shadowOf(GoogleApiAvailability.getInstance());
final Dialog expectedDialog = mock(Dialog.class);
final Activity mockActivity = mock(Activity.class);
final DialogInterface.OnCancelListener mockOnCancelListener = mock(DialogInterface.OnCancelListener.class);
final int mockErrorCode = ConnectionResult.API_UNAVAILABLE;
final int mockRequestCode = 1234;
shadowGoogleApiAvailability.setErrorDialog(expectedDialog);
final Dialog actualDialog = GoogleApiAvailability.getInstance().getErrorDialog(mockActivity, mockErrorCode, mockRequestCode, mockOnCancelListener);
assertThat(actualDialog).isNotNull().isEqualTo(expectedDialog);
}
use of android.app.Dialog in project robolectric by robolectric.
the class ShadowGoogleApiAvailabilityTest method setErrorDialog.
@Test
public void setErrorDialog() {
final ShadowGoogleApiAvailability shadowGoogleApiAvailability = Shadows.shadowOf(GoogleApiAvailability.getInstance());
final Dialog expectedDialog = mock(Dialog.class);
final Activity mockActivity = mock(Activity.class);
final int mockErrorCode = ConnectionResult.API_UNAVAILABLE;
final int mockRequestCode = 1234;
shadowGoogleApiAvailability.setErrorDialog(expectedDialog);
final Dialog actualDialog = GoogleApiAvailability.getInstance().getErrorDialog(mockActivity, mockErrorCode, mockRequestCode);
assertThat(actualDialog).isNotNull().isEqualTo(expectedDialog);
}
use of android.app.Dialog in project robolectric by robolectric.
the class ShadowActivityTest method showDialog_shouldCreatePrepareAndShowDialog.
@Test
public void showDialog_shouldCreatePrepareAndShowDialog() {
final DialogLifeCycleActivity activity = Robolectric.setupActivity(DialogLifeCycleActivity.class);
final AtomicBoolean dialogWasShown = new AtomicBoolean(false);
new Dialog(activity) {
{
activity.dialog = this;
}
@Override
public void show() {
dialogWasShown.set(true);
}
};
activity.showDialog(1);
assertTrue(activity.createdDialog);
assertTrue(activity.preparedDialog);
assertTrue(dialogWasShown.get());
}
use of android.app.Dialog in project robolectric by robolectric.
the class ShadowActivityTest method removeDialog_shouldCreateDialogAgain.
@Test
public void removeDialog_shouldCreateDialogAgain() {
final DialogCreatingActivity activity = Robolectric.setupActivity(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);
}
Aggregations