FileDocCategorySizeDatePackage
ListHorizontalFocusWithinItemWinsTest.javaAPI DocAndroid 1.5 API2913Wed May 06 22:42:02 BST 2009com.android.frameworktest.listview.focus

ListHorizontalFocusWithinItemWinsTest

public class ListHorizontalFocusWithinItemWinsTest extends android.test.ActivityInstrumentationTestCase

Fields Summary
private android.widget.ListView
mListView
private android.widget.Button
mTopLeftButton
private android.widget.Button
mTopRightButton
private android.widget.Button
mBottomMiddleButton
Constructors Summary
public ListHorizontalFocusWithinItemWinsTest()

        super("com.android.frameworktest", ListHorizontalFocusWithinItemWins.class);
    
Methods Summary
protected voidsetUp()

        super.setUp();

        mListView = getActivity().getListView();
        mTopLeftButton = getActivity().getTopLeftButton();
        mTopRightButton = getActivity().getTopRightButton();
        mBottomMiddleButton = getActivity().getBottomMiddleButton();
    
public voidtestOptionWithinItemTrumpsGlobal()

        sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT);

        assertEquals("list position", 0, mListView.getSelectedItemPosition());
        assertTrue("mTopRightButton.isFocused()", mTopRightButton.isFocused());

        sendKeys(KeyEvent.KEYCODE_DPAD_LEFT);
        assertEquals("list position", 0, mListView.getSelectedItemPosition());
        assertTrue("mTopLeftButton.isFocused()", mTopLeftButton.isFocused());
    
public voidtestPreconditions()

        assertEquals("list position", 0, mListView.getSelectedItemPosition());
        assertTrue("mTopLeftButton.isFocused()", mTopLeftButton.isFocused());
        assertEquals("global focus search to right from top left is bottom middle",
                mBottomMiddleButton,
                FocusFinder.getInstance().findNextFocus(mListView, mTopLeftButton, View.FOCUS_RIGHT));
        assertEquals("global focus search to left from top right is bottom middle",
                mBottomMiddleButton,
                FocusFinder.getInstance().findNextFocus(mListView, mTopRightButton, View.FOCUS_LEFT));