use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method onlyScaleDownOriginalBiggerHeightIs0.
@Test
public void onlyScaleDownOriginalBiggerHeightIs0() {
Bitmap source = Bitmap.createBitmap(50, 50, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(40, 0).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.8 0.8");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method exifRotation.
@Test
public void exifRotation() {
Request data = new Request.Builder(URI_1).rotate(-45).build();
Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
Bitmap result = transformResult(data, source, ORIENTATION_ROTATE_90);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameInstanceAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertThat(shadowMatrix.getPreOperations()).containsExactly("rotate 90.0");
}
use of org.robolectric.shadows.ShadowBitmap 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()).isSameInstanceAs(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()).containsExactly("scale 0.5 0.5");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method onlyScaleDownOriginalBiggerWidthIs0.
@Test
public void onlyScaleDownOriginalBiggerWidthIs0() {
Bitmap source = Bitmap.createBitmap(50, 50, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(0, 40).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.8 0.8");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method centerCropWideTooSmall.
@Test
public void centerCropWideTooSmall() {
Bitmap source = Bitmap.createBitmap(20, 10, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop().build();
Bitmap result = transformResult(data, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameInstanceAs(source);
assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(5);
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()).containsExactly("scale 4.0 4.0");
}
Aggregations