Search in sources :

Example 1 with LayoutManagerFactory

use of com.beloo.chipslayoutmanager.sample.ui.LayoutManagerFactory in project ChipsLayoutManager by BelooS.

the class ColumnTest method setUp.

@Before
public void setUp() throws Throwable {
    MockitoAnnotations.initMocks(this);
    activity = activityTestRule.getActivity();
    recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));
    layoutManager = getLayoutManager();
    LayoutManagerFactory layoutManagerFactory = new LayoutManagerFactory() {

        @Override
        public RecyclerView.LayoutManager layoutManager(Context context) {
            //we need clean layout manager for each request
            return retrieveLayoutManager();
        }
    };
    //set items
    ChipsFacade chipsFacade = spy(new ChipsFacade());
    items = chipsFacade.getItems();
    when(chipsFacade.getItems()).thenReturn(items);
    TestActivity.setItemsFactory(chipsFacade);
    TestActivity.setLmFactory(layoutManagerFactory);
    activity.runOnUiThread(() -> activity.initialize());
}
Also used : Context(android.content.Context) RecyclerView(android.support.v7.widget.RecyclerView) ChipsFacade(com.beloo.chipslayoutmanager.sample.ui.ChipsFacade) LayoutManagerFactory(com.beloo.chipslayoutmanager.sample.ui.LayoutManagerFactory) Before(org.junit.Before)

Example 2 with LayoutManagerFactory

use of com.beloo.chipslayoutmanager.sample.ui.LayoutManagerFactory in project ChipsLayoutManager by BelooS.

the class RowTest method setUp.

@Before
public final void setUp() throws Throwable {
    MockitoAnnotations.initMocks(this);
    activity = activityTestRule.getActivity();
    LayoutManagerFactory layoutManagerFactory = new LayoutManagerFactory() {

        @Override
        public RecyclerView.LayoutManager layoutManager(Context context) {
            return retrieveLayoutManager();
        }
    };
    RecyclerView rvTest = (RecyclerView) activityTestRule.getActivity().findViewById(R.id.rvTest);
    //disable all animations
    rvTest.setItemAnimator(null);
    //set items
    ChipsFacade chipsFacade = spy(new ChipsFacade());
    items = chipsFacade.getItems();
    when(chipsFacade.getItems()).thenReturn(items);
    TestActivity.setItemsFactory(chipsFacade);
    TestActivity.setLmFactory(layoutManagerFactory);
    recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));
    onSetUp();
    activity.runOnUiThread(() -> activity.initialize());
}
Also used : Context(android.content.Context) RecyclerView(android.support.v7.widget.RecyclerView) ChipsFacade(com.beloo.chipslayoutmanager.sample.ui.ChipsFacade) LayoutManagerFactory(com.beloo.chipslayoutmanager.sample.ui.LayoutManagerFactory) Before(org.junit.Before)

Aggregations

Context (android.content.Context)2 RecyclerView (android.support.v7.widget.RecyclerView)2 ChipsFacade (com.beloo.chipslayoutmanager.sample.ui.ChipsFacade)2 LayoutManagerFactory (com.beloo.chipslayoutmanager.sample.ui.LayoutManagerFactory)2 Before (org.junit.Before)2