android - simple way to convert View to Matcher<View> in espresso -


for ins, following example, hope first set listener , them work espresso, how implement tomatcher

@test     public void testspinner2() throws exception {         r.launchactivity(null);         spinner sp = (spinner) r.getactivity().findviewbyid(r.id.spinner);         sp.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                //do smth             }         });          onview(tomatcher(sp));     } 

i guess following code can work:

public static matcher<view> tomatcher(final view v) {         return new typesafematcher<view>() {             @override             protected boolean matchessafely(view item) {                 return item == v;             }              @override              public void describeto(description description) {                 description.appendtext(v.tostring());             }         };     } 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -