use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method exifRotationSizing.
@Test
public void exifRotationSizing() {
Request data = new Request.Builder(URI_1).resize(5, 10).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()).contains("scale 1.0 0.5");
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method huntDecodesWithRequestHandler.
@Test
public void huntDecodesWithRequestHandler() throws Exception {
Action action = mockAction(CUSTOM_URI_KEY, CUSTOM_URI);
BitmapHunter hunter = forRequest(mockPicasso(new CustomRequestHandler()), dispatcher, cache, action);
RequestHandler.Result.Bitmap result = hunter.hunt();
assertThat(result.getBitmap()).isEqualTo(bitmap);
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method huntReturnsWhenResultInCache.
@Test
public void huntReturnsWhenResultInCache() throws Exception {
cache.set(URI_KEY_1 + KEY_SEPARATOR, bitmap);
Action action = mockAction(URI_KEY_1, URI_1, mockImageViewTarget());
TestableBitmapHunter hunter = new TestableBitmapHunter(picasso, dispatcher, cache, action, bitmap);
RequestHandler.Result.Bitmap result = hunter.hunt();
assertThat(cache.hitCount()).isEqualTo(1);
assertThat(result).isNotNull();
assertThat(result.getBitmap()).isEqualTo(bitmap);
assertThat(result.loadedFrom).isEqualTo(MEMORY);
verify(picasso, never()).bitmapDecoded(bitmap);
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method huntDecodesWhenNotInCache.
@Test
public void huntDecodesWhenNotInCache() throws Exception {
Action action = mockAction(URI_KEY_1, URI_1, mockImageViewTarget());
TestableBitmapHunter hunter = new TestableBitmapHunter(picasso, dispatcher, cache, action, bitmap);
RequestHandler.Result.Bitmap result = hunter.hunt();
assertThat(cache.missCount()).isEqualTo(1);
assertThat(result).isNotNull();
assertThat(result.getBitmap()).isEqualTo(bitmap);
assertThat(result.loadedFrom).isEqualTo(NETWORK);
verify(picasso).bitmapDecoded(bitmap);
}
use of com.squareup.picasso3.RequestHandler.Result in project picasso by square.
the class BitmapHunterTest method centerCropWithGravityVerticalTop.
@Test
public void centerCropWithGravityVerticalTop() {
Bitmap source = Bitmap.createBitmap(10, 20, ARGB_8888);
Request data = new Request.Builder(URI_1).resize(40, 40).centerCrop(Gravity.TOP).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");
}
Aggregations