FileDocCategorySizeDatePackage
ListTouchBottomGravityTest.javaAPI DocAndroid 1.5 API3285Wed May 06 22:42:02 BST 2009com.android.frameworktest.listview.touch

ListTouchBottomGravityTest

public class ListTouchBottomGravityTest extends android.test.ActivityInstrumentationTestCase
Touch tests for a list where all of the items fit on the screen, and the list stacks from the bottom.

Fields Summary
private com.android.frameworktest.listview.ListBottomGravity
mActivity
private android.widget.ListView
mListView
Constructors Summary
public ListTouchBottomGravityTest()

        super("com.android.frameworktest", ListBottomGravity.class);
    
Methods Summary
protected voidsetUp()

        super.setUp();

        mActivity = getActivity();
        mListView = getActivity().getListView();
    
public voidtestPreconditions()

        assertNotNull(mActivity);
        assertNotNull(mListView);
        
        // First item should be selected
        assertEquals(mListView.getAdapter().getCount() - 1, mListView.getSelectedItemPosition());
    
public voidtestPullDown()

        View firstChild = mListView.getChildAt(0);
        
        TouchUtils.dragViewToBottom(this, firstChild);
        
        View lastChild = mListView.getChildAt(mListView.getChildCount() - 1);
        
        // Nothing should be selected
        assertEquals("Selection still available after touch", -1, 
                mListView.getSelectedItemPosition());
        
        assertEquals("List is not scrolled to the bottom", mListView.getAdapter().getCount() - 1,
                lastChild.getId());

        assertEquals("Last item is not touching the bottom edge", 
                mListView.getHeight() - mListView.getListPaddingBottom(), lastChild.getBottom());
    
public voidtestPushUp()

        View lastChild = mListView.getChildAt(mListView.getChildCount() - 1);
        
        TouchUtils.dragViewToTop(this, lastChild);

        lastChild = mListView.getChildAt(mListView.getChildCount() - 1);
        
        // Nothing should be selected
        assertEquals("Selection still available after touch", -1, 
                mListView.getSelectedItemPosition());
        
        assertEquals("List is not scrolled to the bottom", mListView.getAdapter().getCount() - 1,
                lastChild.getId());

        assertEquals("Last item is not touching the bottom edge",  
                mListView.getHeight() - mListView.getListPaddingBottom(), lastChild.getBottom());