Added the test case to ensure the background color encoding options on JPEG works
This commit is contained in:
parent
f798b89fc2
commit
db610363f4
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "SDTestCase.h"
|
#import "SDTestCase.h"
|
||||||
|
#import "UIColor+HexString.h"
|
||||||
|
|
||||||
@interface SDWebImageDecoderTests : SDTestCase
|
@interface SDWebImageDecoderTests : SDTestCase
|
||||||
|
|
||||||
|
@ -82,6 +83,21 @@
|
||||||
expect(decodedImage.size.height).to.equal(image.size.height);
|
expect(decodedImage.size.height).to.equal(image.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)test08ThatEncodeAlphaImageToJPGWithBackgroundColor {
|
||||||
|
NSString * testImagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestImage" ofType:@"png"];
|
||||||
|
UIImage *image = [[UIImage alloc] initWithContentsOfFile:testImagePath];
|
||||||
|
UIColor *backgroundColor = [UIColor blackColor];
|
||||||
|
NSData *encodedData = [SDImageCodersManager.sharedManager encodedDataWithImage:image format:SDImageFormatJPEG options:@{SDImageCoderEncodeBackgroundColor : backgroundColor}];
|
||||||
|
expect(encodedData).notTo.beNil();
|
||||||
|
UIImage *decodedImage = [SDImageCodersManager.sharedManager decodedImageWithData:encodedData options:nil];
|
||||||
|
expect(decodedImage).notTo.beNil();
|
||||||
|
expect(decodedImage.size.width).to.equal(image.size.width);
|
||||||
|
expect(decodedImage.size.height).to.equal(image.size.height);
|
||||||
|
// Check background color, should not be white but the black color
|
||||||
|
UIColor *testColor = [decodedImage sd_colorAtPoint:CGPointMake(1, 1)];
|
||||||
|
expect(testColor.sd_hexString).equal(backgroundColor.sd_hexString);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)test11ThatAPNGPCoderWorks {
|
- (void)test11ThatAPNGPCoderWorks {
|
||||||
NSURL *APNGURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"apng"];
|
NSURL *APNGURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"apng"];
|
||||||
[self verifyCoder:[SDImageAPNGCoder sharedCoder]
|
[self verifyCoder:[SDImageAPNGCoder sharedCoder]
|
||||||
|
|
Loading…
Reference in New Issue