use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExtended.
the class DevelopmentSettingsDashboardFragmentTest method onSwitchChanged_turnOff_andOffloadIsNotDefaultValue_shouldShowWarningDialog.
@Test
@Config(shadows = ShadowDisableDevSettingsDialogFragment.class)
public void onSwitchChanged_turnOff_andOffloadIsNotDefaultValue_shouldShowWarningDialog() {
final BluetoothA2dpHwOffloadPreferenceController controller = mock(BluetoothA2dpHwOffloadPreferenceController.class);
when(mDashboard.getContext()).thenReturn(mContext);
when(mDashboard.getDevelopmentOptionsController(BluetoothA2dpHwOffloadPreferenceController.class)).thenReturn(controller);
when(controller.isDefaultValue()).thenReturn(false);
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
mDashboard.onSwitchChanged(mSwitch, false);
AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_disable_a2dp_hw_offload_dialog_title));
assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.bluetooth_disable_a2dp_hw_offload_dialog_message));
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExtended.
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);
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExtended.
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);
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExtended.
the class NetworkRequestErrorDialogFragmentTest method display_shouldShowTimeoutDialog.
@Test
public void display_shouldShowTimeoutDialog() {
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(alertDialog).isNotNull();
assertThat(alertDialog.isShowing()).isTrue();
ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
assertThat(RuntimeEnvironment.application.getString(R.string.network_connection_timeout_dialog_message)).isEqualTo(shadowAlertDialog.getMessage());
}
use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project packages_apps_Settings by PixelExtended.
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?");
}
Aggregations