FileDocCategorySizeDatePackage
TallTextAboveButtonTest.javaAPI DocAndroid 1.5 API3016Wed May 06 22:42:02 BST 2009com.android.frameworktest.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.frameworktest", 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());