Skip to content

Commit bf6de35

Browse files
committed
Added test case test46WebPEncodingMonochrome
1 parent 304bed2 commit bf6de35

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Tests/SDWebImageWebPCoderTests.m

+15
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,21 @@ - (void)test45WebPEncodingMaxFileSize {
218218
XCTAssertLessThanOrEqual(dataWithLimit.length, maxFileSize);
219219
}
220220

221+
- (void)test46WebPEncodingMonochrome {
222+
CGSize size = CGSizeMake(512, 512);
223+
SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
224+
format.scale = 1;
225+
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:size format:format];
226+
UIColor *monochromeColor = UIColor.clearColor;
227+
UIImage *monochromeImage = [renderer imageWithActions:^(CGContextRef ctx) {
228+
[monochromeColor setFill];
229+
CGContextFillRect(ctx, CGRectMake(0, 0, size.width, size.height));
230+
}];
231+
XCTAssert(monochromeImage);
232+
NSData *data = [SDImageWebPCoder.sharedCoder encodedDataWithImage:monochromeImage format:SDImageFormatWebP options:nil];
233+
XCTAssert(data);
234+
}
235+
221236
- (void)testWebPDecodeDoesNotTriggerCACopyImage {
222237
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestColorspaceStatic" withExtension:@"webp"];
223238
NSData *data = [NSData dataWithContentsOfURL:staticWebPURL];

0 commit comments

Comments
 (0)