Search in sources :

Example 1 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ForgetDeviceDialogFragmentTest method createDialog_untetheredDevice_showUntetheredMessage.

@Test
public void createDialog_untetheredDevice_showUntetheredMessage() {
    when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn("true".getBytes());
    FragmentController.setupFragment(mFragment, FragmentActivity.class, 0, /* containerViewId */
    null);
    final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
    assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.bluetooth_untethered_unpair_dialog_body, DEVICE_NAME));
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 2 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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 3 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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

Example 4 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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

Example 5 with ShadowAlertDialogCompat

use of com.android.settings.testutils.shadow.ShadowAlertDialogCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SetupSkipDialogTest method dialogMessage_whenSkipPinSetupForFace_shouldShownCorrectly.

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

Aggregations

AlertDialog (androidx.appcompat.app.AlertDialog)30 ShadowAlertDialogCompat (com.android.settings.testutils.shadow.ShadowAlertDialogCompat)30 Test (org.junit.Test)30 BatteryTipDialogFragment (com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 RestrictAppTip (com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip)1 OnLockTypeSelectedListener (com.android.settings.password.ChooseLockTypeDialogFragment.OnLockTypeSelectedListener)1 PartnerCustomizationLayout (com.google.android.setupcompat.PartnerCustomizationLayout)1 ArrayList (java.util.ArrayList)1 Config (org.robolectric.annotation.Config)1