DataInteraction

public class DataInteraction
extends Object

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


与AdapterViews中显示的数据交互的接口。

该接口建立在 ViewInteraction ,应该是与AdapterViews中显示的元素进行交互的首选方式。

这是必要的,因为AdapterView可能不会将其适配器所持有的所有数据加载到视图层次结构中,直到用户交互使其成为必需。 此外,它更流畅/不易碎,以匹配数据对象被渲染到显示器中,然后渲染本身。

默认情况下,DataInteraction针对在当前屏幕中找到的任何AdapterView发生,如果显示了多个AdapterView对象,则需要使用inAdapterView方法缩小选择范围。

如果您需要在子视图上操作(例如:列表中的Button),则在调用执行或检查之前,使用onChildView方法检查和执行方法在适配器视图的顶级子级上操作。

Summary

Public methods

DataInteraction atPosition(Integer atPosition)

根据数据匹配器选择匹配适配器上第n个位置的视图。

ViewInteraction check(ViewAssertion assertion)

在我们强制加载数据后,对视图的状态执行断言。

DataInteraction inAdapterView(Matcher<View> adapterMatcher)

选择一个特定的适配器视图进行操作,默认情况下,我们在屏幕上的任何适配器视图上进行操作。

DataInteraction inRoot(Matcher<Root> rootMatcher)

使此数据交互在由给定的根匹配器指定的Root内工作。

DataInteraction onChildView(Matcher<View> childMatcher)

导致在Adapter.getView()返回的视图的特定子视图上执行和检查方法

ViewInteraction perform(ViewAction... actions)

强制加载数据后,对视图执行操作。

DataInteraction usingAdapterViewProtocol(AdapterViewProtocol adapterViewProtocol)

如果适配器实现不满足AdapterView协议(如@code ExpandableListView),请使用不同的AdapterViewProtocol

Inherited methods

From class java.lang.Object

Public methods

atPosition

DataInteraction atPosition (Integer atPosition)

根据数据匹配器选择匹配适配器上第n个位置的视图。

Parameters
atPosition Integer
Returns
DataInteraction

check

ViewInteraction check (ViewAssertion assertion)

在我们强制加载数据后,对视图的状态执行断言。

Parameters
assertion ViewAssertion
Returns
ViewInteraction an ViewInteraction for more assertions or actions.

inAdapterView

DataInteraction inAdapterView (Matcher<View> adapterMatcher)

选择一个特定的适配器视图进行操作,默认情况下,我们在屏幕上的任何适配器视图上进行操作。

Parameters
adapterMatcher Matcher
Returns
DataInteraction

inRoot

DataInteraction inRoot (Matcher<Root> rootMatcher)

使此数据交互在由给定的根匹配器指定的Root内工作。

Parameters
rootMatcher Matcher
Returns
DataInteraction

onChildView

DataInteraction onChildView (Matcher<View> childMatcher)

导致在Adapter.getView()返回的视图的特定子视图上执行和检查方法

Parameters
childMatcher Matcher
Returns
DataInteraction

perform

ViewInteraction perform (ViewAction... actions)

强制加载数据后,对视图执行操作。

Parameters
actions ViewAction
Returns
ViewInteraction an ViewInteraction for more assertions or actions.

usingAdapterViewProtocol

DataInteraction usingAdapterViewProtocol (AdapterViewProtocol adapterViewProtocol)

如果适配器实现不满足AdapterView协议(如@code ExpandableListView),请使用不同的AdapterViewProtocol

Parameters
adapterViewProtocol AdapterViewProtocol
Returns
DataInteraction