android.support.test.espresso.action.AdapterViewProtocol |
A sadly necessary layer of indirection to interact with AdapterViews.
Generally any subclass should respect the contracts and behaviors of its superclass. Otherwise it becomes impossible to work generically with objects that all claim to share a supertype - you need special cases to perform the same operation 'owned' by the supertype for each sub-type. The 'is - a' relationship is broken.
Android breaks the Liskov substitution principal with ExpandableListView - you can't use getAdapter(), getItemAtPosition(), and other methods common to AdapterViews on an ExpandableListView because an ExpandableListView isn't an adapterView - they just share a lot of code.
This interface exists to work around this wart (which sadly is copied in other projects too) and lets the implementor translate Espresso's needs and manipulations of the AdapterView into calls that make sense for the given subtype and context.
If you have to implement this to talk to widgets your own project defines - I'm sorry.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AdapterViewProtocol.AdaptedData | A holder that associates a data object from an AdapterView with a token the AdapterViewProtocol can use to force that data object to be rendered as a child or deeper descendant of the adapter view. | ||||||||||
AdapterViewProtocol.DataFunction |
A custom function that is applied when getData() is executed.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns all data this AdapterViewProtocol can find within the given AdapterView.
| |||||||||||
Returns the data object this particular view is rendering if possible.
| |||||||||||
Indicates whether or not there now exists a descendant view within adapterView that
is rendering this data.
| |||||||||||
Requests that a particular piece of data held in this AdapterView is actually rendered by it.
|
Returns all data this AdapterViewProtocol can find within the given AdapterView.
Any AdaptedData returned by this method can be passed to makeDataRenderedWithinView and the implementation should make the AdapterView bring that data item onto the screen.
adapterView | the AdapterView we want to interrogate the contents of. |
---|
Iterable
of AdaptedDatas representing all data the implementation sees in
this viewIllegalArgumentException | if the implementation doesn't know how to manipulate the given adapter view. |
---|
Returns the data object this particular view is rendering if possible.
Implementations are expected to create a relationship between the data in the AdapterView and the descendant views of the AdapterView that obeys the following conditions:
For example - if a PersonObject is rendered into:
LinearLayout
ImageView picture
TextView firstName
TextView lastName
It would be expected that getDataRenderedByView(adapter, LinearLayout) would return the PersonObject. If it were called instead with the TextView or ImageView it would return Object.absent().
adapterView | the adapterview hosting the data. |
---|---|
descendantView | a view which is a child, grand-child, or deeper descendant of adapterView |
IllegalArgumentException | if this protocol cannot interrogate this class of adapterView |
---|
Indicates whether or not there now exists a descendant view within adapterView that is rendering this data.
adapterView | the AdapterView hosting this data. |
---|---|
adaptedData | the data we are checking the display state for. |
Requests that a particular piece of data held in this AdapterView is actually rendered by it.
After calling this method it expected that there will exist some descendant view of adapterView for which calling getDataRenderedByView(adapterView, descView).get() == data.data is true.
Note: this need not happen immediately. EG: an implementor handling ListView may call listView.smoothScrollToPosition(data.opaqueToken) - which kicks off an animated scroll over the list to the given position. The animation may be in progress after this call returns. The only guarantee is that eventually - with no further interaction necessary - this data item will be rendered as a child or deeper descendant of this AdapterView.
adapterView | the adapterView hosting the data. |
---|---|
data | an AdaptedData instance retrieved by a prior call to getDataInAdapterView |
IllegalArgumentException | if this protocol cannot manipulate adapterView or if data is not owned by this AdapterViewProtocol. |
---|