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

ListTouchTest

public class ListTouchTest extends android.test.ActivityInstrumentationTestCase
Touch tests for a list where all of the items fit on the screen.

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

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

        super.setUp();

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

        assertNotNull(mActivity);
        assertNotNull(mListView);
        
        // First item should be selected
        assertEquals(0, mListView.getSelectedItemPosition());
    
public voidtestPullDown()

        View firstChild = mListView.getChildAt(0);
        
        TouchUtils.dragViewToBottom(this, firstChild);
        
        // Nothing should be selected
        assertEquals("Selection still available after touch", -1, 
                mListView.getSelectedItemPosition());
        
        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(),
                firstChild.getTop());
    
public voidtestPushUp()

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

        // 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());
        
        assertEquals("Item zero not at the top of the list", mListView.getListPaddingTop(),
                firstChild.getTop());