Skip to content

Most visited

Recently visited

navigation

DataInteraction

public class DataInteraction
extends Object

java.lang.Object
   ↳ android.support.test.espresso.DataInteraction


An interface to interact with data displayed in AdapterViews.

This interface builds on top of ViewInteraction and should be the preferred way to interact with elements displayed inside AdapterViews.

This is necessary because an AdapterView may not load all the data held by its Adapter into the view hierarchy until a user interaction makes it necessary. Also it is more fluent / less brittle to match upon the data object being rendered into the display then the rendering itself.

By default, a DataInteraction takes place against any AdapterView found within the current screen, if you have multiple AdapterView objects displayed, you will need to narrow the selection by using the inAdapterView method.

The check and perform method operate on the top level child of the adapter view, if you need to operate on a subview (eg: a Button within the list) use the onChildView method before calling perform or check.

Summary

Nested classes

class DataInteraction.DisplayDataMatcher

Internal matcher that is required for onData(Matcher)

Public methods

DataInteraction atPosition(Integer atPosition)

Selects the view which matches the nth position on the adapter based on the data matcher.

ViewInteraction check(ViewAssertion assertion)

Performs an assertion on the state of the view after we force the data to be loaded.

DataInteraction inAdapterView(Matcher<View> adapterMatcher)

Selects a particular adapter view to operate on, by default we operate on any adapter view on the screen.

DataInteraction inRoot(Matcher<Root> rootMatcher)

Causes this data interaction to work within the Root specified by the given root matcher.

DataInteraction onChildView(Matcher<View> childMatcher)

Causes perform and check methods to take place on a specific child view of the view returned by Adapter.getView()

ViewInteraction perform(ViewAction... actions)

Performs an action on the view after we force the data to be loaded.

DataInteraction usingAdapterViewProtocol(AdapterViewProtocol adapterViewProtocol)

Use a different AdapterViewProtocol if the Adapter implementation does not satisfy the AdapterView contract like (@code ExpandableListView)

Inherited methods

From class java.lang.Object

Public methods

atPosition

DataInteraction atPosition (Integer atPosition)

Selects the view which matches the nth position on the adapter based on the data matcher.

Parameters
atPosition Integer

Returns
DataInteraction

check

ViewInteraction check (ViewAssertion assertion)

Performs an assertion on the state of the view after we force the data to be loaded.

Parameters
assertion ViewAssertion

Returns
ViewInteraction an ViewInteraction for more assertions or actions.

inAdapterView

DataInteraction inAdapterView (Matcher<View> adapterMatcher)

Selects a particular adapter view to operate on, by default we operate on any adapter view on the screen.

Parameters
adapterMatcher Matcher

Returns
DataInteraction

inRoot

DataInteraction inRoot (Matcher<Root> rootMatcher)

Causes this data interaction to work within the Root specified by the given root matcher.

Parameters
rootMatcher Matcher

Returns
DataInteraction

onChildView

DataInteraction onChildView (Matcher<View> childMatcher)

Causes perform and check methods to take place on a specific child view of the view returned by Adapter.getView()

Parameters
childMatcher Matcher

Returns
DataInteraction

perform

ViewInteraction perform (ViewAction... actions)

Performs an action on the view after we force the data to be loaded.

Parameters
actions ViewAction

Returns
ViewInteraction an ViewInteraction for more assertions or actions.

usingAdapterViewProtocol

DataInteraction usingAdapterViewProtocol (AdapterViewProtocol adapterViewProtocol)

Use a different AdapterViewProtocol if the Adapter implementation does not satisfy the AdapterView contract like (@code ExpandableListView)

Parameters
adapterViewProtocol AdapterViewProtocol

Returns
DataInteraction

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.