Search in sources :

Example 11 with ImageOptions

use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.

the class HierarcherImplTest method testApplyRoundingOptions_whenRoundAsCircle_thenReturnDrawable.

@Test
public void testApplyRoundingOptions_whenRoundAsCircle_thenReturnDrawable() {
    final Drawable drawable = new ColorDrawable(Color.YELLOW);
    when(mResources.getDrawable(RES_ID)).thenReturn(drawable);
    ImageOptions options = mock(ImageOptions.class);
    when(options.getRoundingOptions()).thenReturn(RoundingOptions.asCircle());
    when(options.getPlaceholderDrawable()).thenReturn(drawable);
    when(options.getPlaceholderApplyRoundingOptions()).thenReturn(true);
    Drawable result = mHierarcher.buildPlaceholderDrawable(mResources, options);
    assertThat(result).isExactlyInstanceOf(RoundedColorDrawable.class);
    when(options.getPlaceholderDrawable()).thenReturn(null);
    when(options.getPlaceholderRes()).thenReturn(RES_ID);
    result = mHierarcher.buildPlaceholderDrawable(mResources, options);
    assertThat(result).isExactlyInstanceOf(RoundedColorDrawable.class);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) RoundedColorDrawable(com.facebook.drawee.drawable.RoundedColorDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) ScaleTypeDrawable(com.facebook.drawee.drawable.ScaleTypeDrawable) RoundedColorDrawable(com.facebook.drawee.drawable.RoundedColorDrawable) RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) Test(org.junit.Test)

Example 12 with ImageOptions

use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.

the class HierarcherImplTest method testBuildOverlayRes_whenSet_thenReturnDrawable.

@Test
public void testBuildOverlayRes_whenSet_thenReturnDrawable() {
    ImageOptions options = ImageOptions.create().overlayRes(RES_ID).build();
    Drawable overlayDrawable = mHierarcher.buildOverlayDrawable(mResources, options);
    assertThat(overlayDrawable).isEqualTo(mDrawable);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) ScaleTypeDrawable(com.facebook.drawee.drawable.ScaleTypeDrawable) RoundedColorDrawable(com.facebook.drawee.drawable.RoundedColorDrawable) RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) Test(org.junit.Test)

Example 13 with ImageOptions

use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.

the class ImagePipelineUtilsImplTest method testBuildImageRequest_whenRoundAsCircleWithAntiAliasing_thenApplyRoundingParameters.

@Test
public void testBuildImageRequest_whenRoundAsCircleWithAntiAliasing_thenApplyRoundingParameters() {
    final ImageOptions imageOptions = ImageOptions.create().round(RoundingOptions.asCircle(true)).build();
    ImageRequest imageRequest = mImagePipelineUtils.buildImageRequest(URI, imageOptions);
    assertThat(imageRequest).isNotNull();
    assertThat(imageRequest.getSourceUri()).isEqualTo(URI);
    ImageDecodeOptions imageDecodeOptions = imageRequest.getImageDecodeOptions();
    assertThat(imageDecodeOptions).isEqualTo(mRoundingDecodeOptionsAntiAliased);
}
Also used : ImageRequest(com.facebook.imagepipeline.request.ImageRequest) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) ImageDecodeOptions(com.facebook.imagepipeline.common.ImageDecodeOptions) Test(org.junit.Test)

Example 14 with ImageOptions

use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.

the class ImagePipelineUtilsImplTest method testBuildImageRequest_whenResizingEnabled_thenSetResizeOptions.

@Test
public void testBuildImageRequest_whenResizingEnabled_thenSetResizeOptions() {
    ResizeOptions resizeOptions = ResizeOptions.forDimensions(123, 234);
    final ImageOptions imageOptions = ImageOptions.create().resize(resizeOptions).build();
    ImageRequest imageRequest = mImagePipelineUtils.buildImageRequest(URI, imageOptions);
    assertThat(imageRequest).isNotNull();
    assertThat(imageRequest.getSourceUri()).isEqualTo(URI);
    assertThat(imageRequest.getResizeOptions()).isEqualTo(resizeOptions);
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) Test(org.junit.Test)

Example 15 with ImageOptions

use of com.facebook.fresco.vito.options.ImageOptions in project fresco by facebook.

the class HierarcherImplTest method testBuildOverlayRes_whenUnset_thenReturnNull.

@Test
public void testBuildOverlayRes_whenUnset_thenReturnNull() {
    ImageOptions options = ImageOptions.create().build();
    Drawable overlayDrawable = mHierarcher.buildOverlayDrawable(mResources, options);
    assertThat(overlayDrawable).isNull();
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) ScaleTypeDrawable(com.facebook.drawee.drawable.ScaleTypeDrawable) RoundedColorDrawable(com.facebook.drawee.drawable.RoundedColorDrawable) RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) Test(org.junit.Test)

Aggregations

ImageOptions (com.facebook.fresco.vito.options.ImageOptions)32 Test (org.junit.Test)32 BitmapDrawable (android.graphics.drawable.BitmapDrawable)21 Drawable (android.graphics.drawable.Drawable)21 RoundedBitmapDrawable (com.facebook.drawee.drawable.RoundedBitmapDrawable)21 ColorDrawable (android.graphics.drawable.ColorDrawable)14 RoundedColorDrawable (com.facebook.drawee.drawable.RoundedColorDrawable)14 ScaleTypeDrawable (com.facebook.drawee.drawable.ScaleTypeDrawable)14 Bitmap (android.graphics.Bitmap)8 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)7 CloseableStaticBitmap (com.facebook.imagepipeline.image.CloseableStaticBitmap)6 ImageDecodeOptions (com.facebook.imagepipeline.common.ImageDecodeOptions)4 Resources (android.content.res.Resources)2 PointF (android.graphics.PointF)2 ImageSource (com.facebook.fresco.vito.source.ImageSource)2 BorderOptions (com.facebook.fresco.vito.options.BorderOptions)1 ImageOptionsDrawableFactory (com.facebook.fresco.vito.options.ImageOptionsDrawableFactory)1 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)1 RotationOptions (com.facebook.imagepipeline.common.RotationOptions)1 CloseableImage (com.facebook.imagepipeline.image.CloseableImage)1