Search in sources :

Example 71 with ShadowBitmap

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");
}
Also used : TestUtils.makeBitmap(com.squareup.picasso3.TestUtils.makeBitmap) ShadowBitmap(org.robolectric.shadows.ShadowBitmap) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) ShadowMatrix(org.robolectric.shadows.ShadowMatrix) BitmapHunter.forRequest(com.squareup.picasso3.BitmapHunter.forRequest) ShadowBitmap(org.robolectric.shadows.ShadowBitmap) ShadowMatrix(org.robolectric.shadows.ShadowMatrix) Test(org.junit.Test)

Example 72 with ShadowBitmap

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");
}
Also used : TestUtils.makeBitmap(com.squareup.picasso3.TestUtils.makeBitmap) ShadowBitmap(org.robolectric.shadows.ShadowBitmap) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) ShadowMatrix(org.robolectric.shadows.ShadowMatrix) BitmapHunter.forRequest(com.squareup.picasso3.BitmapHunter.forRequest) ShadowBitmap(org.robolectric.shadows.ShadowBitmap) ShadowMatrix(org.robolectric.shadows.ShadowMatrix) Test(org.junit.Test)

Example 73 with ShadowBitmap

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");
}
Also used : TestUtils.makeBitmap(com.squareup.picasso3.TestUtils.makeBitmap) ShadowBitmap(org.robolectric.shadows.ShadowBitmap) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) ShadowMatrix(org.robolectric.shadows.ShadowMatrix) BitmapHunter.forRequest(com.squareup.picasso3.BitmapHunter.forRequest) ShadowBitmap(org.robolectric.shadows.ShadowBitmap) ShadowMatrix(org.robolectric.shadows.ShadowMatrix) Test(org.junit.Test)

Example 74 with ShadowBitmap

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");
}
Also used : TestUtils.makeBitmap(com.squareup.picasso3.TestUtils.makeBitmap) ShadowBitmap(org.robolectric.shadows.ShadowBitmap) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix) ShadowMatrix(org.robolectric.shadows.ShadowMatrix) BitmapHunter.forRequest(com.squareup.picasso3.BitmapHunter.forRequest) ShadowBitmap(org.robolectric.shadows.ShadowBitmap) ShadowMatrix(org.robolectric.shadows.ShadowMatrix) Test(org.junit.Test)

Aggregations

ShadowBitmap (org.robolectric.shadows.ShadowBitmap)74 Bitmap (android.graphics.Bitmap)73 Test (org.junit.Test)73 Matrix (android.graphics.Matrix)67 ShadowMatrix (org.robolectric.shadows.ShadowMatrix)67 BitmapHunter.forRequest (com.squareup.picasso.BitmapHunter.forRequest)39 TestUtils.makeBitmap (com.squareup.picasso.TestUtils.makeBitmap)39 BitmapHunter.forRequest (com.squareup.picasso3.BitmapHunter.forRequest)34 TestUtils.makeBitmap (com.squareup.picasso3.TestUtils.makeBitmap)34