我想监视如果startService(...)呼叫正处于活动取得:Service Intent - 它会被ActivityMonitor捕获吗?
public void testShouldCallServiceOnSendButtonPress() throws Exception {
assertNotNull(activity.pictureToSend);
ActivityMonitor androidMock = help.mockIntent(1);
TouchUtils.clickView(this, activity.sendButton);
help.assertBehavior(androidMock);
}
public ActivityMonitor mockIntent(int numberOfExpectedIntentsSentToAndroid) {
this.numberOfExpectedIntentsSentToAndroid = numberOfExpectedIntentsSentToAndroid;
IntentFilter intentFilter = null;
return androidMock = instrumentation.addMonitor(intentFilter, null, true);// catch all
}
上面我加入一个包罗万象的监视器(应该抓住这两个活动和服务意图,对不对? !)
assertNotNull(this.startService(new Intent(this, MyService.class)));
上面我验证服务是否已成功启动,并且是。
可是......包罗万象的显示器从不打,instrumentation.checkMonitorHit()不是> = 1
任何想法,为什么?
是否有可能代码嘲笑你? ;)尽管如此,你是否尝试过监视特定的活动?如果您遇到了更普遍的问题,或者这是一个简单的错误修正,这可能会给您一个想法。 – Codeman
它嘲笑我所有的时间:),是的,当测试意向MediaStore.ActionImageCapture beeing抛出,监视器工作,所以... 问题转述:ActivityMonitors应该为服务以及活动,工作,对吗? – user77115