# IdlingRegistry

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

*** ** * ** ***


```
public final class IdlingRegistry
```

<br />

*** ** * ** ***

Handles registering and unregistering of `https://developer.android.com/reference/androidx/test/espresso/IdlingResource`s with Espresso from within your application code.

These resources are required by Espresso to provide synchronisation against your application code. All registered resources with this registry will be automatically synchronized against for each Espresso interaction.

This registry along with `https://developer.android.com/reference/androidx/test/espresso/IdlingResource` interface are bundled together in a small light weight module so that it can be pulled in as a dependency of the App under test with close to no overhead.

## Summary

| ### Public fields |
|---|---|
| `static final https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry` | `https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry#instance()` |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry` | `https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry#getInstance()()` Returns a singleton instance of this `https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry` that should be globally used for registering and unregistering `https://developer.android.com/reference/androidx/test/espresso/IdlingResource`s |
| `https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/android/os/Looper.html>` | `https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry#getLoopers()()` Returns a set of all currently registered `https://developer.android.com/reference/android/os/Looper.html`s. |
| `https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/androidx/test/espresso/IdlingResource>` | `https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry#getResources()()` Returns a set of all currently registered `https://developer.android.com/reference/androidx/test/espresso/IdlingResource`s. |
| `boolean` | `https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry#register(androidx.test.espresso.IdlingResource...)(IdlingResource[] idlingResources)` Registers one or more `https://developer.android.com/reference/androidx/test/espresso/IdlingResource`s. |
| `void` | `https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry#registerLooperAsIdlingResource(android.os.Looper)(https://developer.android.com/reference/android/os/Looper.html looper)` Registers a `https://developer.android.com/reference/android/os/Looper.html` for idle checking with the framework. |
| `boolean` | `https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry#unregister(androidx.test.espresso.IdlingResource...)(IdlingResource[] idlingResources)` Unregisters one or more `https://developer.android.com/reference/androidx/test/espresso/IdlingResource`s. |
| `boolean` | `https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry#unregisterLooperAsIdlingResource(android.os.Looper)(https://developer.android.com/reference/android/os/Looper.html looper)` Unregisters a `https://developer.android.com/reference/android/os/Looper.html`. |

## Public fields

### instance

```
public static final IdlingRegistry instance
```

## Public methods

### getInstance

```
public static IdlingRegistry getInstance()
```

Returns a singleton instance of this `https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry` that should be globally used for registering and unregistering `https://developer.android.com/reference/androidx/test/espresso/IdlingResource`s

### getLoopers

```
public Collection<Looper> getLoopers()
```

Returns a set of all currently registered `https://developer.android.com/reference/android/os/Looper.html`s.

### getResources

```
public Collection<IdlingResource> getResources()
```

Returns a set of all currently registered `https://developer.android.com/reference/androidx/test/espresso/IdlingResource`s.

### register

```
public boolean register(IdlingResource[] idlingResources)
```

Registers one or more `https://developer.android.com/reference/androidx/test/espresso/IdlingResource`s. When registering more than one resource, ensure that each has a unique name returned from `https://developer.android.com/reference/androidx/test/espresso/IdlingResource#getName()`

| Returns |
|---|---|
| `boolean` | `true` if at least one resource was successfully added to the registry |

### registerLooperAsIdlingResource

```
public void registerLooperAsIdlingResource(Looper looper)
```

Registers a `https://developer.android.com/reference/android/os/Looper.html` for idle checking with the framework. This is intended for use with non-UI thread `https://developer.android.com/reference/android/os/Looper.html`s only.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if looper is the main looper. |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if looper is null. |

### unregister

```
public boolean unregister(IdlingResource[] idlingResources)
```

Unregisters one or more `https://developer.android.com/reference/androidx/test/espresso/IdlingResource`s.

| Returns |
|---|---|
| `boolean` | `true` if at least one resource was successfully removed from the registry |

### unregisterLooperAsIdlingResource

```
public boolean unregisterLooperAsIdlingResource(Looper looper)
```

Unregisters a `https://developer.android.com/reference/android/os/Looper.html`.

Attempting to unregister a looper that is not registered is a no-op.

| Returns |
|---|---|
| `boolean` | `true` if the looper was successfully removed from the registry |