Skip to content

Instantly share code, notes, and snippets.

@prolificcoder
Last active December 30, 2016 01:10
Show Gist options
  • Save prolificcoder/d536bd098ad7c7dde40d75af96cdaf0c to your computer and use it in GitHub Desktop.
Save prolificcoder/d536bd098ad7c7dde40d75af96cdaf0c to your computer and use it in GitHub Desktop.
@Test
public void parallaxToolbarTest() {
//Go to the screen to perform the swipe action
//Verify that image is indeed collapsed
onView(withId(R.id.appbarLayout)).check(matches(withContentDescription(expandedImageContentDescription)));
//perform is sequential so click and swipeUp = drag up gesture
onView(withId(R.id.appbarLayout)).perform(click(), swipeUp());
//We can't be really sure if the swiping has finished by the time we come to this point on all devices (slow)
//so either a collaped or collapsing state passes the test
onView(withId(R.id.appbarLayout).check(matches(anyOf(
withContentDescription(R.string.cd_image_collapsed), withContentDescription(R.string.cd_image_collapsing))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment