# IdlingRegistry

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/test/espresso/IdlingRegistry "View this page in Java")

<br />

```
class IdlingRegistry
```

<br />

*** ** * ** ***

Handles registering and unregistering of[IdlingResource](https://developer.android.com/reference/kotlin/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[IdlingResource](https://developer.android.com/reference/kotlin/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 functions                                                                                                                                                         |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)`)`[Collection](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html)`<`[Looper](https://developer.android.com/reference/android/os/Looper.html)`!>!`                               | [getLoopers](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingRegistry#getLoopers())`()` Returns a set of all currently registered[Looper](https://developer.android.com/reference/android/os/Looper.html)s.                                                                                                                                                                                                                                                                   |
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)`)`[Collection](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html)`<`[IdlingResource](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingResource)`!>!` | [getResources](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingRegistry#getResources())`()` Returns a set of all currently registered[IdlingResource](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingResource)s.                                                                                                                                                                                                                                 |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                                                                                                                                                 | [register](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingRegistry#register(androidx.test.espresso.IdlingResource...))`(idlingResources: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[IdlingResource](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingResource)`!>!)` Registers one or more[IdlingResource](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingResource)s.       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                                                                                                                                                       | [registerLooperAsIdlingResource](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingRegistry#registerLooperAsIdlingResource(android.os.Looper))`(looper: `[Looper](https://developer.android.com/reference/android/os/Looper.html)`!)` Registers a[Looper](https://developer.android.com/reference/android/os/Looper.html)for idle checking with the framework.                                                                                                                  |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                                                                                                                                                 | [unregister](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingRegistry#unregister(androidx.test.espresso.IdlingResource...))`(idlingResources: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[IdlingResource](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingResource)`!>!)` Unregisters one or more[IdlingResource](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingResource)s. |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                                                                                                                                                 | [unregisterLooperAsIdlingResource](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingRegistry#unregisterLooperAsIdlingResource(android.os.Looper))`(looper: `[Looper](https://developer.android.com/reference/android/os/Looper.html)`!)` Unregisters a[Looper](https://developer.android.com/reference/android/os/Looper.html).                                                                                                                                                |

|                                               ### Public properties                                               |
|-------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| `const `[IdlingRegistry](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingRegistry)`!` | [instance](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingRegistry#instance()) |

## Public functions

### getLoopers

```
fun getLoopers(): (Mutable)Collection<Looper!>!
```

Returns a set of all currently registered[Looper](https://developer.android.com/reference/android/os/Looper.html)s.  

### getResources

```
fun getResources(): (Mutable)Collection<IdlingResource!>!
```

Returns a set of all currently registered[IdlingResource](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingResource)s.  

### register

```
fun register(idlingResources: Array<IdlingResource!>!): Boolean
```

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

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if at least one resource was successfully added to the registry |

### registerLooperAsIdlingResource

```
fun registerLooperAsIdlingResource(looper: Looper!): Unit
```

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

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

### unregister

```
fun unregister(idlingResources: Array<IdlingResource!>!): Boolean
```

Unregisters one or more[IdlingResource](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingResource)s.  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if at least one resource was successfully removed from the registry |

### unregisterLooperAsIdlingResource

```
fun unregisterLooperAsIdlingResource(looper: Looper!): Boolean
```

Unregisters a[Looper](https://developer.android.com/reference/android/os/Looper.html).

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

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|----------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if the looper was successfully removed from the registry |

## Public properties

### instance

```
const val instance: IdlingRegistry!
```