Skip to content

Instantly share code, notes, and snippets.

@cdmunoz
Created October 13, 2018 23:19
Show Gist options
  • Save cdmunoz/3b6dd824663991911076c625a0916b35 to your computer and use it in GitHub Desktop.
Save cdmunoz/3b6dd824663991911076c625a0916b35 to your computer and use it in GitHub Desktop.
TextViewColorMatcher: Verifies that a TextView has an specific color
public static Matcher<View> textViewTextColorMatcher(final int matcherColor) {
return new BoundedMatcher<View, TextView>(TextView.class) {
@Override
public void describeTo(Description description) {
description.appendText("with text color: " + matcherColor);
}
@Override
protected boolean matchesSafely(TextView textView) {
return matcherColor == textView.getCurrentTextColor();
}
};
}
//how to use it
onView(withId(R.id.search_action_button)).check(matches(textViewTextColorMatcher(TEXT_BTN_COLOR_DISABLED)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment