AtomAction

public final class AtomAction<E> implements ViewAction, Bindable


A ViewAction which causes the provided Atom to be evaluated within a webview.

It is not recommended to use AtomAction directly.

Instead {@see androidx.test.espresso.web.sugar.Web} for examples of how to interact with a WebView's content through Atoms.

If you must use AtomAction directly, take care to remember that they are Stateful (unlike most ViewActions) and the caller must call get to ensure that the action has completed.

Parameters
<E>

The type the specific Atom returns.

Summary

Public constructors

AtomAction(
    Atom<E> atom,
    @Nullable WindowReference window,
    @Nullable ElementReference element
)

Creates an AtomAction.

Public methods

E
get()

Blocks until the atom has completed execution.

E
get(long val, TimeUnit unit)

Blocks until the atom has completed execution with a configurable timeout.

Matcher<View>

A mechanism for ViewActions to specify what type of views they can operate on.

String

Returns a description of the view action.

Future<E>

Return a Future, which will be set and transformed from futureEval.

IBinder
String
void
perform(UiController uiController, View view)

Performs this action on the given view.

void

Sets the IBinder of the implementing class.

Public constructors

AtomAction

public AtomAction(
    Atom<E> atom,
    @Nullable WindowReference window,
    @Nullable ElementReference element
)

Creates an AtomAction.

Parameters
Atom<E> atom

the atom to execute

@Nullable WindowReference window

(optional/nullable) the window context to execute on.

@Nullable ElementReference element

(optional/nullable) the element to execute on.

Public methods

get

public E get()

Blocks until the atom has completed execution.

Throws
java.util.concurrent.ExecutionException java.util.concurrent.ExecutionException
java.lang.InterruptedException java.lang.InterruptedException

get

public E get(long val, TimeUnit unit)

Blocks until the atom has completed execution with a configurable timeout.

Throws
java.util.concurrent.ExecutionException java.util.concurrent.ExecutionException
java.lang.InterruptedException java.lang.InterruptedException
java.util.concurrent.TimeoutException java.util.concurrent.TimeoutException

getConstraints

public Matcher<ViewgetConstraints()

A mechanism for ViewActions to specify what type of views they can operate on.

A ViewAction can demand that the view passed to perform meets certain constraints. For example it may want to ensure the view is already in the viewable physical screen of the device or is of a certain type.

Returns
Matcher<View>

a Matcher that will be tested prior to calling perform.

getDescription

public String getDescription()

Returns a description of the view action. The description should not be overly long and should fit nicely in a sentence like: "performing %description% action on view with id ..."

getFuture

public Future<E> getFuture()

Return a Future, which will be set and transformed from futureEval. Espresso's public API cannot have guava types in its method signatures, so return Future instead of ListenableFuture or SettableFuture.

getIBinder

public IBinder getIBinder()
Returns
IBinder

the IBinder of the implementing class.

getId

public String getId()
Returns
String

the id of the Bindable class.

perform

public void perform(UiController uiController, View view)

Performs this action on the given view.

Parameters
UiController uiController

the controller to use to interact with the UI.

View view

the view to act upon. never null.

setIBinder

public void setIBinder(IBinder binder)

Sets the IBinder of the implementing class.

Parameters
IBinder binder

the IBinder