Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. Matcher<View> hasValueEqualTo(final String content) {
  2. return new TypeSafeMatcher<View>() {
  3. @Override
  4. public void describeTo(Description description) {
  5. description.appendText("Has EditText/TextView the value: " + content);
  6. }
  7.  
  8. @Override
  9. public boolean matchesSafely(View view) {
  10. if (!(view instanceof TextView) && !(view instanceof EditText)) {
  11. return false;
  12. }
  13. if (view != null) {
  14. String text;
  15. if (view instanceof TextView) {
  16. text = ((TextView) view).getText().toString();
  17. } else {
  18. text = ((EditText) view).getText().toString();
  19. }
  20.  
  21. return (text.equalsIgnoreCase(content));
  22. }
  23. return false;
  24. }
  25. };
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement