Search in sources :

Example 41 with Dialog

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());
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Dialog(android.app.Dialog) ShadowDialog(org.robolectric.shadows.ShadowDialog) Test(org.junit.Test)

Example 42 with Dialog

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);
}
Also used : DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) Activity(android.app.Activity) Test(org.junit.Test)

Example 43 with Dialog

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);
}
Also used : Dialog(android.app.Dialog) Activity(android.app.Activity) Test(org.junit.Test)

Example 44 with Dialog

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());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Dialog(android.app.Dialog) Test(org.junit.Test)

Example 45 with Dialog

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);
}
Also used : Dialog(android.app.Dialog) Test(org.junit.Test)

Aggregations

Dialog (android.app.Dialog)385 View (android.view.View)122 AlertDialog (android.app.AlertDialog)115 DialogInterface (android.content.DialogInterface)98 TextView (android.widget.TextView)87 AlertDialog (android.support.v7.app.AlertDialog)49 Intent (android.content.Intent)44 LayoutInflater (android.view.LayoutInflater)39 EditText (android.widget.EditText)39 ListView (android.widget.ListView)36 ProgressDialog (android.app.ProgressDialog)35 Context (android.content.Context)33 AdapterView (android.widget.AdapterView)31 ImageView (android.widget.ImageView)30 LinearLayout (android.widget.LinearLayout)29 WindowManager (android.view.WindowManager)28 Test (org.junit.Test)25 Button (android.widget.Button)24 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)23 NonNull (android.support.annotation.NonNull)23