CvvEditText extends ErrorEditText implements TextWatcher { public void setCardType(CardType cardType) { mCardType = cardType; InputFilter[] filters = { new LengthFilter(cardType.getSecurityCodeLength()) }; setFilters(filters); setContentDescription(getContext().getString(cardType.getSecurityCodeName())); setFieldHint(cardType.getSecurityCodeName()); invalidate(); } CvvEditText(Context context);  CvvEditText(Context context, AttributeSet attrs);  CvvEditText(Context context, AttributeSet attrs, int defStyle); void setCardType(CardType cardType); void setMask(boolean mask); @Override void afterTextChanged(Editable editable); @Override boolean isValid(); @Override String getErrorMessage(); @Override void beforeTextChanged(CharSequence s, int start, int count, int after);  }
@Test public void customLimits() { for (CardType type : CardType.values()) { mView.setCardType(type); if (type == CardType.AMEX) { type("1234").assertTextIs("1234"); type("5").assertTextIs("1234"); } else { type("123").assertTextIs("123"); type("4").assertTextIs("123"); } mView.getText().clear(); } }
@Test public void hintChangesForCardType() { for (CardType cardType : CardType.values()) { mView.setCardType(cardType); assertEquals(RuntimeEnvironment.application.getString(cardType.getSecurityCodeName()), mView.getTextInputLayoutParent().getHint()); assertEquals(RuntimeEnvironment.application.getString(cardType.getSecurityCodeName()), mView.getContentDescription()); } }