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

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