/** * 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 EspTextView byId(int resourceId) { return new EspTextView(resourceId); }
/** * 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 EspTextView byText(String text) { return new EspTextView(withText(text)); }
public EspTextView errorMessage() { return new EspTextView(R.id.textViewErrorMessage); } }
public EspTextView textView() { return new EspTextView(baseMatcherForItemChild(withId(LongListActivity.itemTextViewId))); } }
@Test public void testTemplateConstructor() { espTextView = new EspTextView(espTextView); espTextView.assertTextIs(textViewText); }
@Test public void testMatchColor() { TextView textView = new TextView(activityTestRule.getActivity()); textView.setText(BLACK); textView.setTextColor(0xff000000); addViewToLayout(textView, BaseActivity.rootLayout); TextView textView2 = new TextView(activityTestRule.getActivity()); textView2.setText(WHITE); textView2.setTextColor(0xffffffff); addViewToLayout(textView2, BaseActivity.rootLayout); new EspTextView(EspTextViewMatcher.withTextColor(0xffffffff)).assertTextIs(WHITE); } }
@Test public void testBaseMatcherForItemChild() { EspTextView espTextView = new EspTextView(itemInitialDisplayed.baseMatcherForItemChild(withId(LongRecyclerActivity.itemTextViewId))); espTextView.assertTextIs("item: 0"); }
@Test public void testScrollTo() { itemInitialNotDisplayed.scrollTo(); EspTextView espTextView = new EspTextView(itemInitialNotDisplayed.baseMatcherForItemChild(withId(LongRecyclerActivity.itemTextViewId))); espTextView.assertTextIs("item: 30"); }
@Test public void testMatcherFailureWhenChildViewNotMatch() { EspTextView espTextView = new EspTextView(itemInitialDisplayed.baseMatcherForItemChild(withId(LongRecyclerActivity.itemTextViewId))); exception.expect(AssertionFailedError.class); exception.expectMessage("'with text: is \"item: 20\"' doesn't match the selected view"); espTextView.assertTextIs("item: 20"); }
@Test public void testBaseMatcherForItemChildFailureWhenItemIsNotDisplayed() { EspTextView espTextView = new EspTextView(itemInitialNotDisplayed.baseMatcherForItemChild(withId(LongRecyclerActivity.itemTextViewId))); exception.expect(AssertionFailedError.class); exception.expectMessage("Requested item is currently not displayed. Try first scrollTo() to make the item visible."); espTextView.assertTextIs("item: 0"); }
@Test public void testScrollTo() { espAdapterView.itemByIndex(99).scrollTo(); espAdapterView.itemByIndex(20).scrollTo(); EspTextView espTextView = new EspTextView(espAdapterView.itemByVisibleIndex(0).baseMatcherForItemChild(withId(LongListActivity.itemTextViewId))); espTextView.assertTextIs("item: 20"); }