### Question:
WearableRecyclerView extends RecyclerView { public void setEdgeItemsCenteringEnabled(boolean isEnabled) { mEdgeItemsCenteringEnabled = isEnabled; if (mEdgeItemsCenteringEnabled) { if (getChildCount() > 0) { setupCenteredPadding(); } else { mCenterEdgeItemsWhenThereAreChildren = true; } } else { setupOriginalPadding(); mCenterEdgeItemsWhenThereAreChildren = false; } } WearableRecyclerView(Context context);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle,
            int defStyleRes); @Override boolean onTouchEvent(MotionEvent event); void setCircularScrollingGestureEnabled(boolean circularScrollingGestureEnabled); boolean isCircularScrollingGestureEnabled(); void setScrollDegreesPerScreen(float degreesPerScreen); float getScrollDegreesPerScreen(); void setBezelFraction(float fraction); float getBezelFraction(); void setEdgeItemsCenteringEnabled(boolean isEnabled); boolean isEdgeItemsCenteringEnabled();  }### Answer:
@Test public void testEdgeItemsCenteringOnAndOff() throws Throwable { mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { WearableRecyclerView wrv = (WearableRecyclerView) mActivityRule.getActivity().findViewById(R.id.wrv); wrv.setEdgeItemsCenteringEnabled(true); } }); InstrumentationRegistry.getInstrumentation().waitForIdleSync(); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { WearableRecyclerView wrv = (WearableRecyclerView) mActivityRule.getActivity().findViewById(R.id.wrv); View child = wrv.getChildAt(0); assertNotNull("child", child); assertEquals((wrv.getHeight() - child.getHeight()) / 2, child.getTop()); } }); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { WearableRecyclerView wrv = (WearableRecyclerView) mActivityRule.getActivity().findViewById(R.id.wrv); wrv.setEdgeItemsCenteringEnabled(false); } }); InstrumentationRegistry.getInstrumentation().waitForIdleSync(); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { WearableRecyclerView wrv = (WearableRecyclerView) mActivityRule.getActivity().findViewById(R.id.wrv); View child = wrv.getChildAt(0); assertNotNull("child", child); assertEquals(0, child.getTop()); } }); }
@Test public void testEdgeItemsCenteringBeforeChildrenDrawn() throws Throwable { mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { Activity activity = mActivityRule.getActivity(); WearableRecyclerView wrv = (WearableRecyclerView) activity.findViewById(R.id.wrv); RecyclerView.Adapter<WearableRecyclerView.ViewHolder> adapter = wrv.getAdapter(); wrv.setAdapter(null); wrv.setEdgeItemsCenteringEnabled(true); wrv.setAdapter(adapter); } }); InstrumentationRegistry.getInstrumentation().waitForIdleSync(); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { WearableRecyclerView wrv = (WearableRecyclerView) mActivityRule.getActivity().findViewById(R.id.wrv); View child = wrv.getChildAt(0); assertNotNull("child", child); assertEquals((wrv.getHeight() - child.getHeight()) / 2, child.getTop()); } }); }