FileDocCategorySizeDatePackage
ZeroSizedTest.javaAPI DocAndroid 1.5 API3510Wed May 06 22:42:02 BST 2009com.android.frameworktest.view

ZeroSizedTest

public class ZeroSizedTest extends android.test.ActivityInstrumentationTestCase
Builds the drawing cache of Views of various dimension. The assumption is that a View with a 0-sized dimension (width or height) will always have a null drawing cache.

Fields Summary
private android.view.View
mWithDimension
private android.view.View
mWithNoWdith
private android.view.View
mWithNoHeight
private android.view.View
mWithNoDimension
Constructors Summary
public ZeroSizedTest()

        super("com.android.frameworktest", ZeroSized.class);
    
Methods Summary
private android.graphics.BitmapcreateCacheForView(android.view.View view)

        final Bitmap[] cache = new Bitmap[1];
        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                view.setDrawingCacheEnabled(true);
                view.invalidate();
                view.buildDrawingCache();
                cache[0] = view.getDrawingCache();
            }
        });
        getInstrumentation().waitForIdleSync();
        return cache[0];
    
public voidsetUp()

        super.setUp();

        final ZeroSized activity = getActivity();
        mWithDimension = activity.findViewById(R.id.dimension);
        mWithNoWdith = activity.findViewById(R.id.noWidth);
        mWithNoHeight = activity.findViewById(R.id.noHeight);
        mWithNoDimension = activity.findViewById(R.id.noDimension);
    
public voidtestDrawingCacheWithDimension()

        assertTrue(mWithDimension.getWidth() > 0);
        assertTrue(mWithDimension.getHeight() > 0);
        assertNotNull(createCacheForView(mWithDimension));
    
public voidtestDrawingCacheWithNoDimension()

        assertTrue(mWithNoDimension.getWidth() == 0);
        assertTrue(mWithNoDimension.getHeight() == 0);
        assertNull(createCacheForView(mWithNoDimension));
    
public voidtestDrawingCacheWithNoHeight()

        assertTrue(mWithNoHeight.getWidth() > 0);
        assertTrue(mWithNoHeight.getHeight() == 0);
        assertNull(createCacheForView(mWithNoHeight));
    
public voidtestDrawingCacheWithNoWidth()

        assertTrue(mWithNoWdith.getWidth() == 0);
        assertTrue(mWithNoWdith.getHeight() > 0);
        assertNull(createCacheForView(mWithNoWdith));
    
public voidtestSetUpConditions()

        assertNotNull(mWithDimension);
        assertNotNull(mWithNoWdith);
        assertNotNull(mWithNoHeight);
        assertNotNull(mWithNoDimension);