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; }
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; }
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; }
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); }
@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()); } }
@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()); } }
@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); }
private static ShadowDrawable shadowOf(Drawable actual) { return (ShadowDrawable) ShadowExtractor.extract(actual); }
public static ShadowDrawable shadowOf(Drawable actual) { return (ShadowDrawable) ShadowExtractor.extract(actual); }
public static ShadowDrawable shadowOf(Drawable instance) { return (ShadowDrawable) shadowOf_(instance); }