Issue
I test my app with UI testing and would like to check if the camera app opens.
I have did this with:
@Test
public void profileImageClickOpensCamera() {
mIntentsRule.getActivity().startActivity(new Intent(mIntentsRule.getActivity(), ProfileActivity.class));
onView(withId(R.id.circleProfileImage)).perform(click());
intended(toPackage("com.android.camera"));
}
It is working fine on most devices, however if I rain it on SAMSUNG Galaxy S8, which has "com.sec.android.app.camera" package of it's camera app, the test fails.
My question is, how could I check with espresso that the package contains the word "camera" ?
It's not the best solution because a device's camera app's package name could be anything, but even better then what I got know.
So I would like to do something like:
intended(StringContains(toPackage("com.android.camera")));
Any suggestions?
Thanks in advance.
Solution
You can test the intent action instead of package.
Something like intended(hasAction(MediaStore.ACTION_IMAGE_CAPTURE)) or intended(hasAction(equalTo(MediaStore.ACTION_IMAGE_CAPTURE))) should work.
Answered By - Eduardo Herzer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.