use of com.facebook.cache.common.SimpleCacheKey in project fresco by facebook.
the class AnimatedFrameCacheTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
MemoryCacheParams params = new MemoryCacheParams(4 * ByteConstants.MB, 256, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
when(mMemoryCacheParamsSupplier.get()).thenReturn(params);
CountingMemoryCache<CacheKey, CloseableImage> countingMemoryCache = BitmapCountingMemoryCacheFactory.get(mMemoryCacheParamsSupplier, mMemoryTrimmableRegistry, mPlatformBitmapFactory, true);
mCacheKey = new SimpleCacheKey("key");
mAnimatedFrameCache = new AnimatedFrameCache(mCacheKey, countingMemoryCache);
mFrame1 = CloseableReference.of(mock(CloseableImage.class));
mFrame2 = CloseableReference.of(mock(CloseableImage.class));
}
use of com.facebook.cache.common.SimpleCacheKey in project fresco by facebook.
the class IterativeBoxBlurPostProcessor method getPostprocessorCacheKey.
@Nullable
@Override
public CacheKey getPostprocessorCacheKey() {
if (mCacheKey == null) {
final String key = String.format((Locale) null, "i%dr%d", mIterations, mBlurRadius);
mCacheKey = new SimpleCacheKey(key);
}
return mCacheKey;
}
use of com.facebook.cache.common.SimpleCacheKey in project fresco by facebook.
the class ImagePipelineTest method testClearMemoryCaches.
@Test
public void testClearMemoryCaches() {
String uriString = "http://dummy/string";
Uri uri = Uri.parse(uriString);
CacheKey dummyCacheKey = mock(CacheKey.class);
mImagePipeline.clearMemoryCaches();
ArgumentCaptor<Predicate> bitmapCachePredicateCaptor = ArgumentCaptor.forClass(Predicate.class);
verify(mBitmapMemoryCache).removeAll(bitmapCachePredicateCaptor.capture());
Predicate<CacheKey> bitmapMemoryCacheKeyPredicate = bitmapCachePredicateCaptor.getValue();
BitmapMemoryCacheKey bitmapMemoryCacheKey1 = mock(BitmapMemoryCacheKey.class);
BitmapMemoryCacheKey bitmapMemoryCacheKey2 = mock(BitmapMemoryCacheKey.class);
when(bitmapMemoryCacheKey1.containsUri(uri)).thenReturn(true);
when(bitmapMemoryCacheKey2.containsUri(uri)).thenReturn(false);
assertTrue(bitmapMemoryCacheKeyPredicate.apply(bitmapMemoryCacheKey1));
assertTrue(bitmapMemoryCacheKeyPredicate.apply(bitmapMemoryCacheKey2));
assertTrue(bitmapMemoryCacheKeyPredicate.apply(dummyCacheKey));
ArgumentCaptor<Predicate> encodedMemoryCachePredicateCaptor = ArgumentCaptor.forClass(Predicate.class);
verify(mEncodedMemoryCache).removeAll(encodedMemoryCachePredicateCaptor.capture());
Predicate<CacheKey> encodedMemoryCacheKeyPredicate = encodedMemoryCachePredicateCaptor.getValue();
SimpleCacheKey simpleCacheKey1 = new SimpleCacheKey(uriString);
SimpleCacheKey simpleCacheKey2 = new SimpleCacheKey("rubbish");
assertTrue(encodedMemoryCacheKeyPredicate.apply(simpleCacheKey1));
assertTrue(encodedMemoryCacheKeyPredicate.apply(simpleCacheKey2));
assertTrue(encodedMemoryCacheKeyPredicate.apply(dummyCacheKey));
}
use of com.facebook.cache.common.SimpleCacheKey in project fresco by facebook.
the class SplitCachesByImageSizeDiskCachePolicyTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
List<CacheKey> keys = new ArrayList<>(1);
keys.add(new SimpleCacheKey("http://dummy.uri"));
mCacheKey = new MultiCacheKey(keys);
when(mCacheKeyFactory.getEncodedCacheKey(mImageRequest, mCallerContext)).thenReturn(mCacheKey);
when(mImageRequest.getCacheChoice()).thenReturn(ImageRequest.CacheChoice.DEFAULT);
when(mImageRequest.isDiskCacheEnabled()).thenReturn(true);
mIsCancelled = new AtomicBoolean(false);
mEncodedImage = new EncodedImage(CloseableReference.of(mImagePooledByteBuffer));
mSplitCachesByImageSizeDiskCachePolicy = new SplitCachesByImageSizeDiskCachePolicy(mDefaultBufferedDiskCache, mSmallImageBufferedDiskCache, mCacheKeyFactory, FORCE_SMALL_CACHE_THRESHOLD);
}
use of com.facebook.cache.common.SimpleCacheKey in project fresco by facebook.
the class StagingAreaTest method setUp.
@Before
public void setUp() {
mStagingArea = StagingArea.getInstance();
mCloseableReference = CloseableReference.of(mock(PooledByteBuffer.class));
mCloseableReference2 = CloseableReference.of(mock(PooledByteBuffer.class));
mEncodedImage = new EncodedImage(mCloseableReference);
mSecondEncodedImage = new EncodedImage(mCloseableReference2);
mCacheKey = new SimpleCacheKey("http://this.is/uri");
mStagingArea.put(mCacheKey, mEncodedImage);
}
Aggregations