@@ -21,6 +21,8 @@ - (void)tearDown {
21
21
}
22
22
}
23
23
24
+ #pragma mark - WebCache
25
+
24
26
- (void )testYYAnimatedImageViewSetImageWithURL {
25
27
XCTestExpectation *expectation = [self expectationWithDescription: @" YYAnimatedImageView setImageWithURL" ];
26
28
@@ -39,6 +41,30 @@ - (void)testYYAnimatedImageViewSetImageWithURL {
39
41
[self waitForExpectationsWithCommonTimeout ];
40
42
}
41
43
44
+ #pragma mark - YYImage && SDAnimatedImage
45
+
46
+ - (void )testYYImageWorksForSDAnimatedImageView {
47
+ SDAnimatedImageView *imageView = [SDAnimatedImageView new ];
48
+ [self .window addSubview: imageView];
49
+ YYImage *image = [YYImage imageWithData: [self testGIFData ]];
50
+ imageView.image = image;
51
+ expect (imageView.image ).notTo .beNil ();
52
+ expect (imageView.currentFrame ).notTo .beNil (); // current frame
53
+ expect (imageView.isAnimating ).to .beTruthy (); // animating
54
+ }
55
+
56
+ - (void )testYYImageInitWithSDImageYYCoder {
57
+ SDImageYYCoder *coder = [[SDImageYYCoder alloc ] initWithAnimatedImageData: [self testGIFData ] options: @{SDWebImageContextImageScaleFactor : @(2 )}];
58
+ SDAnimatedImage *image = [[SDAnimatedImage alloc ] initWithAnimatedCoder: coder scale: 2 ];
59
+ YYAnimatedImageView *imageView = [[YYAnimatedImageView alloc ] init ];
60
+ [self .window addSubview: imageView];
61
+ imageView.image = image;
62
+ expect (imageView.image ).notTo .beNil ();
63
+ expect (imageView.image .scale ).to .equal (2 );
64
+ expect (imageView.currentAnimatedImageIndex ).to .equal (0 ); // current frame
65
+ expect (imageView.currentIsPlayingAnimation ).to .beTruthy (); // animating
66
+ }
67
+
42
68
- (void )testSDAnimatedImageWorksForYYAnimatedImageView {
43
69
YYAnimatedImageView *imageView = [[YYAnimatedImageView alloc ] init ];
44
70
[self .window addSubview: imageView];
@@ -49,16 +75,38 @@ - (void)testSDAnimatedImageWorksForYYAnimatedImageView {
49
75
expect (imageView.currentIsPlayingAnimation ).to .beTruthy (); // animating
50
76
}
51
77
52
- - (void )testYYImageWorksForSDAnimatedImageView {
78
+ - (void )testSDAnimatedImageInitWithSDImageYYCoder {
79
+ SDImageYYCoder *coder = [[SDImageYYCoder alloc ] initWithAnimatedImageData: [self testGIFData ] options: @{SDWebImageContextImageScaleFactor : @(2 )}];
80
+ SDAnimatedImage *image = [[SDAnimatedImage alloc ] initWithAnimatedCoder: coder scale: 2 ];
53
81
SDAnimatedImageView *imageView = [SDAnimatedImageView new ];
54
82
[self .window addSubview: imageView];
55
- YYImage *image = [YYImage imageWithData: [self testGIFData ]];
56
83
imageView.image = image;
57
84
expect (imageView.image ).notTo .beNil ();
85
+ expect (imageView.image .scale ).to .equal (2 );
58
86
expect (imageView.currentFrame ).notTo .beNil (); // current frame
59
87
expect (imageView.isAnimating ).to .beTruthy (); // animating
60
88
}
61
89
90
+ #pragma mark - SDImageYYCoder
91
+
92
+ - (void )testSDImageYYCoderProgressiveJPEGWorks {
93
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Progressive JPEG download" ];
94
+ // Add coder
95
+ [SDImageCodersManager.sharedManager addCoder: SDImageYYCoder.sharedCoder];
96
+
97
+ 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) {
99
+ if (image && data && !error && finished) {
100
+ [expectation fulfill ];
101
+ } else if (finished) {
102
+ XCTFail (@" Something went wrong" );
103
+ } else {
104
+ // progressive updates
105
+ }
106
+ }];
107
+ [self waitForExpectationsWithCommonTimeout ];
108
+ }
109
+
62
110
- (void )testSDImageYYCoderPNGWorks {
63
111
NSURL *staticWebPURL = [[NSBundle bundleForClass: [self class ]] URLForResource: @" TestImage" withExtension: @" png" ];
64
112
[self verifyCoder: [SDImageYYCoder sharedCoder ]
0 commit comments