In Espresso, How Can I Test That Textview Shows Only Two Lines
I have a TextView which has the following text: 'line1.\nline2.\n line3'. I set the TextView to be ellipsized at the end and limit to maximum two lines. To test that it shows ellip
Solution 1:
I wrote that matcher to check lines count:
publicstaticTypeSafeMatcher<View> isTextInLines(final int lines) {
returnnewTypeSafeMatcher<View>() {
@OverrideprotectedbooleanmatchesSafely(View item) {
return ((TextView) item).getLineCount() == lines;
}
@OverridepublicvoiddescribeTo(Description description) {
description.appendText("isTextInLines");
}
};
}
Usage:
onView(withId(R.id.activity_main_text_tv))
.check(matches(CustomMatchers.isTextInLines(1)));
Post a Comment for "In Espresso, How Can I Test That Textview Shows Only Two Lines"