ErrorEditText extends TextInputEditText { public void setError(@Nullable String errorMessage) { mError = !TextUtils.isEmpty(errorMessage); TextInputLayout textInputLayout = getTextInputLayoutParent(); if (textInputLayout != null) { textInputLayout.setErrorEnabled(!TextUtils.isEmpty(errorMessage)); textInputLayout.setError(errorMessage); } if (mErrorAnimator != null && mError) { startAnimation(mErrorAnimator); VibrationHelper.vibrate(getContext(), 10); } } ErrorEditText(Context context);  ErrorEditText(Context context, AttributeSet attrs);  ErrorEditText(Context context, AttributeSet attrs, int defStyle); @Override void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter); void setFieldHint(int hint); void setFieldHint(String hint); @SuppressWarnings("WrongConstant") View focusNextView(); void setOptional(boolean optional); boolean isOptional(); boolean isError(); void setError(@Nullable String errorMessage); boolean isValid(); String getErrorMessage(); void validate(); void closeSoftKeyboard(); @Nullable TextInputLayout getTextInputLayoutParent();  }
@Test public void setError_setsErrorWhenParentViewIsATextInputLayout() { mView = (CardEditText) Robolectric.setupActivity(TestActivity.class) .findViewById(R.id.bt_card_form_card_number); mView.setError("Error"); assertEquals("Error", ((TextInputLayout) mView.getParent().getParent()).getError()); }