### Question:
GridLayoutManager extends LinearLayoutManager { public SpanSizeLookup getSpanSizeLookup() { return mSpanSizeLookup; } GridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr,
                             int defStyleRes);  GridLayoutManager(Context context, int spanCount);  GridLayoutManager(Context context, int spanCount,
            @RecyclerView.Orientation int orientation, boolean reverseLayout); @Override void setStackFromEnd(boolean stackFromEnd); @Override int getRowCountForAccessibility(RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override int getColumnCountForAccessibility(RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler,
            RecyclerView.State state, View host, AccessibilityNodeInfoCompat info); @Override void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state); @Override void onLayoutCompleted(RecyclerView.State state); @Override void onItemsAdded(RecyclerView recyclerView, int positionStart, int itemCount); @Override void onItemsChanged(RecyclerView recyclerView); @Override void onItemsRemoved(RecyclerView recyclerView, int positionStart, int itemCount); @Override void onItemsUpdated(RecyclerView recyclerView, int positionStart, int itemCount,
            Object payload); @Override void onItemsMoved(RecyclerView recyclerView, int from, int to, int itemCount); @Override RecyclerView.LayoutParams generateDefaultLayoutParams(); @Override RecyclerView.LayoutParams generateLayoutParams(Context c, AttributeSet attrs); @Override RecyclerView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp); @Override boolean checkLayoutParams(RecyclerView.LayoutParams lp); void setSpanSizeLookup(SpanSizeLookup spanSizeLookup); SpanSizeLookup getSpanSizeLookup(); @Override void setMeasuredDimension(Rect childrenBounds, int wSpec, int hSpec); @Override int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler,
            RecyclerView.State state); int getSpanCount(); void setSpanCount(int spanCount); @Override View onFocusSearchFailed(View focused, int focusDirection,
            RecyclerView.Recycler recycler, RecyclerView.State state); @Override boolean supportsPredictiveItemAnimations(); static final int DEFAULT_SPAN_COUNT; }### Answer:
@Test public void notifyDataSetChange() throws Throwable { final RecyclerView recyclerView = setupBasic(new Config(3, 100)); final GridLayoutManager.SpanSizeLookup ssl = mGlm.getSpanSizeLookup(); ssl.setSpanIndexCacheEnabled(true); waitForFirstLayout(recyclerView); assertTrue("some positions should be cached", ssl.mSpanIndexCache.size() > 0); final Callback callback = new Callback() { @Override public void onBeforeLayout(RecyclerView.Recycler recycler, RecyclerView.State state) { if (!state.isPreLayout()) { assertEquals("cache should be empty", 0, ssl.mSpanIndexCache.size()); } } @Override public void onAfterLayout(RecyclerView.Recycler recycler, RecyclerView.State state) { if (!state.isPreLayout()) { assertTrue("some items should be cached", ssl.mSpanIndexCache.size() > 0); } } }; mGlm.mCallbacks.add(callback); mGlm.expectLayout(2); mAdapter.deleteAndNotify(2, 3); mGlm.waitForLayout(2); checkForMainThreadException(); }