@Test public void testLoadBitmap_asBitmap() { Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); requestManager .asBitmap() .load(bitmap) .into(target); verify(target).onResourceReady(eq(bitmap), any(Transition.class)); }
private static RequestBuilder<Bitmap> getRequestBuilder( RequestManager requestManager, int width, int height) { return requestManager .asBitmap() .apply( diskCacheStrategyOf(DiskCacheStrategy.NONE) .useAnimationPool(true) .skipMemoryCache(true) .override(width, height)); }
@Override public void run() throws Throwable { Glide.with(context) .asBitmap() .load(ResourceIds.drawable.shape_drawable) .submit() .get(); } });
@Test public void load_withShapeDrawableResourceId_asBitmap_withValidSize_returnsNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(ResourceIds.drawable.shape_drawable) .submit(100, 200) .get(); assertThat(bitmap).isNotNull(); assertThat(bitmap.getWidth()).isEqualTo(100); assertThat(bitmap.getHeight()).isEqualTo(200); }
@Test public void load_withWideGamutImage_returnsWideGamutBitmap() { Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(ResourceIds.raw.webkit_logo_p3) .submit()); assertThat(bitmap.getConfig()).isEqualTo(Bitmap.Config.RGBA_F16); }
@Test public void loadVideoResourceId_asBitmap_decodesFrame() { Bitmap frame = concurrency.get( Glide.with(context) .asBitmap() .load(ResourceIds.raw.video) .submit()); assertThat(frame).isNotNull(); }
@Test public void testAsBitmapOption() { Uri uri = Uri.parse("content://something/else"); mockUri(uri); requestManager.asBitmap().load(uri).into(target); verify(target).onResourceReady(isA(Bitmap.class), isA(Transition.class)); }
@Test public void load_withBitmapResourceId_asBitmap_producesNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(android.R.drawable.star_big_off) .submit() .get(); assertThat(bitmap).isNotNull(); }
@Test public void load_withVectorDrawableResourceId_asBitmap_producesNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(ResourceIds.drawable.vector_drawable) .submit() .get(); assertThat(bitmap).isNotNull(); }
@Test public void load_withBitmapAliasResourceId_asBitmap_producesNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(ResourceIds.drawable.bitmap_alias) .submit() .get(); assertThat(bitmap).isNotNull(); }
@Test public void load_withNinePatchResourceId_asBitmap_producesNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(ResourceIds.drawable.googlelogo_color_120x44dp) .submit() .get(); assertThat(bitmap).isNotNull(); }
@Test public void load_withStateListDrawableResourceId_asBitmap_producesNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(ResourceIds.drawable.state_list_drawable) .submit() .get(); assertThat(bitmap).isNotNull(); }
@Test public void load_withJpegAsDataUriString_returnsBitmap() { Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(getDataUriString(CompressFormat.JPEG)) .submit()); assertThat(bitmap).isNotNull(); }
@Test public void load_withPngAsDataUri_returnsBitmap() { Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(getDataUri(CompressFormat.PNG)) .submit()); assertThat(bitmap).isNotNull(); }
@Test public void load_withJpegAsDataUri_returnsBitmap() { Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(getDataUri(CompressFormat.JPEG)) .submit()); assertThat(bitmap).isNotNull(); }
@Test public void loadTransparentGifResource_withNoOtherLoaders_fromBytes_decodesResource() { byte[] data = getBytes(ResourceIds.raw.transparent_gif); Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(data) .submit()); assertThat(bitmap).isNotNull(); }
@Test public void load_withPngDataUriString_returnsBitmap() { Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(getDataUriString(CompressFormat.PNG)) .submit()); assertThat(bitmap).isNotNull(); }
@Test public void loadOpaqueGifResource_asBytes_decodesResource() { byte[] data = getBytes(ResourceIds.raw.opaque_gif); Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(data) .submit()); assertThat(bitmap).isNotNull(); }
@Test public void load_withVectorDrawableResourceId_asBitmap_withTransformation_producesNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(ResourceIds.drawable.vector_drawable) .apply(centerCropTransform()) .submit() .get(); assertThat(bitmap).isNotNull(); }
@Test public void load_withNinePatchResourceId_asBitmap_withTransformation_producesNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(ResourceIds.drawable.googlelogo_color_120x44dp) .apply(centerCropTransform()) .submit() .get(); assertThat(bitmap).isNotNull(); }