Java 类org.robolectric.shadows.ShadowDrawable 实例源码

项目:materialandroid    文件:AbstractGridItemViewAssert.java   
public AbstractGridItemViewAssert hasIcon(@DrawableRes int expectedIcon) {
  isNotNull();
  ShadowDrawable shadowIcon = shadowOf(actual.getIcon());
  int createdFromResId = shadowIcon.getCreatedFromResId();
  Assertions.assertThat(createdFromResId)
      .overridingErrorMessage("Expected icon res ID <%s> but was <%s>.",
          expectedIcon, createdFromResId)
      .isEqualTo(expectedIcon);
  return myself;
}
项目:materialandroid    文件:AbstractListItemViewAssert.java   
public AbstractListItemViewAssert hasIcon(@DrawableRes int expectedIcon) {
  isNotNull();
  ShadowDrawable shadowIcon = shadowOf(actual.getIcon());
  int createdFromResId = shadowIcon.getCreatedFromResId();
  Assertions.assertThat(createdFromResId)
      .overridingErrorMessage("Expected icon res ID <%s> but was <%s>.",
          expectedIcon, createdFromResId)
      .isEqualTo(expectedIcon);
  return myself;
}
项目:materialandroid    文件:AbstractListItemViewAssert.java   
public AbstractListItemViewAssert hasAvatar(@DrawableRes int expectedAvatar) {
  isNotNull();
  ShadowDrawable shadowAvatar = shadowOf(actual.getAvatar());
  int createdFromResId = shadowAvatar.getCreatedFromResId();
  Assertions.assertThat(createdFromResId)
      .overridingErrorMessage("Expected avatar res ID <%s> but was <%s>.",
          expectedAvatar, createdFromResId)
      .isEqualTo(expectedAvatar);
  return myself;
}
项目:materialandroid    文件:AbstractPasswordEditTextAssert.java   
private void assertThatToggleHasResId(@DrawableRes int resId) {
  Drawable[] drawables = actual.getDrawables();
  ShadowDrawable shadow = shadowOf(drawables[2]);
  int actualResId = shadow.getCreatedFromResId();
  Assertions.assertThat(actualResId)
      .overridingErrorMessage("Expected toggle <%s> but was <%s>.",
          actual.getResources().getResourceEntryName(resId),
          actual.getResources().getResourceEntryName(actualResId))
      .isNotNull()
      .isEqualTo(resId);

}
项目:digits-android    文件:ThemeUtilsTest.java   
@Test
public void testGetLogoDrawable() throws Exception {
    if (BuildConfig.DEBUG) {
        RuntimeEnvironment.application.setTheme(R.style.DigitsDebugLightTheme);
        final ShadowDrawable drawable = (ShadowDrawable) ShadowExtractor
                .extract(ThemeUtils.getLogoDrawable(RuntimeEnvironment.application.getTheme()));
        assertEquals(R.drawable.dgts__logo, drawable.getCreatedFromResId());
    }
}
项目:digits-android    文件:LogoImageViewTest.java   
@Test
public void testConstructor_themeWithDrawable() throws Exception {
    if (BuildConfig.DEBUG) {
        RuntimeEnvironment.application.setTheme(R.style.DigitsDebugLightTheme);
        final LogoImageView imageView = new LogoImageView(RuntimeEnvironment.application);
        final ShadowDrawable drawable = (ShadowDrawable) ShadowExtractor
                .extract(imageView.getDrawable());
        assertEquals(R.drawable.dgts__logo, drawable.getCreatedFromResId());
        assertEquals(View.VISIBLE, imageView.getVisibility());
    }
}
项目:FullRobolectricTestSample    文件:RobolectricPackageManagerTest.java   
@Test
public void canResolveDrawableGivenPackageAndResourceId() throws Exception {
  Drawable drawable = ShadowDrawable.createFromStream(new ByteArrayInputStream(new byte[0]), "my_source");
  rpm.addDrawableResolution("com.example.foo", 4334, drawable);
  Drawable actual = rpm.getDrawable("com.example.foo", 4334, null);
  assertThat(actual).isSameAs(drawable);
}
项目:materialandroid    文件:AbstractGridItemViewAssert.java   
private static ShadowDrawable shadowOf(Drawable actual) {
  return (ShadowDrawable) ShadowExtractor.extract(actual);
}
项目:materialandroid    文件:AbstractListItemViewAssert.java   
private static ShadowDrawable shadowOf(Drawable actual) {
  return (ShadowDrawable) ShadowExtractor.extract(actual);
}
项目:materialandroid    文件:AbstractPasswordEditTextAssert.java   
public static ShadowDrawable shadowOf(Drawable actual) {
  return (ShadowDrawable) ShadowExtractor.extract(actual);
}
项目:FullRobolectricTestSample    文件:Robolectric.java   
public static ShadowDrawable shadowOf(Drawable instance) {
  return (ShadowDrawable) shadowOf_(instance);
}