@Test
  public void testFrequentlyUsedEvictionWhithoutChangingLFU() {
    // Cache has 4 entries; 2 for LFU and 2 for MFU
    // key is considered as MFU, if its accessCount > 1
    mCache =
        createDummyAdaptiveCountingMemoryCache(
            mParamsSupplier,
            mCacheTrimStrategy,
            mValueDescriptor,
            100,
            1,
            2,
            initialLFUCacheFractionPromil);

    // insert item1 to MFU
    CloseableReference<Integer> originalRef1 = newReference(10);
    CloseableReference<Integer> valueRef1a = mCache.cache(KEYS[1], originalRef1);
    CloseableReference<Integer> valueRef1b = mCache.get(KEYS[1]);
    originalRef1.close();
    valueRef1a.close();
    valueRef1b.close();
    assertMFUExclusivelyOwned(KEYS[1], 10);

    // insert item2 to LFU
    CloseableReference<Integer> originalRef2 = newReference(20);
    CloseableReference<Integer> valueRef2 = mCache.cache(KEYS[2], originalRef2);
    originalRef2.close();
    valueRef2.close();
    assertMFUExclusivelyOwned(KEYS[1], 10);
    assertLFUExclusivelyOwned(KEYS[2], 20);

    // insert item3 to MFU
    CloseableReference<Integer> originalRef3 = newReference(30);
    CloseableReference<Integer> valueRef3a = mCache.cache(KEYS[3], originalRef3);
    CloseableReference<Integer> valueRef3b = mCache.get(KEYS[3]);
    originalRef3.close();
    valueRef3a.close();
    valueRef3b.close();
    assertMFUExclusivelyOwned(KEYS[1], 10);
    assertMFUExclusivelyOwned(KEYS[3], 30);
    assertLFUExclusivelyOwned(KEYS[2], 20);
    assertExclusivelyOwnedSize(3, 60);

    // insert item4 to MFU, this should evict item1 from the cache
    CloseableReference<Integer> originalRef4 = newReference(40);
    CloseableReference<Integer> valueRef4a = mCache.cache(KEYS[4], originalRef4);
    CloseableReference<Integer> valueRef4b = mCache.get(KEYS[4]);
    originalRef4.close();
    valueRef4a.close();
    valueRef4b.close();
    assertNotCached(KEYS[1], 10);
    assertMFUExclusivelyOwned(KEYS[3], 30);
    assertLFUExclusivelyOwned(KEYS[2], 20);
    assertMFUExclusivelyOwned(KEYS[4], 40);
  }
add 2 frequently used items and one LFU item. Then add a new frequently used item. Expected:
the cache should evict one of the MFU items and not the LFU item.
imagepipeline-base/src/test/java/com/facebook/imagepipeline/cache/AbstractAdaptiveCountingMemoryCacheTest.java