From 9ae93e54568e989ac289010d4a8455112f29ee87 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Tue, 9 Jan 2024 17:04:55 +0800 Subject: [PATCH] Update the test case for new behavior --- Tests/Tests/SDWebImageManagerTests.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Tests/Tests/SDWebImageManagerTests.m b/Tests/Tests/SDWebImageManagerTests.m index a35231f1..c57285a3 100644 --- a/Tests/Tests/SDWebImageManagerTests.m +++ b/Tests/Tests/SDWebImageManagerTests.m @@ -482,11 +482,15 @@ [SDImageCache.sharedImageCache queryCacheOperationForKey:fullSizeKey options:0 context:@{SDWebImageContextImageThumbnailPixelSize : @(thumbnailSize)} done:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) { expect(image.size).equal(thumbnailSize); expect(cacheType).equal(SDImageCacheTypeDisk); - // Currently, thumbnail decoding does not write back to the original key's memory cache - // But this may change in the future once I change the API for `SDImageCacheProtocol` - expect([SDImageCache.sharedImageCache imageFromMemoryCacheForKey:fullSizeKey]).beNil(); - expect([SDImageCache.sharedImageCache imageFromMemoryCacheForKey:thumbnailKey]).beNil(); + // Check the full image should not be in memory cache (because we have only full data + thumbnail image) + // Check the thumbnail image should be in memory cache (because we have only full data + thumbnail image) + expect([SDImageCache.sharedImageCache imageFromMemoryCacheForKey:fullSizeKey].size).equal(CGSizeZero); + expect([SDImageCache.sharedImageCache imageFromDiskCacheForKey:fullSizeKey]).notTo.beNil(); + expect([SDImageCache.sharedImageCache imageFromMemoryCacheForKey:thumbnailKey].size).equal(thumbnailSize); + expect([SDImageCache.sharedImageCache imageFromDiskCacheForKey:thumbnailKey]).beNil(); + [SDImageCache.sharedImageCache removeImageFromDiskForKey:fullSizeKey]; + [SDImageCache.sharedImageCache removeImageFromMemoryForKey:thumbnailKey]; [expectation fulfill]; }];