use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by Evolution-X.
the class ForgetDeviceDialogFragmentTest method createDialog_normalDevice_showNormalMessage.
@Test
public void createDialog_normalDevice_showNormalMessage() {
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn("false".getBytes());
FragmentController.setupFragment(mFragment, FragmentActivity.class, 0, /* containerViewId */
null);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.bluetooth_unpair_dialog_body, DEVICE_NAME));
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by Evolution-X.
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 Evolution-X.
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 Evolution-X.
the class PreferredSimDialogFragmentTest method onCreateDialog_twoSimsSelectFirst_correctMessage.
@Test
public void onCreateDialog_twoSimsSelectFirst_correctMessage() {
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSim1, mSim2));
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(mSim1, mSim2));
mIntent.putExtra(PREFERRED_SIM, 0);
final AlertDialog alertDialog = startDialog();
final ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
final String message = (String) shadowDialog.getMessage();
assertThat(message).contains(SIM1_NAME);
assertThat(message).doesNotContain(SIM2_NAME);
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by Evolution-X.
the class NetworkRequestErrorDialogFragmentTest method display_shouldShowTimeoutDialog.
@Test
public void display_shouldShowTimeoutDialog() {
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(alertDialog).isNotNull();
assertThat(alertDialog.isShowing()).isTrue();
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
assertThat(RuntimeEnvironment.application.getString(R.string.network_connection_timeout_dialog_message)).isEqualTo(shadowAlertDialog.getMessage());
}
Aggregations