/** * This test clicks the floating action button and checks to see if a new * item has been added to the RecyclerView with the text "+ Word 20". */ @Test public void recyclerViewTest() { ViewInteraction floatingActionButton = onView( allOf(withId(R.id.fab), childAtPosition( childAtPosition( withId(android.R.id.content), 0), 2), isDisplayed())); floatingActionButton.perform(click()); ViewInteraction textView = onView( allOf(withId(R.id.word), withText("+ Word 20"), childAtPosition( childAtPosition( withId(R.id.recyclerview), 13), 0), isDisplayed())); textView.check(matches(withText("+ Word 20"))); }
@Test public void recyclerViewTest() { ViewInteraction recyclerView = onView( allOf(withId(R.id.recyclerview), isDisplayed())); recyclerView.perform(actionOnItemAtPosition(15, click())); ViewInteraction textView = onView( allOf(withId(R.id.word), withText("Clicked! Word 15"), childAtPosition( childAtPosition( withId(R.id.recyclerview), 11), 0), isDisplayed())); textView.check(matches(withText("Clicked! Word 15"))); }