com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher Java Examples

The following examples show how to use com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LongListMatchers.java    From soas with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a matcher against the text stored in R.id.item_content. This text is roughly
 * "item: $row_number".
 */
@SuppressWarnings("rawtypes")
public static Matcher<Object> withItemContent(final Matcher<String> itemTextMatcher) {
  // use preconditions to fail fast when a test is creating an invalid matcher.
  checkNotNull(itemTextMatcher);
  return new BoundedMatcher<Object, Map>(Map.class) {
    @Override
    public boolean matchesSafely(Map map) {
      return hasEntry(equalTo("STR"), itemTextMatcher).matches(map);
    }

    @Override
    public void describeTo(Description description) {
      description.appendText("with item content: ");
      itemTextMatcher.describeTo(description);
    }
  };
}
 
Example #2
Source File: LongListMatchers.java    From soas with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a matcher against the text stored in R.id.item_size. This text is the size of the text
 * printed in R.id.item_content.
 */
@SuppressWarnings("rawtypes")
public static Matcher<Object> withItemSize(final Matcher<Integer> itemSizeMatcher) {
  // use preconditions to fail fast when a test is creating an invalid matcher.
  checkNotNull(itemSizeMatcher);
  return new BoundedMatcher<Object, Map>(Map.class) {
    @Override
    public boolean matchesSafely(Map map) {
      return hasEntry(equalTo("LEN"), itemSizeMatcher).matches(map);
    }

    @Override
    public void describeTo(Description description) {
      description.appendText("with item size: ");
      itemSizeMatcher.describeTo(description);
    }
  };
}
 
Example #3
Source File: FloatLabelMatchers.java    From AndroidFloatLabel with Apache License 2.0 5 votes vote down vote up
/**
 * @param floatLabelHint
 * @return View Matcher for the child EditText
 */
public static Matcher<View> withFloatLabelHint(final String floatLabelHint) {
    return new BoundedMatcher<View, EditText>(EditText.class) {

        @Override
        public void describeTo(Description description) {
            description.appendText("has floatlabel hint ");
            description.appendValue(floatLabelHint);

            if (null != floatLabelHint) {
                description.appendText("[");
                description.appendText(floatLabelHint);
                description.appendText("]");
            }

            if (null != floatLabelHint) {
                description.appendText(" value: ");
                description.appendText(floatLabelHint);
            }
        }

        @Override
        protected boolean matchesSafely(EditText editText) {
            if (!(editText instanceof EditText)) {
                return false;
            }

            String hint = ((EditText) editText).getHint().toString();

            return floatLabelHint.equals(hint);
        }
    };
}
 
Example #4
Source File: FloatLabelMatchers.java    From AndroidFloatLabel with Apache License 2.0 5 votes vote down vote up
/**
 * @param floatLabelHint
 * @return View Matcher for the child EditText
 */
public static Matcher<View> withFloatLabelHint(final String floatLabelHint) {
    return new BoundedMatcher<View, EditText>(EditText.class) {

        @Override
        public void describeTo(Description description) {
            description.appendText("has floatlabel hint ");
            description.appendValue(floatLabelHint);

            if (null != floatLabelHint) {
                description.appendText("[");
                description.appendText(floatLabelHint);
                description.appendText("]");
            }

            if (null != floatLabelHint) {
                description.appendText(" value: ");
                description.appendText(floatLabelHint);
            }
        }

        @Override
        protected boolean matchesSafely(EditText editText) {
            if (!(editText instanceof EditText)) {
                return false;
            }

            String hint = ((EditText) editText).getHint().toString();

            return floatLabelHint.equals(hint);
        }
    };
}
 
Example #5
Source File: EspressoTestsMatchers.java    From droidcon-android-espresso with Apache License 2.0 5 votes vote down vote up
public static Matcher<View> withChildCount(final Matcher<Integer> numberMatcher) {
    return new BoundedMatcher<View, ViewGroup>(ViewGroup.class) {
        @Override
        protected boolean matchesSafely(ViewGroup viewGroup) {
            return numberMatcher.matches(viewGroup.getChildCount());
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("number of child views ");
            numberMatcher.describeTo(description);
        }
    };
}