@@ -35,7 +35,31 @@ - (void)testYYAnimatedImageViewSetImageWithURL {
3535 expect (error).to .beNil ();
3636 expect (originalImageURL).to .equal (imageURL);
3737
38- expect (imageView.image .class ).to .equal (YYImage.class );
38+ expect (image.class ).to .equal (YYImage.class );
39+ [expectation fulfill ];
40+ }];
41+ [self waitForExpectationsWithCommonTimeout ];
42+ }
43+
44+ - (void )testYYAnimatedImageViewSetImageWithURLPreloadAllFrames {
45+ XCTestExpectation *expectation = [self expectationWithDescription: @" YYAnimatedImageView setImageWithURL preloadAllFrames" ];
46+
47+ YYAnimatedImageView *imageView = [[YYAnimatedImageView alloc ] init ];
48+ NSURL *originalImageURL = [NSURL URLWithString: kTestAPNGPURL ];
49+
50+ [imageView sd_setImageWithURL: originalImageURL
51+ placeholderImage: nil
52+ options: SDWebImagePreloadAllFrames
53+ completed: ^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
54+ expect (image).toNot .beNil ();
55+ expect (error).to .beNil ();
56+ expect (originalImageURL).to .equal (imageURL);
57+
58+ YYImage *animatedImage = (YYImage *)image;
59+ expect (animatedImage.class ).to .equal (YYImage.class );
60+ expect (animatedImage.isAllFramesLoaded ).beTruthy ();
61+ [animatedImage unloadAllFrames ];
62+ expect (animatedImage.isAllFramesLoaded ).beFalsy ();
3963 [expectation fulfill ];
4064 }];
4165 [self waitForExpectationsWithCommonTimeout ];
@@ -95,7 +119,7 @@ - (void)testSDImageYYCoderProgressiveJPEGWorks {
95119 [SDImageCodersManager.sharedManager addCoder: SDImageYYCoder.sharedCoder];
96120
97121 NSURL *imageURL = [NSURL URLWithString: kTestProgressiveJPEGURL ];
98- [[SDWebImageDownloader sharedDownloader ] downloadImageWithURL: imageURL options: SDWebImageDownloaderProgressiveLoad progress: nil completed: ^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
122+ [[SDWebImageDownloader sharedDownloader ] downloadImageWithURL: imageURL options: SDWebImageDownloaderProgressiveLoad context: @{SDWebImageContextAnimatedImageClass : YYImage. class } progress: nil completed: ^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
99123 if (image && data && !error && finished) {
100124 [expectation fulfill ];
101125 } else if (finished) {
0 commit comments