CollectionView extends FrameLayout { void showLoading() { if (adapter == null) { throw new NullPointerException("adapter is null"); } if (getChildCount() == 2) { removeViewAt(1); } refreshLayout.setRefreshing(true); } CollectionView(
      @NonNull Context context,
      @Nullable AttributeSet attrs); @SuppressWarnings("unchecked") @Override void onAttachedToWindow(); @Override void onDetachedFromWindow(); void setAdapter(@NonNull Adapter adapter);  }
@Test public void testShowLoading() throws Exception { tested.showLoading(); assertThat(tested.refreshLayout.isRefreshing()).isTrue(); assertThat(tested.getChildCount()).isEqualTo(1); }