android - Espresso List header non-clickable -


in functional tests while using espresso want click on view inside header in listview.

according https://code.google.com/p/android-test-kit/wiki/espressosamples#matching_a_view_that_is_a_footer/header_in_a_listview in order have access header in test need this:

listview.addheaderview(headerview, header, true); 

and access this:

public static matcher<object> isheader() {     return allof(is(instanceof(string.class)), matchers.<object>is(testutil.header)); } 

&

ondata(viewmatchers.isheader())         .inadapterview(allof(withid(r.id.list_view), isdisplayed()))         .onchildview(withid(r.id.view_to_click))         .check(matches(isdisplayed()))         .perform(click()); 

however, when that, header clickable.

when use:

listview.addheaderview(headerview, header, false); 

espresso not able access view anymore.

how can access view test without making header view clickable?

so far best workaround have found following:

set data on headerview.

listview.addheaderview(header, testutil.header, true); 

ignore click on headerview.

@override public void onitemclick(final adapterview<?> parent, final view view, final int position, final long id) {     // ignore headerview.     if (position == 0) {         return;     }     ... } 

hide ui change on header click.

android:listselector="@android:color/transparent" 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -