@Test public void testTemplateConstructor() { EspButton template = EspButton.byText(buttonText); this.espButton = new EspButton(template); this.espButton.assertIsVisible(); } }
/** * Access neutral button element. * * @return New element for actions and assertions. * * @since Espresso Macchiato 0.2 */ public EspButton cancelButton() { return EspButton.byId(spec.cancelButtonResource); }
@Test public void testDialogWithDeny() { addDialog(new AlertDialog.Builder(activityTestRule.getActivity()) .setTitle(TITLE) .setMessage(MESSAGE) .setPositiveButton(OK, clickListener) .setNegativeButton(DENY, clickListener)); espAlertDialog.denyButton().click(); espAlertDialog.assertNotExist(); espTextView.assertTextIs(CLICKED_BUTTON + DialogInterface.BUTTON_NEGATIVE); }
/** * Create new instance matching an element with given resourceId. * * @param resourceId Identifier for this element. * * @return New element instance for actions and assertions. * * @since Espresso Macchiato 0.1 */ public static EspButton byId(int resourceId) { return new EspButton(resourceId); }
@Test public void testDummyLauncher() { EspPage.byId(EspDummyLauncherActivity.rootLayout).assertIsDisplayedOnScreen(); // test start method EspDummyLauncherActivity activity = getActivity(); activity.setStartIntent(BaseActivity.class); activity.start(); EspPage.byId(BaseActivity.rootLayout).assertIsDisplayedOnScreen(); EspDevice.root().clickBackButton(); EspPage.byId(EspDummyLauncherActivity.rootLayout).assertIsDisplayedOnScreen(); // test click action EspButton.byId(EspDummyLauncherActivity.buttonId).click(); EspPage.byId(BaseActivity.rootLayout).assertIsDisplayedOnScreen(); }
@Test public void testWrongLogin() { loginPage.confirm().assertIsDisabled(); loginPage.username().replaceText("MyUserName"); loginPage.password().replaceText("*****"); loginPage.confirm().click(); loginPage.errorMessage().assertTextIs("Username or password not correct."); } }
@Test public void testByText() { espButton = EspButton.byText(buttonText); espButton.assertIsVisible(); }
/** * Checks that the current text matches the expected text. * * @param expected Expected text. * * @since Espresso Macchiato 0.1 */ public void assertTextIs(String expected) { findView().check(matches(withText(expected))); } }
@Test public void testAssertTextIs() { espButton.assertTextIs(buttonText); }
@Test public void testDialogWithDeny() { addDialog(new AlertDialog.Builder(activityTestRule.getActivity()) .setTitle(TITLE) .setMessage(MESSAGE) .setPositiveButton(OK, clickListener) .setNegativeButton(DENY, clickListener)); espSupportAlertDialog.denyButton().click(); espSupportAlertDialog.assertNotExist(); espTextView.assertTextIs(CLICKED_BUTTON + DialogInterface.BUTTON_NEGATIVE); }
/** * Create new instance matching an element with given text. * * @param text Identifier for this element. * * @return New element instance for actions and assertions. * * @since Espresso Macchiato 0.2 */ public static EspButton byText(String text) { return new EspButton(withText(text)); }
@Test public void testDialogWithCancel() { addDialog(new AlertDialog.Builder(activityTestRule.getActivity()) .setTitle(TITLE) .setMessage(MESSAGE) .setPositiveButton(OK, clickListener) .setNeutralButton(CANCEL, clickListener) .setNegativeButton(DENY, clickListener)); espSupportAlertDialog.cancelButton().click(); espSupportAlertDialog.assertNotExist(); espTextView.assertTextIs(CLICKED_BUTTON + DialogInterface.BUTTON_NEUTRAL); }
public EspButton confirm() { return new EspButton(R.id.buttonConfirm); }
/** * Access negative button element. * * @return New element for actions and assertions. * * @since Espresso Macchiato 0.2 */ public EspButton denyButton() { return EspButton.byId(spec.denyButtonResource); }
@Test public void testDialogWithCancel() { addDialog(new AlertDialog.Builder(activityTestRule.getActivity()) .setTitle(TITLE) .setMessage(MESSAGE) .setPositiveButton(OK, clickListener) .setNeutralButton(CANCEL, clickListener) .setNegativeButton(DENY, clickListener)); espAlertDialog.cancelButton().click(); espAlertDialog.assertNotExist(); espTextView.assertTextIs(CLICKED_BUTTON + DialogInterface.BUTTON_NEUTRAL); }
/** * Access positive button element. * * @return New element for actions and assertions. * * @since Espresso Macchiato 0.2 */ public EspButton confirmButton() { return EspButton.byId(spec.confirmButtonResource); }
@Test public void testTemplateConstructor() { espSupportAlertDialog = new EspSupportAlertDialog(espSupportAlertDialog); addDialog(new AlertDialog.Builder(activityTestRule.getActivity()) .setTitle(TITLE) .setMessage(MESSAGE) .setPositiveButton(OK, clickListener)); espSupportAlertDialog.confirmButton().click(); espTextView.assertTextIs(CLICKED_BUTTON + DialogInterface.BUTTON_POSITIVE); }
@Test public void testTemplateConstructor() { espAlertDialog = new EspAlertDialog(espAlertDialog); addDialog(new AlertDialog.Builder(activityTestRule.getActivity()) .setTitle(TITLE) .setMessage(MESSAGE) .setPositiveButton(OK, clickListener)); espAlertDialog.confirmButton().click(); espTextView.assertTextIs(CLICKED_BUTTON + DialogInterface.BUTTON_POSITIVE); }
@Test public void testDialogWithConfirm() { espAlertDialog.assertNotExist(); addDialog(new AlertDialog.Builder(activityTestRule.getActivity()) .setTitle(TITLE) .setMessage(MESSAGE) .setPositiveButton(OK, clickListener)); espAlertDialog.assertIsVisible(); espAlertDialog.title().assertTextIs(TITLE); espAlertDialog.message().assertTextIs(MESSAGE); espAlertDialog.confirmButton().click(); espAlertDialog.assertNotExist(); espTextView.assertTextIs(CLICKED_BUTTON + DialogInterface.BUTTON_POSITIVE); }
@Test public void testDialogWithConfirm() { espSupportAlertDialog.assertNotExist(); addDialog(new AlertDialog.Builder(activityTestRule.getActivity()) .setTitle(TITLE) .setMessage(MESSAGE) .setPositiveButton(OK, clickListener)); espSupportAlertDialog.assertIsVisible(); espSupportAlertDialog.title().assertTextIs(TITLE); espSupportAlertDialog.message().assertTextIs(MESSAGE); espSupportAlertDialog.confirmButton().click(); espSupportAlertDialog.assertNotExist(); espTextView.assertTextIs(CLICKED_BUTTON + DialogInterface.BUTTON_POSITIVE); }