Search in sources :

Example 91 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class BluetoothPairingDialogTest method dialogAsksForPairCodeOnUserEntryVariant.

@Test
public void dialogAsksForPairCodeOnUserEntryVariant() {
    // set the dialog variant to user entry
    when(controller.getDialogType()).thenReturn(BluetoothPairingController.USER_ENTRY_DIALOG);
    // we don't care about these for this test
    when(controller.getDeviceVariantMessageId()).thenReturn(BluetoothPairingController.INVALID_DIALOG_TYPE);
    when(controller.getDeviceVariantMessageHintId()).thenReturn(BluetoothPairingController.INVALID_DIALOG_TYPE);
    Context context = spy(ShadowApplication.getInstance().getApplicationContext());
    InputMethodManager imm = mock(InputMethodManager.class);
    doReturn(imm).when(context).getSystemService(Context.INPUT_METHOD_SERVICE);
    // build the fragment
    BluetoothPairingDialogFragment frag = spy(new BluetoothPairingDialogFragment());
    when(frag.getContext()).thenReturn(context);
    setupFragment(frag);
    AlertDialog alertDialog = frag.getmDialog();
    // check that the pin/passkey input field is visible to the user
    View view = alertDialog.findViewById(R.id.text);
    assertThat(view.getVisibility()).isEqualTo(View.VISIBLE);
    // check that showSoftInput was called to make input method appear when the dialog was shown
    assertThat(view.isFocused()).isTrue();
    assertThat(imm.isActive());
    verify(imm).showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
Also used : Context(android.content.Context) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) InputMethodManager(android.view.inputmethod.InputMethodManager) View(android.view.View) TextView(android.widget.TextView) Test(org.junit.Test)

Example 92 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class RemoteDeviceNameDialogFragmentTest method deviceNameDisplayIsCorrect.

@Test
public void deviceNameDisplayIsCorrect() {
    String deviceName = "ABC Corp Headphones";
    AlertDialog dialog = startDialog(deviceName);
    EditText 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(android.app.AlertDialog) EditText(android.widget.EditText) Button(android.widget.Button) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 93 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class ChooseLockTypeDialogFragmentTest method testThat_OnClickListener_IsNotCalledWhenCancelled.

@Test
public void testThat_OnClickListener_IsNotCalledWhenCancelled() {
    mFragment.mDelegate = mock(OnLockTypeSelectedListener.class);
    AlertDialog lockDialog = startLockFragment();
    lockDialog.dismiss();
    verify(mFragment.mDelegate, never()).onLockTypeSelected(any(ScreenLockType.class));
}
Also used : ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) OnLockTypeSelectedListener(com.android.settings.password.ChooseLockTypeDialogFragment.OnLockTypeSelectedListener) Test(org.junit.Test)

Example 94 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class SetupChooseLockPasswordTest method allSecurityOptions_shouldBeShown_When_OptionsButtonIsClicked.

@Test
public void allSecurityOptions_shouldBeShown_When_OptionsButtonIsClicked() {
    SetupChooseLockPassword activity = createSetupChooseLockPassword();
    activity.findViewById(R.id.screen_lock_options).performClick();
    AlertDialog latestAlertDialog = ShadowAlertDialog.getLatestAlertDialog();
    int count = Shadows.shadowOf(latestAlertDialog).getAdapter().getCount();
    assertThat(count).named("List items shown").isEqualTo(3);
}
Also used : ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) Test(org.junit.Test)

Example 95 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class SetupSkipDialogTest method frpMessages_areShownCorrectly_whenSupported.

@Test
public void frpMessages_areShownCorrectly_whenSupported() {
    SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(true);
    setupSkipDialog.show(mActivity.getFragmentManager());
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alertDialog);
    assertEquals(application.getString(R.string.lock_screen_intro_skip_title), shadowAlertDialog.getTitle());
    assertEquals(application.getString(R.string.lock_screen_intro_skip_dialog_text_frp), shadowAlertDialog.getMessage());
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Test(org.junit.Test)

Aggregations

AlertDialog (android.app.AlertDialog)1029 DialogInterface (android.content.DialogInterface)573 View (android.view.View)278 TextView (android.widget.TextView)213 Intent (android.content.Intent)172 EditText (android.widget.EditText)160 Test (org.junit.Test)148 ShadowAlertDialog (org.robolectric.shadows.ShadowAlertDialog)111 Context (android.content.Context)96 ListView (android.widget.ListView)87 ImageView (android.widget.ImageView)86 LayoutInflater (android.view.LayoutInflater)80 Button (android.widget.Button)78 AdapterView (android.widget.AdapterView)72 Activity (android.app.Activity)66 SuppressLint (android.annotation.SuppressLint)61 Bundle (android.os.Bundle)56 OnClickListener (android.content.DialogInterface.OnClickListener)54 ArrayList (java.util.ArrayList)50 Dialog (android.app.Dialog)46