要素が遅延してフェッチされる ListView があります (リストの最後の要素までスクロールすると、新しいフェッチが発生し、完了すると、新しい要素がリストの最後に追加されます)。私の ListView アダプターはProduct
オブジェクトで支えられています:
public class Product {
private String name;
public String getName() {
return name;
}
}
特定の名前を持つ要素は、たとえば 25 番目の位置にあります。onData(Matcher<Object> dataMatcher)
安全に使用できるように、アイテムがアダプターで使用可能になるまでリストをスクロールするような動作を実装するにはどうすればよいですか? 今、使用するonData( ... )
と、次の例外が発生します。
android.support.test.espresso.PerformException: Error performing 'load adapter data' on view 'is assignable from class: class android.widget.AdapterView'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:70)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:53)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
at android.support.test.espresso.DataInteraction.load(DataInteraction.java:151)
at android.support.test.espresso.DataInteraction.perform(DataInteraction.java:128)
at com.example.main.MainPageTest.testLazyList(MainPageTest.java:69)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:257)
at org.junit.rules.RunRules.evaluate(RunRules.java:18)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:228)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1873)
Caused by: java.lang.RuntimeException: No data found matching: Product with name: "sdasd" contained values: <[Data: Product{name='Sony PlayStation 4 500GB'} (class: com.example.Product) token: 0, Data: Product{name='Samsung UE48H6400'} (class: com.example.Product) token: 1, Data: Product{name='Grand Theft Auto V (Gra PC)'} (class: com.example.Product) token: 2, Data: Product{name='Samsung UE55H6400'} (class: com.example.Product) token: 3, Data: Product{name='Zelmer Aquawelt 919.0 ST'} (class: com.example.Product) token: 4, Data: Product{name='Panasonic TX-47AS650E'} (class: com.example.Product) token: 5, Data: Product{name='LG 42LB650V'} (class: com.example.Product) token: 6, Data: Product{name='Samsung UE40H6400'} (class: com.example.Product) token: 7, Data: Product{name='Panasonic TX-48AS640E'} (class: com.example.Product) token: 8, Data: Product{name='Panasonic TX-42AS650E'} (class: com.example.Product) token: 9, Data: Product{name='Samsung UE50H6400'} (class: com.example.Product) token: 10, Data: Product{name='Zelmer ZVC425HT'} (class: com.example.Product) token: 11, Data: Product{name='Calvin Klein Euphoria Woman Woda perfumowana 100 ml spray'} (class: com.example.Product) token: 12, Data: Product{name='Sony KDL-50W829B'} (class: com.example.Product) token: 13, Data: Product{name='Samsung UE40H6200'} (class: com.example.Product) token: 14, Data: Product{name='Sony KDL-40W605B'} (class: com.example.Product) token: 15, Data: Product{name='Panasonic TX-55AS640E'} (class: com.example.Product) token: 16, Data: Product{name='LG 42LB5800'} (class: com.example.Product) token: 17]>
at android.support.test.espresso.action.AdapterDataLoaderAction.perform(AdapterDataLoaderAction.java:96)
at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:144)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5834)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)