FileDocCategorySizeDatePackage
GridTouchStackFromBottomManyTest.javaAPI DocAndroid 5.1 API2958Thu Mar 12 22:22:12 GMT 2015android.widget.gridview.touch

GridTouchStackFromBottomManyTest

public class GridTouchStackFromBottomManyTest extends android.test.ActivityInstrumentationTestCase

Fields Summary
private android.widget.gridview.GridStackFromBottomMany
mActivity
private android.widget.GridView
mGridView
Constructors Summary
public GridTouchStackFromBottomManyTest()

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

        super.setUp();

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

        assertNotNull(mActivity);
        assertNotNull(mGridView);

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

        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("Grid is not scrolled to the bottom", mGridView.getAdapter().getCount() - 1,
                lastChild.getId());

        assertEquals("Last item is not touching the bottom edge",
                mGridView.getHeight() - mGridView.getListPaddingBottom(), lastChild.getBottom());
    
public voidtestScrollToTop()

        View firstChild;
        TouchUtils.scrollToTop(this, mGridView);

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

        firstChild = mGridView.getChildAt(0);

        assertEquals("Item zero not the first child in the grid", 0, firstChild.getId());

        assertEquals("Item zero not at the top of the grid",
                mGridView.getListPaddingTop(), firstChild.getTop());