/** * 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 EspEditText byId(int resourceId) { return new EspEditText(resourceId); }
@Test public void testByText() { espEditText.replaceText(INITIAL_TEXT); espEditText = EspEditText.byText(INITIAL_TEXT); espEditText.assertIsDisplayedOnScreen(); }
@Test public void testReplaceText() { espEditText.assertTextIs(""); espEditText.replaceText(INITIAL_TEXT); espEditText.assertTextIs(INITIAL_TEXT); espEditText.replaceText(CHANGED_TEXt); espEditText.assertTextIs(CHANGED_TEXt); }
@Test public void testCustomBaseMatcher() { espEditText.replaceText(INITIAL_TEXT); espEditText = new EspEditText(withText(INITIAL_TEXT)); espEditText.assertIsVisible(); }
@Test public void testTemplateConstructor() { espEditText = new EspEditText(espEditText); espEditText.assertIsVisible(); } }
@Test public void testByAll() { espEditText = EspEditText.byAll().withId(editTextId).build(); espEditText.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 testAssertSoftKeyboardIsClosedFailure() { exception.expect(AssertionFailedError.class); exception.expectMessage(containsString("Keyboard should be closed.")); exception.expectMessage(containsString("Expected: is <true>")); exception.expectMessage(containsString("Got: <false>")); givenEditTextToOpenSoftKeyboard(); // other test works and difference is this extra check for initial closed. espDevice.assertSoftKeyboardIsClosed(); espEditText.click(); espDevice.assertSoftKeyboardIsClosed(); }
@Test public void testHint() { espEditText.assertHintTextIs(HINT_TEXT); }
@Test public void testCloseSoftKeyboard() { givenEditTextToOpenSoftKeyboard(); espDevice.assertSoftKeyboardIsClosed(); espEditText.click(); espDevice.assertSoftKeyboardIsOpen(); espDevice.closeSoftKeyboard(); espDevice.assertSoftKeyboardIsClosed(); }
/** * 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 EspEditText byText(String text) { return new EspEditText(withText(text)); }
public EspEditText username() { return new EspEditText(R.id.editTextUsername); }
public EspEditText password() { return new EspEditText(R.id.editTextPassword); }