Skip to content

Commit

Permalink
Fix some tests to work with Robolectric upgrade (#496)
Browse files Browse the repository at this point in the history
Summary:
Robolectric 4 is stricter with Drawable.equals, and one of these tests was just wrong...
Pull Request resolved: #496

Reviewed By: marco-cova

Differential Revision: D14164028

Pulled By: passy

fbshipit-source-id: 8c44cad2ae9fecee51b868c72d67e5ad7a5df6d4
  • Loading branch information
vinc3m1 authored and facebook-github-bot committed Feb 21, 2019
1 parent d0c3094 commit 05e0653
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 @@ -920,7 +920,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 05e0653

Please sign in to comment.