Created
October 29, 2014 07:44
-
-
Save realdadfish/2622caecc1b2d498cd1a to your computer and use it in GitHub Desktop.
Workaround for Espresso / Android Test Kit to "support" RecyclerView matching.
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 class ViewMatchers | |
{ | |
@SuppressWarnings("unchecked") | |
public static Matcher<View> withRecyclerView(@IdRes int viewId) | |
{ | |
return allOf(isAssignableFrom(RecyclerView.class), withId(viewId)); | |
} | |
@SuppressWarnings("unchecked") | |
public static ViewInteraction onRecyclerItemView(@IdRes int identifyingView, Matcher<View> identifyingMatcher, Matcher<View> childMatcher) | |
{ | |
Matcher<View> itemView = allOf(withParent(withRecyclerView(R.id.start_grid)), | |
withChild(allOf(withId(identifyingView), identifyingMatcher))); | |
return Espresso.onView(allOf(isDescendantOfA(itemView), childMatcher)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Probably, recycler_view_id.