use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project android_packages_apps_Settings by AOSPA.
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.");
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project android_packages_apps_Settings by AOSPA.
the class BatteryTipDialogFragmentTest method testOnCreateDialog_defenderTip_fireDialog.
@Test
public void testOnCreateDialog_defenderTip_fireDialog() {
mDialogFragment = BatteryTipDialogFragment.newInstance(mDefenderTip, METRICS_KEY);
FragmentController.setupFragment(mDialogFragment, FragmentActivity.class, 0, /* containerViewId */
null);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo(mContext.getString(R.string.battery_tip_limited_temporarily_title));
assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.battery_tip_limited_temporarily_dialog_msg, "80%"));
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project android_packages_apps_Settings by AOSPA.
the class BatteryTipDialogFragmentTest method testOnCreateDialog_highUsageTip_fireHighUsageDialog.
@Test
public void testOnCreateDialog_highUsageTip_fireHighUsageDialog() {
Robolectric.getForegroundThreadScheduler().pause();
mDialogFragment = BatteryTipDialogFragment.newInstance(mHighUsageTip, METRICS_KEY);
FragmentController.setupFragment(mDialogFragment, FragmentActivity.class, 0, /* containerViewId */
null);
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.battery_tip_dialog_message, 1));
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project android_packages_apps_Settings by AOSPA.
the class BatteryTipDialogFragmentTest method testOnCreateDialog_restrictSixAppsTip_fireRestrictSixAppsDialog.
@Test
public void testOnCreateDialog_restrictSixAppsTip_fireRestrictSixAppsDialog() {
Robolectric.getForegroundThreadScheduler().pause();
final List<AppInfo> appInfos = new ArrayList<>();
for (int i = 0; i < 6; i++) {
appInfos.add(mAppInfo);
}
final RestrictAppTip restrictSixAppsTip = new RestrictAppTip(BatteryTip.StateType.NEW, appInfos);
mDialogFragment = BatteryTipDialogFragment.newInstance(restrictSixAppsTip, METRICS_KEY);
FragmentController.setupFragment(mDialogFragment, FragmentActivity.class, 0, /* containerViewId */
null);
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo("Restrict 6 apps?");
assertThat(shadowDialog.getMessage()).isEqualTo("To save battery, stop these apps from using battery in the background. " + "Restricted apps may not work properly and notifications may be" + " delayed.\n\nApps:\napp, app, app, app, app, and app.");
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project android_packages_apps_Settings by AOSPA.
the class SetupSkipDialogTest method dialogMessage_whenSkipPinSetupForBiometrics_shouldShownCorrectly.
@Test
public void dialogMessage_whenSkipPinSetupForBiometrics_shouldShownCorrectly() {
SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(true, false, false, 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_pin_skip_biometrics_title));
assertThat(shadowAlertDialog.getMessage()).isEqualTo(mActivity.getString(R.string.lock_screen_pin_skip_biometrics_message));
}
Aggregations