FileDocCategorySizeDatePackage
ListWithNoFadingEdgeTest.javaAPI DocAndroid 5.1 API2685Thu Mar 12 22:22:12 GMT 2015android.widget.listview.arrowscroll

ListWithNoFadingEdgeTest

public class ListWithNoFadingEdgeTest extends android.test.ActivityInstrumentationTestCase

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

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