{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ViewAssertions

class ViewAssertions


Collection of common ViewAssertions.

Summary

Public constructors

Public functions

java-static ViewAssertion!

Returns an assert that ensures the view matcher does not find any matching view in the hierarchy.

java-static ViewAssertion!
matches(viewMatcher: Matcher<Any!>!)

Returns a generic ViewAssertion that asserts that a view exists in the view hierarchy and is matched by the given view matcher.

java-static ViewAssertion!
selectedDescendantsMatch(selector: Matcher<View!>!, matcher: Matcher<View!>!)

Returns a generic ViewAssertion that asserts that the descendant views selected by the selector match the specified matcher.

Public constructors

ViewAssertions

ViewAssertions()

Public functions

doesNotExist

java-static fun doesNotExist(): ViewAssertion!

Returns an assert that ensures the view matcher does not find any matching view in the hierarchy.

matches

java-static fun matches(viewMatcher: Matcher<Any!>!): ViewAssertion!

Returns a generic ViewAssertion that asserts that a view exists in the view hierarchy and is matched by the given view matcher.

selectedDescendantsMatch

java-static fun selectedDescendantsMatch(selector: Matcher<View!>!, matcher: Matcher<View!>!): ViewAssertion!

Returns a generic ViewAssertion that asserts that the descendant views selected by the selector match the specified matcher.

Example: onView(rootView).check(selectedDescendantsMatch(not(isAssignableFrom(TextView.class)), hasContentDescription()));