# IdlingResource

Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/IdlingResource.kt+class:androidx.compose.ui.test.IdlingResource) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface IdlingResource
  ```

*** ** * ** ***

Represents a resource of an application under test which can cause asynchronous background work to happen during test execution (e.g. an http request in response to a button click).

By default, all interactions from the test with the compose tree (finding nodes, performing gestures, making assertions) will be synchronized with pending work in Compose's internals (such as applying state changes, recomposing, measuring, etc). This ensures that the UI is in a stable state when the interactions are performed, so that e.g. no pending recompositions are still scheduled that could potentially change the UI. However, any asynchronous work that is not done through one of Compose's mechanisms won't be included in the default synchronization. For such work, test authors can create an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/IdlingResource` and register it into the test with androidx.compose.ui.test.junit4.ComposeTestRule
.registerIdlingResource, and the interaction will wait for that resource to become idle prior to performing it.

## Summary

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/IdlingResource#getDiagnosticMessageIfBusy()()` Returns diagnostics that explain why the idling resource is busy, or `null` if the resource is not busy. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/IdlingResource#isIdleNow()` Whether or not the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/IdlingResource` is idle when reading this value. | Cmn |

## Public functions

### getDiagnosticMessageIfBusy

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
open fun getDiagnosticMessageIfBusy(): String?
```

Returns diagnostics that explain why the idling resource is busy, or `null` if the resource is not busy. Default implementation returns `null`.

## Public properties

### isIdleNow

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val isIdleNow: Boolean
```

Whether or not the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/IdlingResource` is idle when reading this value. This should always be called from the main thread, which is why it should be lightweight and fast.

If one idling resource returns `false`, the synchronization system will keep polling all idling resources until they are all idle.