Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom Espresso entry points
/** Modified default root matcher at {@link androidx.test.espresso.matcher.RootMatchers.DEFAULT} */
internal val activityRootMatcher: Matcher<Root> = allOf(
hasWindowLayoutParams(),
allOf(
IsSubwindowOfCurrentActivity(),
isFocusable()
)
)
/** Modified default root matcher at {@link androidx.test.espresso.matcher.RootMatchers.DEFAULT} */
internal val dialogRootMatcher: Matcher<Root> = allOf(
hasWindowLayoutParams(),
allOf(
allOf(isDialog(), withDecorView(HasWindowFocus())),
isFocusable()
)
)
fun onView(viewMatcher: Matcher<View>): ViewInteraction {
return Espresso.onView(viewMatcher).inRoot(activityRootMatcher)
}
fun onBottomSheetView(viewMatcher: Matcher<View>): ViewInteraction {
return Espresso.onView(viewMatcher).inRoot(dialogRootMatcher)
}
fun onDialogView(viewMatcher: Matcher<View>): ViewInteraction {
return Espresso.onView(viewMatcher).inRoot(dialogRootMatcher)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment