Last active
November 6, 2015 20:29
-
-
Save KevinTCoughlin/92f6ce9fecdb7dfff3d1 to your computer and use it in GitHub Desktop.
Custom edit text layout espresso test question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Espresso type into custom edit text view test **/ | |
| Espresso.onView(ViewMatchers.withId(R.id.email)).perform(ViewActions.typeTextIntoFocusedView("[email protected]")); | |
| /** CustomEditTextLayout.java **/ | |
| public class CustomEditTextLayout extends RelativeLayout implements OnClickListener { | |
| private CustomEditText mEditText; | |
| private TextView mErrorText; | |
| public CustomEditTextLayout(final Context context) { | |
| super(context); | |
| init(context, null); | |
| } | |
| public CustomEditTextLayout(final Context context, final AttributeSet attrs) { | |
| super(context, attrs); | |
| init(context, attrs); | |
| } | |
| public CustomEditTextLayout(final Context context, final AttributeSet attrs, final int defStyle) { | |
| super(context, attrs, defStyle); | |
| init(context, attrs); | |
| } | |
| private int getLayoutResource() { | |
| return R.layout.custom_edit_text_layout; | |
| } | |
| private EditText getEditText() { | |
| return (EditText) findViewByChangedId(R.id.inner_edit_text); | |
| } | |
| private void init(final Context context, final AttributeSet attrs); | |
| public CharSequence getText() { | |
| if (mEditText == null) { | |
| return ""; | |
| } | |
| return mEditText.getText(); | |
| } | |
| } | |
| /** activity_layout.xml **/ | |
| <LinearLayout> | |
| <com.sample.widget.CustomEditTextLayout | |
| android:id="@+id/email" /> | |
| </LinearLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment