Reputation: 7383
I have buttons in my app that launch Android Chooser intents (ACTION_VIEW, etc.) And i was wondering how to use an Espresso idling resource. to wait and detect display of the dialog and how to cancel it and return after.
I am not asking for code per se .. just wondering how to do it?
e.g.
onView(withId(R.id.ad_email_button)).perform(click());
this button opens the intent
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
So how to cancel the dialog so the test doesn't hang and verify the appropriate system dialog was shown?
Upvotes: 1
Views: 2271
Reputation: 1813
As far as I know using Espresso we are limited to actions and verifications inside specific Activity. But I found out that we can access UiAutomator as well and perform BACK action to dismiss alert dialog:
InstrumentationRegistry.getInstrumentation().getUiAutomation()
.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
Upvotes: 4
Reputation: 7383
Looks like the answer is to use UIAutomator for these tests: https://developer.android.com/tools/testing-support-library/index.html#features
Upvotes: 1