@Nullable Bitmap quickMemoryCacheCheck(String key) { Bitmap cached = cache.get(key); if (cached != null) { stats.dispatchCacheHit(); } else { stats.dispatchCacheMiss(); } return cached; }
private void assertMiss(PlatformLruCache cache, String key) { assertThat(cache.get(key)).isNull(); expectedMissCount++; assertStatistics(cache); }
private void assertHit(PlatformLruCache cache, String key, Bitmap value) { assertThat(cache.get(key)).isEqualTo(value); expectedHitCount++; assertStatistics(cache); }
@Test public void throwsWithNullKey() { PlatformLruCache cache = new PlatformLruCache(1); try { cache.get(null); fail("Expected NullPointerException"); } catch (NullPointerException expected) { } }
Result hunt() throws IOException { if (shouldReadFromMemoryCache(data.memoryPolicy)) { Bitmap bitmap = cache.get(key); if (bitmap != null) { stats.dispatchCacheHit();
@Test public void performCompleteSetsResultInCache() { Request data = new Request.Builder(URI_1).build(); Action action = noopAction(data); BitmapHunter hunter = new BitmapHunter(mockPicasso(), dispatcher, cache, stats, action, EMPTY_REQUEST_HANDLER); hunter.result = new RequestHandler.Result(bitmap1, MEMORY); dispatcher.performComplete(hunter); assertThat(cache.get(hunter.getKey())).isSameAs(hunter.result.getBitmap()); }