Язык: Kotlin, API 36, Compose UI < /p>
Код: Выделить всё
class SimpleToastMatcher : TypeSafeMatcher() {
override fun matchesSafely(root: Root): Boolean {
val type = root.windowLayoutParams.get().type
if (type == WindowManager.LayoutParams.TYPE_TOAST) {
return true
}
// For overlays that might be toasts (e.g., on API 30+)
// they are typically not focusable.
if (type == WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY) {
return !root.decorView.isFocusable && !root.decorView.isFocusableInTouchMode
}
return false
}
override fun describeTo(description: Description?) {
description?.appendText("is toast")
}
}
< /code>
onView(withText(toastText))
.inRoot(SimpleToastMatcher())
.check(matches(isDisplayed()))
Подробнее здесь: https://stackoverflow.com/questions/797 ... th-compose
Мобильная версия