Search in sources :

Example 1 with MatrixDrawable

use of com.facebook.drawee.drawable.MatrixDrawable 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);
}
Also used : MatrixDrawable(com.facebook.drawee.drawable.MatrixDrawable) FadeDrawable(com.facebook.drawee.drawable.FadeDrawable) Test(org.junit.Test)

Aggregations

FadeDrawable (com.facebook.drawee.drawable.FadeDrawable)1 MatrixDrawable (com.facebook.drawee.drawable.MatrixDrawable)1 Test (org.junit.Test)1