@Test
  public void testInUseCount() {
    mCache =
        createDummyAdaptiveCountingMemoryCache(
            mParamsSupplier,
            mCacheTrimStrategy,
            mValueDescriptor,
            100,
            1,
            2,
            initialLFUCacheFractionPromil);
    CloseableReference<Integer> cachedRef1 = mCache.cache(KEY, newReference(100));

    CloseableReference<Integer> cachedRef2a = mCache.get(KEY);
    CloseableReference<Integer> cachedRef2b = cachedRef2a.clone();
    assertTotalSize(1, 100);
    assertExclusivelyOwnedSize(0, 0);
    assertSharedWithCount(KEY, 100, 2);

    CloseableReference<Integer> cachedRef3a = mCache.get(KEY);
    CloseableReference<Integer> cachedRef3b = cachedRef3a.clone();
    CloseableReference<Integer> cachedRef3c = cachedRef3b.clone();
    assertTotalSize(1, 100);
    assertExclusivelyOwnedSize(0, 0);
    assertSharedWithCount(KEY, 100, 3);

    cachedRef1.close();
    assertTotalSize(1, 100);
    assertExclusivelyOwnedSize(0, 0);
    assertSharedWithCount(KEY, 100, 2);

    // all copies of cachedRef2a need to be closed for usage count to drop
    cachedRef2a.close();
    assertTotalSize(1, 100);
    assertExclusivelyOwnedSize(0, 0);
    assertSharedWithCount(KEY, 100, 2);
    cachedRef2b.close();
    assertTotalSize(1, 100);
    assertExclusivelyOwnedSize(0, 0);
    assertSharedWithCount(KEY, 100, 1);

    // all copies of cachedRef3a need to be closed for usage count to drop
    cachedRef3c.close();
    assertTotalSize(1, 100);
    assertExclusivelyOwnedSize(0, 0);
    assertSharedWithCount(KEY, 100, 1);
    cachedRef3b.close();
    assertTotalSize(1, 100);
    assertExclusivelyOwnedSize(0, 0);
    assertSharedWithCount(KEY, 100, 1);
    cachedRef3a.close();
    assertTotalSize(1, 100);
    assertExclusivelyOwnedSize(1, 100);
    assertExclusivelyOwned(KEY, 100);
  }
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