use of android.app.AlertDialog in project robolectric by robolectric.
the class ShadowAlertDialogTest method clickingPositiveButtonDismissesDialog.
@Test
public void clickingPositiveButtonDismissesDialog() throws Exception {
AlertDialog alertDialog = new AlertDialog.Builder(application).setPositiveButton("Positive", null).create();
alertDialog.show();
assertTrue(alertDialog.isShowing());
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick();
assertFalse(alertDialog.isShowing());
}
use of android.app.AlertDialog in project robolectric by robolectric.
the class ShadowAlertDialogTest method shouldOnlyCreateRequestedButtons.
@Test
public void shouldOnlyCreateRequestedButtons() throws Exception {
AlertDialog.Builder builder = new AlertDialog.Builder(application);
builder.setPositiveButton("OK", null);
AlertDialog dialog = builder.create();
dialog.show();
assertThat(dialog.getButton(AlertDialog.BUTTON_POSITIVE).getVisibility()).isEqualTo(View.VISIBLE);
assertThat(dialog.getButton(AlertDialog.BUTTON_NEGATIVE).getVisibility()).isEqualTo(View.GONE);
}
use of android.app.AlertDialog in project robolectric by robolectric.
the class ShadowAlertDialogTest method shouldSetView_withLayoutId.
@Test
@Config(minSdk = LOLLIPOP)
public void shouldSetView_withLayoutId() throws Exception {
AlertDialog.Builder builder = new AlertDialog.Builder(application);
builder.setView(R.layout.custom_layout);
AlertDialog alert = builder.create();
View view = shadowOf(alert).getView();
assertThat(view.getClass()).isEqualTo(CustomView.class);
}
use of android.app.AlertDialog in project robolectric by robolectric.
the class ShadowAlertDialogTest method shouldAllowNullButtonListeners.
@Test
public void shouldAllowNullButtonListeners() throws Exception {
AlertDialog.Builder builder = new AlertDialog.Builder(application);
builder.setPositiveButton("OK", null);
AlertDialog dialog = builder.create();
dialog.show();
ShadowView.clickOn(dialog.getButton(AlertDialog.BUTTON_POSITIVE));
}
use of android.app.AlertDialog in project robolectric by robolectric.
the class ShadowAlertDialogTest method clickingNeutralButtonDismissesDialog.
@Test
public void clickingNeutralButtonDismissesDialog() throws Exception {
AlertDialog alertDialog = new AlertDialog.Builder(application).setNeutralButton("Neutral", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).create();
alertDialog.show();
assertTrue(alertDialog.isShowing());
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL).performClick();
assertFalse(alertDialog.isShowing());
}
Aggregations