use of com.beloo.chipslayoutmanager.sample.entity.ChipsEntity in project ChipsLayoutManager by BelooS.
the class FewChipsRowTest method setUp.
@Before
public void setUp() throws Throwable {
MockitoAnnotations.initMocks(this);
activity = activityTestRule.getActivity();
RecyclerView rvTest = (RecyclerView) activityTestRule.getActivity().findViewById(R.id.rvTest);
//disable all animations
rvTest.setItemAnimator(null);
layoutManager = getLayoutManager();
doReturn(layoutManager).when(layoutManagerFactory).layoutManager(any());
IItemsFacade<ChipsEntity> chipsFacade = spy(new FewChipsFacade());
items = chipsFacade.getItems();
when(chipsFacade.getItems()).thenReturn(items);
TestActivity.setItemsFactory(chipsFacade);
TestActivity.setLmFactory(layoutManagerFactory);
}
use of com.beloo.chipslayoutmanager.sample.entity.ChipsEntity in project ChipsLayoutManager by BelooS.
the class ShortChipsFactory method getItems.
@Override
public List<ChipsEntity> getItems() {
List<ChipsEntity> chipsEntities = getFewItems();
List<ChipsEntity> secondPortion = getFewItems();
Collections.reverse(secondPortion);
chipsEntities.addAll(secondPortion);
chipsEntities.addAll(getFewItems());
chipsEntities.addAll(getFewItems());
for (int i = 0; i < chipsEntities.size(); i++) {
ChipsEntity chipsEntity = chipsEntities.get(i);
chipsEntity.setName(chipsEntity.getName() + " " + i);
}
return chipsEntities;
}
use of com.beloo.chipslayoutmanager.sample.entity.ChipsEntity in project ChipsLayoutManager by BelooS.
the class FewChipsColumnTest method deleteItemInTheFirstLine_ItemHasMaximumWidth_SameStartPadding.
@Test
public void deleteItemInTheFirstLine_ItemHasMaximumWidth_SameStartPadding() throws Exception {
//arrange
{
//just adapt input items list to required start values
items.remove(1);
items.remove(9);
ChipsEntity longItem = items.remove(8);
items.add(1, longItem);
}
activity.runOnUiThread(() -> activity.initialize());
ViewInteraction recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));
//just adapt input items list to required start values
InstrumentalUtil.waitForIdle();
View second = layoutManager.getChildAt(1);
double expectedX = second.getX();
//act
recyclerView.perform(actionDelegate(((uiController, view) -> items.remove(1))), notifyItemRemovedAction(1));
InstrumentalUtil.waitForIdle();
second = layoutManager.getChildAt(5);
double resultX = second.getX();
//assert
assertNotEquals(0, expectedX, 0.01);
assertNotEquals(0, resultX, 0.01);
assertEquals(resultX, expectedX, 0.01);
}
use of com.beloo.chipslayoutmanager.sample.entity.ChipsEntity in project ChipsLayoutManager by BelooS.
the class ChipsFactory method getItems.
@Override
public List<ChipsEntity> getItems() {
List<ChipsEntity> chipsEntities = getFewItems();
List<ChipsEntity> secondPortion = getFewItems();
Collections.reverse(secondPortion);
chipsEntities.addAll(secondPortion);
chipsEntities.addAll(getFewItems());
chipsEntities.addAll(getFewItems());
for (int i = 0; i < chipsEntities.size(); i++) {
ChipsEntity chipsEntity = chipsEntities.get(i);
chipsEntity.setName(chipsEntity.getName() + " " + i);
}
return chipsEntities;
}
Aggregations