Merge pull request #3103 from seven332/master
Test case for coder priority in SDAnimatedImage
This commit is contained in:
commit
a55ffe0b87
|
@ -13,6 +13,41 @@
|
|||
|
||||
static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop count
|
||||
|
||||
// Check whether the coder is called
|
||||
@interface SDImageAPNGTestCoder : SDImageAPNGCoder
|
||||
|
||||
@property (nonatomic, class, assign) BOOL isCalled;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SDImageAPNGTestCoder
|
||||
|
||||
static BOOL _isCalled;
|
||||
|
||||
+ (BOOL)isCalled {
|
||||
return _isCalled;
|
||||
}
|
||||
|
||||
+ (void)setIsCalled:(BOOL)isCalled {
|
||||
_isCalled = isCalled;
|
||||
}
|
||||
|
||||
+ (instancetype)sharedCoder {
|
||||
static SDImageAPNGTestCoder *coder;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
coder = [[SDImageAPNGTestCoder alloc] init];
|
||||
});
|
||||
return coder;
|
||||
}
|
||||
|
||||
- (instancetype)initWithAnimatedImageData:(NSData *)data options:(SDImageCoderOptions *)options {
|
||||
SDImageAPNGTestCoder.isCalled = YES;
|
||||
return [super initWithAnimatedImageData:data options:options];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// Internal header
|
||||
@interface SDAnimatedImageView ()
|
||||
|
||||
|
@ -561,6 +596,12 @@ static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop coun
|
|||
[self waitForExpectationsWithCommonTimeout];
|
||||
}
|
||||
|
||||
- (void)test30AnimatedImageCoderPriority {
|
||||
[SDImageCodersManager.sharedManager addCoder:SDImageAPNGTestCoder.sharedCoder];
|
||||
[SDAnimatedImage imageWithData:[self testAPNGPData]];
|
||||
expect(SDImageAPNGTestCoder.isCalled).equal(YES);
|
||||
}
|
||||
|
||||
#pragma mark - Helper
|
||||
- (UIWindow *)window {
|
||||
if (!_window) {
|
||||
|
|
Loading…
Reference in New Issue