public final class ViewTreeAssert
extends <any>
NOTE: Assertions looking for visible attributes are limited to checking the visibility of the nodes, but do not check actual layout. So a visible view might have 0 pixels available for it in actual app code and still pass the checks done here
Modifier and Type | Method and Description |
---|---|
static ViewTreeAssert |
assertThat(ViewTree actual) |
<V extends View> |
doesNotHaveVisible(Class<V> clazz,
<any> predicate) |
ViewTreeAssert |
doesNotHaveVisibleDrawable(Drawable drawable)
Tests all views in the hierarchy under the root, for which the path is visible, are not
displaying the requested drawable
|
ViewTreeAssert |
doesNotHaveVisibleDrawable(int resourceId)
Tests all views in the hierarchy under the root, for which the path is visible, do not have the
requested drawable by the given resource id.
|
ViewTreeAssert |
doesNotHaveVisibleText()
Tests that all views in the hierarchy under the root, for which the path is visible, do not
have any text appearing on them
|
ViewTreeAssert |
doesNotHaveVisibleText(int resourceId)
Tests that all views in the hierarchy under the root, for which the path is visible, do not
have text equal to the string matching the given resource id
|
ViewTreeAssert |
doesNotHaveVisibleText(String text)
Tests that all views in the hierarchy under the root, for which the path is visible, do not
have text equal to the given string
|
ViewTreeAssert |
doesNotHaveVisibleTextMatching(String pattern)
Tests that all views in the hierarchy under the root, for which the path is visible, do not
have text that matches against the given regular expression
|
ViewTreeAssert |
doesNotHaveVisibleViewWithId(int viewId)
Whether there is not a visible view in the hierarchy with the given id.
|
ViewTreeAssert |
hasContentDescription(int resourceId)
Tests if any view hierarchy under the root has the given contentDescription.
|
ViewTreeAssert |
hasContentDescription(String contentDescription)
Tests if any view hierarchy under the root has the given contentDescription.
|
ViewTreeAssert |
hasViewTag(int tagId,
Object tagValue)
Tests if any view hierarchy under the root has the given view tag and value.
|
<V extends View> |
hasVisible(Class<V> clazz,
<any> predicate) |
ViewTreeAssert |
hasVisibleDrawable(Drawable drawable)
Tests if any view in the hierarchy under the root, for which the path is visible, is displaying
the requested drawable
|
ViewTreeAssert |
hasVisibleDrawable(int resourceId)
Tests if any view in the hierarchy under the root, for which the path is visible, is displaying
the requested drawable by the given resource id.
|
ViewTreeAssert |
hasVisibleText(int resourceId)
Tests if any view has visible text identified by the resource id
|
ViewTreeAssert |
hasVisibleText(String text)
Tests if any view in the hierarchy under the root, for which the path is visible, has the
requested piece of text as its text
|
ViewTreeAssert |
hasVisibleTextMatching(String pattern)
Tests if any view in the hierarchy under the root, for which the path is visible, has text that
matches the given regular expression
|
ViewTreeAssert |
hasVisibleTextWithTag(String text,
int tagId,
Object tagValue)
Tests if any view in the hierarchy under the root, for which the path is visible, has the
requested piece of text as its text and has a tag set on that TextView with the given tag id
and tag value.
|
ViewTreeAssert |
hasVisibleViewWithId(int viewId)
Whether there is a visible view in the hierarchy with the given id.
|
public static ViewTreeAssert assertThat(ViewTree actual)
public ViewTreeAssert hasVisibleText(String text)
text
- the text to search forpublic ViewTreeAssert hasVisibleTextWithTag(String text, int tagId, Object tagValue)
text
- the text to search fortagId
- the tag to look for on the TextView containing the searched texttagValue
- the expected value of the tag associated with tagIdpublic ViewTreeAssert hasVisibleText(int resourceId)
resourceId
- resource id of the textpublic ViewTreeAssert doesNotHaveVisibleText(String text)
text
- the text to search forpublic ViewTreeAssert hasViewTag(int tagId, Object tagValue)
tagId
- the id to look fortagValue
- the value that the id should havepublic ViewTreeAssert hasContentDescription(String contentDescription)
contentDescription
- the contentDescription to search forpublic ViewTreeAssert doesNotHaveVisibleText(int resourceId)
resourceId
- resource id of the textpublic ViewTreeAssert hasContentDescription(int resourceId)
resourceId
- the resId of the contentDescription to search forpublic ViewTreeAssert hasVisibleTextMatching(String pattern)
pattern
- the regular expression to match againstpublic ViewTreeAssert doesNotHaveVisibleTextMatching(String pattern)
pattern
- the regular expression to match againstpublic ViewTreeAssert doesNotHaveVisibleText()
public ViewTreeAssert hasVisibleDrawable(int resourceId)
For this assertion to work, Robolectric must be immediately available and be able to load the drawable corresponding to this resource id.
resourceId
- the resource id of the drawable to look forpublic ViewTreeAssert hasVisibleDrawable(Drawable drawable)
drawable
- the drawable to look forpublic ViewTreeAssert doesNotHaveVisibleDrawable(int resourceId)
resourceId
- the resource id of the drawable to look forpublic ViewTreeAssert doesNotHaveVisibleDrawable(Drawable drawable)
drawable
- the drawable to look forpublic ViewTreeAssert hasVisibleViewWithId(int viewId)
public ViewTreeAssert doesNotHaveVisibleViewWithId(int viewId)
public <V extends View> ViewTreeAssert hasVisible(Class<V> clazz, <any> predicate)
public <V extends View> ViewTreeAssert doesNotHaveVisible(Class<V> clazz, <any> predicate)