I am trying to get a number of lines, in Espresso, of the TextView from one of the elements from recycler view. This is my macher for it:
public static TypeSafeMatcher<RecyclerView.ViewHolder> isTextInLines(final int lines) {
return new TypeSafeMatcher<RecyclerView.ViewHolder>() {
@Override
protected boolean matchesSafely(RecyclerView.ViewHolder item) {
Log.e("Lines", ((TextView) item.itemView.findViewById(R.id.textTextView)).getLineCount() + "");
return ((TextView) item.itemView.findViewById(R.id.textTextView)).getLineCount() == lines;
}
@Override
public void describeTo(Description description) {
description.appendText("isTextInLines");
}
};
}
The problem is that it prints that all of them has 0 lines. As I understand the problem might be that it is still in drawing phase according to this:
https://stackoverflow.com/a/24035591/6470918
Any idea how to solve it?
PS. This is the code which uses this matcher:
onView(withId(R.id.recyclerView))
.perform(scrollToHolder(isTextInLines(12)));