androidx.glance.testing.unit
Classes
GlanceMappedNode |
An implementation of |
MappedNode |
Hold a Glance composable node in a form that enables performing assertion on it. |
Top-level functions summary
GlanceNodeMatcher<MappedNode> |
hasAnyDescendant(matcher: GlanceNodeMatcher<MappedNode>)Returns a matcher that matches if a given node has a descendant node somewhere in its sub-hierarchy that the matches the provided matcher. |
GlanceNodeMatcher<MappedNode> |
Returns a matcher that matches if the given node has clickable modifier set. |
GlanceNodeMatcher<MappedNode> |
hasContentDescription(value: String, ignoreCase: Boolean)Returns whether the content description set directly on the node contains the provided |
GlanceNodeMatcher<MappedNode> |
hasContentDescriptionEqualTo(value: String, ignoreCase: Boolean)Returns whether the content description set directly on the node is equal to the provided |
GlanceNodeMatcher<MappedNode> |
Returns a matcher that matches if the given node doesn't have a clickable modifier or |
GlanceNodeMatcher<MappedNode> |
hasStartActivityClickAction(Returns a matcher that matches if a given node has a clickable set with action that starts an activity. |
inline GlanceNodeMatcher<MappedNode> |
<T : Activity> hasStartActivityClickAction(Returns a matcher that matches if a given node has a clickable set with action that starts an activity. |
GlanceNodeMatcher<MappedNode> |
hasTestTag(testTag: String)Returns a matcher that matches if a node is annotated by the given test tag. |
GlanceNodeMatcher<MappedNode> |
Returns a matcher that matches if text on node contains the provided text as its substring. |
GlanceNodeMatcher<MappedNode> |
hasTextEqualTo(text: String, ignoreCase: Boolean)Returns a matcher that matches if node is a text node and its text is equal to the provided text. |
Extension functions summary
Top-level functions
hasAnyDescendant
fun hasAnyDescendant(matcher: GlanceNodeMatcher<MappedNode>): GlanceNodeMatcher<MappedNode>
Returns a matcher that matches if a given node has a descendant node somewhere in its sub-hierarchy that the matches the provided matcher.
This can be passed in GlanceNodeAssertionsProvider.onNode and GlanceNodeAssertionsProvider.onAllNodes functions on assertion providers to filter out matching node(s) or in assertions to validate that node(s) satisfy the condition.
| Parameters | |
|---|---|
matcher: GlanceNodeMatcher<MappedNode> |
a matcher that needs to be satisfied for the descendant node to be matched |
hasClickAction
fun hasClickAction(): GlanceNodeMatcher<MappedNode>
Returns a matcher that matches if the given node has clickable modifier set.
This can be passed in GlanceNodeAssertionsProvider.onNode and GlanceNodeAssertionsProvider.onAllNodes functions on assertion providers to filter out matching node(s) or in assertions to validate that node(s) satisfy the condition.
hasContentDescription
fun hasContentDescription(value: String, ignoreCase: Boolean = false): GlanceNodeMatcher<MappedNode>
Returns whether the content description set directly on the node contains the provided value.
This can be passed in GlanceNodeAssertionsProvider.onNode and GlanceNodeAssertionsProvider.onAllNodes functions on assertion providers to filter out matching node(s) or in assertions to validate that node(s) satisfy the condition.
| Parameters | |
|---|---|
value: String |
value that should be substring of the content description set directly on the node. |
ignoreCase: Boolean = false |
whether case should be ignored. Default is case sensitive. |
| See also | |
|---|---|
ContentDescription |
hasContentDescriptionEqualTo
fun hasContentDescriptionEqualTo(value: String, ignoreCase: Boolean = false): GlanceNodeMatcher<MappedNode>
Returns whether the content description set directly on the node is equal to the provided value.
This can be passed in GlanceNodeAssertionsProvider.onNode and GlanceNodeAssertionsProvider.onAllNodes functions on assertion providers to filter out matching node(s) or in assertions to validate that node(s) satisfy the condition.
| Parameters | |
|---|---|
value: String |
value that should match exactly with content description set directly on the node. |
ignoreCase: Boolean = false |
whether case should be ignored. Default is case sensitive. |
| See also | |
|---|---|
ContentDescription |
hasNoClickAction
fun hasNoClickAction(): GlanceNodeMatcher<MappedNode>
Returns a matcher that matches if the given node doesn't have a clickable modifier or onClick set.
This can be passed in GlanceNodeAssertionsProvider.onNode and GlanceNodeAssertionsProvider.onAllNodes functions on assertion providers to filter out matching node(s) or in assertions to validate that node(s) satisfy the condition.
hasStartActivityClickAction
fun hasStartActivityClickAction(
componentName: ComponentName,
parameters: ActionParameters = actionParametersOf()
): GlanceNodeMatcher<MappedNode>
Returns a matcher that matches if a given node has a clickable set with action that starts an activity.
This can be passed in GlanceNodeAssertionsProvider.onNode and GlanceNodeAssertionsProvider.onAllNodes functions on assertion providers to filter out matching node(s) or in assertions to validate that node(s) satisfy the condition.
| Parameters | |
|---|---|
componentName: ComponentName |
component of the activity that is expected to have been passed in the |
parameters: ActionParameters = actionParametersOf() |
the parameters associated with the action that are expected to have been passed in the |
hasStartActivityClickAction
inline fun <T : Activity> hasStartActivityClickAction(
parameters: ActionParameters = actionParametersOf(),
activityOptions: Bundle? = null
): GlanceNodeMatcher<MappedNode>
Returns a matcher that matches if a given node has a clickable set with action that starts an activity.
This can be passed in GlanceNodeAssertionsProvider.onNode and GlanceNodeAssertionsProvider.onAllNodes functions on assertion providers to filter out matching node(s) or in assertions to validate that node(s) satisfy the condition.
| Parameters | |
|---|---|
<T : Activity> |
class of the activity that is expected to have been passed in the |
parameters: ActionParameters = actionParametersOf() |
the parameters associated with the action that are expected to have been passed in the |
activityOptions: Bundle? = null |
Additional options built from an |
hasTestTag
fun hasTestTag(testTag: String): GlanceNodeMatcher<MappedNode>
Returns a matcher that matches if a node is annotated by the given test tag.
This can be passed in GlanceNodeAssertionsProvider.onNode and GlanceNodeAssertionsProvider.onAllNodes functions on assertion providers to filter out matching node(s) or in assertions to validate that node(s) satisfy the condition.
| Parameters | |
|---|---|
testTag: String |
value to match against the free form string specified in the |
hasText
fun hasText(text: String, ignoreCase: Boolean = false): GlanceNodeMatcher<MappedNode>
Returns a matcher that matches if text on node contains the provided text as its substring.
This can be passed in GlanceNodeAssertionsProvider.onNode and GlanceNodeAssertionsProvider.onAllNodes functions on assertion providers to filter out matching node(s) or in assertions to validate that node(s) satisfy the condition.
hasTextEqualTo
fun hasTextEqualTo(text: String, ignoreCase: Boolean = false): GlanceNodeMatcher<MappedNode>
Returns a matcher that matches if node is a text node and its text is equal to the provided text.
This can be passed in GlanceNodeAssertionsProvider.onNode and GlanceNodeAssertionsProvider.onAllNodes functions on assertion providers to filter out matching node(s) or in assertions to validate that node(s) satisfy the condition.
Extension functions
GlanceNodeAssertion.assertHasClickAction
fun GlanceNodeAssertion<MappedNode, GlanceMappedNode>.assertHasClickAction(
): GlanceNodeAssertion<MappedNode, GlanceMappedNode>
Asserts that a given node has a clickable modifier or onClick set.
| Throws | |
|---|---|
AssertionError |
if the matcher does not match or the node can no longer be found. |
GlanceNodeAssertion.assertHasContentDescription
fun GlanceNodeAssertion<MappedNode, GlanceMappedNode>.assertHasContentDescription(
value: String,
ignoreCase: Boolean = false
): GlanceNodeAssertion<MappedNode, GlanceMappedNode>
Asserts that the content description set on the node contains the provided value as substring.
| Parameters | |
|---|---|
value: String |
value that should be matched as a substring of the node's content description. |
ignoreCase: Boolean = false |
whether case should be ignored. Defaults to case sensitive. |
| Throws | |
|---|---|
AssertionError |
if the matcher does not match or the node can no longer be found. |
| See also | |
|---|---|
ContentDescription |
GlanceNodeAssertion.assertHasContentDescriptionEqualTo
fun GlanceNodeAssertion<MappedNode, GlanceMappedNode>.assertHasContentDescriptionEqualTo(
value: String,
ignoreCase: Boolean = false
): GlanceNodeAssertion<MappedNode, GlanceMappedNode>
Asserts that the content description set on the node is equal to the provided value
| Parameters | |
|---|---|
value: String |
value that should be matched to be equal to the node's content description. |
ignoreCase: Boolean = false |
whether case should be ignored. Defaults to case sensitive. |
| Throws | |
|---|---|
AssertionError |
if the matcher does not match or the node can no longer be found. |
| See also | |
|---|---|
ContentDescription |
GlanceNodeAssertion.assertHasNoClickAction
fun GlanceNodeAssertion<MappedNode, GlanceMappedNode>.assertHasNoClickAction(
): GlanceNodeAssertion<MappedNode, GlanceMappedNode>
Asserts that a given node doesn't have a clickable modifier or onClick set.
| Throws | |
|---|---|
AssertionError |
if the matcher does not match or the node can no longer be found. |
GlanceNodeAssertion.assertHasStartActivityClickAction
fun GlanceNodeAssertion<MappedNode, GlanceMappedNode>.assertHasStartActivityClickAction(
componentName: ComponentName,
parameters: ActionParameters = actionParametersOf()
): GlanceNodeAssertion<MappedNode, GlanceMappedNode>
Asserts that a given node has a clickable set with action that starts an activity.
| Parameters | |
|---|---|
componentName: ComponentName |
component of the activity that is expected to have been passed in the |
parameters: ActionParameters = actionParametersOf() |
the parameters associated with the action that are expected to have been passed in the |
| Throws | |
|---|---|
AssertionError |
if the matcher does not match or the node can no longer be found. |
GlanceNodeAssertion.assertHasStartActivityClickAction
inline fun <T : Activity> GlanceNodeAssertion<MappedNode, GlanceMappedNode>.assertHasStartActivityClickAction(
parameters: ActionParameters = actionParametersOf(),
activityOptions: Bundle? = null
): GlanceNodeAssertion<MappedNode, GlanceMappedNode>
Asserts that a given node has a clickable set with action that starts an activity.
| Parameters | |
|---|---|
<T : Activity> |
class of the activity that is expected to have been passed in the |
parameters: ActionParameters = actionParametersOf() |
the parameters associated with the action that are expected to have been passed in the |
activityOptions: Bundle? = null |
Additional options built from an |
| Throws | |
|---|---|
AssertionError |
if the matcher does not match or the node can no longer be found. |
GlanceNodeAssertion.assertHasTestTag
fun GlanceNodeAssertion<MappedNode, GlanceMappedNode>.assertHasTestTag(
testTag: String
): GlanceNodeAssertion<MappedNode, GlanceMappedNode>
Asserts that a given node is annotated by the given test tag.
| Parameters | |
|---|---|
testTag: String |
value to match against the free form string specified in the |
| Throws | |
|---|---|
AssertionError |
if the matcher does not match or the node can no longer be found. |
GlanceNodeAssertion.assertHasText
fun GlanceNodeAssertion<MappedNode, GlanceMappedNode>.assertHasText(
text: String,
ignoreCase: Boolean = false
): GlanceNodeAssertion<MappedNode, GlanceMappedNode>
Asserts that text on the given node is a text node and its text contains the provided text as substring.
GlanceNodeAssertion.assertHasTextEqualTo
fun GlanceNodeAssertion<MappedNode, GlanceMappedNode>.assertHasTextEqualTo(
text: String,
ignoreCase: Boolean = false
): GlanceNodeAssertion<MappedNode, GlanceMappedNode>
Asserts that text on the given node is text node and its text is equal to the provided text.