FileDocCategorySizeDatePackage
ListWithNoFadingEdgeTest.javaAPI DocAndroid 1.5 API2700Wed May 06 22:42:02 BST 2009com.android.frameworktest.listview.arrowscroll

ListWithNoFadingEdgeTest

public class ListWithNoFadingEdgeTest extends android.test.ActivityInstrumentationTestCase

Fields Summary
private android.widget.ListView
mListView
Constructors Summary
public ListWithNoFadingEdgeTest()

        super("com.android.frameworktest", ListWithNoFadingEdge.class);
    
Methods Summary
protected voidsetUp()

        super.setUp();

        mListView = getActivity().getListView();
    
public voidtestPreconditions()

        assertNotNull(mListView);
        assertEquals("listview vertical fading edge", 0, mListView.getVerticalFadingEdgeLength());
        assertTrue("expecting that not all views fit on screen",
                mListView.getChildCount() < mListView.getCount());
    
public voidtestScrollDownToBottom()

        final int numItems = mListView.getCount();

        for (int i = 0; i < numItems; i++) {
            assertEquals("selected position", i, mListView.getSelectedItemPosition());
            sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        }
        assertEquals("selected position", numItems - 1, mListView.getSelectedItemPosition());            
    
public voidtestScrollFromBottomToTop()

        final int numItems = mListView.getCount();

        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                mListView.setSelection(numItems - 1);
            }
        });
        getInstrumentation().waitForIdleSync();

        for (int i = numItems - 1; i >=0; i--) {
            assertEquals(i, mListView.getSelectedItemPosition());
            sendKeys(KeyEvent.KEYCODE_DPAD_UP);
        }

        assertEquals("selected position", 0, mListView.getSelectedItemPosition());