Code example for Button

Methods: isFocused

0
 
        assertTrue("top button should be off screen",
                getBottomWithinScrollView(mTopButton) < mScrollView.getScrollY());
 
        assertFalse("top button should have lost focus",
                mTopButton.isFocused());
 
        assertTrue("scroll view should be focused", mScrollView.isFocused());
    } 
 
    @MediumTest 
    public void testScrollDownToBottomButton() throws Exception { 
        final int screenBottom = mScrollView.getScrollY() + mScrollView.getHeight();
        final int numDownsToButtonButton =
                ((getBottomWithinScrollView(mBottomButton) - screenBottom)) / mScrollView.getMaxScrollAmount() + 1;
 
        for (int i = 0; i < numDownsToButtonButton; i++) {
            sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        } 
 
        assertTrue("bottombutton.isFocused", mBottomButton.isFocused());