Add test case to ensure that Static WebP does not create CGContext
This commit is contained in:
parent
6e88c64f4f
commit
7cd404cccc
|
@ -10,6 +10,7 @@
|
|||
@import XCTest;
|
||||
#import <SDWebImage/SDWebImage.h>
|
||||
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
const int64_t kAsyncTestTimeout = 5;
|
||||
|
||||
|
@ -172,6 +173,18 @@ const int64_t kAsyncTestTimeout = 5;
|
|||
}
|
||||
}
|
||||
|
||||
- (void)test34StaticImageNotCreateCGContext {
|
||||
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageStatic" withExtension:@"webp"];
|
||||
NSData *data = [NSData dataWithContentsOfURL:staticWebPURL];
|
||||
SDImageWebPCoder *coder = [[SDImageWebPCoder alloc] initWithAnimatedImageData:data options:nil];
|
||||
XCTAssertTrue(coder.animatedImageFrameCount == 1);
|
||||
UIImage *image = [coder animatedImageFrameAtIndex:0];
|
||||
XCTAssertNotNil(image);
|
||||
Ivar ivar = class_getInstanceVariable(coder.class, "_canvas");
|
||||
CGContextRef canvas = ((CGContextRef (*)(id, Ivar))object_getIvar)(coder, ivar);
|
||||
XCTAssert(canvas == NULL);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SDWebImageWebPCoderTests (Helpers)
|
||||
|
|
Loading…
Reference in New Issue