### Question:
IconMixin implements Mixin { public void setIcon(Drawable icon) { final ImageView iconView = getView(); if (iconView != null) { iconView.setImageDrawable(icon); iconView.setVisibility(icon != null ? View.VISIBLE : View.GONE); } } IconMixin(TemplateLayout layout, AttributeSet attrs, int defStyleAttr); void setIcon(Drawable icon); void setIcon(@DrawableRes int icon); Drawable getIcon(); void setContentDescription(CharSequence description); CharSequence getContentDescription();  }### Answer:
@Test public void testSetIcon() { final ColorDrawable drawable = new ColorDrawable(Color.CYAN); IconMixin mixin = new IconMixin(mTemplateLayout, null, 0); mixin.setIcon(drawable); assertSame(drawable, mIconView.getDrawable()); assertEquals(View.VISIBLE, mIconView.getVisibility()); }
@Test public void setIcon_resourceId_shouldSetIcon() { int icon = android.R.drawable.ic_menu_add; IconMixin mixin = new IconMixin(mTemplateLayout, null, 0); mixin.setIcon(icon); Drawable drawable = mIconView.getDrawable(); assertThat(drawable).isInstanceOf(BitmapDrawable.class); assertEquals(View.VISIBLE, mIconView.getVisibility()); }
@Test public void setIcon_shouldSetVisibilityToGone_whenIconIsNull() { IconMixin mixin = new IconMixin(mTemplateLayout, null, 0); mixin.setIcon(null); assertEquals(View.GONE, mIconView.getVisibility()); }