thatMatchesActivity
Returns a TypeSafeMatcher for Root which matches the root which belongs to the given type-safe activityClass.
This can be used to ensure that a TypeSafeMatcher is used to match views on a specific Android Activity.
When obtaining ViewInteraction with onView, pass root matcher to ViewInteraction.inRoot. When obtaining ViewInteraction with waitForView, pass root matcher as an argument. Example:
waitForView(thatIsStopNavigationButton, rootMatcher =
thatMatchesActivity(TestNavigationActivity::class))
.check(matches(isDisplayed()))
.perform(click()
onView(thatIsStopNavigationButton)
.inRoot(thatMatchesActivity(TestNavigationActivity::class))
.waitForMatcher(isDisplayed())
.perform(click())
Content copied to clipboard