Added test case `test46WebPEncodingMonochrome`

This commit is contained in:
DreamPiggy 2024-01-30 15:15:48 +08:00
parent 304bed2c4b
commit bf6de35302
1 changed files with 15 additions and 0 deletions

View File

@ -218,6 +218,21 @@ const int64_t kAsyncTestTimeout = 5;
XCTAssertLessThanOrEqual(dataWithLimit.length, maxFileSize);
}
- (void)test46WebPEncodingMonochrome {
CGSize size = CGSizeMake(512, 512);
SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
format.scale = 1;
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:size format:format];
UIColor *monochromeColor = UIColor.clearColor;
UIImage *monochromeImage = [renderer imageWithActions:^(CGContextRef ctx) {
[monochromeColor setFill];
CGContextFillRect(ctx, CGRectMake(0, 0, size.width, size.height));
}];
XCTAssert(monochromeImage);
NSData *data = [SDImageWebPCoder.sharedCoder encodedDataWithImage:monochromeImage format:SDImageFormatWebP options:nil];
XCTAssert(data);
}
- (void)testWebPDecodeDoesNotTriggerCACopyImage {
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestColorspaceStatic" withExtension:@"webp"];
NSData *data = [NSData dataWithContentsOfURL:staticWebPURL];