### Question:
WarnableTextInputValidator extends SimpleTextWatcher implements View.OnFocusChangeListener, View.OnTouchListener { public boolean performClick() { boolean blockTouchEvent = doValidate(false) == ReturnState.STATE_ERROR; return blockTouchEvent; } WarnableTextInputValidator(
      Context context,
      EditText editText,
      WarnableTextInputLayout textInputLayout,
      View positiveButton,
      OnTextValidate validator); @Override void onFocusChange(View v, boolean hasFocus); @Override boolean onTouch(View v, MotionEvent event); boolean performClick(); @Override void afterTextChanged(Editable s);  }### Answer:
@Test public void testValidate() { EditText textfield = new AppCompatEditText(context); WarnableTextInputLayout layout = new WarnableTextInputLayout(context, Robolectric.buildAttributeSet().build()); Button button = new AppCompatButton(context); WarnableTextInputValidator.OnTextValidate validator = text -> ("Pass".equals(text)) ? new WarnableTextInputValidator.ReturnState( WarnableTextInputValidator.ReturnState.STATE_NORMAL, R.string.ok) : new WarnableTextInputValidator.ReturnState( WarnableTextInputValidator.ReturnState.STATE_ERROR, R.string.error); WarnableTextInputValidator target = new WarnableTextInputValidator( ApplicationProvider.getApplicationContext(), textfield, layout, button, validator); textfield.setText(""); target.performClick(); assertFalse(button.isEnabled()); assertEquals(context.getString(R.string.error), layout.getError()); textfield.setText("pass"); target.performClick(); assertFalse(button.isEnabled()); assertEquals(context.getString(R.string.error), layout.getError()); textfield.setText("Pass"); target.performClick(); assertTrue(button.isEnabled()); assertNull(layout.getError()); }