public final class EspressoRemote implements RemoteInteraction


A singleton class that facilitates communication between other Espresso instance that may be running in different processes.

This class depends on InstrumentationConnection to notify about the discovery of other remote Espresso instances and provide their Messenger object to use for further IPC.

To get the instance of this object getInstance should be called. The user of this class should then call init prior to attempting to use any functionality of this class. Call terminate after using EspressoRemote to release any resources. Failure to do so will lead to memory leaks and unexpected behavior.

Summary

Public fields

volatile static boolean

Represents whether the current instance is running in a remote process or not

Public methods

synchronized Callable<Void>
createRemoteCheckCallable(
    Matcher<Root> rootMatcher,
    Matcher<View> viewMatcher,
    Map<StringIBinder> iBinders,
    ViewAssertion viewAssertion
)

Creates a callable to run Espresso check interaction on remote processes

synchronized Callable<Void>
createRemotePerformCallable(
    Matcher<Root> rootMatcher,
    Matcher<View> viewMatcher,
    Map<StringIBinder> iBinders,
    ViewAction[] viewActions
)

Creates a callable to run a perform interaction on remote processes.

static EspressoRemote

Returns an instance of EspressoRemote object.

synchronized void

Must be called prior to using any functionality of this class.

boolean

Returns {code true} if the current Espresso instance is communicating with another Espresso instance in a remote process.

synchronized static boolean

Returns true if the current Espresso instance running in a remote process.

synchronized void

Must be called to disable further use of this class.

Inherited Constants

From androidx.test.espresso.remote.RemoteInteraction
static final String
BUNDLE_EXECUTION_STATUS = "executionStatus"

Public fields

isRemoteProcess

volatile public static boolean isRemoteProcess

Represents whether the current instance is running in a remote process or not

Public methods

createRemoteCheckCallable

synchronized public Callable<VoidcreateRemoteCheckCallable(
    Matcher<Root> rootMatcher,
    Matcher<View> viewMatcher,
    Map<StringIBinder> iBinders,
    ViewAssertion viewAssertion
)

Creates a callable to run Espresso check interaction on remote processes

Parameters
Matcher<Root> rootMatcher

the root matcher to use.

Matcher<View> viewMatcher

the view matcher to use.

Map<StringIBinder> iBinders

a list of binders to pass along to the remote process instance

ViewAssertion viewAssertion

the view assertion to use.

Returns
Callable<Void>

the Callable

createRemotePerformCallable

synchronized public Callable<VoidcreateRemotePerformCallable(
    Matcher<Root> rootMatcher,
    Matcher<View> viewMatcher,
    Map<StringIBinder> iBinders,
    ViewAction[] viewActions
)

Creates a callable to run a perform interaction on remote processes.

If there no remote Espresso currently running in a timely manner the interaction will not be executed and a NoRemoteEspressoInstanceException will be thrown.

Parameters
Matcher<Root> rootMatcher

the root matcher to use.

Matcher<View> viewMatcher

the view matcher to use.

Map<StringIBinder> iBinders

a list of binders to pass along to the remote process instance

ViewAction[] viewActions

one or more actions to execute.

Returns
Callable<Void>

a Callable that performs the action.

getInstance

public static EspressoRemote getInstance()

Returns an instance of EspressoRemote object.

init

synchronized public void init()

Must be called prior to using any functionality of this class.

During initialization the instance of this class will be registered with .

isRemoteClient

public boolean isRemoteClient()

Returns {code true} if the current Espresso instance is communicating with another Espresso instance in a remote process.

isRemoteProcess

synchronized public static boolean isRemoteProcess()

Returns true if the current Espresso instance running in a remote process.

terminate

synchronized public void terminate()

Must be called to disable further use of this class.

During termination the instance of this class will be un-registered with and clear the list of known remote Espresso Messengers.