Skip to content

Instantly share code, notes, and snippets.

@zaki50
Last active September 7, 2015 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaki50/03c6b3f213881e6c5e16 to your computer and use it in GitHub Desktop.
Save zaki50/03c6b3f213881e6c5e16 to your computer and use it in GitHub Desktop.
Data Binding を使うと Espresso 標準の withText(String) の Matcher が使い物にならなくなるので Data Binding 使用時にも使える withText(String) の実装。Data Binding は Stringではない CharSequence をセットするのが原因。
private static Matcher<View> withText(final String expectedText) {
return new BoundedMatcher<View, TextView>(TextView.class) {
@Override
public void describeTo(Description description) {
description.appendText("with string : ");
description.appendValue(expectedText);
}
@Override
public boolean matchesSafely(TextView textView) {
return null != expectedText && expectedText.equals(textView.getText().toString());
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment