use of com.google.android.apps.common.testing.ui.espresso.action.AdapterViewProtocol.AdaptedData in project double-espresso by JakeWharton.
the class DataInteraction method displayingData.
private Matcher<View> displayingData(final Matcher<View> adapterMatcher, final Matcher<Object> dataMatcher, final AdapterViewProtocol adapterViewProtocol, final AdapterDataLoaderAction adapterDataLoaderAction) {
checkNotNull(adapterMatcher);
checkNotNull(dataMatcher);
checkNotNull(adapterViewProtocol);
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText(" displaying data matching: ");
dataMatcher.describeTo(description);
description.appendText(" within adapter view matching: ");
adapterMatcher.describeTo(description);
}
@SuppressWarnings("unchecked")
@Override
public boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
while (parent != null && !(parent instanceof AdapterView)) {
parent = parent.getParent();
}
if (parent != null && adapterMatcher.matches(parent)) {
Optional<AdaptedData> data = adapterViewProtocol.getDataRenderedByView((AdapterView<? extends Adapter>) parent, view);
if (data.isPresent()) {
return adapterDataLoaderAction.getAdaptedData().opaqueToken.equals(data.get().opaqueToken);
}
}
return false;
}
};
}
Aggregations