# IdlingPolicies

Summary:[Methods](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies#)  

# IdlingPolicies

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
IdlingPolicies
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object.html)`


``


`

|---|----------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | android.support.test.espresso.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 methods                                                                                                                                                                                                                                                 ||
|--------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[IdlingPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicy) | ` `[getDynamicIdlingResourceErrorPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies#getDynamicIdlingResourceErrorPolicy())`() `                                                                                                                                                                                                                            |
| ` static `[IdlingPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicy) | ` `[getDynamicIdlingResourceWarningPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies#getDynamicIdlingResourceWarningPolicy())`() `                                                                                                                                                                                                                        |
| ` static `[IdlingPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicy) | ` `[getMasterIdlingPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies#getMasterIdlingPolicy())`() `                                                                                                                                                                                                                                                        |
| ` static void`                                                                                               | ` `[setIdlingResourceTimeout](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies#setIdlingResourceTimeout(long, java.util.concurrent.TimeUnit))`(long timeout, `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit.html)` unit) ` Updates the IdlingPolicy used by IdlingResourceRegistry to determine when IdlingResources timeout. |
| ` static void`                                                                                               | ` `[setMasterPolicyTimeout](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies#setMasterPolicyTimeout(long, java.util.concurrent.TimeUnit))`(long timeout, `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit.html)` unit) ` Updates the IdlingPolicy used in UiController.loopUntil to detect AppNotIdleExceptions.                |
| ` static void`                                                                                               | ` `[setMasterPolicyTimeoutWhenDebuggerAttached](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies#setMasterPolicyTimeoutWhenDebuggerAttached(boolean))`(boolean timeoutWhenDebuggerAttached) ` This method overrides Espresso's default behaviour of disabling timeouts when a step debugger is attached to the VM.                                               |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                                | | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                             | ` finalize() `                                                                             | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||

## Public methods

### getDynamicIdlingResourceErrorPolicy

```
IdlingPolicy getDynamicIdlingResourceErrorPolicy ()
```

<br />

<br />

|                                                  Returns                                                   ||
|----------------------------------------------------------------------------------------------------|--------|
| [IdlingPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicy) | <br /> |

### getDynamicIdlingResourceWarningPolicy

```
IdlingPolicy getDynamicIdlingResourceWarningPolicy ()
```

<br />

<br />

|                                                  Returns                                                   ||
|----------------------------------------------------------------------------------------------------|--------|
| [IdlingPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicy) | <br /> |

### getMasterIdlingPolicy

```
IdlingPolicy getMasterIdlingPolicy ()
```

<br />

<br />

|                                                  Returns                                                   ||
|----------------------------------------------------------------------------------------------------|--------|
| [IdlingPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicy) | <br /> |

### setIdlingResourceTimeout

```
void setIdlingResourceTimeout (long timeout, 
                TimeUnit unit)
```

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

<br />

|                                         Parameters                                         ||
|-----------|---------------------------------------------------------------------------------|
| `timeout` | `long`: the timeout before an IdlingResourceTimeoutException is created. <br /> |
| `unit`    | `TimeUnit`: the unit of the timeout value. <br />                               |

### setMasterPolicyTimeout

```
void setMasterPolicyTimeout (long timeout, 
                TimeUnit unit)
```

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

<br />

|                                   Parameters                                    ||
|-----------|----------------------------------------------------------------------|
| `timeout` | `long`: the timeout before an AppNotIdleException is created. <br /> |
| `unit`    | `TimeUnit`: the unit of the timeout value. <br />                    |

### setMasterPolicyTimeoutWhenDebuggerAttached

```
void setMasterPolicyTimeoutWhenDebuggerAttached (boolean timeoutWhenDebuggerAttached)
```

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.

The value set in this method is superseded if[ERROR(/#unsafeMakeMasterPolicyWarning())](https://developer.android.com/)is also called.

<br />

|                   Parameters                    ||
|-------------------------------|------------------|
| `timeoutWhenDebuggerAttached` | `boolean` <br /> |

-

  ## Interfaces

  - [EspressoException](https://developer.android.com/reference/android/support/test/espresso/EspressoException)
  - [FailureHandler](https://developer.android.com/reference/android/support/test/espresso/FailureHandler)
  - [IdlingResource](https://developer.android.com/reference/android/support/test/espresso/IdlingResource)
  - [IdlingResource.ResourceCallback](https://developer.android.com/reference/android/support/test/espresso/IdlingResource.ResourceCallback)
  - [UiController](https://developer.android.com/reference/android/support/test/espresso/UiController)
  - [ViewAction](https://developer.android.com/reference/android/support/test/espresso/ViewAction)
  - [ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion)
  - [ViewFinder](https://developer.android.com/reference/android/support/test/espresso/ViewFinder)
  - [ViewInteractionComponent](https://developer.android.com/reference/android/support/test/espresso/ViewInteractionComponent)
-

  ## Classes

  - [AmbiguousViewMatcherException.Builder](https://developer.android.com/reference/android/support/test/espresso/AmbiguousViewMatcherException.Builder)
  - [DataInteraction](https://developer.android.com/reference/android/support/test/espresso/DataInteraction)
  - [DataInteraction.DisplayDataMatcher](https://developer.android.com/reference/android/support/test/espresso/DataInteraction.DisplayDataMatcher)
  - [Espresso](https://developer.android.com/reference/android/support/test/espresso/Espresso)
  - [IdlingPolicies](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies)
  - [IdlingPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicy)
  - [IdlingRegistry](https://developer.android.com/reference/android/support/test/espresso/IdlingRegistry)
  - [NoMatchingViewException.Builder](https://developer.android.com/reference/android/support/test/espresso/NoMatchingViewException.Builder)
  - [PerformException.Builder](https://developer.android.com/reference/android/support/test/espresso/PerformException.Builder)
  - [Root](https://developer.android.com/reference/android/support/test/espresso/Root)
  - [Root.Builder](https://developer.android.com/reference/android/support/test/espresso/Root.Builder)
  - [ViewInteraction](https://developer.android.com/reference/android/support/test/espresso/ViewInteraction)
-

  ## Exceptions

  - [AmbiguousViewMatcherException](https://developer.android.com/reference/android/support/test/espresso/AmbiguousViewMatcherException)
  - [AppNotIdleException](https://developer.android.com/reference/android/support/test/espresso/AppNotIdleException)
  - [IdlingResourceTimeoutException](https://developer.android.com/reference/android/support/test/espresso/IdlingResourceTimeoutException)
  - [InjectEventSecurityException](https://developer.android.com/reference/android/support/test/espresso/InjectEventSecurityException)
  - [NoActivityResumedException](https://developer.android.com/reference/android/support/test/espresso/NoActivityResumedException)
  - [NoMatchingRootException](https://developer.android.com/reference/android/support/test/espresso/NoMatchingRootException)
  - [NoMatchingViewException](https://developer.android.com/reference/android/support/test/espresso/NoMatchingViewException)
  - [PerformException](https://developer.android.com/reference/android/support/test/espresso/PerformException)