Search in sources :

Example 96 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by Spark-Rom.

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());
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) PartnerCustomizationLayout(com.google.android.setupcompat.PartnerCustomizationLayout) Intent(android.content.Intent) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 97 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by Spark-Rom.

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();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 98 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by Spark-Rom.

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));
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 99 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by Spark-Rom.

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);
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 100 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by Spark-Rom.

the class PreferredSimDialogFragmentTest method onCreateDialog_twoSimsSelectSecond_correctMessage.

@Test
public void onCreateDialog_twoSimsSelectSecond_correctMessage() {
    SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mSim1, mSim2));
    SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(mSim1, mSim2));
    mIntent.putExtra(PREFERRED_SIM, 1);
    final AlertDialog alertDialog = startDialog();
    final ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
    final String message = (String) shadowDialog.getMessage();
    assertThat(message).contains(SIM2_NAME);
    assertThat(message).doesNotContain(SIM1_NAME);
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Aggregations

AlertDialog (androidx.appcompat.app.AlertDialog)496 ShadowAlertDialogCompat (com.android.settings.testutils.shadow.ShadowAlertDialogCompat)496 Test (org.junit.Test)496 BatteryTipDialogFragment (com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment)28 Intent (android.content.Intent)14 Bundle (android.os.Bundle)14 RestrictAppTip (com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip)14 OnLockTypeSelectedListener (com.android.settings.password.ChooseLockTypeDialogFragment.OnLockTypeSelectedListener)14 PartnerCustomizationLayout (com.google.android.setupcompat.PartnerCustomizationLayout)14 ArrayList (java.util.ArrayList)14 Config (org.robolectric.annotation.Config)14