Fix the test case because of cache key

This commit is contained in:
DreamPiggy 2019-08-03 17:42:38 +08:00
parent b444652412
commit caae8f171f
2 changed files with 7 additions and 3 deletions

View File

@ -203,6 +203,8 @@
- (void)testUIViewCancelCurrentImageLoad {
UIView *imageView = [[UIView alloc] init];
NSURL *originalImageURL = [NSURL URLWithString:kTestJPEGURL];
[SDImageCache.sharedImageCache removeImageFromDiskForKey:kTestJPEGURL];
[SDImageCache.sharedImageCache removeImageFromMemoryForKey:kTestJPEGURL];
[imageView sd_internalSetImageWithURL:originalImageURL placeholderImage:nil options:0 context:nil setImageBlock:nil progress:nil completed:nil];
[imageView sd_cancelCurrentImageLoad];
NSString *operationKey = NSStringFromClass(UIView.class);
@ -214,6 +216,8 @@
UIView *imageView = [[UIView alloc] init];
NSURL *originalImageURL = [NSURL URLWithString:kTestJPEGURL];
[SDImageCache.sharedImageCache removeImageFromDiskForKey:kTestJPEGURL];
[SDImageCache.sharedImageCache removeImageFromMemoryForKey:kTestJPEGURL];
[imageView sd_internalSetImageWithURL:originalImageURL placeholderImage:nil options:0 context:nil setImageBlock:nil progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
expect(error).notTo.beNil();
expect(error.code).equal(SDWebImageErrorCancelled);

View File

@ -154,9 +154,9 @@
- (void)test07DownloaderCancelDuringPrefetching {
XCTestExpectation *expectation = [self expectationWithDescription:@"Downloader cancel during prefetch should not hung up"];
NSArray *imageURLs = @[@"http://via.placeholder.com/3000x3000.jpg",
@"http://via.placeholder.com/4000x4000.jpg",
@"http://via.placeholder.com/5000x5000.jpg"];
NSArray *imageURLs = @[@"http://via.placeholder.com/5000x5000.jpg",
@"http://via.placeholder.com/6000x6000.jpg",
@"http://via.placeholder.com/7000x7000.jpg"];
for (NSString *url in imageURLs) {
[SDImageCache.sharedImageCache removeImageFromDiskForKey:url];
}