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

BigCacheTest

public class BigCacheTest extends android.test.ActivityInstrumentationTestCase
Builds the drawing cache of two Views, one smaller than the maximum cache size, one larger than the maximum cache size. The latter should always have a null drawing cache.

Fields Summary
private android.view.View
mTiny
private android.view.View
mLarge
Constructors Summary
public BigCacheTest()

        super("com.android.frameworktest", BigCache.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 BigCache activity = getActivity();
        mTiny = activity.findViewById(R.id.a);
        mLarge = activity.findViewById(R.id.b);
    
public voidtestDrawingCacheAboveMaximumSize()

        final int max = ViewConfiguration.getMaximumDrawingCacheSize();
        assertTrue(mLarge.getWidth() * mLarge.getHeight() * 2 > max);
        assertNull(createCacheForView(mLarge));
    
public voidtestDrawingCacheBelowMaximumSize()

        final int max = ViewConfiguration.getMaximumDrawingCacheSize();
        assertTrue(mTiny.getWidth() * mTiny.getHeight() * 2 < max);
        assertNotNull(createCacheForView(mTiny));
    
public voidtestSetUpConditions()

        assertNotNull(mTiny);
        assertNotNull(mLarge);