use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testHierarchy_WithRoundedOverlayColor.
@Test
public void testHierarchy_WithRoundedOverlayColor() throws Exception {
RoundingParams roundingParams = RoundingParams.fromCornersRadius(10).setOverlayColor(0xFFFFFFFF);
GenericDraweeHierarchy dh = mBuilder.setRoundingParams(roundingParams).build();
RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
RoundedCornersDrawable roundedDrawable = (RoundedCornersDrawable) rootDrawable.getCurrent();
assertRoundingParams(roundingParams, roundedDrawable);
assertEquals(roundingParams.getOverlayColor(), roundedDrawable.getOverlayColor());
FadeDrawable fadeDrawable = (FadeDrawable) roundedDrawable.getCurrent();
assertNotNull(fadeDrawable);
verifyCallback(rootDrawable, fadeDrawable);
}
use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testSetActualImageScaleType.
@Test
public void testSetActualImageScaleType() {
GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mPlaceholderImage).build();
// actual image index in DH tree
final int imageIndex = 2;
FadeDrawable fadeDrawable = (FadeDrawable) dh.getTopLevelDrawable().getCurrent();
ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) fadeDrawable.getDrawable(imageIndex);
ScaleType scaleType1 = ScaleType.FOCUS_CROP;
dh.setActualImageScaleType(scaleType1);
assertEquals(scaleType1, scaleTypeDrawable.getScaleType());
ScaleType scaleType2 = ScaleType.CENTER;
dh.setActualImageScaleType(scaleType2);
assertEquals(scaleType2, scaleTypeDrawable.getScaleType());
}
use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testHierarchy_WithRetryImage.
@Test
public void testHierarchy_WithRetryImage() throws Exception {
GenericDraweeHierarchy dh = mBuilder.setRetryImage(mRetryImage, ScaleType.CENTER).build();
RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
assertScaleTypeAndDrawable(mRetryImage, ScaleType.CENTER, fadeDrawable.getDrawable(4));
verifyCallback(rootDrawable, mRetryImage);
}
use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testSetDrawable.
private void testSetDrawable(GenericDraweeHierarchy dh, int index, SetDrawableCallback callback) {
FadeDrawable fadeDrawable = (FadeDrawable) dh.getTopLevelDrawable().getCurrent();
// null
callback.setDrawable(null);
assertNull(fadeDrawable.getDrawable(index));
// null -> null
callback.setDrawable(null);
assertNull(fadeDrawable.getDrawable(index));
// null -> drawable
Drawable drawable1 = DrawableTestUtils.mockDrawable();
callback.setDrawable(drawable1);
assertSame(drawable1, fadeDrawable.getDrawable(index));
// drawable -> drawable
Drawable drawable2 = DrawableTestUtils.mockDrawable();
callback.setDrawable(drawable2);
assertSame(drawable2, fadeDrawable.getDrawable(index));
// drawable -> null
callback.setDrawable(null);
assertNull(fadeDrawable.getDrawable(index));
// null -> scaletype + drawable
Drawable drawable3 = DrawableTestUtils.mockDrawable();
callback.setDrawable(drawable3, ScaleType.FOCUS_CROP);
assertScaleTypeAndDrawable(drawable3, ScaleType.FOCUS_CROP, fadeDrawable.getDrawable(index));
// scaletype + drawable -> scaletype + drawable
Drawable drawable4 = DrawableTestUtils.mockDrawable();
callback.setDrawable(drawable4, ScaleType.CENTER);
assertScaleTypeAndDrawable(drawable4, ScaleType.CENTER, fadeDrawable.getDrawable(index));
// scaletype + drawable -> null
callback.setDrawable(null);
assertNull(fadeDrawable.getDrawable(index));
// drawable -> scaletype + drawable
callback.setDrawable(drawable1);
Drawable drawable5 = DrawableTestUtils.mockDrawable();
callback.setDrawable(drawable5, ScaleType.FIT_CENTER);
assertScaleTypeAndDrawable(drawable5, ScaleType.FIT_CENTER, fadeDrawable.getDrawable(index));
// scaletype + drawable -> drawable (kep the old scaletype)
Drawable drawable6 = DrawableTestUtils.mockDrawable();
callback.setDrawable(drawable6);
assertScaleTypeAndDrawable(drawable6, ScaleType.FIT_CENTER, fadeDrawable.getDrawable(index));
}
use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testHierarchy_WithBackgroundAndSingleOverlay.
@Test
public void testHierarchy_WithBackgroundAndSingleOverlay() throws Exception {
GenericDraweeHierarchy dh = mBuilder.setBackground(mBackground).setOverlay(mOverlay2).build();
RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
assertEquals(7, fadeDrawable.getNumberOfLayers());
assertSame(mBackground, fadeDrawable.getDrawable(0));
assertSame(mOverlay2, fadeDrawable.getDrawable(6));
verifyCallback(rootDrawable, mBackground);
verifyCallback(rootDrawable, mOverlay2);
}
Aggregations