use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method centerInsideTallTooSmall.
@Test
public void centerInsideTallTooSmall() {
Bitmap source = Bitmap.createBitmap(20, 10, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(50, 50).centerInside().build();
Bitmap result = transformResult(data, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameInstanceAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 2.5 2.5");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method exifTransverse.
@Test
public void exifTransverse() {
Request data = new Request.Builder(URI_1).rotate(-45).build();
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Bitmap result = transformResult(data, source, ORIENTATION_TRANSVERSE);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameInstanceAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPostOperations()).containsExactly("scale -1.0 1.0");
assertThat(shadowMatrix.getPreOperations()).containsExactly("rotate 270.0");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method rotation.
@Test
public void rotation() {
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Request data = new Request.Builder(URI_1).rotate(-45).build();
Bitmap result = transformResult(data, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameInstanceAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getSetOperations()).containsEntry("rotate", "-45.0");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method resize.
@Test
public void resize() {
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(20, 15).build();
Bitmap result = transformResult(data, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameInstanceAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPreOperations()).containsExactly("scale 2.0 1.5");
}
use of org.robolectric.shadows.ShadowBitmap 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()).isSameInstanceAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getSetOperations()).containsEntry("rotate", "-45.0 10.0 10.0");
}
Aggregations