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

ListOfTouchablesTest

public class ListOfTouchablesTest 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.ListOfTouchables
mActivity
private android.widget.ListView
mListView
Constructors Summary
public ListOfTouchablesTest()

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

        super.setUp();

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

        View lastChild = mListView.getChildAt(mListView.getChildCount() - 1);
        
        int lastTop = lastChild.getTop();
        
        int distance = TouchUtils.dragViewToY(this, lastChild, 
                Gravity.TOP | Gravity.LEFT, mListView.getTop());
        
        assertEquals("View scrolled to wrong position", 
                lastTop - (distance - ViewConfiguration.getTouchSlop() - 1), lastChild.getTop());
    
public voidtestPreconditions()

        assertNotNull(mActivity);
        assertNotNull(mListView);
    
public voidtestShortScroll()

        View firstChild = mListView.getChildAt(0);
        View lastChild = mListView.getChildAt(mListView.getChildCount() - 1);
        
        int firstTop = firstChild.getTop();
        
        TouchUtils.dragViewBy(this, lastChild, Gravity.TOP | Gravity.LEFT,
                0, -(ViewConfiguration.getTouchSlop() + 1 + 10));
        
        View newFirstChild = mListView.getChildAt(0);
        
        assertEquals("View scrolled too early", firstTop, newFirstChild.getTop() + 10);
        assertEquals("Wrong view in first position", 0, newFirstChild.getId());