FileDocCategorySizeDatePackage
ListTouchTest.javaAPI DocAndroid 5.1 API2942Thu Mar 12 22:22:12 GMT 2015android.widget.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 android.widget.listview.ListTopGravity
mActivity
private android.widget.ListView
mListView
Constructors Summary
public ListTouchTest()

        super("com.android.frameworks.coretests", 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());