Add a test for SDWebImageRefreshCached
Showing
1 changed file
with
20 additions
and
1 deletions
@@ -73,7 +73,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | @@ -73,7 +73,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | ||
73 | XCTFail(@"Image should be in cache"); | 73 | XCTFail(@"Image should be in cache"); |
74 | } | 74 | } |
75 | }]; | 75 | }]; |
76 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 76 | + [self waitForExpectationsWithCommonTimeout]; |
77 | } | 77 | } |
78 | 78 | ||
79 | - (void)test05DiskImageExistsForURL { | 79 | - (void)test05DiskImageExistsForURL { |
@@ -108,4 +108,23 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | @@ -108,4 +108,23 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | ||
108 | [self waitForExpectationsWithCommonTimeout]; | 108 | [self waitForExpectationsWithCommonTimeout]; |
109 | } | 109 | } |
110 | 110 | ||
111 | +- (void)test07ThatLoadImageWithSDWebImageRefreshCachedWorks { | ||
112 | + XCTestExpectation *expectation = [self expectationWithDescription:@"Image download twice with SDWebImageRefresh failed"]; | ||
113 | + NSURL *originalImageURL = [NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage007.jpg"]; | ||
114 | + [[SDImageCache sharedImageCache] clearDiskOnCompletion:nil]; | ||
115 | + | ||
116 | + [[SDWebImageManager sharedManager] loadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { | ||
117 | + expect(image).toNot.beNil(); | ||
118 | + expect(error).to.beNil(); | ||
119 | + // #1993, load image with SDWebImageRefreshCached twice should not fail if the first time success. | ||
120 | + | ||
121 | + [[SDWebImageManager sharedManager] loadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { | ||
122 | + expect(image).toNot.beNil(); | ||
123 | + expect(error).to.beNil(); | ||
124 | + [expectation fulfill]; | ||
125 | + }]; | ||
126 | + }]; | ||
127 | + [self waitForExpectationsWithCommonTimeout]; | ||
128 | +} | ||
129 | + | ||
111 | @end | 130 | @end |
-
Please register or login to post a comment