ColoringTest.java 文件源码

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

项目:silly-android 作者:
/**
 * Tests the {@link Coloring#createMultiStateDrawable(Drawable, Drawable, Drawable, boolean)} method.
 * <p>
 * Unfortunately some Drawable properties are not shadowed by Robolectric yet, so we can test only the basic stuff here.
 */
@Test
public final void testCreateMultiStateDrawable() {
    // noinspection deprecation - can't enforce Lollipop here
    final BitmapDrawable normal = (BitmapDrawable) mActivityContext.getResources().getDrawable(android.R.drawable.btn_star_big_on);
    assertNotNull("Normal drawable is null", normal);

    // noinspection deprecation - can't enforce Lollipop here
    final BitmapDrawable clicked = (BitmapDrawable) mActivityContext.getResources().getDrawable(android.R.drawable.btn_star_big_off);
    assertNotNull("Clicked drawable is null", clicked);

    // noinspection deprecation - can't enforce Lollipop here
    final BitmapDrawable checked = (BitmapDrawable) mActivityContext.getResources().getDrawable(android.R.drawable.star_off);
    assertNotNull("Checked drawable is null", checked);

    final StateListDrawable stateList = Coloring.createMultiStateDrawable(normal, clicked, checked, true);
    assertNotNull("Contrast state drawable is null", stateList);
    assertTrue("Contrast state drawable is not stateful", stateList.isStateful());
    final Drawable.ConstantState constantState = stateList.getConstantState();
    assertNotNull("Constant state is null", constantState);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号