use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.
the class SetupFingerprintEnrollFindSensorTest method fingerprintEnroll_showsAlert_whenClickingSkip.
@Test
public void fingerprintEnroll_showsAlert_whenClickingSkip() {
final Intent intent = new Intent().putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
final SetupFingerprintEnrollFindSensor activity = Robolectric.buildActivity(SetupFingerprintEnrollFindSensor.class, intent).setup().get();
PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
layout.getMixin(FooterBarMixin.class).getSecondaryButtonView().performClick();
final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(alertDialog).isNotNull();
final ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
final int titleRes = R.string.setup_fingerprint_enroll_skip_title;
assertThat(application.getString(titleRes)).isEqualTo(shadowAlertDialog.getTitle());
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.
the class ChooseLockTypeDialogFragmentTest method testThat_OnClickListener_IsCalled.
@Test
public void testThat_OnClickListener_IsCalled() {
mFragment.mDelegate = mock(OnLockTypeSelectedListener.class);
AlertDialog lockDialog = startLockFragment();
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(lockDialog);
shadowAlertDialog.clickOnItem(0);
verify(mFragment.mDelegate, times(1)).onLockTypeSelected(any(ScreenLockType.class));
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.
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 PixelExperience.
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 PixelExperience.
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();
}
Aggregations