-
-
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
Fixes click on RecyclerView when ItemView is wrapped #48
Conversation
This test proves that click() and clickUsingPerformClick() have different behaviors when clicking the parent (wrapper) of a view.
Tests are passing even though the feature is broken. \o/
The click listener should be on the row (itemView), not in the label (textView). Otherwise clicking the row won't open the next activity.
Otherwise use espresso's click action (which simulates a tap)
@@ -21,32 +21,32 @@ | |||
@Test | |||
public void checkClickRecyclerViewItem_byPosition_atTwo() { | |||
clickRecyclerViewItem(R.id.recycler, 2); | |||
assertDisplayed("Avocado"); | |||
assertDisplayed("Avocado has been clicked"); |
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.
Thanks :·)
view.performClick(); | ||
} else { | ||
click().perform(uiController, view); | ||
} |
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.
As this is a bit of magic, we should explain why are we doing this trick. I don't have any suggestions but I feel that project newcomers will cry when they see this thing.
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.
Maybe if we extract the line click().perform(uiController, view);
to a method called propagateClickToChildren()
?
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.
Wow, YES! Great name!
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.
Done! 🎉
new ActivityTestRule<>(WrappedViewActivity.class); | ||
|
||
@Test | ||
public void click_on_button() throws Exception { |
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.
There are tons of tests written with the camel case style. If you prefer to start using other style, please, change all Barista's tests.
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.
Shit. Old habits.
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.
Done! 🎉
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.
Party! 😄
It's merge time! Feel free to bump a new version 🎉 |
This PR fixes the issue in #47.
On PR #40 we introduced a change to avoid clicking wrong things in a RecyclerView row, and allow clicking child views inside a row.
Unfortunately, that last change also broke the click when the ClickListener is set in a child view and not directly in the ItemView, as described in #47.
In this PR we:
WrappedViewClickTest
).performClick()
when the view is clickable, or else use Espresso'sclick()
action to allow propagating the click as usual.