Skip to content

Instantly share code, notes, and snippets.

@catehstn
Created April 25, 2016 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catehstn/fa07f93b513de61475907f742fb40ef3 to your computer and use it in GitHub Desktop.
Save catehstn/fa07f93b513de61475907f742fb40ef3 to your computer and use it in GitHub Desktop.
@Test
public void testTapGalleryButtonAndReturnCancel() {
// Build a result to return when the activity is launched.
Intent resultData = new Intent();
Instrumentation.ActivityResult result =
new Instrumentation.ActivityResult(Activity.RESULT_CANCELED, resultData);
// Set up result stubbing when an intent sent to "choose photo" is seen.
intending(toPackage("com.android.gallery")).respondWith(result);
onView(withId(R.id.home_gallery_button)).check(matches(withText("Gallery")));
onView(withId(R.id.home_gallery_button)).perform(click());
// Check image processor is not reset.
verify(imageProcessor, never()).resetOriginalImage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment