Code example for ListView

Methods: scrollToTopgetChildAtgetChildCountgetListPaddingTop, getSelectedItemPosition

        assertEquals(mListView.getAdapter().getCount() - 1, mListView.getSelectedItemPosition());
    public void testPullDown() {      
        int originalCount = mListView.getChildCount();
        TouchUtils.scrollToTop(this, mListView);
        // Nothing should be selected 
        assertEquals("Selection still available after touch", -1, 
        View firstChild = mListView.getChildAt(0);
        assertEquals("Item zero not the first child in the list", 0, firstChild.getId());
        assertEquals("Item zero not at the top of the list", mListView.getListPaddingTop(),
        assertTrue(String.format("Too many children created: %d expected no more than %d", 
                mListView.getChildCount(), originalCount + 1), 
                mListView.getChildCount() <= originalCount + 1);
    public void testPushUp() { 
        TouchUtils.scrollToBottom(this, mListView);