Search in sources :

Example 1 with BitmapCounter

use of com.facebook.imagepipeline.memory.BitmapCounter in project fresco by facebook.

the class GingerbreadPurgeableDecoderTest method setUp.

@Before
public void setUp() {
    mBitmap = MockBitmapFactory.create();
    mBitmapCounter = new BitmapCounter(MAX_BITMAP_COUNT, MAX_BITMAP_SIZE);
    mockStatic(BitmapCounterProvider.class);
    when(BitmapCounterProvider.get()).thenReturn(mBitmapCounter);
    mockStatic(BitmapFactory.class);
    when(BitmapFactory.decodeFileDescriptor(any(FileDescriptor.class), any(Rect.class), any(BitmapFactory.Options.class))).thenReturn(mBitmap);
    mInputBuf = new byte[LENGTH];
    PooledByteBuffer input = new TrivialPooledByteBuffer(mInputBuf, POINTER);
    mByteBufferRef = CloseableReference.of(input);
    mEncodedImage = new EncodedImage(mByteBufferRef);
    mDecodeBuf = new byte[LENGTH + 2];
    mDecodeBufRef = CloseableReference.of(mDecodeBuf, mock(ResourceReleaser.class));
    mockStatic(Bitmaps.class);
    mGingerbreadPurgeableDecoder = new GingerbreadPurgeableDecoder();
}
Also used : BitmapCounter(com.facebook.imagepipeline.memory.BitmapCounter) Rect(android.graphics.Rect) TrivialPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialPooledByteBuffer) PooledByteBuffer(com.facebook.common.memory.PooledByteBuffer) TrivialPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialPooledByteBuffer) EncodedImage(com.facebook.imagepipeline.image.EncodedImage) FileDescriptor(java.io.FileDescriptor) Before(org.junit.Before)

Example 2 with BitmapCounter

use of com.facebook.imagepipeline.memory.BitmapCounter in project fresco by facebook.

the class KitKatPurgeableDecoderTest method setUp.

@Before
public void setUp() {
    mFlexByteArrayPool = mock(FlexByteArrayPool.class);
    mBitmap = MockBitmapFactory.create();
    mBitmapCounter = new BitmapCounter(MAX_BITMAP_COUNT, MAX_BITMAP_SIZE);
    mockStatic(BitmapCounterProvider.class);
    when(BitmapCounterProvider.get()).thenReturn(mBitmapCounter);
    mockStatic(BitmapFactory.class);
    when(BitmapFactory.decodeByteArray(any(byte[].class), anyInt(), anyInt(), any(BitmapFactory.Options.class))).thenReturn(mBitmap);
    mInputBuf = new byte[LENGTH];
    PooledByteBuffer input = new TrivialPooledByteBuffer(mInputBuf, POINTER);
    mByteBufferRef = CloseableReference.of(input);
    mEncodedImage = new EncodedImage(mByteBufferRef);
    mDecodeBuf = new byte[LENGTH + 2];
    mDecodeBufRef = CloseableReference.of(mDecodeBuf, mock(ResourceReleaser.class));
    when(mFlexByteArrayPool.get(Integer.valueOf(LENGTH))).thenReturn(mDecodeBufRef);
    mockStatic(Bitmaps.class);
    mKitKatPurgeableDecoder = new KitKatPurgeableDecoder(mFlexByteArrayPool);
}
Also used : BitmapCounter(com.facebook.imagepipeline.memory.BitmapCounter) TrivialPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialPooledByteBuffer) PooledByteBuffer(com.facebook.common.memory.PooledByteBuffer) FlexByteArrayPool(com.facebook.imagepipeline.memory.FlexByteArrayPool) TrivialPooledByteBuffer(com.facebook.imagepipeline.testing.TrivialPooledByteBuffer) EncodedImage(com.facebook.imagepipeline.image.EncodedImage) Before(org.junit.Before)

Aggregations

PooledByteBuffer (com.facebook.common.memory.PooledByteBuffer)2 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)2 BitmapCounter (com.facebook.imagepipeline.memory.BitmapCounter)2 TrivialPooledByteBuffer (com.facebook.imagepipeline.testing.TrivialPooledByteBuffer)2 Before (org.junit.Before)2 Rect (android.graphics.Rect)1 FlexByteArrayPool (com.facebook.imagepipeline.memory.FlexByteArrayPool)1 FileDescriptor (java.io.FileDescriptor)1