square / assertj-android

A set of AssertJ helpers geared toward testing Android.
https://square.github.io/assertj-android/
Apache License 2.0
1.58k stars 156 forks source link

Fix hasDrawable by use of Bitmap #179

Closed mapyo closed 8 years ago

mapyo commented 8 years ago

Thank you for this great library!

It's the following methods and passes the test.

Drawable drawable = context.getResources().getDrawable(R.drawable.star);
testImageView.setImageDrawable(drawable);
assertThat(testImageView).hasDrawable(drawable);

However, the test does not pass to be the following method.

<ImageView
    android:id="@+id/test_image_view"
    android:src="@drawable/star"
    android:layout_width="wrap_content"
    android:layout_height="match_parent" />
Drawable drawable = context.getResources().getDrawable(R.drawable.star);
assertThat(testImageView).hasDrawable(drawable);

So, I fixed hasDrawable by use of Bitmap.

Thank you.

JakeWharton commented 8 years ago

What if the ImageView isn't displaying a Bitmap?

On Sun, Nov 15, 2015, 6:28 PM mapyo notifications@github.com wrote:

Thank you for this great library!

It's the following methods and passes the test.

Drawable drawable = context.getResources().getDrawable(R.drawable.star); testImageView.setImageDrawable(drawable); assertThat(testImageView).hasDrawable(drawable);

However, the test does not pass to be the following method.

<ImageView android:id="@+id/test_image_view" android:src="@drawable/star" android:layout_width="wrap_content" android:layout_height="match_parent" />

Drawable drawable = context.getResources().getDrawable(R.drawable.star); assertThat(testImageView).hasDrawable(drawable);

So, I fixed hasDrawable by use of Bitmap.

Thank you.

You can view, comment on, or merge this pull request online at:

https://github.com/square/assertj-android/pull/179 Commit Summary

  • Fix hasDrawable

File Changes

Patch Links:

— Reply to this email directly or view it on GitHub https://github.com/square/assertj-android/pull/179.

mapyo commented 8 years ago

Oh, I am sorry. Other Drawables not working. I would be better off closing this pr...