suli1 / android-test-kit

Automatically exported from code.google.com/p/android-test-kit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onData check for non-selectable list headers doesn't work on API 22

GoogleCodeExporter opened this issue · comments

Using Espresso 2.2

What steps will reproduce the problem?
1. Create a ListView with lots of items and add Headers via addHeaderView with 
isSelectable == false
2. On a very short screen API 22 emulator, Use espresso to check something much 
lower in the list
3. Then use onData to check something in the header view.

In step 3, the header view will scroll into position and then right back out of 
position.

I think the problem is in 
AdapterViewProtocols.StandardAdapterViewProtocol#isDataRenderedWithinAdapterView

it contains this code:

      if (inView) {
        // stops animations - locks in our x/y location.
        adapterView.setSelection(dataPosition);
      }

but adapterView.setSelection(dataPosition) goes to the first *selectable* item, 
but our header view is not selectable.

in API 22, ListView#lookForSelectablePosition does this:

  while (position < count && !adapter.isEnabled(position)) {
                    position++;
      }

HeaderViewListAdapter#isEnabled does this:

 return mHeaderViewInfos.get(position).isSelectable;


Actual: 

Can't use onData to check stuff on non-selectable ListVIew headers.

Expected: 
*Can* check stuff on non-selectable ListVIew headers ( i.e. check contents, etc 
)


NOTE: this might also happen in other API versions.

Original issue reported on code.google.com by YogurtE...@gmail.com on 28 Jul 2015 at 11:23