-
public interface NodeActions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumNodeActions.ComposeBaseActionType
-
Method Summary
Modifier and Type Method Description UnitperformClick()Performs a click action on the element represented by the given semantics node. UnitperformScrollTo()Scrolls the closest enclosing scroll parent by the smallest amount such that this node is fully visible in its viewport. UnitperformScrollToIndex(Integer index)Scrolls a scrollable container with items to the item with the given index. UnitperformScrollToKey(Object key)Scrolls a scrollable container with keyed items to the item with the given key, such as androidx.compose.foundation.lazy. UnitperformGesture(Function1<GestureScope, Unit> block)Executes the (partial) gesture specified in the given block. <T extends Function<Boolean>> UnitperformSemanticsAction(SemanticsPropertyKey<AccessibilityAction<T>> key, Function1<T, Unit> invocation)Provides support to call custom semantics actions on this node. UnitperformSemanticsAction(SemanticsPropertyKey<AccessibilityAction<Function0<Boolean>>> key)Provides support to call custom semantics actions on this node. abstract ComposeDelegategetDelegate()-
-
Method Detail
-
performClick
Unit performClick()
Performs a click action on the element represented by the given semantics node.
-
performScrollTo
Unit performScrollTo()
Scrolls the closest enclosing scroll parent by the smallest amount such that this node is fully visible in its viewport. If this node is larger than the viewport, scrolls the scroll parent by the smallest amount such that this node fills the entire viewport. A scroll parent is a parent node that has the semantics action SemanticsActions.ScrollBy (usually implemented by defining scrollBy).
This action should be performed on the node that is part of the scrollable content, not on the scrollable container.
Throws an AssertionError if there is no scroll parent.
-
performScrollToIndex
Unit performScrollToIndex(Integer index)
Scrolls a scrollable container with items to the item with the given index.
Note that not all scrollable containers have item indices. For example, a androidx.compose.foundation.gestures.scrollable doesn't have items with an index, while androidx.compose.foundation.lazy.LazyColumn does.
This action should be performed on a node that is a scrollable container, not on a node that is part of the content of that container.
Throws an AssertionError if the node doesn't have ScrollToIndex defined.
- Parameters:
index- The index of the item to scroll to
-
performScrollToKey
Unit performScrollToKey(Object key)
Scrolls a scrollable container with keyed items to the item with the given key, such as androidx.compose.foundation.lazy.LazyColumn or androidx.compose.foundation.lazy.LazyRow.
This action should be performed on a node that is a scrollable container, not on a node that is part of the content of that container.
Throws an AssertionError if the node doesn't have IndexForKey or ScrollToIndex defined.
- Parameters:
key- The key of the item to scroll to
-
performGesture
Unit performGesture(Function1<GestureScope, Unit> block)
Executes the (partial) gesture specified in the given block. The gesture doesn't need to be complete and can be resumed in a later invocation of performGesture. It is the responsibility of the caller to make sure partial gestures don't leave the test in an inconsistent state.
All events that are injected from the block are batched together and sent after block is complete. This method blocks until all those events have been injected, which normally takes as long as the duration of the gesture. If an error occurs during execution of block or injection of the events, all (subsequent) events are dropped and the error is thrown here.
This method must not be called from the main thread. The block will be executed on the same thread as the caller.
Example usage:
onNodeWithTag("myWidget") .performGesture { swipeUp() } onNodeWithTag("myWidget") .performGesture { click(center) } onNodeWithTag("myWidget") .performGesture { down(topLeft) } .assertHasClickAction() .performGesture { up(topLeft) }
-
performSemanticsAction
<T extends Function<Boolean>> Unit performSemanticsAction(SemanticsPropertyKey<AccessibilityAction<T>> key, Function1<T, Unit> invocation)
Provides support to call custom semantics actions on this node.
This method is supposed to be used for actions with parameters.
This will properly verify that the actions exists and provide clear error message in case it does not. It also handle synchronization and performing the action on the UI thread. This call is blocking until the action is performed
- Parameters:
key- Key of the action to be performed.invocation- Place where you call your action.
-
performSemanticsAction
Unit performSemanticsAction(SemanticsPropertyKey<AccessibilityAction<Function0<Boolean>>> key)
Provides support to call custom semantics actions on this node.
This method is for calling actions that have no parameters.
This will properly verify that the actions exists and provide clear error message in case it does not. It also handle synchronization and performing the action on the UI thread. This call is blocking until the action is performed
- Parameters:
key- Key of the action to be performed.
-
getDelegate
abstract ComposeDelegate getDelegate()
-
-
-
-