use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testHierarchy_WithPressedStateOverlay.
@Test
public void testHierarchy_WithPressedStateOverlay() throws Exception {
GenericDraweeHierarchy dh = mBuilder.setOverlay(mOverlay2).setPressedStateOverlay(mOverlay1).build();
RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
assertEquals(8, fadeDrawable.getNumberOfLayers());
assertSame(mOverlay2, fadeDrawable.getDrawable(6));
StateListDrawable stateListDrawable = (StateListDrawable) fadeDrawable.getDrawable(7);
assertNotNull(stateListDrawable);
}
use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testHierarchy_WithOverlays.
@Test
public void testHierarchy_WithOverlays() throws Exception {
GenericDraweeHierarchy dh = mBuilder.setOverlays(Arrays.asList(mOverlay1, mOverlay2)).build();
RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
assertEquals(8, fadeDrawable.getNumberOfLayers());
assertSame(mOverlay1, fadeDrawable.getDrawable(6));
assertSame(mOverlay2, fadeDrawable.getDrawable(7));
verifyCallback(rootDrawable, mOverlay1);
verifyCallback(rootDrawable, mOverlay2);
}
use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testHierarchy_WithMatrix.
@Test
public void testHierarchy_WithMatrix() throws Exception {
GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mPlaceholderImage, null).setRetryImage(mRetryImage, null).setFailureImage(mFailureImage, null).setProgressBarImage(mProgressBarImage, null).setActualImageMatrix(mActualImageMatrix).build();
RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
assertEquals(7, fadeDrawable.getNumberOfLayers());
assertNull(fadeDrawable.getDrawable(0));
assertSame(mPlaceholderImage, fadeDrawable.getDrawable(1));
assertSame(mProgressBarImage, fadeDrawable.getDrawable(3));
assertSame(mRetryImage, fadeDrawable.getDrawable(4));
assertSame(mFailureImage, fadeDrawable.getDrawable(5));
assertNull(fadeDrawable.getDrawable(6));
MatrixDrawable matrixDrawable = (MatrixDrawable) fadeDrawable.getDrawable(2);
assertNotNull(matrixDrawable);
assertEquals(mActualImageMatrix, matrixDrawable.getMatrix());
assertSame(ForwardingDrawable.class, matrixDrawable.getCurrent().getClass());
verifyCallback(rootDrawable, mPlaceholderImage);
}
use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testHierarchy_NoScaleTypeNorMatrix.
@Test
public void testHierarchy_NoScaleTypeNorMatrix() throws Exception {
GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mPlaceholderImage, null).setRetryImage(mRetryImage, null).setFailureImage(mFailureImage, null).setProgressBarImage(mProgressBarImage, null).setActualImageScaleType(null).build();
RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
assertEquals(7, fadeDrawable.getNumberOfLayers());
assertNull(fadeDrawable.getDrawable(0));
assertSame(mPlaceholderImage, fadeDrawable.getDrawable(1));
assertSame(ForwardingDrawable.class, fadeDrawable.getDrawable(2).getClass());
assertSame(mProgressBarImage, fadeDrawable.getDrawable(3));
assertSame(mRetryImage, fadeDrawable.getDrawable(4));
assertSame(mFailureImage, fadeDrawable.getDrawable(5));
assertNull(fadeDrawable.getDrawable(6));
verifyCallback(rootDrawable, mPlaceholderImage);
}
use of com.facebook.drawee.drawable.FadeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testHierarchy_WithAllBranches.
@Test
public void testHierarchy_WithAllBranches() throws Exception {
GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mPlaceholderImage, ScaleType.CENTER).setRetryImage(mRetryImage, ScaleType.FIT_CENTER).setFailureImage(mFailureImage, ScaleType.FIT_CENTER).setProgressBarImage(mProgressBarImage, ScaleType.CENTER).setActualImageScaleType(ScaleType.CENTER_CROP).build();
RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
assertEquals(7, fadeDrawable.getNumberOfLayers());
assertNull(fadeDrawable.getDrawable(0));
assertScaleTypeAndDrawable(mPlaceholderImage, ScaleType.CENTER, fadeDrawable.getDrawable(1));
assertActualImageScaleType(ScaleType.CENTER_CROP, null, fadeDrawable.getDrawable(2));
assertScaleTypeAndDrawable(mProgressBarImage, ScaleType.CENTER, fadeDrawable.getDrawable(3));
assertScaleTypeAndDrawable(mRetryImage, ScaleType.FIT_CENTER, fadeDrawable.getDrawable(4));
assertScaleTypeAndDrawable(mFailureImage, ScaleType.FIT_CENTER, fadeDrawable.getDrawable(5));
assertNull(fadeDrawable.getDrawable(6));
verifyCallback(rootDrawable, mPlaceholderImage);
}
Aggregations