|
14 | 14 | import static org.mockito.Mockito.when;
|
15 | 15 |
|
16 | 16 | import android.graphics.Bitmap;
|
| 17 | +import android.os.Build; |
17 | 18 | import java.util.ArrayDeque;
|
18 | 19 | import java.util.ArrayList;
|
19 | 20 | import java.util.Collections;
|
@@ -98,25 +99,32 @@ public void testEvictedBitmapsAreRecycled() {
|
98 | 99 | }
|
99 | 100 | }
|
100 | 101 |
|
| 102 | + @Config(sdk = Build.VERSION_CODES.KITKAT) |
101 | 103 | @Test
|
102 |
| - public void testTrimMemoryUiHiddenOrLessRemovesHalfOfBitmaps() { |
| 104 | + public void testTrimMemoryUiHiddenOrLessRemovesHalfOfBitmaps_preM() { |
103 | 105 | testTrimMemory(MAX_SIZE, TRIM_MEMORY_UI_HIDDEN, MAX_SIZE / 2);
|
104 | 106 | }
|
105 | 107 |
|
| 108 | + @Config(sdk = Build.VERSION_CODES.M) |
| 109 | + @Test |
| 110 | + public void testTrimMemoryUiHiddenOrLessRemovesHalfOfBitmaps_postM() { |
| 111 | + testTrimMemory(MAX_SIZE, TRIM_MEMORY_UI_HIDDEN, 0); |
| 112 | + } |
| 113 | + |
106 | 114 | @Test
|
107 | 115 | public void testTrimMemoryRunningCriticalRemovesHalfOfBitmaps() {
|
108 | 116 | testTrimMemory(MAX_SIZE, TRIM_MEMORY_RUNNING_CRITICAL, MAX_SIZE / 2);
|
109 | 117 | }
|
110 | 118 |
|
111 | 119 | @Test
|
112 |
| - public void testTrimMemoryUiHiddenOrLessRemovesNoBitmapsIfPoolLessThanHalfFull() { |
113 |
| - testTrimMemory(MAX_SIZE / 2, TRIM_MEMORY_UI_HIDDEN, 0); |
| 120 | + public void testTrimMemoryRunningCriticalOrLessRemovesNoBitmapsIfPoolLessThanHalfFull() { |
| 121 | + testTrimMemory(MAX_SIZE / 2, TRIM_MEMORY_RUNNING_CRITICAL, MAX_SIZE / 2); |
114 | 122 | }
|
115 | 123 |
|
116 | 124 | @Test
|
117 | 125 | public void testTrimMemoryBackgroundOrGreaterRemovesAllBitmaps() {
|
118 | 126 | for (int trimLevel : new int[] {TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE}) {
|
119 |
| - testTrimMemory(MAX_SIZE, trimLevel, MAX_SIZE); |
| 127 | + testTrimMemory(MAX_SIZE, trimLevel, 0); |
120 | 128 | }
|
121 | 129 | }
|
122 | 130 |
|
@@ -161,7 +169,7 @@ private void testTrimMemory(int fillSize, int trimLevel, int expectedSize) {
|
161 | 169 | LruBitmapPool pool = new LruBitmapPool(MAX_SIZE, strategy, ALLOWED_CONFIGS);
|
162 | 170 | fillPool(pool, fillSize);
|
163 | 171 | pool.trimMemory(trimLevel);
|
164 |
| - assertEquals("Failed level=" + trimLevel, expectedSize, strategy.numRemoves); |
| 172 | + assertEquals("Failed level=" + trimLevel, expectedSize, strategy.bitmaps.size()); |
165 | 173 | }
|
166 | 174 |
|
167 | 175 | @Test
|
|
0 commit comments