# EspressoRemote

Artifact: [androidx.test.espresso:espresso-remote](https://developer.android.com/jetpack/androidx/releases/test-espresso) [View Source](https://cs.android.com/search?q=file:androidx/test/espresso/remote/EspressoRemote.java+class:androidx.test.espresso.remote.EspressoRemote)

*** ** * ** ***


```
public final class EspressoRemote implements RemoteInteraction
```

<br />

*** ** * ** ***

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

This class depends on to notify about the discovery of other remote Espresso instances and provide their `https://developer.android.com/reference/android/os/Messenger.html` object to use for further IPC.

To get the instance of this object `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#getInstance()` should be called. The user of this class should then call `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#init()` prior to attempting to use any functionality of this class. Call `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#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` | `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#isRemoteProcess()` Represents whether the current instance is running in a remote process or not |

| ### Public methods |
|---|---|
| `synchronized https://developer.android.com/reference/java/util/concurrent/Callable.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#createRemoteCheckCallable(org.hamcrest.Matcher<androidx.test.espresso.Root>,org.hamcrest.Matcher<android.view.View>,java.util.Map<java.lang.String,android.os.IBinder>,androidx.test.espresso.ViewAssertion)( https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/androidx/test/espresso/Root> rootMatcher, https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/view/View.html> viewMatcher, https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/android/os/IBinder.html> iBinders, https://developer.android.com/reference/androidx/test/espresso/ViewAssertion viewAssertion )` Creates a callable to run Espresso check interaction on remote processes |
| `synchronized https://developer.android.com/reference/java/util/concurrent/Callable.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#createRemotePerformCallable(org.hamcrest.Matcher<androidx.test.espresso.Root>,org.hamcrest.Matcher<android.view.View>,java.util.Map<java.lang.String,android.os.IBinder>,androidx.test.espresso.ViewAction...)( https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/androidx/test/espresso/Root> rootMatcher, https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/view/View.html> viewMatcher, https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/android/os/IBinder.html> iBinders, ViewAction[] viewActions )` Creates a callable to run a perform interaction on remote processes. |
| `static https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote` | `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#getInstance()()` Returns an instance of `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote` object. |
| `synchronized void` | `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#init()()` Must be called prior to using any functionality of this class. |
| `boolean` | `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#isRemoteClient()()` Returns {code true} if the current Espresso instance is communicating with another Espresso instance in a remote process. |
| `synchronized static boolean` | `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#isRemoteProcess()()` Returns `true` if the current Espresso instance running in a remote process. |
| `synchronized void` | `https://developer.android.com/reference/androidx/test/espresso/remote/EspressoRemote#terminate()()` Must be called to disable further use of this class. |

### Inherited Constants

From [androidx.test.espresso.remote.RemoteInteraction](https://developer.android.com/reference/androidx/test/espresso/remote/RemoteInteraction) `static final https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/androidx/test/espresso/remote/RemoteInteraction#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<Void> createRemoteCheckCallable(
    Matcher<Root> rootMatcher,
    Matcher<View> viewMatcher,
    Map<String, IBinder> iBinders,
    ViewAssertion viewAssertion
)
```

Creates a callable to run Espresso check interaction on remote processes

| Parameters |
|---|---|
| `https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/androidx/test/espresso/Root> rootMatcher` | the root matcher to use. |
| `https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/view/View.html> viewMatcher` | the view matcher to use. |
| `https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/android/os/IBinder.html> iBinders` | a list of binders to pass along to the remote process instance |
| `https://developer.android.com/reference/androidx/test/espresso/ViewAssertion viewAssertion` | the view assertion to use. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/Callable.html<https://developer.android.com/reference/java/lang/Void.html>` | the Callable |

### createRemotePerformCallable

```
synchronized public Callable<Void> createRemotePerformCallable(
    Matcher<Root> rootMatcher,
    Matcher<View> viewMatcher,
    Map<String, IBinder> 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 `https://developer.android.com/reference/androidx/test/espresso/remote/NoRemoteEspressoInstanceException` will be thrown.

| Parameters |
|---|---|
| `https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/androidx/test/espresso/Root> rootMatcher` | the root matcher to use. |
| `https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/view/View.html> viewMatcher` | the view matcher to use. |
| `https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/android/os/IBinder.html> iBinders` | a list of binders to pass along to the remote process instance |
| `ViewAction[] viewActions` | one or more actions to execute. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/Callable.html<https://developer.android.com/reference/java/lang/Void.html>` | a `https://developer.android.com/reference/java/util/concurrent/Callable.html` that performs the action. |

### getInstance

```
public static EspressoRemote getInstance()
```

Returns an instance of `https://developer.android.com/reference/androidx/test/espresso/remote/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.