Search in sources :

Example 51 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.

the class BatteryTipDialogFragmentTest method testOnCreateDialog_restrictOneAppTip_fireRestrictOneAppDialog.

@Test
public void testOnCreateDialog_restrictOneAppTip_fireRestrictOneAppDialog() {
    mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictedOneAppTip, METRICS_KEY);
    FragmentController.setupFragment(mDialogFragment, FragmentActivity.class, 0, /* containerViewId */
    null);
    final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
    assertThat(shadowDialog.getTitle()).isEqualTo("Restrict app?");
    assertThat(shadowDialog.getMessage()).isEqualTo("To save battery, stop app from using battery in the background. This app" + " may not work properly and notifications may be delayed.");
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 52 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.

the class BatteryTipDialogFragmentTest method testOnCreateDialog_summaryTip_fireDialog.

@Test
public void testOnCreateDialog_summaryTip_fireDialog() {
    doReturn(AVERAGE_TIME_MS).when(mSummaryTip).getAverageTimeMs();
    mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip, METRICS_KEY);
    FragmentController.setupFragment(mDialogFragment, FragmentActivity.class, 0, /* containerViewId */
    null);
    final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
    assertThat(shadowDialog.getMessage()).isEqualTo("Your apps are using a normal amount of battery. If apps use too much battery, " + "your phone will suggest actions you can take.\n\nYou can always turn" + " on Battery Saver if you’re running low on battery.");
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 53 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.

the class SetupSkipDialogTest method dialogMessage_whenSkipPasswordSetupForFace_shouldShownCorrectly.

@Test
public void dialogMessage_whenSkipPasswordSetupForFace_shouldShownCorrectly() {
    SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(true, false, true, false, true, false);
    setupSkipDialog.show(mActivity.getSupportFragmentManager());
    AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    assertThat(alertDialog).isNotNull();
    ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
    assertThat(shadowAlertDialog.getTitle()).isEqualTo(mActivity.getString(R.string.lock_screen_password_skip_face_title));
    assertThat(shadowAlertDialog.getMessage()).isEqualTo(mActivity.getString(R.string.lock_screen_password_skip_face_message));
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 54 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.

the class SetupSkipDialogTest method frpMessages_areShownCorrectly_whenNotSupported.

@Test
public void frpMessages_areShownCorrectly_whenNotSupported() {
    SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(false, false, false, false, false, false);
    setupSkipDialog.show(mActivity.getSupportFragmentManager());
    AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    assertThat(alertDialog).isNotNull();
    ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
    assertThat(mActivity.getString(R.string.lock_screen_intro_skip_title)).isEqualTo(shadowAlertDialog.getTitle());
    assertThat(mActivity.getString(R.string.lock_screen_intro_skip_dialog_text)).isEqualTo(shadowAlertDialog.getMessage());
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 55 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.

the class SetupSkipDialogTest method dialogMessage_whenSkipPasswordSetupForBiometrics_shouldShownCorrectly.

@Test
public void dialogMessage_whenSkipPasswordSetupForBiometrics_shouldShownCorrectly() {
    SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(true, false, true, false, false, true);
    setupSkipDialog.show(mActivity.getSupportFragmentManager());
    AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    assertThat(alertDialog).isNotNull();
    ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
    assertThat(shadowAlertDialog.getTitle()).isEqualTo(mActivity.getString(R.string.lock_screen_password_skip_biometrics_title));
    assertThat(shadowAlertDialog.getMessage()).isEqualTo(mActivity.getString(R.string.lock_screen_password_skip_biometrics_message));
}
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