Issue
I would like to create an Espresso test which verifies that SwipeRefreshLayout
is showing the refreshing indicator. How can I do this?
Solution
There is no standard Espresso matcher for this, but you can create a custom one:
object SwipeRefreshLayoutMatchers {
@JvmStatic
fun isRefreshing(): Matcher<View> {
return object : BoundedMatcher<View, SwipeRefreshLayout>(
SwipeRefreshLayout::class.java) {
override fun describeTo(description: Description) {
description.appendText("is refreshing")
}
override fun matchesSafely(view: SwipeRefreshLayout): Boolean {
return view.isRefreshing
}
}
}
}
And then you can use it like this:
onView(withId(R.id.swipe_refresh_layout)).check(matches(isRefreshing()))
Answered By - makovkastar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.