如何使用Espresso with System对话框

时间:2015-03-13 11:13:05

标签: android

我的应用程序中有按钮启动Android Chooser意图(ACTION_VIEW等)我想知道如何使用Espresso空闲资源。等待并检测对话框的显示以及如何取消它并在之后返回。

我本身并不是要求代码..只是想知道怎么做?

e.g。

onView(withId(R.id.ad_email_button)).perform(click());

此按钮可打开意图

final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));

那么如何取消对话框以便测试不会挂起并验证是否显示了相应的系统对话框?

2 个答案:

答案 0 :(得分:2)

据我所知,使用Espresso我们仅限于特定活动中的操作和验证。但我发现我们也可以访问UiAutomator并执行BACK操作来解除警报对话框:

NSArray *withoutDUP2 = [[NSOrderedSet orderedSetWithArray:duplicateList] array];

答案 1 :(得分:1)

看起来答案是使用UIAutomator进行这些测试: https://developer.android.com/tools/testing-support-library/index.html#features