Stay organized with collections Save and categorize content based on your preferences.

DataInteraction

class 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 types

class DataInteraction.DisplayDataMatcher

Internal matcher that is required for Espresso#onData(Matcher).

Public constructors

Public functions

DataInteraction!
atPosition(atPosition: Int!)

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

ViewInteraction!
check(assertion: ViewAssertion!)

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

DataInteraction!
inAdapterView(adapterMatcher: Matcher<View>!)

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

DataInteraction!
inRoot(rootMatcher: Matcher<Root>!)

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

DataInteraction!
onChildView(childMatcher: Matcher<View>!)

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

ViewInteraction!
perform(actions: Array<ViewAction!>!)

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

DataInteraction!

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

Public constructors

DataInteraction

DataInteraction()

Public functions

atPosition

fun atPosition(atPosition: Int!): DataInteraction!

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

check

fun check(assertion: ViewAssertion!): ViewInteraction!

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

Returns
ViewInteraction!

an ViewInteraction for more assertions or actions.

Throws
java.lang.RuntimeException: java.lang.RuntimeException

when being invoked on the main thread.

inAdapterView

fun inAdapterView(adapterMatcher: Matcher<View>!): DataInteraction!

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

inRoot

fun inRoot(rootMatcher: Matcher<Root>!): DataInteraction!

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

onChildView

fun onChildView(childMatcher: Matcher<View>!): DataInteraction!

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

perform

fun perform(actions: Array<ViewAction!>!): ViewInteraction!

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

Returns
ViewInteraction!

an ViewInteraction for more assertions or actions.

Throws
java.lang.RuntimeException: java.lang.RuntimeException

when being invoked on the main thread.

usingAdapterViewProtocol

fun usingAdapterViewProtocol(adapterViewProtocol: AdapterViewProtocol!): DataInteraction!

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