Search in sources :

Example 26 with Options

use of com.bumptech.glide.load.Options in project glide by bumptech.

the class StreamEncoderTest method testWritesDataFromInputStreamToOutputStream.

@Test
public void testWritesDataFromInputStreamToOutputStream() throws IOException {
    String fakeData = "SomeRandomFakeData";
    ByteArrayInputStream is = new ByteArrayInputStream(fakeData.getBytes("UTF-8"));
    encoder.encode(is, file, new Options());
    byte[] data = ByteBufferUtil.toBytes(ByteBufferUtil.fromFile(file));
    assertEquals(fakeData, new String(data, "UTF-8"));
}
Also used : Options(com.bumptech.glide.load.Options) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 27 with Options

use of com.bumptech.glide.load.Options in project glide by bumptech.

the class AssetUriLoaderTest method testHandlesAssetUris.

@Test
public void testHandlesAssetUris() {
    Uri assetUri = Uri.parse("file:///android_asset/assetName");
    when(factory.buildFetcher(any(AssetManager.class), eq("assetName"))).thenReturn(fetcher);
    assertTrue(loader.handles(assetUri));
    assertEquals(fetcher, Preconditions.checkNotNull(loader.buildLoadData(assetUri, IMAGE_SIDE, IMAGE_SIDE, new Options())).fetcher);
}
Also used : Options(com.bumptech.glide.load.Options) AssetManager(android.content.res.AssetManager) Uri(android.net.Uri) Test(org.junit.Test)

Example 28 with Options

use of com.bumptech.glide.load.Options in project glide by bumptech.

the class DataUrlLoaderTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    DataUrlLoader.StreamFactory<String> factory = new DataUrlLoader.StreamFactory<>();
    options = new Options();
    dataUrlLoader = (DataUrlLoader<String, InputStream>) factory.build(multiFactory);
    fetcher = dataUrlLoader.buildLoadData(VALID_PNG, -1, -1, options).fetcher;
}
Also used : Options(com.bumptech.glide.load.Options) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Before(org.junit.Before)

Example 29 with Options

use of com.bumptech.glide.load.Options in project glide by bumptech.

the class ResourceLoaderTest method testCanHandleId.

@Test
public void testCanHandleId() {
    int id = android.R.drawable.star_off;
    Uri contentUri = Uri.parse("android.resource://android/drawable/star_off");
    when(uriLoader.buildLoadData(eq(contentUri), anyInt(), anyInt(), any(Options.class))).thenReturn(new ModelLoader.LoadData<>(key, fetcher));
    assertTrue(loader.handles(id));
    assertEquals(fetcher, Preconditions.checkNotNull(loader.buildLoadData(id, 100, 100, new Options())).fetcher);
}
Also used : Options(com.bumptech.glide.load.Options) Uri(android.net.Uri) Test(org.junit.Test)

Example 30 with Options

use of com.bumptech.glide.load.Options in project glide by bumptech.

the class StringLoaderTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    options = new Options();
    when(uriLoader.handles(any(Uri.class))).thenReturn(true);
    loader = new StringLoader<>(uriLoader);
}
Also used : Options(com.bumptech.glide.load.Options) Uri(android.net.Uri) Before(org.junit.Before)

Aggregations

Options (com.bumptech.glide.load.Options)33 Before (org.junit.Before)14 Test (org.junit.Test)10 Bitmap (android.graphics.Bitmap)4 Uri (android.net.Uri)3 NonNull (android.support.annotation.NonNull)3 ImageHeaderParser (com.bumptech.glide.load.ImageHeaderParser)3 ObjectKey (com.bumptech.glide.signature.ObjectKey)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 CheckResult (android.support.annotation.CheckResult)2 CacheKeyUpdater (com.bumptech.glide.load.Option.CacheKeyUpdater)2 LruArrayPool (com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool)2 DefaultImageHeaderParser (com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser)2 ByteBuffer (java.nio.ByteBuffer)2 MessageDigest (java.security.MessageDigest)2 Application (android.app.Application)1 AssetManager (android.content.res.AssetManager)1 BitmapFactory (android.graphics.BitmapFactory)1