Espresso CursorAdapter:点击第一项

时间:2014-03-19 11:43:26

标签: android android-espresso

我无法点击Listview支持的CursorAdapter的第一项。 这是我试过的:

onData(is(instanceOf(ContactsListFragment.ContactsAdapter.class)))
    // .inAdapterView(withId(android.R.id.list))
    .atPosition(0)
    .perform(click());

......这就是我得到的:

  

com.google.android.apps.common.testing.ui.espresso.PerformException:   在视图上执行'加载适配器数据'时出错“可从中分配   class:class android.widget.AdapterView'。在   com.google.android.apps.common.testing.ui.espresso.PerformException $ Builder.build(PerformException.java:67)   在   com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:57)   在   com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:40)   在   com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:159)   在   com.google.android.apps.common.testing.ui.espresso.ViewInteraction.doPerform(ViewInteraction.java:90)   在   com.google.android.apps.common.testing.ui.espresso.ViewInteraction.perform(ViewInteraction.java:73)   在   com.google.android.apps.common.testing.ui.espresso.DataInteraction.load(DataInteraction.java:135)   在   com.google.android.apps.common.testing.ui.espresso.DataInteraction.perform(DataInteraction.java:112)   在   .test.ui.activity.ContactsListActivityTest.testShouldSendResultsBackToMailActivity(ContactsListActivityTest.java:21)   在java.lang.reflect.Method.invokeNative(Native Method)at   android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)   在   android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)   在   android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)   在android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)   在android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)   在   android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)   在   com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.onStart(GoogleInstrumentationTestRunner.java:167)   在   android.app.Instrumentation $ InstrumentationThread.run(Instrumentation.java:1701)   引起:java.lang.RuntimeException:找不到匹配的数据:是一个   的例子   .ui.activity.delivery.contacts.ContactsListFragment $ ContactsAdapter   包含的值:< [数据:   android.content.ContentResolver$CursorWrapperInner@b312ecd8(类:   class android.content.ContentResolver $ CursorWrapperInner)token:0,   数据:android.content.ContentResolver$CursorWrapperInner@b312ecd8   (类:类android.content.ContentResolver $ CursorWrapperInner)   令牌:1,数据:   android.content.ContentResolver$CursorWrapperInner@b312ecd8(类:   class android.content.ContentResolver $ CursorWrapperInner)token:2]>   在   com.google.android.apps.common.testing.ui.espresso.action.AdapterDataLoaderAction.perform(AdapterDataLoaderAction.java:80)   在   com.google.android.apps.common.testing.ui.espresso.ViewInteraction $ 1.run(ViewInteraction.java:119)   在   java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:390)   在java.util.concurrent.FutureTask.run(FutureTask.java:234)at   android.os.Handler.handleCallback(Handler.java:730)at   android.os.Handler.dispatchMessage(Handler.java:92)at   android.os.Looper.loop(Looper.java:137)at   android.app.ActivityThread.main(ActivityThread.java:5103)at   java.lang.reflect.Method.invokeNative(Native Method)at   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:737)   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)at   dalvik.system.NativeStart.main(原生方法)

1 个答案:

答案 0 :(得分:1)

将在下一版本(Espresso 1.2)中解决。请参阅相关问题:https://code.google.com/p/android-test-kit/issues/detail?id=69