Closed Bug 798683 Opened 9 years ago Closed 9 years ago
Child Count() calls on List View
In several places in our code (especially robocop tests), we call getChildCount() on a ListView to determine how many children it has. Problem is, this method is from ViewGroup and returns the number of items in the View, not the number of items in the entire list. ListViews destroy and reuse views as they come into view, so getChildCount() is really just the number of *visible* views. To count the number of children from the adapter, we should consider changing list.getChildCount() to list.getAdapter().getCount() where applicable. I ran into this when running testAllPagesView on my Galaxy S. With the keyboard up, only 4 entries in the AwesomeScreen are visible, so this assertion was failing: http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/tests/testAllPagesTab.java.in#61
You're right. I missed that in my patch review. Wes wrote the tests, CC'ing him.
A number of our tests are probably failing because of this bug. I'll see if I can fix them.
Assignee: nobody → bnicholson
Is this what you had in mind? There are a few remaining getChildCount() calls, but on ViewGroups. https://tbpl.mozilla.org/?tree=Try&rev=df4b8aa6e0f5
Assignee: bnicholson → gbrown
Status: NEW → ASSIGNED
Attachment #717553 - Flags: review?(bnicholson)
Comment on attachment 717553 [details] [diff] [review] replace getChildCount() calls on ListView Yeah, looks good to me. Hopefully this will help.
Attachment #717553 - Flags: review?(bnicholson) → review+
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 22
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.