Is there any possibility:
- to disable all animation for recycler view or run them on UI thread for testing with espresso?
Or
- to add idlingresources to android.support.v7.recyclerview.extensions.ListAdapter?
The problem is the following: The exception is thrown for Espresso test
android.support.test.espresso.PerformException: Error performing 'android.support.test.espresso.contrib.RecyclerViewActions$ActionOnItemAtPositionViewAction@3d4956f' on view 'with id: XXX:id/items_rcv'.
When trying to execute the following code:
//... code that executes recyclerView.adapter.submitList(items)
onView(withId(R.id.items_rcv))
.perform(RecyclerViewActions.actionOnItemAtPosition<ViewHolder>(
0, click()
));
The problem is that items are not visible when a click action is executed. They are shown with some delay because adapter for RecyclerView is extended from android.support.v7.recyclerview.extensions.ListAdapter:
class ItemsAdapter : ListAdapter<Item, RecyclerView.ViewHolder>() {
...
}
so it uses the AsyncListDiffer which shows items in recycler view with some animation.
Thank You in advance
UPDATE:
The following does not help: 1) set BackgroundThreadExecutor as MainThreadExecutor for AsyncListDiffer
ItemsAdapter(AsyncDifferConfig.Builder<Item>(ItemsDiffCallback)
.setBackgroundThreadExecutor(MainThreadExecutor())
.build())
2) disable itemAnimator for RecyclerView
mActivityTestRule.activity.findViewById<RecyclerView>(R.id.items_rcv).itemAnimator = null