use of com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher in project glide by bumptech.
the class FileDescriptorLocalUriFetcherTest method testLoadResource_withNullFileDescriptor_callsLoadFailed.
@Test
public void testLoadResource_withNullFileDescriptor_callsLoadFailed() {
Context context = RuntimeEnvironment.application;
Uri uri = Uri.parse("file://nothing");
ContentResolver contentResolver = context.getContentResolver();
ContentResolverShadow shadow = (ContentResolverShadow) ShadowExtractor.extract(contentResolver);
shadow.registerFileDescriptor(uri, null);
FileDescriptorLocalUriFetcher fetcher = new FileDescriptorLocalUriFetcher(context.getContentResolver(), uri);
fetcher.loadData(Priority.NORMAL, callback);
verify(callback).onLoadFailed(isA(FileNotFoundException.class));
}
use of com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher in project glide by bumptech.
the class FileDescriptorLocalUriFetcherTest method testLoadResource_returnsFileDescriptor.
@Test
public void testLoadResource_returnsFileDescriptor() throws Exception {
Context context = RuntimeEnvironment.application;
Uri uri = Uri.parse("file://nothing");
ContentResolver contentResolver = context.getContentResolver();
ContentResolverShadow shadow = (ContentResolverShadow) ShadowExtractor.extract(contentResolver);
AssetFileDescriptor assetFileDescriptor = mock(AssetFileDescriptor.class);
ParcelFileDescriptor parcelFileDescriptor = mock(ParcelFileDescriptor.class);
when(assetFileDescriptor.getParcelFileDescriptor()).thenReturn(parcelFileDescriptor);
shadow.registerFileDescriptor(uri, assetFileDescriptor);
FileDescriptorLocalUriFetcher fetcher = new FileDescriptorLocalUriFetcher(context.getContentResolver(), uri);
fetcher.loadData(Priority.NORMAL, callback);
verify(callback).onDataReady(eq(parcelFileDescriptor));
}
Aggregations