Java Code Examples for android.support.test.espresso.core.deps.guava.base.Predicate

The following are top voted examples for showing how to use android.support.test.espresso.core.deps.guava.base.Predicate. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: AndroidSnooper   File: SnooperRepoTest.java   View source code 5 votes vote down vote up
private Matcher<? super List<HttpHeaderValue>> containsWithValue(final String value) {
  return new CustomTypeSafeMatcher<List<HttpHeaderValue>>("contains with value:" + value) {
    @Override
    protected boolean matchesSafely(List<HttpHeaderValue> list) {
      return any(list, new Predicate<HttpHeaderValue>() {
        @Override
        public boolean apply(@Nullable HttpHeaderValue httpHeaderValue) {
          return httpHeaderValue.getValue().equals(value);
        }
      });
    }
  };
}
 
Example 2
Project: americano   File: RelativeMatcher.java   View source code 5 votes vote down vote up
private RelativeMatcher(Matcher<View> target, DoublePredicate<View> predicate, String description, Type type) {
    mTarget = target;
    mTargetPredicate = new Predicate<View>() {
        @Override
        public boolean apply(@Nullable View view) {
            return mTarget.matches(view);
        }
    };
    mPredicate = predicate;
    mDescription = description;
    mType = type;
}
 
Example 3
Project: americano   File: RelativeMatcher.java   View source code 5 votes vote down vote up
@Override
public boolean matchesSafely(final View testView) {
    if (!mTargetPredicate.apply(testView))
        return false;

    Predicate<View> pred = new Predicate<View>() {
        @Override
        public boolean apply(@Nullable View targetView) {
            return mPredicate.apply(testView, targetView);
        }
    };
    Iterable<View> traversal = Iterables.filter(breadthFirstViewTraversal(testView.getRootView()), new Predicate<View>() {
        @Override
        public boolean apply(@Nullable View input) {
            return input != testView && mTargetPredicate.apply(input);
        }
    });
    if (Iterables.isEmpty(traversal)) {
        throw new NoMatchingViewException.Builder().withViewMatcher(mTarget).build(); // TODO: build an actual err msg
    }
    switch (mType) {
        case ANY:   return Iterables.any(traversal, pred);
        case ALL:   return Iterables.all(traversal, pred);
        case NONE:  return !Iterables.any(traversal, pred);
        default:    throw new IllegalStateException("impossible mType");
    }
}