Last active
August 29, 2015 14:19
-
-
Save Sushisugre/989eff328ad5fa4841b7 to your computer and use it in GitHub Desktop.
Works with child view inside of RecyclerView item using espresso, inspired by https://gist.github.com/tommyd3mdi/2622caecc1b2d498cd1a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Matcher<View> withRecyclerViewId(int recyclerViewId) { | |
return allOf(isAssignableFrom(RecyclerView.class), withId(recyclerViewId)); | |
} | |
/** | |
* Returns a matcher for an item (cell) in recycler view. | |
* | |
* @param recyclerViewId | |
* @param childViewMatcher | |
* @return | |
*/ | |
public static Matcher<View> withRecyclerItemView( | |
int recyclerViewId, | |
Matcher<View> childViewMatcher) { | |
return allOf(withParent(withRecyclerViewId(recyclerViewId)), | |
(childViewMatcher)); | |
} | |
/** | |
* Get the view interaction of the child view inside of a RecyclerView item | |
* | |
* @param recyclerViewId resources Id of target RecyclerView | |
* @param ItemIdentifier Matcher for the desired item (cell) | |
* @param childViewMatcher Matcher for the child view in the item | |
* @return | |
* | |
*/ | |
public static ViewInteraction onRecyclerItemView( | |
int recyclerViewId, | |
Matcher<View> ItemIdentifier, | |
Matcher<View> childViewMatcher) { | |
Matcher<View> itemView = withRecyclerItemView(recyclerViewId, ItemIdentifier); | |
return Espresso.onView(allOf(isDescendantOfA(itemView), childViewMatcher)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unlike working with DataInteractions, this workaround doesn't load the view(data) in adapter that is not yet visible.