Skip to content

Commit

Permalink
Fix some tests to work with Robolectric upgrade
Browse files Browse the repository at this point in the history
Robolectric 4 is stricter with Drawable.equals, and one of these tests was just wrong...
  • Loading branch information
vinc3m1 committed Feb 20, 2019
1 parent a6b7dfb commit 4cda525
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ public void testGetLinkedDrawableForAnimation() {
assertThat(drawables).hasSize(1);
assertThat(drawables).contains(d3);

unmount(2, mountItem2);
unmount(1, mountItem2);

drawables = mHost.getDrawables();
assertThat(drawables).hasSize(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static com.facebook.litho.reference.Reference.acquire;
import static com.facebook.yoga.YogaEdge.LEFT;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.robolectric.Shadows.shadowOf;

import android.graphics.drawable.Drawable;
import android.view.ContextThemeWrapper;
Expand Down Expand Up @@ -57,7 +58,8 @@ public void testResolveDrawableAttribute() {
Drawable d = mContext.getResources().getDrawable(test_bg);
ComparableDrawableWrapper comparable =
(ComparableDrawableWrapper) acquire(mContext.getAndroidContext(), node.getBackground());
assertThat(comparable.getWrappedDrawable()).isEqualTo(d);
assertThat(shadowOf(comparable.getWrappedDrawable()).getCreatedFromResId())
.isEqualTo(shadowOf(d).getCreatedFromResId());
}

@Test
Expand All @@ -81,7 +83,8 @@ public void testDefaultDrawableAttribute() {
Drawable d = mContext.getResources().getDrawable(test_bg);
ComparableDrawableWrapper comparable =
(ComparableDrawableWrapper) acquire(mContext.getAndroidContext(), node.getBackground());
assertThat(comparable.getWrappedDrawable()).isEqualTo(d);
assertThat(shadowOf(comparable.getWrappedDrawable()).getCreatedFromResId())
.isEqualTo(shadowOf(d).getCreatedFromResId());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public void testReleaseAndGet() {
mCache.release(drawable2, 1);
mCache.release(drawable3, 1);

assertThat(mCache.get(1, resources)).isEqualTo(drawable);
assertThat(mCache.get(1, resources)).isEqualTo(drawable2);
assertThat(mCache.get(1, resources)).isEqualTo(drawable3);
assertThat(mCache.get(1, resources)).isSameAs(drawable3);
assertThat(mCache.get(1, resources)).isSameAs(drawable2);
assertThat(mCache.get(1, resources)).isSameAs(drawable);
}

}

0 comments on commit 4cda525

Please sign in to comment.