Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Reset the state of matrix object using a proper reset method. #56

Merged
merged 1 commit into from
Oct 18, 2014

Conversation

rafaelportela
Copy link

This library is pretty awesome, I'm really happy with that! :)

Currently I'm having an issue when trying to run Robolectric tests that inflates layouts containing a RoundedImageView:

Caused by: java.lang.NullPointerException: can't get a shadow for null
    at org.robolectric.bytecode.ShadowWrangler.shadowOf(ShadowWrangler.java:432)
    at org.robolectric.Robolectric.shadowOf_(Robolectric.java:1034)
    at org.robolectric.Robolectric.shadowOf(Robolectric.java:741)
    at org.robolectric.shadows.ShadowMatrix.set(ShadowMatrix.java:64)
    at android.graphics.Matrix.set(Matrix.java)

Since android.graphics.Matrix.set(param) does a null check, and calls android.graphics.Matrix.reset() when the param is null - see android.graphics.Matrix code, line 260, it might not be a problem to directly call the reset instead of set(null). This would keep everything working as before, and would make Robolectric happy! =]

The Matrix method 'set(null)', with null parameter, works fine on emulators and real
devices, but doesn't play well in unit tests with Robolectric, which
throw an Exception after checking for null params.

Since a proper method for reseting the state of Matrixes are available,
should not be an issue using it.
@vinc3m1
Copy link
Owner

vinc3m1 commented Oct 9, 2014

The changes look good, will do some testing to double check and merge and make a release when I get a chance, but you should report this upstream to robolectric as well!

@rafaelportela
Copy link
Author

Nice, man! Thanks for that!

vinc3m1 added a commit that referenced this pull request Oct 18, 2014
Reset the state of matrix object using a proper reset method.
@vinc3m1 vinc3m1 merged commit 920b083 into vinc3m1:master Oct 18, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants