use of com.bumptech.glide.load.data.StreamLocalUriFetcher in project glide by bumptech.
the class StreamLocalUriFetcherTest method testLoadResource_returnsInputStream.
@Test
public void testLoadResource_returnsInputStream() throws Exception {
Context context = RuntimeEnvironment.application;
Uri uri = Uri.parse("file://nothing");
ContentResolver contentResolver = context.getContentResolver();
ContentResolverShadow shadow = (ContentResolverShadow) ShadowExtractor.extract(contentResolver);
shadow.registerInputStream(uri, new ByteArrayInputStream(new byte[0]));
StreamLocalUriFetcher fetcher = new StreamLocalUriFetcher(context.getContentResolver(), uri);
fetcher.loadData(Priority.NORMAL, callback);
verify(callback).onDataReady(isNotNull(InputStream.class));
}
use of com.bumptech.glide.load.data.StreamLocalUriFetcher in project glide by bumptech.
the class StreamLocalUriFetcherTest method testLoadResource_withNullInputStream_callsLoadFailed.
@Test
public void testLoadResource_withNullInputStream_callsLoadFailed() {
Context context = RuntimeEnvironment.application;
Uri uri = Uri.parse("file://nothing");
ContentResolver contentResolver = context.getContentResolver();
ContentResolverShadow shadow = (ContentResolverShadow) ShadowExtractor.extract(contentResolver);
shadow.registerInputStream(uri, null);
StreamLocalUriFetcher fetcher = new StreamLocalUriFetcher(context.getContentResolver(), uri);
fetcher.loadData(Priority.LOW, callback);
verify(callback).onLoadFailed(isA(FileNotFoundException.class));
}
Aggregations