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

ShadowMatrix does not implement map* methods #3602

Closed
Kalabasa opened this issue Dec 14, 2017 · 3 comments
Closed

ShadowMatrix does not implement map* methods #3602

Kalabasa opened this issue Dec 14, 2017 · 3 comments
Milestone

Comments

@Kalabasa
Copy link
Contributor

Description

ShadowMatrix does not implement mapPoints and mapVectors methods.

Steps to Reproduce

// in a Robolectric test
Matrix matrix = new Matrix();
matrix.setTranslate(1, 2);

float[] test = new float[] { 0, 0 };

matrix.mapPoints(test); // nothing happens here

assert test[0] == 1;
assert test[1] == 2;

Robolectric & Android Version

robolectric: 3.5.1
android: 26

@jongerrish
Copy link
Contributor

jongerrish commented Dec 14, 2017 via email

@Kalabasa
Copy link
Contributor Author

Possibly! I've written a quick fix for my project just now. mapPoints is working ok for mine now.

@Implements(Matrix.class)
public class ShadowMatrix extends org.robolectric.shadows.ShadowMatrix {
	@Implementation
	public void mapPoints(float[] dst, int dstIndex, float[] src, int srcIndex, int pointCount) {
		for (int i = 0; i < pointCount; i++) {
			PointF mapped = mapPoint(src[srcIndex + i * 2], src[srcIndex + i * 2 + 1]);
			dst[dstIndex + i * 2] = mapped.x;
			dst[dstIndex + i * 2 + 1] = mapped.y;
		}
	}
}

But, for the mapVectors method, I'm not sure how vectors are mapped.

@Kalabasa
Copy link
Contributor Author

Kalabasa commented Dec 16, 2017

Hi, I'm working on a fix. Will make a pull request later. 😄

Update: #3609

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants