Search in sources :

Example 1 with ChipsEntity

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);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) FewChipsFacade(com.beloo.chipslayoutmanager.sample.ui.FewChipsFacade) ChipsEntity(com.beloo.chipslayoutmanager.sample.entity.ChipsEntity) Before(org.junit.Before)

Example 2 with ChipsEntity

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;
}
Also used : ChipsEntity(com.beloo.chipslayoutmanager.sample.entity.ChipsEntity)

Example 3 with ChipsEntity

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);
}
Also used : ViewInteraction(android.support.test.espresso.ViewInteraction) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Espresso.onView(android.support.test.espresso.Espresso.onView) ChipsEntity(com.beloo.chipslayoutmanager.sample.entity.ChipsEntity) Test(org.junit.Test)

Example 4 with ChipsEntity

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;
}
Also used : ChipsEntity(com.beloo.chipslayoutmanager.sample.entity.ChipsEntity)

Aggregations

ChipsEntity (com.beloo.chipslayoutmanager.sample.entity.ChipsEntity)4 RecyclerView (android.support.v7.widget.RecyclerView)2 Espresso.onView (android.support.test.espresso.Espresso.onView)1 ViewInteraction (android.support.test.espresso.ViewInteraction)1 View (android.view.View)1 FewChipsFacade (com.beloo.chipslayoutmanager.sample.ui.FewChipsFacade)1 Before (org.junit.Before)1 Test (org.junit.Test)1