SignInButton extends FrameLayout { @VisibleForTesting Drawable getIcon() { return ((ImageView) findViewById(R.id.lib_button_sign_in_icon)).getDrawable(); } SignInButton(Context context);  SignInButton(Context context, AttributeSet attrs);  SignInButton(Context context, AttributeSet attrs, int defStyleAttr); void setText(@StringRes int text); void setTextSize(@DimenRes int textSize); void setColor(@ColorRes int color); void setIcon(@DrawableRes int icon); void setTextColor(@ColorRes int textColor);  }
@Test public void shouldObtainIconFromAttrs() { AttributeSet attributeSet = AttributeSetBuilder.from(context) .addAttribute("lib_signInIcon", "@drawable/lib_ic_sign_in_google") .build(); SignInButton signInButton = new SignInButton(context, attributeSet); assertThat(shadowOf(signInButton.getIcon()).getCreatedFromResId()).isEqualTo( R.drawable.lib_ic_sign_in_google); }