浓咖啡:等待活动接收onNewIntent

时间:2018-06-19 13:12:42

标签: android-espresso

我有一个singleInstance活动,我是通过规则在测试中启动的:

@Rule
@JvmField
val activityRule = ActivityTestRule(MyActivity::class.java)

在测试中,我需要我的活动来处理几个新的意图,例如:

@Test
fun myTest() {
    val context = InstrumentationRegistry.getTargetContext()
    myTestParams.forEach { param ->
        context.startActivity(Intent(context, MyActivity::class.java).putExtra("param", param))
        InstrumentationRegistry.getInstrumentation().waitForIdleSync() // try to make espresso wait for intent being handled. DOESN'T WORK

        takeScreenshot() // sometimes screenshot is taken before activity is rendered with new param
    }
}

是否有任何方法可以使浓缩咖啡在执行MyActivity.onNewIntent之前等待调用takeScreenshot的方法?

0 个答案:

没有答案