public static Matcher<View> withBGColor(final int color) { Checks.checkNotNull(color); return new BoundedMatcher<View, View>(View.class) { @Override public boolean matchesSafely(View view) { int currentColor = ((ColorDrawable) view.getBackground()).getColor(); return color == currentColor; } @Override public void describeTo(Description description) { description.appendText("with background color: " + color); } }; }
public static Matcher<View> withTextColor(final int color) { Checks.checkNotNull(color); return new BoundedMatcher<View, TextView>(TextView.class) { @Override public boolean matchesSafely(TextView warning) { return color == warning.getCurrentTextColor(); } @Override public void describeTo(Description description) { description.appendText("with text color: "); } }; }
public static Matcher<View> withTextColor(final int color) { Checks.checkNotNull(color); return new BoundedMatcher<View, TextView>(TextView.class) { @Override public boolean matchesSafely(TextView textView) { return color == textView.getCurrentTextColor(); } @Override public void describeTo(Description description) { description.appendText("Expected Color: " + color); } }; }