Search in sources :

Example 56 with AlertDialog

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

the class NetworkRequestErrorDialogFragmentTest method clickNegativeButton_shouldCallReject.

@Test
public void clickNegativeButton_shouldCallReject() {
    final NetworkRequestUserSelectionCallback rejectCallback = mock(NetworkRequestUserSelectionCallback.class);
    mFragment.setRejectCallback(rejectCallback);
    final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    final Button negativeButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
    negativeButton.performClick();
    verify(rejectCallback, times(1)).reject();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button) NetworkRequestUserSelectionCallback(android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback) Test(org.junit.Test)

Example 57 with AlertDialog

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

the class NetworkRequestErrorDialogFragmentTest method clickNegativeButton_shouldCloseTheDialog.

@Test
public void clickNegativeButton_shouldCloseTheDialog() {
    AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    assertThat(alertDialog.isShowing()).isTrue();
    Button negativeButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
    assertThat(negativeButton).isNotNull();
    negativeButton.performClick();
    assertThat(alertDialog.isShowing()).isFalse();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button) Test(org.junit.Test)

Example 58 with AlertDialog

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

the class NetworkRequestDialogFragmentTest method cancelDialog_callsReject.

@Test
public void cancelDialog_callsReject() {
    // Assert
    networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */
    null);
    final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    final NetworkRequestUserSelectionCallback selectionCallback = mock(NetworkRequestUserSelectionCallback.class);
    networkRequestDialogFragment.onUserSelectionCallbackRegistration(selectionCallback);
    // Action
    final Button button = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    button.performClick();
    // Check
    verify(selectionCallback, times(1)).reject();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button) NetworkRequestUserSelectionCallback(android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback) Test(org.junit.Test)

Example 59 with AlertDialog

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

the class NetworkRequestDialogFragmentTest method display_shouldShowTheDialog.

@Test
public void display_shouldShowTheDialog() {
    networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
    AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    assertThat(alertDialog).isNotNull();
    assertThat(alertDialog.isShowing()).isTrue();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Test(org.junit.Test)

Example 60 with AlertDialog

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

the class NetworkRequestDialogFragmentTest method display_shouldShowTitleWithAppName.

@Test
public void display_shouldShowTitleWithAppName() {
    networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */
    null);
    final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    final String targetTitle = mContext.getString(R.string.network_connection_request_dialog_title, TEST_APP_NAME);
    final TextView view = alertDialog.findViewById(R.id.network_request_title_text);
    assertThat(view.getText()).isEqualTo(targetTitle);
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) TextView(android.widget.TextView) 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