-
-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
eff57be
Add an Activity with a ViewPager that contains five RecyclerViews wit…
rocboronat 3303863
Reproduce the issue #49 with tests
rocboronat f03434d
Remove all tests that are also tested on RecyclerViewTest to avoid te…
rocboronat 13887e8
Also reproduce the issue in the method that uses the ID, not the text
rocboronat 3827703
Fix the issue reproduced by the tests
rocboronat c326c1d
Reformat code with SquareAndroid style to pass the checkstyle rule
rocboronat 5b8ec82
Fix a Findbugs violation making a inner class static
rocboronat 9167eea
Avoid taking in consideration the position of the item in the nested …
rocboronat 7d0b16f
Use uppercase to showcase constants at code (thanks, Checkstyle!)
rocboronat b72664b
Create Matchers that just match with displayed items
rocboronat f27a09d
Use the new matchers on all BaristaActions that interact only with th…
rocboronat d3a98a5
Avoid inlining the annotations
rocboronat d92a84a
Merge branch 'clicking-recycleritem-inside-viewpager' into just-inste…
rocboronat 30891fb
Merge branch 'master' into just-insteract-with-visible-things
rocboronat 00a592c
Reverse the calls to Espresso matchers to exactly meet the method name
rocboronat 73b108e
Remove uneeded imports
rocboronat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
library/src/main/java/com/schibsted/spain/barista/custom/DisplayedMatchers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.schibsted.spain.barista.custom; | ||
|
||
import android.support.annotation.IdRes; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.StringRes; | ||
import android.view.View; | ||
|
||
import org.hamcrest.Matcher; | ||
|
||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.core.AllOf.allOf; | ||
|
||
public class DisplayedMatchers { | ||
|
||
@NonNull | ||
public static Matcher<View> displayedWithId(@IdRes int id) { | ||
return allOf(isDisplayed(), withId(id)); | ||
} | ||
|
||
@NonNull | ||
public static Matcher<View> displayedWithText(@StringRes int text) { | ||
return allOf(isDisplayed(), withText(text)); | ||
} | ||
|
||
@NonNull | ||
public static Matcher<View> displayedWithText(String text) { | ||
return allOf(isDisplayed(), withText(text)); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.