-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Just interact with visible things #51
Conversation
…sting same behavior multiple times
…RecyclerView tests
…e visible widgets
…ract-with-visible-things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.core.AllOf.allOf; | ||
|
||
public class DisplayedMatchers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some javadocs to the class or methods might be helpful for users, to understand the magic of these matchers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wo... Actually, I think that the code is autoexplained. In addition, in this great example, the really nice method name also explains the implementation 😂
displayedWithId(int id) = allOf(withId(id), isDisplayed());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me change the order of the matchers, to make them more readable if possible :·D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-explaining code doesn't work for public APIs, IMHO ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this code is not part of the public API, isn't it? It's code that we call from Barista. I know that someone can call it cos it's public, but... that's not what Barista aims to do.
In the other hand, the method does exactly what it explains. I mean, if I know how Espresso works, if I see a matcher called displayedWithId(@ResId int id)
, it sounds that it matches with displayed views that had the given ID.
Let me skip adding the Javadoc. If it's a issue, we will add in as soon as it adds value to Barista users.
Espresso tests passed! 🎉 |
At #48, @despinola highlited an issue related with Recyclers inside ViewPagers. But #17 is related with the same issue. Actually, all BaristaActions* should only be applied to the visible item, to avoid issues with Fragments inside ViewPagers again and again.
This PR just adds the
isDisplayed()
matcher to all calls.When this PR is applied, we will avoid having lots of
MultipleMatchingExceptions
when working with items inside ViewPagers.scrollTo
needs to work on invisible widgets, too :·)BEWARE THE ALIEN! This PR depends on #50