Search in sources :

Example 51 with AlertDialog

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

the class ListWithEntrySummaryPreferenceTest method onSaveAndRestoreInstanceState_resumePreference_shouldNotChangeEntries.

@Test
public void onSaveAndRestoreInstanceState_resumePreference_shouldNotChangeEntries() {
    setEntries_customEntries_shouldUpdateEntries();
    final Parcelable parcelable = mPreference.onSaveInstanceState();
    ListWithEntrySummaryPreference preference = new ListWithEntrySummaryPreference(mContext, null);
    preference.setEntries(mDefaultEntries);
    preference.setEntryValues(mDefaultEntryValues);
    preference.setEntrySummaries(mDefaultEntrySummaries);
    preference.onRestoreInstanceState(parcelable);
    AlertDialog dialog = showDialog(preference);
    ListAdapter adapter = dialog.getListView().getAdapter();
    int len = mCustomEntries.length;
    assertThat(adapter.getCount()).isEqualTo(len);
    for (int i = 0; i < len; i++) {
        TextView title = adapter.getView(i, null, null).findViewById(R.id.title);
        TextView summary = adapter.getView(i, null, null).findViewById(R.id.summary);
        assertThat(title.getText()).isEqualTo(mCustomEntries[i]);
        assertThat(summary.getText()).isEqualTo(mCustomEntrySummaries[i]);
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Parcelable(android.os.Parcelable) TextView(android.widget.TextView) ListAdapter(android.widget.ListAdapter) Test(org.junit.Test)

Example 52 with AlertDialog

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

the class ListWithEntrySummaryPreferenceTest method initialize_defaultEntries_shouldDisplayDefalutEntries.

@Test
public void initialize_defaultEntries_shouldDisplayDefalutEntries() {
    AlertDialog dialog = showDialog(mPreference);
    ListAdapter adapter = dialog.getListView().getAdapter();
    int len = mDefaultEntries.length;
    assertThat(adapter.getCount()).isEqualTo(len);
    for (int i = 0; i < len; i++) {
        TextView title = adapter.getView(i, null, null).findViewById(R.id.title);
        TextView summary = adapter.getView(i, null, null).findViewById(R.id.summary);
        assertThat(title.getText()).isEqualTo(mDefaultEntries[i]);
        assertThat(summary.getText()).isEqualTo(mDefaultEntrySummaries[i]);
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) TextView(android.widget.TextView) ListAdapter(android.widget.ListAdapter) Test(org.junit.Test)

Example 53 with AlertDialog

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

the class NetworkRequestDialogActivityTest method launchActivity_shouldShowNetworkRequestDialog.

@Test
public void launchActivity_shouldShowNetworkRequestDialog() {
    Robolectric.setupActivity(NetworkRequestDialogActivity.class);
    final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    assertThat(alertDialog.isShowing()).isTrue();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Test(org.junit.Test)

Example 54 with AlertDialog

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

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 55 with AlertDialog

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

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());
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Bundle(android.os.Bundle) 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