use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExtended.
the class ButtonActionDialogFragmentTest method testOnCreateDialog_forceStopDialog.
@Test
public void testOnCreateDialog_forceStopDialog() {
ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(FORCE_STOP_ID);
FragmentController.setupFragment(fragment, FragmentActivity.class, 0, /* containerViewId */
null);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(mShadowContext.getString(R.string.force_stop_dlg_text));
assertThat(shadowDialog.getTitle()).isEqualTo(mShadowContext.getString(R.string.force_stop_dlg_title));
assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(mShadowContext.getString(R.string.dlg_ok));
assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(mShadowContext.getString(R.string.dlg_cancel));
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExtended.
the class LocaleListEditorTest method showRemoveLocaleWarningDialog_allLocaleSelected_shouldShowErrorDialog.
@Test
public void showRemoveLocaleWarningDialog_allLocaleSelected_shouldShowErrorDialog() {
// pre-condition
when(mAdapter.getCheckedCount()).thenReturn(1);
when(mAdapter.getItemCount()).thenReturn(1);
when(mAdapter.isFirstLocaleChecked()).thenReturn(true);
ReflectionHelpers.setField(mLocaleListEditor, "mRemoveMode", true);
ReflectionHelpers.setField(mLocaleListEditor, "mShowingRemoveDialog", true);
// launch dialog
mLocaleListEditor.showRemoveLocaleWarningDialog();
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
final ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo(mContext.getString(R.string.dlg_remove_locales_error_title));
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExtended.
the class LocaleListEditorTest method showRemoveLocaleWarningDialog_mainLocaleSelected_shouldShowLocaleChangeDialog.
@Test
public void showRemoveLocaleWarningDialog_mainLocaleSelected_shouldShowLocaleChangeDialog() {
// pre-condition
when(mAdapter.getCheckedCount()).thenReturn(1);
when(mAdapter.getItemCount()).thenReturn(2);
when(mAdapter.isFirstLocaleChecked()).thenReturn(true);
ReflectionHelpers.setField(mLocaleListEditor, "mRemoveMode", true);
ReflectionHelpers.setField(mLocaleListEditor, "mShowingRemoveDialog", true);
// launch dialog
mLocaleListEditor.showRemoveLocaleWarningDialog();
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
final ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.dlg_remove_locales_message));
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExtended.
the class LocaleListEditorTest method showRemoveLocaleWarningDialog_mainLocaleNotSelected_shouldShowConfirmDialog.
@Test
public void showRemoveLocaleWarningDialog_mainLocaleNotSelected_shouldShowConfirmDialog() {
// pre-condition
when(mAdapter.getCheckedCount()).thenReturn(1);
when(mAdapter.getItemCount()).thenReturn(2);
when(mAdapter.isFirstLocaleChecked()).thenReturn(false);
ReflectionHelpers.setField(mLocaleListEditor, "mRemoveMode", true);
ReflectionHelpers.setField(mLocaleListEditor, "mShowingRemoveDialog", true);
// launch dialog
mLocaleListEditor.showRemoveLocaleWarningDialog();
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
final ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isNull();
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by Evolution-X.
the class ButtonActionDialogFragmentTest method testOnCreateDialog_specialDisableDialog.
@Test
public void testOnCreateDialog_specialDisableDialog() {
ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(SPECIAL_DISABLE_ID);
FragmentController.setupFragment(fragment, FragmentActivity.class, 0, /* containerViewId */
null);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(mShadowContext.getString(R.string.app_disable_dlg_text));
assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(mShadowContext.getString(R.string.app_disable_dlg_positive));
assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(mShadowContext.getString(R.string.dlg_cancel));
}
Aggregations