Created
May 5, 2021 00:19
-
-
Save cmathew/8a1dcee0fa3d01f64257ee66d3407283 to your computer and use it in GitHub Desktop.
Custom Espresso entry points
This file contains hidden or 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
/** 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