use of org.hamcrest.TypeSafeMatcher 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;
}
};
}
use of org.hamcrest.TypeSafeMatcher in project flink by apache.
the class S3RecoverableFsDataOutputStreamTest method hasContent.
private static TypeSafeMatcher<TestMultipartUpload> hasContent(final Collection<byte[]> expectedContents) throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
for (byte[] c : expectedContents) {
stream.write(c);
}
byte[] expectedContent = stream.toByteArray();
return new TypeSafeMatcher<TestMultipartUpload>() {
@Override
protected boolean matchesSafely(TestMultipartUpload testMultipartUpload) {
return Arrays.equals(testMultipartUpload.getPublishedContents(), expectedContent);
}
@Override
public void describeTo(Description description) {
description.appendText("a TestMultipartUpload with contents='").appendValue(expectedContent).appendText("'");
}
};
}
use of org.hamcrest.TypeSafeMatcher in project chefly_android by chef-ly.
the class RecipeDetailTest method childAtPosition.
private static Matcher<View> childAtPosition(final Matcher<View> parentMatcher, final int position) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("Child at position " + position + " in parent ");
parentMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
return parent instanceof ViewGroup && parentMatcher.matches(parent) && view.equals(((ViewGroup) parent).getChildAt(position));
}
};
}
use of org.hamcrest.TypeSafeMatcher in project SeriesGuide by UweTrottmann.
the class ShowsActivityTest method childAtPosition.
private static Matcher<View> childAtPosition(final Matcher<View> parentMatcher, final int position) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("Child at position " + position + " in parent ");
parentMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
return parent instanceof ViewGroup && parentMatcher.matches(parent) && view.equals(((ViewGroup) parent).getChildAt(position));
}
};
}
use of org.hamcrest.TypeSafeMatcher in project Team-Plant-Power by Alexander1994.
the class HistoricalLightTest method childAtPosition.
private static Matcher<View> childAtPosition(final Matcher<View> parentMatcher, final int position) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("Child at position " + position + " in parent ");
parentMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
return parent instanceof ViewGroup && parentMatcher.matches(parent) && view.equals(((ViewGroup) parent).getChildAt(position));
}
};
}
Aggregations