FileDocCategorySizeDatePackage
ListRetainsFocusAcrossLayoutsTest.javaAPI DocAndroid 5.1 API3051Thu Mar 12 22:22:12 GMT 2015android.widget.listview

ListRetainsFocusAcrossLayoutsTest

public class ListRetainsFocusAcrossLayoutsTest extends android.test.ActivityInstrumentationTestCase

Fields Summary
Constructors Summary
public ListRetainsFocusAcrossLayoutsTest()

        super("com.android.frameworks.coretests", ListItemFocusablesClose.class);
    
Methods Summary
private voidrequestLayoutOnList()

        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                getActivity().getListView().requestLayout();
            }
        });
    
public voidtestBottomButtonOfSecondPositionRetainsFocusAfterLayout()

        sendRepeatedKeys(3, KeyEvent.KEYCODE_DPAD_DOWN);

        assertTrue("bottom botton at position 1 should be focused",
                getActivity().getChildOfItem(1, 2).isFocused());

        requestLayoutOnList();
        getInstrumentation().waitForIdleSync();

        assertTrue("bottom botton at position 1 should be focused after layout",
                getActivity().getChildOfItem(1, 2).isFocused());
    
public voidtestBottomButtonRetainsFocusAfterLayout()


        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);

        assertTrue("bottom botton at position 0 should be focused",
                getActivity().getChildOfItem(0, 2).isFocused());

        requestLayoutOnList();
        getInstrumentation().waitForIdleSync();

        assertTrue("bottom botton at position 0 should be focused after layout",
                getActivity().getChildOfItem(0, 2).isFocused());
    
public voidtestPreconditions()

        assertTrue("top button at position 0 should be focused",
                getActivity().getChildOfItem(0, 0).isFocused());
    
public voidtestTopButtonOfSecondPositionRetainsFocusAfterLayout()

        sendRepeatedKeys(2, KeyEvent.KEYCODE_DPAD_DOWN);

        assertTrue("top botton at position 1 should be focused",
                getActivity().getChildOfItem(1, 0).isFocused());

        requestLayoutOnList();
        getInstrumentation().waitForIdleSync();

        assertTrue("top botton at position 1 should be focused after layout",
                getActivity().getChildOfItem(1, 0).isFocused());