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

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