@MediumTest public void testMoveSelectionDownRequiringScroll() { int lastItemIndex = mListView.getChildCount() - 1; for (int i = 0; i < lastItemIndex; i++) { sendKeys(KeyEvent.KEYCODE_DPAD_DOWN); } getInstrumentation().waitForIdleSync(); assertEquals("list position", lastItemIndex, mListView.getSelectedItemPosition()); assertEquals("expanded height", mExpandedHeight, mListView.getSelectedView().getHeight()); assertEquals( "should be above bottom fading edge", mListBottom - mListView.getVerticalFadingEdgeLength(), mListView.getSelectedView().getBottom()); }
@LargeTest public void testMoveSelectionUpRequiringScroll() { int childrenPerScreen = mListView.getChildCount(); // go down past last child on screen for (int i = 0; i < childrenPerScreen; i++) { sendKeys(KeyEvent.KEYCODE_DPAD_DOWN); } // go back up to second to last for (int i = 0; i < childrenPerScreen - 1; i++) { sendKeys(KeyEvent.KEYCODE_DPAD_UP); } getInstrumentation().waitForIdleSync(); assertEquals("list position", 1, mListView.getSelectedItemPosition()); assertEquals("expanded height", mExpandedHeight, mListView.getSelectedView().getHeight()); assertEquals( "should be below top fading edge", mListTop + mListView.getVerticalFadingEdgeLength(), mListView.getSelectedView().getTop()); }