Is it possible to check if the background color matches a given color with espresso?
Update:
I made a custom matcher, similar to what @Irfa
In my tests I have the following matcher for testing EditText color:
public static Matcher withTextColor(final int color) {
Checks.checkNotNull(color);
return new BoundedMatcher(EditText.class) {
@Override
public boolean matchesSafely(EditText warning) {
return color == warning.getCurrentTextColor();
}
@Override
public void describeTo(Description description) {
description.appendText("with text color: ");
}
};
}
And usage is :
onView(withId(R.id.password_edittext)).check(matches(withTextColor(Color.RED)));