@Test public void testDefaultBitmapPoolSize() { Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass()); float bitmapPoolSize = harness.getCalculator().getBitmapPoolSize(); assertThat(bitmapPoolSize).isEqualTo(harness.getScreenSize() * harness.bitmapPoolScreens); }
@Test public void testCanSetCustomMemoryCacheSize() { harness.memoryCacheScreens = 9.5f; Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass()); float memoryCacheSize = harness.getCalculator().getMemoryCacheSize(); assertThat(memoryCacheSize).isEqualTo(harness.getScreenSize() * harness.memoryCacheScreens); }
@Test public void testDefaultMemoryCacheSizeIsTwiceScreenSize() { Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass()); float memoryCacheSize = harness.getCalculator().getMemoryCacheSize(); assertThat(memoryCacheSize).isEqualTo(harness.getScreenSize() * harness.memoryCacheScreens); }
@Test public void testCanSetCustomBitmapPoolSize() { harness.bitmapPoolScreens = 2f; Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass()); float bitmapPoolSize = harness.getCalculator().getBitmapPoolSize(); assertThat(bitmapPoolSize).isEqualTo(harness.getScreenSize() * harness.bitmapPoolScreens); }
@Test public void testByteArrayPoolSize_withLowRamDevice_isHalfTheSpecifiedBytes() { LowRamActivityManager activityManager = Shadow.extract(harness.activityManager); activityManager.setMemoryClass(getLargeEnoughMemoryClass()); activityManager.setIsLowRam(); int byteArrayPoolSize = harness.getCalculator().getArrayPoolSizeInBytes(); assertThat(byteArrayPoolSize).isEqualTo(harness.byteArrayPoolSizeBytes / 2); }
@Test public void testCumulativePoolAndMemoryCacheSizesAreSmallerOnLowMemoryDevices() { Shadows.shadowOf(harness.activityManager).setMemoryClass(getLargeEnoughMemoryClass() / 2); final int normalMemoryCacheSize = harness.getCalculator().getMemoryCacheSize(); final int normalBitmapPoolSize = harness.getCalculator().getBitmapPoolSize(); Util.setSdkVersionInt(10); // Keep the bitmap pool size constant, even though normally it would change. harness.byteArrayPoolSizeBytes *= 2; final int smallMemoryCacheSize = harness.getCalculator().getMemoryCacheSize(); final int smallBitmapPoolSize = harness.getCalculator().getBitmapPoolSize(); assertThat(smallMemoryCacheSize).isLessThan(normalMemoryCacheSize); assertThat(smallBitmapPoolSize).isLessThan(normalBitmapPoolSize); }