FileDocCategorySizeDatePackage
ViewGroupAttributesTest.javaAPI DocAndroid 1.5 API3290Wed May 06 22:42:02 BST 2009android.view

ViewGroupAttributesTest

public class ViewGroupAttributesTest extends android.test.AndroidTestCase

Fields Summary
private MyViewGroup
mViewGroup
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();
        mViewGroup = new MyViewGroup(getContext());
    
public voidtestDescendantFocusabilityEnum()

        assertEquals("expected ViewGroup.FOCUS_BEFORE_DESCENDANTS to be default",
                ViewGroup.FOCUS_BEFORE_DESCENDANTS, mViewGroup.getDescendantFocusability());

        // remember some state before we muck with flags
        final boolean isAnimationCachEnabled = mViewGroup.isAnimationCacheEnabled();
        final boolean isAlwaysDrawnWithCacheEnabled = mViewGroup.isAlwaysDrawnWithCacheEnabled();
        final boolean isChildrenDrawnWithCacheEnabled = mViewGroup.isChildrenDrawnWithCacheEnabled();

        mViewGroup.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        assertEquals(ViewGroup.FOCUS_AFTER_DESCENDANTS, mViewGroup.getDescendantFocusability());

        mViewGroup.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
        assertEquals(ViewGroup.FOCUS_BLOCK_DESCENDANTS, mViewGroup.getDescendantFocusability());

        mViewGroup.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        assertEquals(ViewGroup.FOCUS_BEFORE_DESCENDANTS, mViewGroup.getDescendantFocusability());

        // verify we didn't change something unrelated
        final String msg = "setDescendantFocusability messed with an unrelated flag";
        assertEquals(msg, isAnimationCachEnabled, mViewGroup.isAnimationCacheEnabled());
        assertEquals(msg, isAlwaysDrawnWithCacheEnabled, mViewGroup.isAlwaysDrawnWithCacheEnabled());
        assertEquals(msg, isChildrenDrawnWithCacheEnabled, mViewGroup.isChildrenDrawnWithCacheEnabled());
    
public voidtestWrongIntSetForDescendantFocusabilityEnum()

        try {
            mViewGroup.setDescendantFocusability(0);
            fail("expected setting wrong flag to throw an exception");
        } catch (IllegalArgumentException expected) {
        }