Code example for ListView

Methods: getAdapter, getSelectedItemPosition

0
    public void testPreconditions() { 
        assertNotNull(mActivity);
        assertNotNull(mListView);
         
        // Last item should be selected 
        assertEquals(mListView.getAdapter().getCount() - 1, mListView.getSelectedItemPosition());
    } 
     
    @LargeTest 
    public void testPullDown() {      
        int originalCount = mListView.getChildCount();
         
        TouchUtils.scrollToTop(this, mListView);
         
        // Nothing should be selected 
        assertEquals("Selection still available after touch", -1, 
                mListView.getSelectedItemPosition());
         
        View firstChild = mListView.getChildAt(0);
         
        assertEquals("Item zero not the first child in the list", 0, firstChild.getId());