Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Add open overflowMenu action (AdevintaSpain#332)
Browse files Browse the repository at this point in the history
* Add function to open the overflow menu without clicking any option and a test to check it works

* Add new feature description on the README
  • Loading branch information
EsteveAguilera authored and alorma committed Dec 2, 2019
1 parent 0b37abb commit aba7161
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ longClickOn("Next");
clickMenu(R.id.menu_item);
```

#### Open the overflow menu without clicking any item
```java
openMenu();
```

#### Writing into widgets
```java
writeTo(R.id.edittext, "A great text");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ object BaristaMenuClickInteractions {
}
}

@JvmStatic
fun openMenu() {
openOverflow()
}

private fun clickDisplayedView(matcher: Matcher<View>, spyFailureHandler: SpyFailureHandler) {
onView(displayedAnd(matcher)).withFailureHandler(spyFailureHandler).perform(click())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import static com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
import static com.schibsted.spain.barista.interaction.BaristaMenuClickInteractions.clickMenu;
import static com.schibsted.spain.barista.interaction.BaristaMenuClickInteractions.openMenu;

@RunWith(AndroidJUnit4.class)
public class MenuClickTest {
Expand Down Expand Up @@ -56,6 +57,13 @@ public void overflowMenuClick_byTitle() {
assertDisplayed("Third menu option");
}

@Test
public void openOverflowMenu_withoutClickingAnyOption() {
openMenu();
assertDisplayed("Menu 3");
assertDisplayed("Menu 4");
}

@Test(expected = BaristaException.class)
public void missingMenuClickFails_byId() throws Exception {
clickMenu(R.id.button);
Expand Down

0 comments on commit aba7161

Please sign in to comment.