PasswordEditText extends AppCompatEditText { public void setHiddenDrawable(Drawable hiddenDrawable) { hiddenIcon = hiddenDrawable; setPasswordVisibility(); } PasswordEditText(Context context);  PasswordEditText(Context context, AttributeSet attrs);  PasswordEditText(Context context, AttributeSet attrs, int defStyleAttr); @Override void setInputType(int type); @Override boolean onTouchEvent(MotionEvent event); boolean isPasswordVisible(); void setPasswordVisible(boolean visible); void togglePasswordVisibility(); @ColorInt int getTintColor(); void setTintColor(@ColorInt int tintColor); void setTintColorRes(@ColorRes int tintColorRes); void setShownDrawable(Drawable shownDrawable); void setShownDrawable(@DrawableRes int shownDrawableRes); void setHiddenDrawable(Drawable hiddenDrawable); void setHiddenDrawable(@DrawableRes int hiddenDrawableRes); void setToggleType(@ToggleType int toggleType); static final int TOGGLE_OPACITY; static final int TOGGLE_STRIKETHROUGH; }
@Test public void givenDrawable_whenSetHiddenDrawable_thenToggleHiddenDrawableUpdated() { passwordView.setHiddenDrawable(getDrawable(R.drawable.ic_avatar_circle)); assertThat(passwordView) .hasToggle(R.drawable.ic_avatar_circle); }
@Test public void givenDrawableResource_whenSetHiddenDrawable_thenToggleHiddenDrawableUpdated() { passwordView.setHiddenDrawable(R.drawable.ic_avatar_circle); assertThat(passwordView) .hasToggle(R.drawable.ic_avatar_circle); }