Search in sources :

Example 11 with TestAdapterBuilder

use of com.tonicartos.superslim.util.TestAdapterBuilder in project SuperSLiM by TonicArtos.

the class GridLayoutTests method test_overscrollAtStartBeforeEnd.

@Test
public void test_overscrollAtStartBeforeEnd() throws Exception {
    final int numItems = 1;
    final int dy = 100;
    RecyclerView.Adapter adapter;
    int[] layoutPadding;
    adapter = new TestAdapterBuilder().addGridSection(numItems, Utils.RV_WIDTH, Utils.RV_HEIGHT - dy, null).build(mActivity);
    layoutPadding = new int[] { 0, 0, 0, 0 };
    Utils.doOverscrollTest(new int[] { 0, 0 }, layoutPadding, false, adapter, mLayoutManager, mRecyclerView);
}
Also used : TestAdapterBuilder(com.tonicartos.superslim.util.TestAdapterBuilder) RecyclerView(android.support.v7.widget.RecyclerView) Test(org.junit.Test)

Example 12 with TestAdapterBuilder

use of com.tonicartos.superslim.util.TestAdapterBuilder in project SuperSLiM by TonicArtos.

the class GridLayoutTests method test_overscrollAtStartAtEnd.

@Test
public void test_overscrollAtStartAtEnd() throws Exception {
    final int numItems = 1;
    RecyclerView.Adapter adapter;
    int[] layoutPadding;
    adapter = new TestAdapterBuilder().addGridSection(numItems, Utils.RV_WIDTH, Utils.RV_HEIGHT, null).build(mActivity);
    layoutPadding = new int[] { 0, 0, 0, 0 };
    Utils.doOverscrollTest(new int[] { 0, 0 }, layoutPadding, false, adapter, mLayoutManager, mRecyclerView);
}
Also used : TestAdapterBuilder(com.tonicartos.superslim.util.TestAdapterBuilder) RecyclerView(android.support.v7.widget.RecyclerView) Test(org.junit.Test)

Example 13 with TestAdapterBuilder

use of com.tonicartos.superslim.util.TestAdapterBuilder in project SuperSLiM by TonicArtos.

the class GridLayoutTests method test_findLastVisibleItemOfScrolledSections.

@Test
public void test_findLastVisibleItemOfScrolledSections() {
    RecyclerView.Adapter adapter = new TestAdapterBuilder().addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).build(mActivity);
    Utils.setupLayoutTest(null, adapter, mLayoutManager, mRecyclerView);
    mRecyclerView.scrollBy(0, 50);
    assertEquals(34, mLayoutManager.findLastVisibleItemPosition());
}
Also used : TestAdapterBuilder(com.tonicartos.superslim.util.TestAdapterBuilder) RecyclerView(android.support.v7.widget.RecyclerView) Test(org.junit.Test)

Example 14 with TestAdapterBuilder

use of com.tonicartos.superslim.util.TestAdapterBuilder in project SuperSLiM by TonicArtos.

the class GridLayoutTests method test_overscrollAfterStartAfterEnd.

@Test
public void test_overscrollAfterStartAfterEnd() throws Exception {
    final int padding = 20;
    final int numItems = 1;
    final int dy = 100;
    RecyclerView.Adapter adapter;
    int[] layoutPadding;
    // Test once with padding.
    adapter = new TestAdapterBuilder().addGridSection(numItems, Utils.RV_WIDTH, Utils.RV_HEIGHT, null).build(mActivity);
    layoutPadding = new int[] { 0, padding, 0, padding };
    Utils.doOverscrollTest(new int[] { 0, dy }, layoutPadding, true, adapter, mLayoutManager, mRecyclerView);
    // Test with no padding.
    layoutPadding = new int[] { 0, 0, 0, 0 };
    Utils.doOverscrollTest(new int[] { 0, dy }, layoutPadding, true, adapter, mLayoutManager, mRecyclerView);
}
Also used : TestAdapterBuilder(com.tonicartos.superslim.util.TestAdapterBuilder) RecyclerView(android.support.v7.widget.RecyclerView) Test(org.junit.Test)

Example 15 with TestAdapterBuilder

use of com.tonicartos.superslim.util.TestAdapterBuilder in project SuperSLiM by TonicArtos.

the class GridLayoutTests method test_findLastCompletelyVisibleItemOfScrolledSections.

@Test
public void test_findLastCompletelyVisibleItemOfScrolledSections() {
    RecyclerView.Adapter adapter = new TestAdapterBuilder().addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).addGridSection(5, Utils.RV_WIDTH, 100, null).build(mActivity);
    Utils.setupLayoutTest(null, adapter, mLayoutManager, mRecyclerView);
    mRecyclerView.scrollBy(0, 50);
    assertEquals(32, mLayoutManager.findLastCompletelyVisibleItemPosition());
}
Also used : TestAdapterBuilder(com.tonicartos.superslim.util.TestAdapterBuilder) RecyclerView(android.support.v7.widget.RecyclerView) Test(org.junit.Test)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)22 TestAdapterBuilder (com.tonicartos.superslim.util.TestAdapterBuilder)22 Test (org.junit.Test)22