Skip to content

Most visited

Recently visited

navigation

IdlingResource

public interface IdlingResource

android.support.test.espresso.IdlingResource
Known Indirect Subclasses


Represents a resource of an application under test which can cause asynchronous background work to happen during test execution (e.g. an intent service that processes a button click). By default, Espresso synchronizes all view operations with the UI thread as well as AsyncTasks; however, it has no way of doing so with "hand-made" resources. In such cases, test authors can register the custom resource and Espresso will wait for the resource to become idle prior to executing a view operation.

Important Note: it is assumed that the resource stays idle most of the time.

Summary

Nested classes

interface IdlingResource.ResourceCallback

Registered by an IdlingResource to notify Espresso of a transition to idle. 

Public methods

abstract String getName()

Returns the name of the resources (used for logging and idempotency of registration).

abstract boolean isIdleNow()

Returns true if resource is currently idle.

abstract void registerIdleTransitionCallback(IdlingResource.ResourceCallback callback)

Registers the given IdlingResource.ResourceCallback with the resource.

Public methods

getName

String getName ()

Returns the name of the resources (used for logging and idempotency of registration).

Returns
String

isIdleNow

boolean isIdleNow ()

Returns true if resource is currently idle. Espresso will always call this method from the main thread, therefore it should be non-blocking and return immediately.

Returns
boolean

registerIdleTransitionCallback

void registerIdleTransitionCallback (IdlingResource.ResourceCallback callback)

Registers the given IdlingResource.ResourceCallback with the resource. Espresso will call this method:

  • with its implementation of IdlingResource.ResourceCallback so it can be notified asynchronously that your resource is idle
  • from the main thread, but you are free to execute the callback's onTransitionToIdle from any thread
  • once (when it is initially given a reference to your IdlingResource)

You only need to call this upon transition from busy to idle - if the resource is already idle when the method is called invoking the call back is optional and has no significant impact.

Parameters
callback IdlingResource.ResourceCallback
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.