FileDocCategorySizeDatePackage
DescendantFocusabilityTest.javaAPI DocAndroid 1.5 API4755Wed May 06 22:42:02 BST 2009com.android.frameworktest.focus

DescendantFocusabilityTest

public class DescendantFocusabilityTest extends android.test.ActivityInstrumentationTestCase

Fields Summary
private com.android.frameworktest.focus.DescendantFocusability
a
Constructors Summary
public DescendantFocusabilityTest()

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

        super.setUp();
        a = getActivity();

    
public voidtestAfterDescendants()

        a.afterDescendants.setFocusable(true);

        assertTrue(a.afterDescendants.requestFocus());
        assertTrue(a.afterDescendantsChild.isFocused());

        a.afterDescendants.setFocusable(false);
        assertTrue(a.afterDescendants.requestFocus());
        assertTrue(a.afterDescendantsChild.isFocused());
    
public voidtestAfterDescendantsEnterTouchMode()

        a.runOnUiThread(new Runnable() {
            public void run() {
                a.afterDescendants.setFocusableInTouchMode(true);
                a.afterDescendantsChild.requestFocus();
            }
        });
        getInstrumentation().waitForIdleSync();
        assertTrue(a.afterDescendantsChild.isFocused());
        assertFalse(a.afterDescendantsChild.isInTouchMode());

        TouchUtils.clickView(this, a.afterDescendantsChild);
        assertTrue(a.afterDescendantsChild.isInTouchMode());
        assertTrue(a.afterDescendants.isFocused());
    
public voidtestBeforeDescendants()

        a.beforeDescendants.setFocusable(true);

        assertTrue(a.beforeDescendants.requestFocus());
        assertTrue(a.beforeDescendants.isFocused());

        a.beforeDescendants.setFocusable(false);
        a.beforeDescendants.requestFocus();
        assertTrue(a.beforeDescendantsChild.isFocused());
    
public voidtestBeforeDescendantsEnterTouchMode()

        a.runOnUiThread(new Runnable() {
            public void run() {
                a.beforeDescendants.setFocusableInTouchMode(true);
                a.beforeDescendantsChild.requestFocus();
            }
        });
        getInstrumentation().waitForIdleSync();
        assertTrue(a.beforeDescendantsChild.isFocused());
        assertFalse(a.beforeDescendantsChild.isInTouchMode());

        TouchUtils.clickView(this, a.beforeDescendantsChild);
        assertTrue(a.beforeDescendantsChild.isInTouchMode());
        assertFalse(a.beforeDescendants.isFocused());        
    
public voidtestBlocksDescendants()

        a.blocksDescendants.setFocusable(true);
        assertTrue(a.blocksDescendants.requestFocus());
        assertTrue(a.blocksDescendants.isFocused());
        assertFalse(a.blocksDescendantsChild.isFocused());

        a.blocksDescendants.setFocusable(false);
        assertFalse(a.blocksDescendants.requestFocus());
        assertFalse(a.blocksDescendants.isFocused());
        assertFalse(a.blocksDescendantsChild.isFocused());
    
public voidtestChildOfDescendantBlockerRequestFocusFails()

        assertFalse(a.blocksDescendantsChild.requestFocus());
    
public voidtestPreconditions()

        assertEquals(ViewGroup.FOCUS_BEFORE_DESCENDANTS,
            a.beforeDescendants.getDescendantFocusability());
        assertEquals(ViewGroup.FOCUS_AFTER_DESCENDANTS,
            a.afterDescendants.getDescendantFocusability());
        assertEquals(ViewGroup.FOCUS_BLOCK_DESCENDANTS,
            a.blocksDescendants.getDescendantFocusability());

        assertTrue(a.beforeDescendantsChild.isFocusable());
        assertTrue(a.afterDescendantsChild.isFocusable());
        assertTrue(a.blocksDescendantsChild.isFocusable());