use of com.beloo.chipslayoutmanager.sample.ui.ChipsFacade 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());
}
use of com.beloo.chipslayoutmanager.sample.ui.ChipsFacade in project ChipsLayoutManager by BelooS.
the class FewChipsColumnTest method setUp.
@Before
public void setUp() throws Throwable {
MockitoAnnotations.initMocks(this);
activity = activityTestRule.getActivity();
layoutManager = getLayoutManager();
doReturn(layoutManager).when(layoutManagerFactory).layoutManager(any());
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);
}
use of com.beloo.chipslayoutmanager.sample.ui.ChipsFacade 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());
}
use of com.beloo.chipslayoutmanager.sample.ui.ChipsFacade in project ChipsLayoutManager by BelooS.
the class ColumnTest method setAdapterTwice_ChipsLayoutManagerHaveSetToRecyclerView_NoException.
@Test
public void setAdapterTwice_ChipsLayoutManagerHaveSetToRecyclerView_NoException() throws Exception {
//arrange
ChipsFacade chipsFacade = spy(new ChipsFacade());
ChipsAdapter chipsAdapter = new ChipsAdapter(chipsFacade.getItems(), null);
//act
recyclerView.perform(setAdapter(chipsAdapter));
recyclerView.perform(setAdapter(chipsAdapter));
InstrumentalUtil.waitForIdle();
//assert
int pos = layoutManager.findFirstVisibleItemPosition();
assertNotEquals(RecyclerView.NO_POSITION, pos);
}
use of com.beloo.chipslayoutmanager.sample.ui.ChipsFacade in project ChipsLayoutManager by BelooS.
the class RowTest method setAdapterTwice_ChipsLayoutManagerHaveSetToRecyclerView_NoException.
@Test
public void setAdapterTwice_ChipsLayoutManagerHaveSetToRecyclerView_NoException() throws Exception {
//arrange
ChipsFacade chipsFacade = spy(new ChipsFacade());
ChipsAdapter chipsAdapter = new ChipsAdapter(chipsFacade.getItems(), null);
//act
recyclerView.perform(setAdapter(chipsAdapter));
recyclerView.perform(setAdapter(chipsAdapter));
InstrumentalUtil.waitForIdle();
//assert
int pos = layoutManager.findFirstVisibleItemPosition();
assertNotEquals(RecyclerView.NO_POSITION, pos);
}
Aggregations