Code example for ScrollView

Methods: getMaxScrollAmount, getHeight, getScrollY

0
 
        getInstrumentation().waitForIdleSync();
 
        assertTrue("bottombutton.isFocused", mBottomButton.isFocused());
        final int maxScroll = getActivity().getLinearLayout().getHeight()
                - mScrollView.getHeight();
        assertEquals("should be fully scrolled to bottom",
                maxScroll,
                mScrollView.getScrollY());
 
        sendKeys(KeyEvent.KEYCODE_DPAD_UP);
 
        assertEquals("scroll view should have scrolled by the max amount for one "
                + "arrow navigation", 
                maxScroll - mScrollView.getMaxScrollAmount(),
                mScrollView.getScrollY());
 
        assertTrue("bottom button should be off screen",
                getTopWithinScrollView(mBottomButton) > mScrollView.getScrollY() + mScrollView.getHeight());
 
        assertFalse("bottom button should have lost focus",
                mBottomButton.isFocused());
 
        assertTrue("scroll view should be focused", mScrollView.isFocused());