Mirage { public void clearCache() { clearMemoryCache(); clearDiskCache(); } Mirage(Context applicationContext); synchronized static void set(Mirage mirage); synchronized static Mirage get(Context context); void dispose(); MirageRequest load(String uri); MirageRequest load(File file); MirageRequest load(@AnyRes int resId); MirageRequest load(BitmapProvider provider); MirageRequest load(Uri uri); @MainThread MirageTask go(MirageRequest request); MirageTask<Void, Void, Bitmap> createGoTask(MirageRequest request); MirageTask<Void, Void, Bitmap> executeGoTask(MirageTask<Void, Void, Bitmap> task, MirageRequest request); @WorkerThread Bitmap goSync(MirageRequest request); MirageTask downloadOnly(MirageRequest request); File downloadOnlySync(MirageRequest request); void cancelRequest(Target target); void cancelRequest(View view); void clearCache(); void removeFromCache(MirageRequest request); void clearMemoryCache(); void clearDiskCache(); void setDefaultUrlConnectionFactory(UrlFactory defaultUrlConnectionFactory); Executor getDefaultExecutor(); Mirage setDefaultExecutor(Executor defaultExecutor); Mirage setDefaultMemoryCache(MemoryCache<String, Bitmap> defaultMemoryCache); MemoryCache<String, Bitmap> getDefaultMemoryCache(); Mirage setDefaultDiskCache(DiskCache defaultDiskCache); DiskCache getDefaultDiskCache(); static final Executor THREAD_POOL_EXECUTOR; }
@Test public void testClearCache() throws Exception { Mirage mirage = new Mirage(RuntimeEnvironment.application); DiskCache diskCache = Mockito.mock(DiskCache.class); MemoryCache<String, Bitmap> memoryCache = Mockito.mock(MemoryCache.class); mirage.setDefaultDiskCache(diskCache); mirage.setDefaultMemoryCache(memoryCache); mirage.clearCache(); Mockito.verify(memoryCache, Mockito.times(1)).clear(); Mockito.verify(diskCache, Mockito.times(1)).clear(); mirage.clearMemoryCache(); Mockito.verify(memoryCache, Mockito.times(2)).clear(); mirage.clearDiskCache(); Mockito.verify(diskCache, Mockito.times(2)).clear(); }