FileDocCategorySizeDatePackage
BigCacheTest.javaAPI DocAndroid 5.1 API2873Thu Mar 12 22:22:12 GMT 2015android.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.frameworks.coretests", 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.get(getActivity()).getScaledMaximumDrawingCacheSize();
        assertTrue(mLarge.getWidth() * mLarge.getHeight() * 2 > max);
        assertNull(createCacheForView(mLarge));
    
public voidtestDrawingCacheBelowMaximumSize()

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

        assertNotNull(mTiny);
        assertNotNull(mLarge);