Search in sources :

Example 1 with ShadowRecyclerViewAdapter

use of io.github.hidroh.materialistic.test.shadow.ShadowRecyclerViewAdapter in project materialistic by hidroh.

the class ListFragmentViewHolderEdgeTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    TestApplication.applicationGraph.inject(this);
    reset(itemManager);
    controller = Robolectric.buildActivity(ListActivity.class).create().start().resume().visible();
    ListActivity activity = controller.get();
    Bundle args = new Bundle();
    args.putString(ListFragment.EXTRA_ITEM_MANAGER, HackerNewsClient.class.getName());
    args.putString(ListFragment.EXTRA_FILTER, ItemManager.TOP_FETCH_MODE);
    activity.getSupportFragmentManager().beginTransaction().add(android.R.id.content, Fragment.instantiate(activity, ListFragment.class.getName(), args)).commit();
    verify(itemManager).getStories(any(), eq(ItemManager.MODE_DEFAULT), storiesListener.capture());
    storiesListener.getValue().onResponse(new Item[] { new TestHnItem(1L) });
    RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
    ShadowRecyclerViewAdapter shadowAdapter = customShadowOf(recyclerView.getAdapter());
    holder = shadowAdapter.getViewHolder(0);
}
Also used : Bundle(android.os.Bundle) RecyclerView(android.support.v7.widget.RecyclerView) ShadowRecyclerViewAdapter(io.github.hidroh.materialistic.test.shadow.ShadowRecyclerViewAdapter) TestHnItem(io.github.hidroh.materialistic.data.TestHnItem) HackerNewsClient(io.github.hidroh.materialistic.data.HackerNewsClient) ListActivity(io.github.hidroh.materialistic.test.ListActivity) Before(org.junit.Before)

Aggregations

Bundle (android.os.Bundle)1 RecyclerView (android.support.v7.widget.RecyclerView)1 HackerNewsClient (io.github.hidroh.materialistic.data.HackerNewsClient)1 TestHnItem (io.github.hidroh.materialistic.data.TestHnItem)1 ListActivity (io.github.hidroh.materialistic.test.ListActivity)1 ShadowRecyclerViewAdapter (io.github.hidroh.materialistic.test.shadow.ShadowRecyclerViewAdapter)1 Before (org.junit.Before)1