FileDocCategorySizeDatePackage
TallTextAboveButtonTest.javaAPI DocAndroid 5.1 API3001Thu Mar 12 22:22:12 GMT 2015android.widget.scroll.arrowscroll

TallTextAboveButtonTest

public class TallTextAboveButtonTest extends android.test.ActivityInstrumentationTestCase

Fields Summary
private android.widget.ScrollView
mScrollView
private android.widget.TextView
mTopText
private android.widget.TextView
mBottomButton
Constructors Summary
public TallTextAboveButtonTest()

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

        super.setUp();

        mScrollView = getActivity().getScrollView();
        mTopText = getActivity().getContentChildAt(0);
        mBottomButton = getActivity().getContentChildAt(1);
    
public voidtestGainFocusAsScrolledOntoScreen()

        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);

        assertTrue("button should have scrolled onto screen",
                mBottomButton.getBottom() >= mScrollView.getBottom());
        assertTrue("button should have gained focus as it was scrolled completely "
                + "into view", mBottomButton.isFocused());

        sendKeys(KeyEvent.KEYCODE_DPAD_UP);
        assertTrue("scroll view should have focus, but " + getActivity().getScrollView().findFocus() + " does instead",
                getActivity().getScrollView().isFocused());
    
public voidtestPreconditions()

        assertTrue("top text should be larger than screen",
                mTopText.getHeight() > mScrollView.getHeight());
        assertTrue("scroll view should have focus (because nothing else focusable "
                + "is on screen), but " + getActivity().getScrollView().findFocus() + " does instead",
                getActivity().getScrollView().isFocused());
    
public voidtestScrollingButtonOffScreenLosesFocus()

        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        assertTrue("button should have focus", mBottomButton.isFocused());
        sendKeys(KeyEvent.KEYCODE_DPAD_UP);
        assertTrue("scroll view should have focus, but " + getActivity().getScrollView().findFocus() + " does instead",
                getActivity().getScrollView().isFocused());