Skip to content

Instantly share code, notes, and snippets.

@rsicarelli
Created November 7, 2016 13:28
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 rsicarelli/ac8b512c457a90bd886a562a288b877c to your computer and use it in GitHub Desktop.
Save rsicarelli/ac8b512c457a90bd886a562a288b877c to your computer and use it in GitHub Desktop.
@Test
public void shouldShareImageFromGallery() {
Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, data);
intending(hasAction(Intent.ACTION_CHOOSER)).respondWith(result);
onView(withId(R.id.share)).perform(click());
intended(allOf(
hasExtras(allOf(
hasEntry(equalTo(Intent.EXTRA_INTENT), hasAction(Intent.ACTION_SEND)),
hasEntry(equalTo(Intent.EXTRA_INTENT), hasType("image/*")),
hasEntry(equalTo(Intent.EXTRA_TITLE), containsString("Share image")
),
hasAction(equalTo(Intent.ACTION_CHOOSER))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment