/**
* 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);
}
}
ColoringTest.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:silly-android
作者:
评论列表
文章目录