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);
}
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();
}
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));
}
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);
}
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());
}
Aggregations