FileDocCategorySizeDatePackage
GridTouchStackFromBottomManyTest.javaAPI DocAndroid 1.5 API2974Wed May 06 22:42:02 BST 2009com.android.frameworktest.gridview.touch

GridTouchStackFromBottomManyTest

public class GridTouchStackFromBottomManyTest extends android.test.ActivityInstrumentationTestCase

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

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