-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create methods to avoid knowing the ID of the ViewPager if there's on…
…ly one ViewPager (#58) * Test that avoiding passing the R.id.pager also works when there are just one ViewPager * Implement the solution to the tests * Introduce new methods on the README.md * Add Javadoc to clarify the automation of the added methods * Add a custom matcher for diplayed views assignable from a given class * Use the new matcher method and reorder methods to meet the newspaper metaphor * Fix an infinite loop due to a bad copy paste (thanks, FindBugs!) * Improve a parameter name to offer a better API
- Loading branch information
1 parent
dc7db28
commit e379a39
Showing
6 changed files
with
83 additions
and
1 deletion.
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
22 changes: 22 additions & 0 deletions
22
library/src/main/java/com/schibsted/spain/barista/BaristaViewPagerActions.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
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
49 changes: 49 additions & 0 deletions
49
sample/src/androidTest/java/com/schibsted/spain/barista/sample/ViewPagerWithoutIdTest.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,49 @@ | ||
package com.schibsted.spain.barista.sample; | ||
|
||
import android.support.test.runner.AndroidJUnit4; | ||
import com.schibsted.spain.barista.flakyespresso.FlakyActivityTestRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.schibsted.spain.barista.BaristaAssertions.assertDisplayed; | ||
import static com.schibsted.spain.barista.BaristaViewPagerActions.swipeViewPagerBack; | ||
import static com.schibsted.spain.barista.BaristaViewPagerActions.swipeViewPagerForward; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class ViewPagerWithoutIdTest { | ||
|
||
@Rule | ||
public FlakyActivityTestRule<ViewPagerActivity> activityRule = new FlakyActivityTestRule<>(ViewPagerActivity.class) | ||
.allowFlakyAttemptsByDefault(10); | ||
|
||
@Test | ||
public void checkSwipeForward() { | ||
swipeViewPagerForward(); | ||
|
||
assertDisplayed("2"); | ||
} | ||
|
||
@Test | ||
public void checkSwipeBack() { | ||
swipeViewPagerForward(); | ||
swipeViewPagerBack(); | ||
|
||
assertDisplayed("1"); | ||
} | ||
|
||
@Test | ||
public void swipingBackInTheFirstPageDoesntCrash() { | ||
swipeViewPagerBack(); | ||
|
||
assertDisplayed("1"); | ||
} | ||
|
||
@Test | ||
public void swipingForwardInTheLastPageDoesntCrash() { | ||
swipeViewPagerForward(); | ||
swipeViewPagerForward(); | ||
|
||
assertDisplayed("2"); | ||
} | ||
} |
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