Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@catehstn
Created April 25, 2016 10:08
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/c9df643deaba4d4aa969763d517b79a3 to your computer and use it in GitHub Desktop.
Save catehstn/c9df643deaba4d4aa969763d517b79a3 to your computer and use it in GitHub Desktop.
@Test
public void testTapCameraButtonAndCancel() {
// Uri needed to launch the Camera intent.
Uri uri = Uri.parse("uri_string");
stub(fileUtilities.getOutputMediaFileUri()).toReturn(uri);
// Build a result to return when the activity is launched.
Intent resultData = new Intent();
Instrumentation.ActivityResult result =
new Instrumentation.ActivityResult(Activity.RESULT_CANCELED, resultData);
// Stub result for camera intent.
intending(toPackage("com.android.camera")).respondWith(result);
onView(withId(R.id.home_camera_button)).check(matches(withText("Camera")));
onView(withId(R.id.home_camera_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