use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.
the class NetworkRequestErrorDialogFragmentTest method display_shouldShowAbortDialog.
@Test
public void display_shouldShowAbortDialog() {
mFragment = spy(NetworkRequestErrorDialogFragment.newInstance());
Bundle bundle = new Bundle();
bundle.putSerializable(NetworkRequestErrorDialogFragment.DIALOG_TYPE, ERROR_DIALOG_TYPE.ABORT);
mFragment.setArguments(bundle);
mFragment.show(mActivity.getSupportFragmentManager(), null);
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(alertDialog).isNotNull();
assertThat(alertDialog.isShowing()).isTrue();
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
assertThat(RuntimeEnvironment.application.getString(R.string.network_connection_errorstate_dialog_message)).isEqualTo(shadowAlertDialog.getMessage());
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.
the class RestrictedAppDetailsTest method createDialogFragment_toRestrict_createRestrictDialog.
@Test
public void createDialogFragment_toRestrict_createRestrictDialog() {
final BatteryTipDialogFragment dialogFragment = mRestrictedAppDetails.createDialogFragment(mAppInfo, true);
FragmentController.setupFragment(dialogFragment, FragmentActivity.class, 0, /* containerViewId */
null);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo("Restrict app?");
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.
the class BatteryTipDialogFragmentTest method testOnCreateDialog_unRestrictAppTip_fireUnRestrictDialog.
@Test
public void testOnCreateDialog_unRestrictAppTip_fireUnRestrictDialog() {
mDialogFragment = BatteryTipDialogFragment.newInstance(mUnrestrictAppTip, METRICS_KEY);
ShadowUtils.setApplicationLabel(PACKAGE_NAME, DISPLAY_NAME);
FragmentController.setupFragment(mDialogFragment, FragmentActivity.class, 0, /* containerViewId */
null);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo("Remove restriction?");
assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.battery_tip_unrestrict_app_dialog_message));
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.
the class BatteryTipDialogFragmentTest method testOnCreateDialog_restrictTwoAppsTip_fireRestrictTwoAppsDialog.
@Test
public void testOnCreateDialog_restrictTwoAppsTip_fireRestrictTwoAppsDialog() {
Robolectric.getForegroundThreadScheduler().pause();
mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictTwoAppsTip, 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 2 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:");
assertThat(shadowDialog.getView()).isNotNull();
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExperience.
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));
}
Aggregations