use of org.robolectric.shadows.ShadowBitmap 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()).isSameInstanceAs(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()).containsExactly("scale 4.0 4.0");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method centerCropTallTooSmall.
@Test
public void centerCropTallTooSmall() {
Bitmap source = Bitmap.createBitmap(10, 20, 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(0);
assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(5);
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");
}
use of org.robolectric.shadows.ShadowBitmap in project picasso by square.
the class BitmapHunterTest method centerCropTallTooLarge.
@Test
public void centerCropTallTooLarge() {
Bitmap source = Bitmap.createBitmap(100, 200, 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(0);
assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(50);
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 centerCropWithGravityVerticalBottom.
@Test
public void centerCropWithGravityVerticalBottom() {
Bitmap source = Bitmap.createBitmap(10, 20, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop(Gravity.BOTTOM).build();
Bitmap result = transformResult(data, source, 0);
ShadowBitmap shadowBitmap = shadowOf(result);
assertThat(shadowBitmap.getCreatedFromBitmap()).isSameInstanceAs(source);
assertThat(shadowBitmap.getCreatedFromX()).isEqualTo(0);
assertThat(shadowBitmap.getCreatedFromY()).isEqualTo(10);
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