Added test23ThatThumbnailEncodeCalculation test case

This commit is contained in:
DreamPiggy 2022-06-20 18:20:34 +08:00
parent fcb53cb5ff
commit 018cf32ab3
1 changed files with 14 additions and 1 deletions

View File

@ -341,7 +341,7 @@
}
}
- (void)test22ThatThumbnailPreserveAspectRatio {
- (void)test22ThatThumbnailDecodeCalculation {
NSString *testImagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestImageLarge" ofType:@"jpg"];
NSData *testImageData = [NSData dataWithContentsOfFile:testImagePath];
CGSize thumbnailSize = CGSizeMake(400, 300);
@ -353,6 +353,19 @@
expect(imageSize.height).equal(263);
}
- (void)test23ThatThumbnailEncodeCalculation {
NSString *testImagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestImageLarge" ofType:@"jpg"];
NSData *testImageData = [NSData dataWithContentsOfFile:testImagePath];
UIImage *image = [SDImageIOCoder.sharedCoder decodedImageWithData:testImageData options:nil];
expect(image.size).equal(CGSizeMake(5250, 3450));
CGSize thumbnailSize = CGSizeMake(4000, 4000); // 3450 < 4000 < 5250
NSData *encodedData = [SDImageIOCoder.sharedCoder encodedDataWithImage:image format:SDImageFormatJPEG options:@{
SDImageCoderEncodeMaxPixelSize: @(thumbnailSize)
}];
UIImage *encodedImage = [UIImage sd_imageWithData:encodedData];
expect(encodedImage.size).equal(CGSizeMake(4000, 2629));
}
#pragma mark - Utils
- (void)verifyCoder:(id<SDImageCoder>)coder