Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some tests to work with Robolectric upgrade #496

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this passes in robolectric3 probably due to Drawable.equals not being strict enough, so d2.equals(d3) == true in robo3 but not robo4.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is terrible. Thanks for fixing this.


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);
}

}