Added the new test case for fixed SDAnimatedImage behavior

This commit is contained in:
DreamPiggy 2024-05-06 15:42:38 +08:00
parent 2c9deffdf2
commit 753649217a
2 changed files with 17 additions and 1 deletions

View File

@ -786,6 +786,22 @@ static BOOL _isCalled;
} }
#endif #endif
- (void)test37AnimatedImageWithStaticDataBehavior {
UIImage *image = [[SDAnimatedImage alloc] initWithData:[self testJPEGData]];
// UIImage+Metadata.h
expect(image).notTo.beNil();
expect(image.sd_isAnimated).beFalsy();
expect(image.sd_imageFormat).equal(SDImageFormatJPEG);
expect(image.sd_imageFrameCount).equal(1);
expect(image.sd_imageLoopCount).equal(0);
// SDImageCoderHelper.h
UIImage *decodedImage = [SDImageCoderHelper decodedImageWithImage:image policy:SDImageForceDecodePolicyAutomatic];
expect(decodedImage).notTo.equal(image);
// SDWebImageDefine.h
UIImage *scaledImage = SDScaledImageForScaleFactor(2.0, image);
expect(scaledImage).notTo.equal(image);
}
#pragma mark - Helper #pragma mark - Helper
- (NSString *)testGIFPath { - (NSString *)testGIFPath {

View File

@ -644,7 +644,7 @@
SDImageCache *cache = [[SDImageCache alloc] initWithNamespace:@"Test"]; SDImageCache *cache = [[SDImageCache alloc] initWithNamespace:@"Test"];
cache.config.shouldUseWeakMemoryCache = YES; cache.config.shouldUseWeakMemoryCache = YES;
SDWebImageManager *imageManager = [[SDWebImageManager alloc] initWithCache:cache loader:[SDWebImageDownloader sharedDownloader]]; SDWebImageManager *imageManager = [[SDWebImageManager alloc] initWithCache:cache loader:[SDWebImageDownloader sharedDownloader]];
[imageView sd_setImageWithURL:kTestJPEGURL placeholderImage:nil options:0 context:@{SDWebImageContextCustomManager:imageManager} progress:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { [imageView sd_setImageWithURL:(NSURL *)kTestJPEGURL placeholderImage:nil options:0 context:@{SDWebImageContextCustomManager:imageManager} progress:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
expect(image).notTo.beNil(); expect(image).notTo.beNil();
[expectation fulfill]; [expectation fulfill];
}]; }];