use of com.tonicartos.superslim.LayoutState in project SuperSLiM by TonicArtos.
the class Utils method doOverscrollTest.
/**
* Perform an overscroll test.
*
* @param offset Offset to apply to simulate overscroll; dx, dy.
* @param padding Padding values; l, t, r, b.
* @param expected Expected bounds; l, t, r, b.
* @param adapter Adapter to use.
* @param mLayoutManager Layout manager to use.
* @param mRecyclerView RecyclerView to use.
*/
public static void doOverscrollTest(int[] offset, int[] padding, boolean expected, RecyclerView.Adapter adapter, LayoutManagerWrapper mLayoutManager, RecyclerView mRecyclerView) throws Exception {
setupLayoutTest(padding, adapter, mLayoutManager, mRecyclerView);
// Shift so that bounds are after start and end.
adjustPosition(mRecyclerView, offset[0], offset[1]);
Method isOverscrolled = LayoutManager.class.getDeclaredMethod("isOverscrolled", LayoutState.class);
isOverscrolled.setAccessible(true);
LayoutState state = mock(LayoutState.class);
RecyclerView.State mRecyclerViewState = mock(RecyclerView.State.class);
when(state.getRecyclerState()).thenReturn(mRecyclerViewState);
when(mRecyclerViewState.getItemCount()).thenReturn(adapter.getItemCount());
boolean result = (Boolean) isOverscrolled.invoke(mLayoutManager, state);
assertEquals(expected, result);
}
Aggregations