本文整理汇总了Java中org.hamcrest.Matcher.describeTo方法的典型用法代码示例。如果您正苦于以下问题:Java Matcher.describeTo方法的具体用法?Java Matcher.describeTo怎么用?Java Matcher.describeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hamcrest.Matcher
的用法示例。
在下文中一共展示了Matcher.describeTo方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: childAtPosition
import org.hamcrest.Matcher; //导入方法依赖的package包/类
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));
}
};
}
示例2: childAtPosition
import org.hamcrest.Matcher; //导入方法依赖的package包/类
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));
}
};
}
示例3: childAtPosition
import org.hamcrest.Matcher; //导入方法依赖的package包/类
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));
}
};
}
示例4: childAtPosition
import org.hamcrest.Matcher; //导入方法依赖的package包/类
private static Matcher<View> childAtPosition(
final Matcher<View> parentMatcher, @SuppressWarnings("SameParameterValue") 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));
}
};
}
示例5: withIndex
import org.hamcrest.Matcher; //导入方法依赖的package包/类
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;
}
};
}
示例6: withItemViewAtPosition
import org.hamcrest.Matcher; //导入方法依赖的package包/类
/**
* <p>
* Returns a matcher that matches an item view at the given position
* in the RecyclerView matched by {@code recyclerViewMatcher}.
* </p>
* <p>
* If the item view at the given position is not laid out,
* the matcher returned by this method will not match anything.
* Call {@link android.support.test.espresso.contrib.RecyclerViewActions#scrollToPosition(int)}
* with the same position prior to calling this method
* in order to ensure that the item view is laid out.
* </p>
* <pre><code>
* onView(withId(R.id.recyclerView).perform(RecyclerViewActions.scrollToPosition(position);
* </code></pre>
*
* @param recyclerViewMatcher a matcher for RecyclerView containing the item view.
* @param position position of the item view in RecyclerView
*/
public static Matcher<View> withItemViewAtPosition(final Matcher<View> recyclerViewMatcher, final int position) {
return new TypeSafeMatcher<View>() {
@Override
protected boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
if (!(parent instanceof RecyclerView) || !recyclerViewMatcher.matches(parent)) {
return false;
}
RecyclerView.ViewHolder viewHolder = ((RecyclerView) parent).findViewHolderForAdapterPosition(position);
return viewHolder != null && viewHolder.itemView.equals(view);
}
@Override
public void describeTo(Description description) {
description.appendText("Item view at position " + position + " in recycler view ");
recyclerViewMatcher.describeTo(description);
}
};
}
示例7: withIndex
import org.hamcrest.Matcher; //导入方法依赖的package包/类
private 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;
}
};
}
示例8: withCollapsingToolbarTitle
import org.hamcrest.Matcher; //导入方法依赖的package包/类
private static Matcher<Object> withCollapsingToolbarTitle(
final Matcher<CharSequence> textMatcher) {
return new BoundedMatcher<Object, CollapsingToolbarLayout>(CollapsingToolbarLayout.class) {
@Override
public void describeTo(Description description) {
description.appendText("with collapsing toolbar title: ");
textMatcher.describeTo(description);
}
@Override
protected boolean matchesSafely(CollapsingToolbarLayout collapsingToolbarLayout) {
return textMatcher.matches(collapsingToolbarLayout.getTitle());
}
};
}
示例9: isNthChildOf
import org.hamcrest.Matcher; //导入方法依赖的package包/类
/**
* Returns a matcher that matches a {@link View} that is a child of the described parent
* at the specified index.
*
* @param parentMatcher A matcher that describes the view's parent.
* @param childIndex The index of the view at which it is a child of the described parent.
*/
private static Matcher<View> isNthChildOf(final Matcher<View> parentMatcher, final int childIndex) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("is child at index "+childIndex+" of view matched by parentMatcher: ");
parentMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(View view) {
ViewGroup parent = (ViewGroup) view.getParent();
return parentMatcher.matches(parent) && view.equals(parent.getChildAt(childIndex));
}
};
}
示例10: withToolbarTitle
import org.hamcrest.Matcher; //导入方法依赖的package包/类
private static Matcher<Object> withToolbarTitle(final Matcher<CharSequence> textMatcher) {
return new BoundedMatcher<Object, Toolbar>(Toolbar.class) {
@Override
public boolean matchesSafely(Toolbar toolbar) {
return textMatcher.matches(toolbar.getTitle());
}
@Override
public void describeTo(Description description) {
description.appendText("with toolbar title: ");
textMatcher.describeTo(description);
}
};
}
示例11: withTextInputLayoutHint
import org.hamcrest.Matcher; //导入方法依赖的package包/类
public static Matcher<View> withTextInputLayoutHint(final Matcher<String> stringMatcher) {
return new BoundedMatcher<View, TextInputLayout>(TextInputLayout.class) {
@Override
public void describeTo(Description description) {
description.appendText("with hint: ");
stringMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(TextInputLayout textInputLayout) {
return stringMatcher.matches(textInputLayout.getHint());
}
};
}
示例12: testIsJsonLongMatcherUpdatesDescription
import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Test
public void testIsJsonLongMatcherUpdatesDescription() {
Matcher<JsonElement> matcher = aJsonLong(equalTo(23L));
Description description = new StringDescription();
matcher.describeTo(description);
String expected = "a number element with a value that is <23L>";
assertThat(description.toString(), is(expected));
}
示例13: testIsJsonMatcherUpdatesDescription
import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Test
public void testIsJsonMatcherUpdatesDescription() {
Conditions conditions = _builder.build();
Matcher<String> stringMatcher = aJsonObjectStringWith(conditions);
Description description = new StringDescription();
stringMatcher.describeTo(description);
assertThat(description.toString(), is("a JSON object where {\n}"));
}
示例14: testIsJsonBooleanMatcherUpdatesDescription
import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Test
public void testIsJsonBooleanMatcherUpdatesDescription() {
Matcher<JsonElement> matcher = aJsonBoolean(false);
Description description = new StringDescription();
matcher.describeTo(description);
String expected = "a boolean element with a value that is <false>";
assertThat(description.toString(), is(expected));
}