Add test case `testUIImageViewSetImageWithURLDiskSync`

This commit is contained in:
soondl 2022-02-20 19:01:12 +09:00
parent 8445f2b1a7
commit 4302777c6f
1 changed files with 24 additions and 0 deletions

View File

@ -35,6 +35,30 @@
[self waitForExpectationsWithCommonTimeout];
}
- (void)testUIImageViewSetImageWithURLDiskSync {
NSData *imageData = [NSData dataWithContentsOfFile:[self testJPEGPath]];
// Ensure the image is cached in disk but not memory
[SDImageCache.sharedImageCache removeImageFromMemoryForKey:kTestJPEGURL];
[SDImageCache.sharedImageCache removeImageFromDiskForKey:kTestJPEGURL];
[SDImageCache.sharedImageCache storeImageDataToDisk:imageData forKey:kTestJPEGURL];
UIImageView *imageView = [[UIImageView alloc] init];
NSURL *originalImageURL = [NSURL URLWithString:kTestJPEGURL];
[imageView sd_setImageWithURL:originalImageURL
placeholderImage:nil
options:SDWebImageQueryDiskDataSync
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
expect(image).toNot.beNil();
expect(error).to.beNil();
expect(originalImageURL).to.equal(imageURL);
expect(imageView.image).to.equal(image);
}];
expect(imageView.sd_imageURL).equal(originalImageURL);
expect(imageView.image).toNot.beNil();
}
#if SD_UIKIT
- (void)testUIImageViewSetHighlightedImageWithURL {
XCTestExpectation *expectation = [self expectationWithDescription:@"UIImageView setHighlightedImageWithURL"];