FileDocCategorySizeDatePackage
GridTouchStackFromBottomTest.javaAPI DocAndroid 5.1 API4337Thu Mar 12 22:22:12 GMT 2015android.widget.gridview.touch

GridTouchStackFromBottomTest

public class GridTouchStackFromBottomTest extends android.test.ActivityInstrumentationTestCase

Fields Summary
private android.widget.gridview.GridStackFromBottom
mActivity
private android.widget.GridView
mGridView
Constructors Summary
public GridTouchStackFromBottomTest()

        super("com.android.frameworks.coretests", GridStackFromBottom.class);
    
Methods Summary
protected voidsetUp()

        super.setUp();

        mActivity = getActivity();
        mGridView = getActivity().getGridView();
    
public voidtestPreconditions()

        assertNotNull(mActivity);
        assertNotNull(mGridView);

        // First item should be selected
        assertEquals(mGridView.getAdapter().getCount() - 1, mGridView.getSelectedItemPosition());
    
public voidtestPullDown()

        TouchUtils.scrollToTop(this, mGridView);

        // Nothing should be selected
        assertEquals("Selection still available after touch", -1,
                mGridView.getSelectedItemPosition());

        View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1);

        assertEquals("Last item not the last child in the grid",
                mGridView.getAdapter().getCount() - 1, lastChild.getId());

        assertEquals("Last item not at the bottom of the grid",
                mGridView.getHeight() - mGridView.getListPaddingBottom(), lastChild.getBottom());
    
public voidtestPullDownFast()

        TouchUtils.dragViewToBottom(this, mGridView.getChildAt(0), 2);

        // Nothing should be selected
        assertEquals("Selection still available after touch", -1,
                mGridView.getSelectedItemPosition());

        View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1);

        assertEquals("Last item not the last child in the grid",
                mGridView.getAdapter().getCount() - 1, lastChild.getId());

        assertEquals("Last item not at the bottom of the grid",
                mGridView.getHeight() - mGridView.getListPaddingBottom(), lastChild.getBottom());
    
public voidtestPushUp()

        TouchUtils.scrollToBottom(this, mGridView);

        // Nothing should be selected
        assertEquals("Selection still available after touch", -1,
                mGridView.getSelectedItemPosition());

        View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1);

        assertEquals("Last item not the last child in the grid",
                mGridView.getAdapter().getCount() - 1, lastChild.getId());

        assertEquals("Last item not at the bottom of the grid",
                mGridView.getHeight() - mGridView.getListPaddingBottom(), lastChild.getBottom());
    
public voidtestPushUpFast()

        TouchUtils.dragViewToTop(this, mGridView.getChildAt(mGridView.getChildCount() - 1), 2);

        // Nothing should be selected
        assertEquals("Selection still available after touch", -1,
                mGridView.getSelectedItemPosition());

        View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1);

        assertEquals("Last item not the last child in the grid",
                mGridView.getAdapter().getCount() - 1, lastChild.getId());

        assertEquals("Last item not at the bottom of the grid",
                mGridView.getHeight() - mGridView.getListPaddingBottom(), lastChild.getBottom());