ViewHelper { public static void setText(EfficientCacheView cacheView, int viewId, CharSequence text) { View view = cacheView.findViewByIdEfficient(viewId); if (view instanceof TextView) { ((TextView) view).setText(text); } }  static void setVisibility(EfficientCacheView cacheView, int viewId, int visibility); static void setBackground(EfficientCacheView cacheView, int viewId, Drawable drawable); static void setBackgroundColor(EfficientCacheView cacheView, int viewId,
            @ColorInt int color); static void setBackgroundResource(EfficientCacheView cacheView, int viewId,
            @DrawableRes int resid); static void setTag(EfficientCacheView cacheView, int viewId, Object tag); static void setTag(EfficientCacheView cacheView, int viewId, int key, Object tag); static void setText(EfficientCacheView cacheView, int viewId, CharSequence text); static void setText(EfficientCacheView cacheView, int viewId, @StringRes int resid); static void setTextColor(EfficientCacheView cacheView, int viewId, @ColorInt int color); static void setTextSize(EfficientCacheView cacheView, int viewId, float size); static void setTextSize(EfficientCacheView cacheView, int viewId, int unit, float size); static void setImageResource(EfficientCacheView cacheView, int viewId,
            @DrawableRes int resId); static void setImageDrawable(EfficientCacheView cacheView, int viewId,
            Drawable drawable); static void setImageUri(EfficientCacheView cacheView, int viewId, @Nullable Uri uri); static void setImageBitmap(EfficientCacheView cacheView, int viewId, Bitmap bm);  }
@Test public void testSetText_textView() throws Exception { CharSequence text = "fake_text"; ViewHelper.setText(mCacheView, TEXTVIEW_ID, text); verify(mTextView).setText(text); verifyNoMoreInteractions(mTextView); }
@Test public void testSetText_notTextView() throws Exception { CharSequence text = "fake_text"; ViewHelper.setText(mCacheView, NULL_VIEW_ID, text); ViewHelper.setText(mCacheView, VIEW_ID, text); ViewHelper.setText(mCacheView, IMAGEVIEW_ID, text); verifyZeroInteractions(mImageView, mView); }
@Test public void testSetTextWithRes_textView() throws Exception { int textRes = android.R.string.cancel; ViewHelper.setText(mCacheView, TEXTVIEW_ID, textRes); verify(mTextView).setText(textRes); verifyNoMoreInteractions(mTextView); }
@Test public void testSetTextWithRes_notTextView() throws Exception { int textRes = android.R.string.cancel; ViewHelper.setText(mCacheView, NULL_VIEW_ID, textRes); ViewHelper.setText(mCacheView, VIEW_ID, textRes); ViewHelper.setText(mCacheView, IMAGEVIEW_ID, textRes); verifyZeroInteractions(mImageView, mView); }