use of org.robolectric.shadows.ShadowMatrix in project picasso by square.
the class BitmapHunterTest method pivotRotation.
@Test
public void pivotRotation() {
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Request data = new Request.Builder(URI_1).rotate(-45, 10, 10).build();
Bitmap result = transformResult(data, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getSetOperations()).contains(entry("rotate", "-45.0 10.0 10.0"));
}
use of org.robolectric.shadows.ShadowMatrix in project picasso by square.
the class BitmapHunterTest method centerCropWideTooLarge.
@Test
public void centerCropWideTooLarge() {
Bitmap source = Bitmap.createBitmap(200, 100, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(50, 50).centerCrop().build();
Bitmap result = transformResult(data, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(50);
assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(0);
assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(100);
assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(100);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPreOperations()).containsOnly("scale 0.5 0.5");
}
use of org.robolectric.shadows.ShadowMatrix in project picasso by square.
the class BitmapHunterTest method keepsAspectRationWhileResizingWhenDesiredWidthIs0.
@Test
public void keepsAspectRationWhileResizingWhenDesiredWidthIs0() {
Request request = new Request.Builder(URI_1).resize(20, 0).build();
Bitmap source = Bitmap.createBitmap(40, 20, ARGB_8888);
Bitmap result = transformResult(request, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPreOperations()).containsOnly("scale 0.5 0.5");
}
use of org.robolectric.shadows.ShadowMatrix in project picasso by square.
the class BitmapHunterTest method rotation180Sizing.
@Test
public void rotation180Sizing() throws Exception {
Request data = new Request.Builder(URI_1).rotate(180).resize(5, 10).build();
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Bitmap result = transformResult(data, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPreOperations()).contains("scale 0.5 1.0");
}
use of org.robolectric.shadows.ShadowMatrix in project picasso by square.
the class BitmapHunterTest method centerCropWithGravityHorizontalLeft.
@Test
public void centerCropWithGravityHorizontalLeft() {
Bitmap source = Bitmap.createBitmap(20, 10, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop(Gravity.LEFT).build();
Bitmap result = transformResult(data, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(0);
assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(0);
assertThat(shadowBitmap.getCreatedFromWidth()).isEqualTo(10);
assertThat(shadowBitmap.getCreatedFromHeight()).isEqualTo(10);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPreOperations()).containsOnly("scale 4.0 4.0");
}
Aggregations