Added `test28ProgressiveDownloadShouldUseSameCoder`

This commit is contained in:
DreamPiggy 2021-03-04 21:09:22 +08:00
parent 319a308995
commit d277514cbe
2 changed files with 28 additions and 0 deletions

View File

@ -707,6 +707,32 @@
[self waitForExpectationsWithCommonTimeout];
}
- (void)test28ProgressiveDownloadShouldUseSameCoder {
XCTestExpectation *expectation = [self expectationWithDescription:@"Progressive download should use the same coder for each animated image"];
SDWebImageDownloader *downloader = [[SDWebImageDownloader alloc] init];
__block SDWebImageDownloadToken *token;
__block id<SDImageCoder> progressiveCoder;
token = [downloader downloadImageWithURL:[NSURL URLWithString:kTestGIFURL] options:SDWebImageDownloaderProgressiveLoad context:@{SDWebImageContextAnimatedImageClass : SDAnimatedImage.class} progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
expect(error).beNil();
expect([image isKindOfClass:SDAnimatedImage.class]).beTruthy();
id<SDImageCoder> coder = ((SDAnimatedImage *)image).animatedCoder;
if (!progressiveCoder) {
progressiveCoder = coder;
}
expect(progressiveCoder).equal(coder);
if (!finished) {
progressiveCoder = coder;
} else {
[expectation fulfill];
}
}];
[self waitForExpectationsWithCommonTimeoutUsingHandler:^(NSError * _Nullable error) {
[downloader invalidateSessionAndCancel:YES];
}];
}
#pragma mark - SDWebImageLoader
- (void)test30CustomImageLoaderWorks {
XCTestExpectation *expectation = [self expectationWithDescription:@"Custom image not works"];

View File

@ -269,6 +269,7 @@
expect(image).notTo.beNil();
expect(image.size).equal(CGSizeMake(1000, 1000));
if (finished) {
expect(image.sd_isIncremental).beFalsy();
[expectation fulfill];
} else {
expect(image.sd_isIncremental).beTruthy();
@ -290,6 +291,7 @@
expect(image.imageOrientation).equal(orientation);
#endif
if (finished) {
expect(image.sd_isIncremental).beFalsy();
[expectation fulfill];
} else {
expect(image.sd_isIncremental).beTruthy();