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));
}
};
}
java类org.hamcrest.TypeSafeMatcher的实例源码
ProfileActivityNavigationTest.java 文件源码
项目:TurboChat
阅读 25
收藏 0
点赞 0
评论 0
AutosaveTest.java 文件源码
项目:SimpleMarkdown
阅读 31
收藏 0
点赞 0
评论 0
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));
}
};
}
AccessibilityViewMatchers.java 文件源码
项目:espresso-support
阅读 29
收藏 0
点赞 0
评论 0
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static Matcher<? super View> withUsageHintOnClick(final Matcher<? extends CharSequence> charSequenceMatcher) {
return new TypeSafeMatcher<View>() {
@Override
protected boolean matchesSafely(View view) {
if (!view.isClickable()) {
return false;
}
AccessibilityNodeInfo.AccessibilityAction clickAction = findAction(view, AccessibilityNodeInfo.ACTION_CLICK);
return charSequenceMatcher.matches(clickAction.getLabel());
}
@Override
public void describeTo(Description description) {
description.appendText("is clickable and has custom usage hint for ACTION_CLICK: ");
charSequenceMatcher.describeTo(description);
}
};
}
MainActivityTest.java 文件源码
项目:privacyidea-authenticator
阅读 34
收藏 0
点赞 0
评论 0
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));
}
};
}
TasksScreenTest.java 文件源码
项目:GitHub
阅读 33
收藏 0
点赞 0
评论 0
/**
* A custom {@link Matcher} which matches an item in a {@link ListView} by its text.
* <p>
* View constraints:
* <ul>
* <li>View must be a child of a {@link ListView}
* <ul>
*
* @param itemText the text to match
* @return Matcher that matches text in the given view
*/
private Matcher<View> withItemText(final String itemText) {
checkArgument(!TextUtils.isEmpty(itemText), "itemText cannot be null or empty");
return new TypeSafeMatcher<View>() {
@Override
public boolean matchesSafely(View item) {
return allOf(
isDescendantOfA(isAssignableFrom(ListView.class)),
withText(itemText)).matches(item);
}
@Override
public void describeTo(Description description) {
description.appendText("is isDescendantOfA LV with text " + itemText);
}
};
}
EmployeeMenu_IntegTest.java 文件源码
项目:rotabuilder
阅读 26
收藏 0
点赞 0
评论 0
private static Matcher<? extends Throwable> causalChainContains(final Class<?> cls) {
return new TypeSafeMatcher<Throwable>() {
@Override
protected boolean matchesSafely(Throwable item) {
final List<Throwable> causalChain = Throwables.getCausalChain(item);
for (Throwable throwable : causalChain) {
if(cls.isAssignableFrom(throwable.getClass())){
return true;
}
}
return false;
}
@Override
public void describeTo(Description description) {
description.appendText("exception with causal chain containing " + cls.getSimpleName());
}
};
}
DefiningInitialFragmentWithState.java 文件源码
项目:frogment
阅读 29
收藏 0
点赞 0
评论 0
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));
}
};
}
MainActivityLoadDataTest.java 文件源码
项目:TurboChat
阅读 27
收藏 0
点赞 0
评论 0
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));
}
};
}
SimpleImplementationTest.java 文件源码
项目:frogment
阅读 23
收藏 0
点赞 0
评论 0
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));
}
};
}
TypeNameMatcher.java 文件源码
项目:raml-java-tools
阅读 28
收藏 0
点赞 0
评论 0
public static Matcher<TypeName> typeName(final Matcher<? super ClassName> matcher) {
final Matcher<? super ClassName> subMatcher = matcher;
return new TypeSafeMatcher<TypeName>() {
@Override
protected boolean matchesSafely(TypeName item) {
return subMatcher.matches(item);
}
@Override
public void describeTo(Description description) {
description.appendText("typename ").appendDescriptionOf(subMatcher);
}
};
}
AnnotationSpecMatchers.java 文件源码
项目:raml-java-tools
阅读 34
收藏 0
点赞 0
评论 0
public static Matcher<AnnotationSpec> hasMember(final String member) {
return new TypeSafeMatcher<AnnotationSpec>() {
@Override
protected boolean matchesSafely(AnnotationSpec item) {
return item.members.containsKey(member);
}
@Override
public void describeTo(Description description) {
description.appendText("has member " + member);
}
};
}
PlaylistActivityTest.java 文件源码
项目:GreenfieldTemplate
阅读 27
收藏 0
点赞 0
评论 0
public static Matcher<View> nthChildOf(final Matcher<View> parentMatcher, final int childPosition) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("with "+childPosition+" child view of type parentMatcher");
}
@Override
public boolean matchesSafely(View view) {
if (!(view.getParent() instanceof ViewGroup)) {
return parentMatcher.matches(view.getParent());
}
ViewGroup group = (ViewGroup) view.getParent();
return parentMatcher.matches(view.getParent()) && group.getChildAt(childPosition).equals(view);
}
};
}
PlaylistActivityTest.java 文件源码
项目:GreenfieldTemplate
阅读 32
收藏 0
点赞 0
评论 0
/**
* Matches a view that is a descendant of the nth item in a recyclerview
* @param listMatcher
* @param childPosition
* @param subviewMatcher
* @return
*/
public static Matcher<View> subfieldOfNthItemWithId(final Matcher<View> listMatcher, final int childPosition, final Matcher<View> subviewMatcher) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("Sub-view of an item from a list");
}
@Override
public boolean matchesSafely(View view) {
//
// Clearly "espresso + recyclerview != love"
//
return allOf(
isDescendantOfA(nthChildOf(listMatcher, childPosition)),
subviewMatcher
).matches(view);
}
};
}
MainActivityTest.java 文件源码
项目:civify-app
阅读 33
收藏 0
点赞 0
评论 0
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));
}
};
}
Matchers.java 文件源码
项目:java-memory-assistant
阅读 37
收藏 0
点赞 0
评论 0
public static Matcher<CharSequence> equalTo(final CharSequence expected) {
return new TypeSafeMatcher<CharSequence>() {
final Matcher<String> stringMatcher = org.hamcrest.Matchers.equalTo(expected.toString());
@Override
public void describeTo(final Description description) {
stringMatcher.describeTo(description);
}
@Override
protected boolean matchesSafely(final CharSequence actual) {
return stringMatcher.matches(actual.toString());
}
};
}
LoginActivityTest.java 文件源码
项目:civify-app
阅读 28
收藏 0
点赞 0
评论 0
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));
}
};
}
TimeZoneRoundingTests.java 文件源码
项目:elasticsearch_my
阅读 28
收藏 0
点赞 0
评论 0
private static Matcher<Long> isDate(final long expected, DateTimeZone tz) {
return new TypeSafeMatcher<Long>() {
@Override
public boolean matchesSafely(final Long item) {
return expected == item.longValue();
}
@Override
public void describeTo(Description description) {
description.appendText("Expected: " + new DateTime(expected, tz) + " [" + expected + "] ");
}
@Override
protected void describeMismatchSafely(final Long actual, final Description mismatchDescription) {
mismatchDescription.appendText(" was ").appendValue(new DateTime(actual, tz) + " [" + actual + "]");
}
};
}
MainActivityTest2.java 文件源码
项目:mongol-library
阅读 29
收藏 0
点赞 0
评论 0
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));
}
};
}
MainActivityTest.java 文件源码
项目:mongol-library
阅读 30
收藏 0
点赞 0
评论 0
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));
}
};
}
SwitchingActivityTest.java 文件源码
项目:frogment
阅读 114
收藏 0
点赞 0
评论 0
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));
}
};
}
SagaEventFormatTest.java 文件源码
项目:incubator-servicecomb-saga
阅读 26
收藏 0
点赞 0
评论 0
private static Matcher<SagaRequest> eqToRequest(SagaRequest expected) {
return new TypeSafeMatcher<SagaRequest>() {
@Override
protected boolean matchesSafely(SagaRequest request) {
return expected.id().equals(request.id())
&& request.serviceName().equals(expected.serviceName())
&& request.task().equals(expected.task())
&& request.type().equals(expected.type())
&& ((RestOperation) request.transaction()).path().equals(((RestOperation) expected.transaction()).path())
&& ((RestOperation) request.transaction()).method().equals(((RestOperation) expected.transaction()).method())
&& ((RestOperation) request.compensation()).path().equals(((RestOperation) expected.compensation()).path())
&& ((RestOperation) request.compensation()).method().equals(((RestOperation) expected.compensation()).method());
}
@Override
public void describeTo(Description description) {
description.appendText(expected.toString());
}
};
}
SagaSpringApplicationTestBase.java 文件源码
项目:incubator-servicecomb-saga
阅读 27
收藏 0
点赞 0
评论 0
private Matcher<SagaEventEntity> eventWith(
long eventId,
String type) {
return new TypeSafeMatcher<SagaEventEntity>() {
@Override
protected boolean matchesSafely(SagaEventEntity event) {
return eventId == event.id() && event.type().equals(type);
}
@Override
protected void describeMismatchSafely(SagaEventEntity item, Description mismatchDescription) {
mismatchDescription.appendText(item.toString());
}
@Override
public void describeTo(Description description) {
description.appendText(
"SagaEventEntity {"
+ "id=" + eventId
+ ", type=" + type);
}
};
}
SaganUpdaterTest.java 文件源码
项目:spring-cloud-release-tools
阅读 30
收藏 0
点赞 0
评论 0
private TypeSafeMatcher<List<ReleaseUpdate>> withReleaseUpdate(final String version,
final String refDocUrl, final String releaseStatus) {
return new TypeSafeMatcher<List<ReleaseUpdate>>() {
@Override protected boolean matchesSafely(List<ReleaseUpdate> items) {
ReleaseUpdate item = items.get(0);
return "foo".equals(item.artifactId) &&
releaseStatus.equals(item.releaseStatus) &&
version.equals(item.version) &&
refDocUrl.equals(item.apiDocUrl) &&
refDocUrl.equals(item.refDocUrl);
}
@Override public void describeTo(Description description) {
}
};
}
MatchWithIndex.java 文件源码
项目:ChimpCheck
阅读 25
收藏 0
点赞 0
评论 0
public static Matcher<View> withIndex(final Matcher<View> matcher, final int index) {
return new TypeSafeMatcher<View>() {
int currentIndex = 0;
@Override
public void describeTo(Description description) {
description.appendText("with index: ");
description.appendValue(index);
matcher.describeTo(description);
}
@Override
public boolean matchesSafely(View view) {
return matcher.matches(view) && currentIndex++ == index;
}
};
}
ViewID.java 文件源码
项目:ChimpCheck
阅读 27
收藏 0
点赞 0
评论 0
public 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));
}
};
}
BackStackTest.java 文件源码
项目:frogment
阅读 109
收藏 0
点赞 0
评论 0
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));
}
};
}
ActivityManager.java 文件源码
项目:ChimpCheck
阅读 31
收藏 0
点赞 0
评论 0
public static Matcher<View> validPosition() {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("not supports input methods");
}
@Override
public boolean matchesSafely(View view) {
// At first glance, it would make sense to use view.onCheckIsTextEditor, but the android
// javadoc is wishy-washy about whether authors are required to implement this method when
// implementing onCreateInputConnection.
return view.getX() != 0 || view.getY() != 0;
}
};
}
TextDateTimeMatcher.java 文件源码
项目:mod-circulation-storage
阅读 27
收藏 0
点赞 0
评论 0
public static Matcher<String> equivalentTo(DateTime expected) {
return new TypeSafeMatcher<String>() {
@Override
public void describeTo(Description description) {
description.appendText(String.format(
"a date time matching: %s", expected.toString()));
}
@Override
protected boolean matchesSafely(String textRepresentation) {
//response representation might vary from request representation
DateTime actual = DateTime.parse(textRepresentation);
return expected.isEqual(actual);
}
};
}
TextDateTimeMatcher.java 文件源码
项目:mod-circulation-storage
阅读 28
收藏 0
点赞 0
评论 0
public static Matcher<String> withinSecondsAfter(Seconds seconds, DateTime after) {
return new TypeSafeMatcher<String>() {
@Override
public void describeTo(Description description) {
description.appendText(String.format(
"a date time within %s seconds after %s",
seconds.getSeconds(), after.toString()));
}
@Override
protected boolean matchesSafely(String textRepresentation) {
//response representation might vary from request representation
DateTime actual = DateTime.parse(textRepresentation);
return actual.isAfter(after) &&
Seconds.secondsBetween(after, actual).isLessThan(seconds);
}
};
}
JsonObjectMatchers.java 文件源码
项目:mod-circulation-storage
阅读 28
收藏 0
点赞 0
评论 0
public static Matcher<JsonObject> identifierMatches(String namespace, String value) {
return new TypeSafeMatcher<JsonObject>() {
@Override
public void describeTo(Description description) {
description.appendText(String.format(
"an identifier with namespace: %s and value: %s", namespace, value));
}
@Override
protected boolean matchesSafely(JsonObject entry) {
return entry.getString("namespace").equals(namespace)
&& entry.getString("value").equals(value);
}
};
}