ViewBuilder

public final class ViewBuilder

Class for building view matchers and interactions

This class helps to build matches for views and get their interactions. Please note that any function invoking will add specific matcher to the list and after that all of them will be combined with help of AllOf.allOf()

See also

AllOf.allOf

()

Constructors

Link copied to clipboard

Functions

Link copied to clipboard
public final Unit containsText(String text)

Matches the view which contain given text

Link copied to clipboard

Returns view interaction delegate based on all given matchers

Link copied to clipboard
public final Matcher<View> getViewMatcher()

Returns combined view matcher with AllOf.allOf()

Link copied to clipboard
public final Unit isAssignableFrom(Class<? extends View> clazz)

Matches views based on instance or subclass of the provided class.

Link copied to clipboard
public final Unit isClickable()

Matches the view that is clickable

Link copied to clipboard
public final Unit isCompletelyDisplayed()

Matches the view that is completely displayed

Link copied to clipboard
public final Unit isDescendantOfA(Function1<ViewBuilder, Unit> function)

Matches the view which is descendant of given matcher

Link copied to clipboard
public final Unit isDisabled()

Matches the view if it is not in ENABLED state

Link copied to clipboard
public final Unit isDisplayed()

Matches the view that is displayed

Link copied to clipboard
public final Unit isEnabled()

Matches the view if it is in ENABLED state

Link copied to clipboard
public final Unit isFirst()

Matches the first view

Link copied to clipboard
public final Unit isGone()

Matches the view with GONE visibility

Link copied to clipboard
public final Unit isInstanceOf(Class<?> clazz)

Matches the view by class instance

Link copied to clipboard
public final Unit isInvisible()

Matches the view with INVISIBLE visibility

Link copied to clipboard
public final Unit isNotClickable()

Matches the view that is not clickable

Link copied to clipboard

Matches the view that is not completely displayed

Link copied to clipboard
public final Unit isNotDisplayed()

Matches the view that is not displayed

Link copied to clipboard
public final Unit isRoot()

Matches only root views

Link copied to clipboard
public final Unit isVisible()

Matches the view with VISIBLE visibility

Link copied to clipboard
public final Unit onPosition(Integer position)

Matches view at given position in ViewGroup

Link copied to clipboard
public final Unit withAnyText()

Matches the view which contains any text

Link copied to clipboard
public final Unit withBackgroundColor(@ColorRes() Integer resId)

Matches the view with given background color

public final Unit withBackgroundColor(String colorCode)

Matches the view with given background color code

Link copied to clipboard
public final Unit withClassName(Matcher<String> matcher)

Matches the view which class name matches given matcher

Link copied to clipboard
public final Unit withContentDescription(@StringRes() Integer resourceId)
public final Unit withContentDescription(String description)

Matches the view with given content description

Link copied to clipboard
public final Unit withDescendant(Function1<ViewBuilder, Unit> function)

Matches the view which has descendant of given matcher

Link copied to clipboard
public final Unit withDrawable(Drawable drawable, Function1<Drawable, Bitmap> toBitmap)
public final Unit withDrawable(@DrawableRes() Integer resId, Function1<Drawable, Bitmap> toBitmap)

Matches the view with given drawable

Link copied to clipboard
public final Unit withHint(String hint)

Matches the view which contain given hint

Link copied to clipboard
public final Unit withId(Integer id)

Matches the view with given resource id

Link copied to clipboard
public final Unit withIndex(Integer index, Function1<ViewBuilder, Unit> function)

Matches only view at given index, if there are multiple views that matches

Link copied to clipboard
public final Unit withMatcher(Matcher<View> matcher)

Matches the view with given custom matcher

Link copied to clipboard
public final Unit withoutText(String text)
public final Unit withoutText(@StringRes() Integer resId, Boolean cacheTextValue)

Matches if the view does not have a given text

Link copied to clipboard
public final Unit withParent(Function1<ViewBuilder, Unit> function)

Matches the view which has parent with given matcher

Link copied to clipboard
public final Unit withRating(Float rating)

Matches the view which is RatingBar with given value

Link copied to clipboard
public final Unit withResourceName(String name)

Matches the view with given resource name

public final Unit withResourceName(Matcher<String> matcher)

Matches the view by resource name with given matcher

Link copied to clipboard
public final Unit withSibling(Function1<ViewBuilder, Unit> function)

Matches the view which has sibling of given matcher

Link copied to clipboard
public final Unit withTag(Object tag)

Matches the view with given tag assigned

Link copied to clipboard
public final Unit withText(String text)
public final Unit withText(@StringRes() Integer textId, Boolean cacheTextValue)

Matches the view with given text

public final Unit withText(Matcher<String> matcher)

Matches the view with given text matcher