Search in sources :

Example 66 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ButtonActionDialogFragmentTest method testOnCreateDialog_disableDialog.

@Test
public void testOnCreateDialog_disableDialog() {
    ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(DISABLE_ID);
    FragmentController.setupFragment(fragment, FragmentActivity.class, 0, /* containerViewId */
    null);
    final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    assertThat(dialog).isNotNull();
    ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
    assertThat(shadowDialog.getMessage()).isEqualTo(mShadowContext.getString(R.string.app_disable_dlg_text));
    assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(mShadowContext.getString(R.string.app_disable_dlg_positive));
    assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(mShadowContext.getString(R.string.dlg_cancel));
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 67 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ButtonActionDialogFragmentTest method testOnCreateDialog_specialDisableDialog.

@Test
public void testOnCreateDialog_specialDisableDialog() {
    ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(SPECIAL_DISABLE_ID);
    FragmentController.setupFragment(fragment, FragmentActivity.class, 0, /* containerViewId */
    null);
    final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    assertThat(dialog).isNotNull();
    ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
    assertThat(shadowDialog.getMessage()).isEqualTo(mShadowContext.getString(R.string.app_disable_dlg_text));
    assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(mShadowContext.getString(R.string.app_disable_dlg_positive));
    assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(mShadowContext.getString(R.string.dlg_cancel));
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 68 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RemoteDeviceNameDialogFragmentTest method deviceNameDisplayIsCorrect.

@Test
public void deviceNameDisplayIsCorrect() {
    String deviceName = "ABC Corp Headphones";
    AlertDialog dialog = startDialog(deviceName);
    EditText editText = dialog.findViewById(R.id.edittext);
    assertThat(editText.getText().toString()).isEqualTo(deviceName);
    // Make sure that the "rename" button isn't enabled since the text hasn't changed yet, but
    // the "cancel" button should be enabled.
    Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
    assertThat(positiveButton.isEnabled()).isFalse();
    Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
    assertThat(negativeButton.isEnabled()).isTrue();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) EditText(android.widget.EditText) Button(android.widget.Button) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 69 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PrivateVolumeForgetTest method OnClickListener_shouldCallForget.

@Test
public void OnClickListener_shouldCallForget() {
    assertThat(ShadowStorageManager.isForgetCalled()).isFalse();
    final Button confirm = mFragment.getView().findViewById(R.id.confirm);
    confirm.performClick();
    final ForgetConfirmFragment confirmFragment = (ForgetConfirmFragment) mActivity.getSupportFragmentManager().findFragmentByTag(PrivateVolumeForget.TAG_FORGET_CONFIRM);
    assertThat(confirmFragment).isNotNull();
    final AlertDialog dialog = (AlertDialog) confirmFragment.getDialog();
    final Button forget = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
    forget.performClick();
    assertThat(ShadowStorageManager.isForgetCalled()).isTrue();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button) ForgetConfirmFragment(com.android.settings.deviceinfo.PrivateVolumeForget.ForgetConfirmFragment) Test(org.junit.Test)

Example 70 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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)256 Test (org.junit.Test)89 View (android.view.View)48 DialogInterface (android.content.DialogInterface)40 Button (android.widget.Button)39 TextView (android.widget.TextView)39 Intent (android.content.Intent)30 ShadowAlertDialogCompat (com.android.settings.testutils.shadow.ShadowAlertDialogCompat)30 NonNull (androidx.annotation.NonNull)27 Context (android.content.Context)26 Bundle (android.os.Bundle)20 SuppressLint (android.annotation.SuppressLint)17 EditText (android.widget.EditText)17 ArrayList (java.util.ArrayList)17 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)14 List (java.util.List)12 Activity (android.app.Activity)11 Uri (android.net.Uri)11 LayoutInflater (android.view.LayoutInflater)11 ListView (android.widget.ListView)10