I would like to create an Espresso test which verifies that SwipeRefreshLayout
is showing the refreshing indicator. How can I do this?
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()))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With