FileDocCategorySizeDatePackage
ListOfShortTallShortTest.javaAPI DocAndroid 5.1 API2966Thu Mar 12 22:22:12 GMT 2015android.widget.listview.arrowscroll

ListOfShortTallShortTest

public class ListOfShortTallShortTest extends android.test.ActivityInstrumentationTestCase

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

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

        super.setUp();

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

        int topBeforeMove = mListView.getChildAt(1).getTop();
        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);

        assertEquals("selection should have moved to tall item below",
                1, mListView.getSelectedItemPosition());
        assertEquals("should not have scrolled; top should be the same.",
                topBeforeMove,
                mListView.getSelectedView().getTop());
    
public voidtestGoUpFromShortToTall()

        int maxMoves = 8;
        while (mListView.getSelectedItemPosition() != 2 && maxMoves > 0) {
            sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        }
        assertEquals("couldn't get to 3rd item",
                2,
                mListView.getSelectedItemPosition());

        assertEquals("should only be two items on screen",
                2, mListView.getChildCount());
        assertEquals("selected item should be last item on screen",
                mListView.getChildAt(1), mListView.getSelectedView());

        final int bottomBeforeMove = mListView.getChildAt(0).getBottom();
        sendKeys(KeyEvent.KEYCODE_DPAD_UP);
        assertEquals("should have moved selection to tall item above",
                1, mListView.getSelectedItemPosition());
        assertEquals("should not have scrolled, top should be the same",
                bottomBeforeMove,
                mListView.getChildAt(0).getBottom());
    
public voidtestPreconditions()

        assertTrue("second item should be taller than screen",
                mListView.getChildAt(1).getHeight() > mListView.getHeight());