Hi, I’m having a problem using ‘Not’ with your matcher.
Nick Cardoso
11
Hi Nick, I think you need a new matcher for that!
In EspressoTestsMatchers I would add:
public static Matcher<View> hasDrawable() {
return new DrawableMatcher(DrawableMatcher.ANY);
}And in the DrawableMatcher you can do something like this:
static final int EMPTY = -1;
static final int ANY = -2;
@Override
protected boolean matchesSafely(View target) {
...
ImageView imageView = (ImageView) target;
if (expectedId == EMPTY){
return imageView.getDrawable() == null;
}
if (expectedId == ANY){
return imageView.getDrawable() != null;
}
...
}
Actually I think I should update my post with your request! The hasDrawable() matcher can be useful :)