Search in sources :

Example 56 with ShadowAlertDialogCompat

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

Example 57 with ShadowAlertDialogCompat

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

Example 58 with ShadowAlertDialogCompat

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

Example 59 with ShadowAlertDialogCompat

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

Example 60 with ShadowAlertDialogCompat

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?");
}
Also used : BatteryTipDialogFragment(com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment) 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