use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method onlyScaleDownOriginalBigger.
@Test
public void onlyScaleDownOriginalBigger() {
Bitmap source = Bitmap.createBitmap(100, 100, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(50, 50).onlyScaleDown().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 0.5 0.5");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method exifHorizontalFlip.
@Test
public void exifHorizontalFlip() {
Request data = new Request.Builder(URI_1).rotate(-45).build();
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Bitmap result = transformResult(data, source, ORIENTATION_FLIP_HORIZONTAL);
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()).doesNotContain("rotate 180.0");
assertThat(shadowMatrix.getPreOperations()).doesNotContain("rotate 90.0");
assertThat(shadowMatrix.getPreOperations()).doesNotContain("rotate 270.0");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method onlyScaleDownOriginalSmaller.
@Test
public void onlyScaleDownOriginalSmaller() {
Bitmap source = Bitmap.createBitmap(50, 50, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(100, 100).onlyScaleDown().build();
Bitmap result = transformResult(data, source, 0);
assertThat(result).isSameInstanceAs(source);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isNull();
assertThat(shadowBitmap.getCreatedFromBitmap()).isNotSameInstanceAs(source);
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method rotation90Sizing.
@Test
public void rotation90Sizing() {
Request data = new Request.Builder(URI_1).rotate(90).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()).isSameInstanceAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPreOperations()).contains("scale 1.0 0.5");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method exifTranspose.
@Test
public void exifTranspose() {
Request data = new Request.Builder(URI_1).rotate(-45).build();
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Bitmap result = transformResult(data, source, ORIENTATION_TRANSPOSE);
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 90.0");
}
Aggregations