# IdlingPolicies

# IdlingPolicies

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

*** ** * ** ***

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

<br />

```
class IdlingPolicies
```

<br />

*** ** * ** ***

Allows users fine grain control over idling policies.

Espresso's default idling policies are suitable for most usecases - however certain execution environments (like the ARM emulator) might be very slow. This class allows users the ability to adjust defaults to sensible values for their environments.

## Summary

|                                    ### Public functions                                     |
|---------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [setIdlingResourceTimeout](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingPolicies#setIdlingResourceTimeout(long,java.util.concurrent.TimeUnit))`(timeout: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, unit: `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit.html)`!)` Updates the IdlingPolicy used by IdlingResourceRegistry to determine when IdlingResources timeout. |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [setMasterPolicyTimeout](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingPolicies#setMasterPolicyTimeout(long,java.util.concurrent.TimeUnit))`(timeout: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, unit: `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit.html)`!)` Updates the IdlingPolicy used in UiController.loopUntil to detect AppNotIdleExceptions.                |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [setMasterPolicyTimeoutWhenDebuggerAttached](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingPolicies#setMasterPolicyTimeoutWhenDebuggerAttached(boolean))`(` ` timeoutWhenDebuggerAttached: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) `)` This method overrides Espresso's default behaviour of disabling timeouts when a step debugger is attached to the VM.                                        |

|                                                    ### Public properties                                                     |
|------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `volatile java-static `[IdlingPolicy](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingPolicy)`!` | [dynamicIdlingResourceErrorPolicy](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingPolicies#dynamicIdlingResourceErrorPolicy())     |
| `volatile java-static `[IdlingPolicy](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingPolicy)`!` | [dynamicIdlingResourceWarningPolicy](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingPolicies#dynamicIdlingResourceWarningPolicy()) |
| `volatile java-static `[IdlingPolicy](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingPolicy)`!` | [masterIdlingPolicy](https://developer.android.com/reference/kotlin/androidx/test/espresso/IdlingPolicies#masterIdlingPolicy())                                 |

## Public functions

### setIdlingResourceTimeout

```
java-static fun setIdlingResourceTimeout(timeout: Long, unit: TimeUnit!): Unit
```

Updates the IdlingPolicy used by IdlingResourceRegistry to determine when IdlingResources timeout.  

|                                            Parameters                                             |
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
| `timeout: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)          | the timeout before an IdlingResourceTimeoutException is created. |
| `unit: `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit.html)`!` | the unit of the timeout value.                                   |

### setMasterPolicyTimeout

```
java-static fun setMasterPolicyTimeout(timeout: Long, unit: TimeUnit!): Unit
```

Updates the IdlingPolicy used in UiController.loopUntil to detect AppNotIdleExceptions.  

|                                            Parameters                                             |
|---------------------------------------------------------------------------------------------------|-------------------------------------------------------|
| `timeout: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)          | the timeout before an AppNotIdleException is created. |
| `unit: `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit.html)`!` | the unit of the timeout value.                        |

### setMasterPolicyTimeoutWhenDebuggerAttached

```
java-static fun setMasterPolicyTimeoutWhenDebuggerAttached(
    timeoutWhenDebuggerAttached: Boolean
): Unit
```

This method overrides Espresso's default behaviour of disabling timeouts when a step debugger is attached to the VM. Setting the timeout flag reenables the behaviour of throwing a timeout exception.  

## Public properties

### dynamicIdlingResourceErrorPolicy

```
volatile java-static val dynamicIdlingResourceErrorPolicy: IdlingPolicy!
```  

### dynamicIdlingResourceWarningPolicy

```
volatile java-static val dynamicIdlingResourceWarningPolicy: IdlingPolicy!
```  

### masterIdlingPolicy

```
volatile java-static val masterIdlingPolicy: IdlingPolicy!
```