Skip to content

Instantly share code, notes, and snippets.

@reactivedroid
Created July 30, 2019 13:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save reactivedroid/f5aa71341c982213b02798f33f5e13d8 to your computer and use it in GitHub Desktop.
fun launchHome(func: HomeRobot.() -> Unit) = HomeRobot().apply { func() }
class HomeRobot {
fun verifyHome() {
onView(withId(R.id.popular_show_header)).check(matches(isDisplayed()))
onView(allOf(withId(R.id.popular_shows), isDisplayed()))
}
fun verifyFavorite() {
// Click on 1st item and mark as favorite
onView(withId(R.id.popular_shows))
.perform(
actionOnItemAtPosition<ShowsAdapter.ShowHolder>
(0, ViewActionUtils.clickChildViewWithId(R.id.favorite))
)
}
fun verifyToast(activity: Activity) {
onView(withText(R.string.added_to_favorites)).inRoot(withDecorView(not(`is`(activity.window.decorView))))
.check(matches(isDisplayed()))
}
fun verifyFavoriteScreen() {
onView(withId(R.id.action_favorites))
.perform(click())
onView(withText(R.string.favorite_shows)).check(matches(isDisplayed()))
onView(withId(R.id.shows))
.check(matches(MatcherUtils.withListSize(1)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment