@@ -35,7 +35,31 @@ - (void)testYYAnimatedImageViewSetImageWithURL {
35
35
expect (error).to .beNil ();
36
36
expect (originalImageURL).to .equal (imageURL);
37
37
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 ();
39
63
[expectation fulfill ];
40
64
}];
41
65
[self waitForExpectationsWithCommonTimeout ];
@@ -95,7 +119,7 @@ - (void)testSDImageYYCoderProgressiveJPEGWorks {
95
119
[SDImageCodersManager.sharedManager addCoder: SDImageYYCoder.sharedCoder];
96
120
97
121
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) {
99
123
if (image && data && !error && finished) {
100
124
[expectation fulfill ];
101
125
} else if (finished) {
0 commit comments