ColoringTest.java 文件源码

java
阅读 33 收藏 0 点赞 0 评论 0

项目:silly-android 作者:
/**
 * Tests the {@link Coloring#colorVectorDrawable(VectorDrawable, int)} method.
 * <p>
 * Unfortunately {@link VectorDrawable#setColorFilter(int, PorterDuff.Mode)} is not mocked in Android JAR yet.
 */
@Test
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public final void testColorVectorDrawable() {
    try {
        final VectorDrawable vectorDrawable = new VectorDrawable();
        assertNotNull("VectorDrawable is null", vectorDrawable);
        final VectorDrawable colored = Coloring.colorVectorDrawable(vectorDrawable, Color.RED);
        final PorterDuff.Mode mode = PorterDuff.Mode.SRC_ATOP;
        assertEquals("Vector color filter does not match", new PorterDuffColorFilter(Color.RED, mode), colored.getColorFilter());
    } catch (RuntimeException e) {
        boolean knownIssue = e.getMessage().contains("not mocked");
        if (!knownIssue) {
            e.printStackTrace();
        }
        assertTrue("Unknown error: " + e.getMessage(), knownIssue);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号