FileDocCategorySizeDatePackage
ListInterleaveFocusablesTest.javaAPI DocAndroid 5.1 API4080Thu Mar 12 22:22:12 GMT 2015android.widget.listview.arrowscroll

ListInterleaveFocusablesTest

public class ListInterleaveFocusablesTest extends android.test.ActivityInstrumentationTestCase2

Fields Summary
private android.widget.ListView
mListView
private android.util.ListUtil
mListUtil
Constructors Summary
public ListInterleaveFocusablesTest()

        super(ListInterleaveFocusables.class);
    
Methods Summary
public voidassertSelectedViewFocus(boolean isFocused)

        final View view = mListView.getSelectedView();
        assertEquals("selected view focused", isFocused, view.isFocused());
        assertEquals("selected position's isSelected should be the inverse "
                + "of it having focus", !isFocused, view.isSelected());
    
protected voidsetUp()

        super.setUp();

        mListView = getActivity().getListView();
        mListUtil = new ListUtil(mListView, getInstrumentation());
    
public voidtestGoingDownFromFocusableToUnfocusableWhenFocusableIsBelow()
Go down from a focusable when there is a focusable below, but it is more than one item away; make sure it won't give that item focus because it is too far away.

        mListUtil.setSelectedPosition(3);
        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        assertEquals("selected item position", 4, mListView.getSelectedItemPosition());
        assertSelectedViewFocus(false);
    
public voidtestGoingDownFromUnFocusableSelectedToFocusableWithOtherFocusableAbove()

        mListUtil.setSelectedPosition(2);
        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        assertEquals("selected item position", 3, mListView.getSelectedItemPosition());
        assertSelectedViewFocus(true);
    
public voidtestGoingFromUnFocusableSelectedToFocusable()

        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);

        assertEquals("selected item position", 1, mListView.getSelectedItemPosition());
        assertSelectedViewFocus(true);
    
public voidtestGoingUpFromFocusableToUnfocusableWhenFocusableIsBelow()

        mListUtil.setSelectedPosition(6);
        sendKeys(KeyEvent.KEYCODE_DPAD_UP);
        assertEquals("selected item position", 5, mListView.getSelectedItemPosition());
        assertSelectedViewFocus(false);
    
public voidtestGoingUpFromUnFocusableSelectedToFocusableWithOtherFocusableAbove()

        mListUtil.setSelectedPosition(2);
        sendKeys(KeyEvent.KEYCODE_DPAD_UP);
        assertEquals("selected item position", 1, mListView.getSelectedItemPosition());
        assertSelectedViewFocus(true);
    
public voidtestPreconditions()

        assertEquals(7, mListView.getChildCount());
        assertTrue(mListView.getChildAt(1).isFocusable());
        assertTrue(mListView.getChildAt(3).isFocusable());
        assertTrue(mListView.getChildAt(6).isFocusable());