use of org.robolectric.shadows.ShadowAlertDialog in project android-uploader by nightscout.
the class MainActivityTest method testOnCreate_ShouldNotShowIUnderstandDialogIfAlreadySet.
@Test
public void testOnCreate_ShouldNotShowIUnderstandDialogIfAlreadySet() {
preferences.setIUnderstand(true);
// make sure we don't have another alert dialog
preferences.setAskedForData(true);
activityController.create().get();
ShadowAlertDialog alertDialog = getShadowApplication().getLatestAlertDialog();
assertThat(alertDialog, is(nullValue()));
}
use of org.robolectric.shadows.ShadowAlertDialog in project android-uploader by nightscout.
the class SettingsActivityTest method testAlert_Mongo_InvalidShowsDialog.
@Test
public void testAlert_Mongo_InvalidShowsDialog() {
EditTextPreference editTextPreference = (EditTextPreference) setUpPreferenceFragment(SettingsActivity.MainPreferenceFragment.class).findPreference(PreferenceKeys.MONGO_URI);
editTextPreference.getOnPreferenceChangeListener().onPreferenceChange(editTextPreference, "invalidMongo");
ShadowAlertDialog alertDialog = getShadowApplication().getLatestAlertDialog();
assertThat(alertDialog, is(not(nullValue())));
assertThat(alertDialog.getMessage().toString(), is(getContext().getString(R.string.illegal_mongo_uri)));
}
use of org.robolectric.shadows.ShadowAlertDialog in project android-uploader by nightscout.
the class SettingsActivityTest method testAlert_RestApi_InvalidShowsDialog.
@Test
public void testAlert_RestApi_InvalidShowsDialog() {
EditTextPreference editTextPreference = (EditTextPreference) setUpPreferenceFragment(SettingsActivity.MainPreferenceFragment.class).findPreference(PreferenceKeys.API_URIS);
editTextPreference.getOnPreferenceChangeListener().onPreferenceChange(editTextPreference, "\\invalidUri");
ShadowAlertDialog alertDialog = getShadowApplication().getLatestAlertDialog();
assertThat(alertDialog, is(not(nullValue())));
assertThat(alertDialog.getMessage().toString(), is(getContext().getString(R.string.invalid_rest_uri, "\\invalidUri")));
}
use of org.robolectric.shadows.ShadowAlertDialog in project android-uploader by nightscout.
the class MainActivityTest method testOnCreate_ShouldShowIUnderstandDialog.
@Test
public void testOnCreate_ShouldShowIUnderstandDialog() {
preferences.setIUnderstand(false);
// make sure we don't have another alert dialog
preferences.setAskedForData(true);
activityController.create().get();
ShadowAlertDialog alertDialog = getShadowApplication().getLatestAlertDialog();
assertThat(alertDialog, is(not(nullValue())));
assertThat(alertDialog.getTitle(), is(getContext().getText(R.string.pref_title_i_understand)));
}
use of org.robolectric.shadows.ShadowAlertDialog in project scdl by passy.
the class DownloadPreferenceErrorAlertDialogFactoryTest method testDialogCanBeShown.
@Test
public void testDialogCanBeShown() throws Exception {
final AlertDialog alertDialog = mFactory.newInstance();
alertDialog.show();
final AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
final ShadowAlertDialog shadowAlertDialog = Robolectric.shadowOf(dialog);
// Maybe too precise, but I want to have a clear indicator that the dialog was
// actually shown.
assertThat(shadowAlertDialog.getTitle()).isEqualTo("Your Download failed :(");
}
Aggregations