@Test
  public void testEviction_ByEvictionQueueCount() {
    mCache =
        createDummyAdaptiveCountingMemoryCache(
            mParamsSupplier,
            mCacheTrimStrategy,
            mValueDescriptor,
            100,
            1,
            2,
            initialLFUCacheFractionPromil);
    CloseableReference<Integer> originalRef1 = newReference(10);
    CloseableReference<Integer> valueRef1 = mCache.cache(KEYS[1], originalRef1);
    originalRef1.close();
    valueRef1.close();
    CloseableReference<Integer> originalRef2 = newReference(20);
    CloseableReference<Integer> valueRef2 = mCache.cache(KEYS[2], originalRef2);
    originalRef2.close();
    valueRef2.close();
    CloseableReference<Integer> originalRef3 = newReference(30);
    CloseableReference<Integer> valueRef3 = mCache.cache(KEYS[3], originalRef3);
    originalRef3.close();
    valueRef3.close();
    CloseableReference<Integer> originalRef4 = newReference(40);
    CloseableReference<Integer> valueRef4 = mCache.cache(KEYS[4], originalRef4);
    originalRef4.close();
    assertTotalSize(2, 70);
    assertExclusivelyOwnedSize(1, 30);
    assertNotCached(KEYS[1], 10);
    assertNotCached(KEYS[2], 20);
    assertExclusivelyOwned(KEYS[3], 30);
    assertSharedWithCount(KEYS[4], 40, 1);

    // closing the client reference for item4 will cause item2 to be evicted as well
    valueRef4.close();
    assertTotalSize(2, 70);
    assertExclusivelyOwnedSize(2, 70);
    assertNotCached(KEYS[1], 10);
    assertNotCached(KEYS[2], 20);
    assertExclusivelyOwned(KEYS[3], 30);
    assertExclusivelyOwned(KEYS[4], 40);
    verify(mReleaser).release(10);
    verify(mReleaser).release(20);
  }
test: pass illegal adaptive rate and illegal initial LFU cache fraction. expected result: fall
back and use the default adaptive rate and initial LFU fraction values.
imagepipeline-base/src/test/java/com/facebook/imagepipeline/cache/AbstractAdaptiveCountingMemoryCacheTest.java