Search in sources :

Example 21 with ImageOptions

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

the class ImagePipelineUtilsImplTest method testBuildImageRequest_whenRotatingEnabled_thenSetRotateOptions.

@Test
public void testBuildImageRequest_whenRotatingEnabled_thenSetRotateOptions() {
    RotationOptions rotationOptions = RotationOptions.forceRotation(RotationOptions.ROTATE_270);
    final ImageOptions imageOptions = ImageOptions.create().rotate(rotationOptions).build();
    ImageRequest imageRequest = mImagePipelineUtils.buildImageRequest(URI, imageOptions);
    assertThat(imageRequest).isNotNull();
    assertThat(imageRequest.getSourceUri()).isEqualTo(URI);
    assertThat(imageRequest.getRotationOptions()).isEqualTo(rotationOptions);
}
Also used : ImageRequest(com.facebook.imagepipeline.request.ImageRequest) ImageOptions(com.facebook.fresco.vito.options.ImageOptions) RotationOptions(com.facebook.imagepipeline.common.RotationOptions) Test(org.junit.Test)

Example 22 with ImageOptions

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

the class HierarcherImplTest method testBuildErrorDrawable_whenScaleTypeSet_thenReturnScaleTypeDrawable.

@Test
public void testBuildErrorDrawable_whenScaleTypeSet_thenReturnScaleTypeDrawable() {
    PointF focusPoint = new PointF(100, 234);
    ImageOptions options = ImageOptions.create().errorRes(RES_ID).errorScaleType(ScalingUtils.ScaleType.FOCUS_CROP).errorFocusPoint(focusPoint).build();
    Drawable errorDrawable = mHierarcher.buildErrorDrawable(mResources, options);
    assertThat(errorDrawable).isNotNull();
    assertThat(errorDrawable).isInstanceOf(ScaleTypeDrawable.class);
    ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) errorDrawable;
    assertThat(scaleTypeDrawable.getScaleType()).isEqualTo(ScalingUtils.ScaleType.FOCUS_CROP);
    assertThat(scaleTypeDrawable.getFocusPoint()).isEqualTo(focusPoint);
    assertThat(scaleTypeDrawable.getCurrent()).isEqualTo(mDrawable);
}
Also used : PointF(android.graphics.PointF) 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) ScaleTypeDrawable(com.facebook.drawee.drawable.ScaleTypeDrawable) Test(org.junit.Test)

Example 23 with ImageOptions

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

the class HierarcherImplTest method testBuildOverlayDrawable_whenInvalidResId_thenThrowNotFoundException.

@Test(expected = Resources.NotFoundException.class)
public void testBuildOverlayDrawable_whenInvalidResId_thenThrowNotFoundException() {
    ImageOptions options = ImageOptions.create().overlayRes(INVALID_RES_ID).build();
    mHierarcher.buildOverlayDrawable(mResources, options);
}
Also used : ImageOptions(com.facebook.fresco.vito.options.ImageOptions) Test(org.junit.Test)

Example 24 with ImageOptions

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

the class HierarcherImplTest method testBuildActualImageWrapper.

@Test
public void testBuildActualImageWrapper() {
    final PointF expectedFocusPoint = new PointF(1, 2);
    final ImageOptions imageOptions = ImageOptions.create().scale(ScalingUtils.ScaleType.FIT_CENTER).focusPoint(expectedFocusPoint).build();
    final Drawable actual = mHierarcher.buildActualImageWrapper(imageOptions, null);
    assertThat(actual).isInstanceOf(ScaleTypeDrawable.class);
    final ScaleTypeDrawable scaleTypeActual = (ScaleTypeDrawable) actual;
    assertThat(scaleTypeActual.getScaleType()).isEqualTo(ScalingUtils.ScaleType.FIT_CENTER);
    assertThat(scaleTypeActual.getFocusPoint()).isEqualTo(expectedFocusPoint);
}
Also used : PointF(android.graphics.PointF) 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) ScaleTypeDrawable(com.facebook.drawee.drawable.ScaleTypeDrawable) Test(org.junit.Test)

Example 25 with ImageOptions

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

the class HierarcherImplTest method testBuildPlaceholderDrawableScale.

@Test
public void testBuildPlaceholderDrawableScale() {
    final Drawable expected = new ColorDrawable(Color.YELLOW);
    ImageOptions options = ImageOptions.create().placeholder(expected).placeholderScaleType(ScalingUtils.ScaleType.CENTER).build();
    final Drawable result = mHierarcher.buildPlaceholderDrawable(mResources, options);
    assertThat(result).isExactlyInstanceOf(ScaleTypeDrawable.class);
    assertThat(result.getCurrent()).isEqualTo(expected);
}
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)

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