本文整理汇总了Java中android.support.test.espresso.matcher.BoundedMatcher类的典型用法代码示例。如果您正苦于以下问题:Java BoundedMatcher类的具体用法?Java BoundedMatcher怎么用?Java BoundedMatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BoundedMatcher类属于android.support.test.espresso.matcher包,在下文中一共展示了BoundedMatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: withPasswordText
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Returns a matcher that matches {@link TextView}s based on text property value.
*
* @param stringMatcher {@link Matcher} of {@link String} with text to match
*/
@NonNull
public static Matcher<View> withPasswordText(final Matcher<String> stringMatcher) {
return new BoundedMatcher<View, TextView>(TextView.class) {
@Override
public void describeTo(final Description description) {
description.appendText("with error text: ");
stringMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(final TextView textView) {
return stringMatcher.matches(textView.getText().toString());
}
};
}
示例2: withCollapsingToolbarTitle
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的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());
}
};
}
示例3: atPosition
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
public static Matcher<View> atPosition(final int position, final Matcher<View> itemMatcher) {
return new BoundedMatcher<View, RecyclerView>(RecyclerView.class) {
@Override
public void describeTo(Description description) {
description.appendText("has item at position " + position + ": ");
itemMatcher.describeTo(description);
}
@Override
protected boolean matchesSafely(final RecyclerView view) {
RecyclerView.ViewHolder viewHolder = view.findViewHolderForAdapterPosition(position);
if (viewHolder == null) {
return false;
}
return itemMatcher.matches(viewHolder.itemView);
}
};
}
示例4: withErrorText
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Returns a matcher that matches {@link TextView}s based on text property value.
*
* @param stringMatcher {@link Matcher} of {@link String} with text to match
*/
@NonNull
public static Matcher<View> withErrorText(final Matcher<String> stringMatcher) {
return new BoundedMatcher<View, TextView>(TextView.class) {
@Override
public void describeTo(final Description description) {
description.appendText("with error text: ");
stringMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(final TextView textView) {
return stringMatcher.matches(textView.getError().toString());
}
};
}
示例5: hasError
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Returns a matcher that matches {@link TextView}s based on text property value.
*/
@NonNull
public static Matcher<View> hasError() {
return new BoundedMatcher<View, TextView>(TextView.class) {
@Override
public void describeTo(final Description description) {
description.appendText("Has error case failed.");
}
@Override
public boolean matchesSafely(final TextView textView) {
return textView.getError() != null;
}
};
}
示例6: checkTextLength
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Returns a matcher that matches {@link TextView}s based on text property value.
*/
@NonNull
public static Matcher<View> checkTextLength(final int length) {
return new BoundedMatcher<View, TextView>(TextView.class) {
@Override
public void describeTo(final Description description) {
description.appendText("Text length is : " + description);
}
@Override
public boolean matchesSafely(final TextView textView) {
return textView.getText().length() == length;
}
};
}
示例7: hasText
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Returns a matcher that matches {@link TextView}s based on text property value.
*/
@NonNull
public static Matcher<View> hasText() {
return new BoundedMatcher<View, TextView>(TextView.class) {
@Override
public void describeTo(final Description description) {
description.appendText("Text length is : " + description);
}
@Override
public boolean matchesSafely(final TextView textView) {
return textView.getText().length() > 0;
}
};
}
示例8: atPosition
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
public static Matcher<View> atPosition(final int position, @NonNull final Matcher<View> itemMatcher) {
checkNotNull(itemMatcher);
return new BoundedMatcher<View, RecyclerView>(RecyclerView.class) {
@Override
public void describeTo(Description description) {
description.appendText("has item at position " + position + ":\n");
itemMatcher.describeTo(description);
}
@Override
protected boolean matchesSafely(final RecyclerView view) {
RecyclerView.ViewHolder viewHolder = view.findViewHolderForAdapterPosition(position);
return viewHolder != null && itemMatcher.matches(viewHolder.itemView);
}
};
}
示例9: withTag
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Matches fragment with specific tag
*
* @param tag fragment tag
* @return BaseMatcher<Fragment>
*/
public static Matcher<Fragment> withTag(final String tag) {
return new BoundedMatcher<Fragment, Fragment>(Fragment.class) {
@Override
public void describeTo(Description description) {
description.appendText("Matches fragment tag");
}
@Override
protected boolean matchesSafely(Fragment item) {
String fragTag = item.getTag();
return fragTag != null && fragTag.equals(tag);
}
};
}
示例10: atPosition
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
public static Matcher<View> atPosition(final int position, @NonNull final Matcher<View> itemMatcher) {
checkNotNull(itemMatcher);
return new BoundedMatcher<View, RecyclerView>(RecyclerView.class) {
@Override
public void describeTo(Description description) {
description.appendText("has item at position " + position + ": ");
itemMatcher.describeTo(description);
}
@Override
protected boolean matchesSafely(final RecyclerView view) {
RecyclerView.ViewHolder viewHolder = view.findViewHolderForAdapterPosition(position);
return viewHolder != null && itemMatcher.matches(viewHolder.itemView);
}
};
}
示例11: atPosition
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Matcher for finding the SwipeView for a SwipeOpenViewHolders in a RecyclerView
* @param position the position of the view holder
* @param itemMatcher matcher to compare the SwipeView to
* @return a Matcher that compares a SwipeOpenViewHolder at a position with a passed in matcher
*/
public static Matcher<View> atPosition(final int position, @NonNull final Matcher<View> itemMatcher) {
checkNotNull(itemMatcher);
return new BoundedMatcher<View, RecyclerView>(RecyclerView.class) {
@Override protected boolean matchesSafely(RecyclerView view) {
RecyclerView.ViewHolder viewHolder = view.findViewHolderForAdapterPosition(position);
if (viewHolder == null || !(viewHolder instanceof SwipeOpenViewHolder)) {
// has no item on such position
return false;
}
return itemMatcher.matches(((SwipeOpenViewHolder) viewHolder).getSwipeView());
}
@Override
public void describeTo(Description description) {
description.appendText("has item at position " + position + ": ");
itemMatcher.describeTo(description);
}
};
}
示例12: checkTranslationX
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Checks for a positive or negative translationX in a View
* @param positive true if positive translation, false if negative
* @return matcher for checking positive/negative translationX
*/
public static Matcher<View> checkTranslationX(final boolean positive) {
return new BoundedMatcher<View, View>(View.class) {
@Override public void describeTo(Description description) {
description.appendText("translationX should be non-zero");
}
@Override protected boolean matchesSafely(View item) {
if (positive) {
return ViewCompat.getTranslationX(item) > 0;
} else {
return ViewCompat.getTranslationX(item) < 0;
}
}
};
}
示例13: atPosition
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
public static Matcher<View> atPosition(final int position, @NonNull final Matcher<View> itemMatcher) {
checkNotNull(itemMatcher);
return new BoundedMatcher<View, RecyclerView>(RecyclerView.class) {
@Override
public void describeTo(Description description) {
description.appendText("has item at position " + position + ": ");
itemMatcher.describeTo(description);
}
@Override
protected boolean matchesSafely(final RecyclerView view) {
RecyclerView.ViewHolder viewHolder = view.findViewHolderForAdapterPosition(position);
if (viewHolder == null) {
// has no item on such position
return false;
}
return itemMatcher.matches(viewHolder.itemView);
}
};
}
示例14: onMenuItems
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
public static Matcher<View> onMenuItems(final Matcher<Iterable<MenuItem>> matcher) {
return new BoundedMatcher<View, NavigationView>(NavigationView.class) {
@Override
protected boolean matchesSafely(NavigationView item) {
try {
viewResources = item.getResources();
return matcher.matches(new IterableMenu(item.getMenu()));
} finally {
viewResources = null;
}
}
@Override
public void describeTo(Description description) {
description.appendText("from navigation menu items ");
description.appendDescriptionOf(matcher);
}
};
}
示例15: atPosition
import android.support.test.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
public static Matcher<View> atPosition(final int position, @NonNull final Matcher<View> itemMatcher) {
checkNotNull(itemMatcher);
return new BoundedMatcher<View, RecyclerView>(RecyclerView.class) {
@Override
public void describeTo(Description description) {
description.appendText("has item at position " + position + ": ");
itemMatcher.describeTo(description);
}
@Override
protected boolean matchesSafely(final RecyclerView view) {
RecyclerView.ViewHolder viewHolder = view.findViewHolderForAdapterPosition(position);
return viewHolder != null && itemMatcher.matches(viewHolder.itemView);
}
};
}