EfficientCacheView { public <T extends View> T findViewByIdEfficient(int id) { return castView(findViewByIdEfficient(0, id)); } EfficientCacheView(View view); View getView(); void clearViewsCached(); void clearViewCached(int viewId); void clearViewCached(int parentId, int viewId); T findViewByIdEfficient(int id); T findViewByIdEfficient(int parentId, int id);  }
@Test public void testReturnRootView() throws Exception { assertEquals(mRootView, mSubject.findViewByIdEfficient(ID_ROOT_VIEW)); }
@Test public void testReturnParents() throws Exception { assertEquals(mViewParent1, mSubject.findViewByIdEfficient(ID_PARENT_1)); assertEquals(mViewParent2, mSubject.findViewByIdEfficient(ID_PARENT_2)); }
@Test public void testReturnChildOfParent1ByDefault() throws Exception { assertEquals(mViewParent1Child1, mSubject.findViewByIdEfficient(ID_CHILD_1)); assertEquals(mViewParent1Child2, mSubject.findViewByIdEfficient(ID_CHILD_2)); }
@Test public void testReturnChildOfParents() throws Exception { assertEquals(mViewParent1Child1, mSubject.findViewByIdEfficient(ID_PARENT_1, ID_CHILD_1)); assertEquals(mViewParent1Child2, mSubject.findViewByIdEfficient(ID_PARENT_1, ID_CHILD_2)); assertEquals(mViewParent2Child1, mSubject.findViewByIdEfficient(ID_PARENT_2, ID_CHILD_1)); assertEquals(mViewParent2Child2, mSubject.findViewByIdEfficient(ID_PARENT_2, ID_CHILD_2)); }