@Test public void enteringIncorrectPassword_andClickingOK_callsOnInCorrectAdminPassword() { TestActivityScenario<SpyAdminPasswordDialogCallbackActivity> activityScenario = TestActivityScenario.launch(SpyAdminPasswordDialogCallbackActivity.class); activityScenario.onActivity(activity -> { AdminPasswordDialogFragment fragment = createFragment(); fragment.show(activity.getSupportFragmentManager(), "tag"); shadowOf(getMainLooper()).idle(); fragment.getInput().setText("not the password"); ((AlertDialog) fragment.getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).performClick(); shadowOf(getMainLooper()).idle(); assertThat(activity.onCorrectAdminPasswordCalledWith, nullValue()); assertThat(activity.onIncorrectAdminPasswordCalled, equalTo(true)); }); }
public EditText getInput() { return input; }
AdminPasswordDialogFragment extends DialogFragment { public EditText getInput() { return input; } }
AdminPasswordDialogFragment extends DialogFragment { public EditText getInput() { return input; }  }
AdminPasswordDialogFragment extends DialogFragment { public EditText getInput() { return input; }  @Override void onAttach(@NotNull Context context); @Override void onStart(); @Override Dialog onCreateDialog(Bundle savedInstanceState); EditText getInput(); }
AdminPasswordDialogFragment extends DialogFragment { public EditText getInput() { return input; }  @Override void onAttach(@NotNull Context context); @Override void onStart(); @Override Dialog onCreateDialog(Bundle savedInstanceState); EditText getInput(); static final String ARG_ACTION; }