android - In espresso, how can I test that textview shows only two lines -


i have textview has text content "line1.\nline2.\n line3" have textview show ellipsized @ end , limit maximum 2 lines. test shows ellipsize, have code

    public static final string test_body = "line1.\nline2.\nline3.";     //a setup method called mail_cell_body_preview_field set above test_body     //...       public void testmessagesnippetisvisible() {                 onview(withid(r.id.mail_cell_body_preview_field)).check(matches(isdisplayed()));         onview(withid(r.id.mail_cell_body_preview_field)).check(matches(hasellipsizedtext()));         onview(withid(r.id.mail_cell_body_preview_field)).check(matches(withtext(test_body))); //add statement verify line3 not visible in ui            } 

how can write test case verify in ui, third line not visible?

onview(withid(r.id.mail_cell_body_preview_field)).check(matches( ......compare length this...); 

use text comparison text length. if have 2 lines text length more.


Comments