Search in sources :

Example 1 with CloseableReferenceFactory

use of com.facebook.imagepipeline.core.CloseableReferenceFactory in project fresco by facebook.

the class DecodeProducerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mProgressiveJpegConfig = new SimpleProgressiveJpegConfig(new SimpleProgressiveJpegConfig.DynamicValueConfig() {

        public List<Integer> getScansToDecode() {
            return Arrays.asList(PREVIEW_SCAN, GOOD_ENOUGH_SCAN);
        }

        public int getGoodEnoughScanNumber() {
            return GOOD_ENOUGH_SCAN;
        }
    });
    PowerMockito.mockStatic(ProgressiveJpegParser.class);
    PowerMockito.whenNew(ProgressiveJpegParser.class).withAnyArguments().thenReturn(mProgressiveJpegParser);
    PowerMockito.mockStatic(JobScheduler.class);
    PowerMockito.whenNew(JobScheduler.class).withAnyArguments().thenReturn(mJobScheduler);
    when(mConfig.getExperiments()).thenReturn(mPipelineExperiments);
    mDecodeProducer = new DecodeProducer(mByteArrayPool, mExecutor, mImageDecoder, mProgressiveJpegConfig, false, /* Set downsampleEnabled to false */
    false, /* Set resizeAndRotateForNetwork to false */
    false, /* We don't cancel when the request is cancelled */
    mInputProducer, MAX_BITMAP_SIZE, new CloseableReferenceFactory(new NoOpCloseableReferenceLeakTracker()), null, Suppliers.BOOLEAN_FALSE);
    PooledByteBuffer pooledByteBuffer = mockPooledByteBuffer(IMAGE_SIZE);
    mByteBufferRef = CloseableReference.of(pooledByteBuffer);
    mEncodedImage = new EncodedImage(mByteBufferRef);
    mEncodedImage.setImageFormat(DefaultImageFormats.JPEG);
    mEncodedImage.setWidth(IMAGE_WIDTH);
    mEncodedImage.setHeight(IMAGE_HEIGHT);
    mEncodedImage.setRotationAngle(IMAGE_ROTATION_ANGLE);
    mEncodedImage.setExifOrientation(IMAGE_EXIF_ORIENTATION);
}
Also used : SimpleProgressiveJpegConfig(com.facebook.imagepipeline.decoder.SimpleProgressiveJpegConfig) NoOpCloseableReferenceLeakTracker(com.facebook.imagepipeline.debug.NoOpCloseableReferenceLeakTracker) CloseableReferenceFactory(com.facebook.imagepipeline.core.CloseableReferenceFactory) PooledByteBuffer(com.facebook.common.memory.PooledByteBuffer) EncodedImage(com.facebook.imagepipeline.image.EncodedImage)

Aggregations

PooledByteBuffer (com.facebook.common.memory.PooledByteBuffer)1 CloseableReferenceFactory (com.facebook.imagepipeline.core.CloseableReferenceFactory)1 NoOpCloseableReferenceLeakTracker (com.facebook.imagepipeline.debug.NoOpCloseableReferenceLeakTracker)1 SimpleProgressiveJpegConfig (com.facebook.imagepipeline.decoder.SimpleProgressiveJpegConfig)1 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)1