Update the test case `test12ThatStoreCacheTypeWork` to ensure the transformed image does not inherit the image format or any attributes from original one
This commit is contained in:
parent
7cdf484fdd
commit
a8177c1327
|
@ -121,7 +121,7 @@
|
|||
SDWebImageManager *manager = [[SDWebImageManager alloc] initWithCache:[SDImageCache sharedImageCache] loader:[SDWebImageDownloader sharedDownloader]];
|
||||
manager.transformer = transformer;
|
||||
[[SDImageCache sharedImageCache] removeImageForKey:kTestJPEGURL withCompletion:^{
|
||||
[manager loadImageWithURL:url options:SDWebImageTransformAnimatedImage progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||
[manager loadImageWithURL:url options:SDWebImageTransformAnimatedImage | SDWebImageTransformVectorImage progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||
expect(image).equal(transformer.testImage);
|
||||
[expectation fulfill];
|
||||
}];
|
||||
|
@ -228,21 +228,30 @@
|
|||
|
||||
// test: original image -> disk only, transformed image -> memory only
|
||||
SDWebImageContext *context = @{SDWebImageContextOriginalStoreCacheType : @(SDImageCacheTypeDisk), SDWebImageContextStoreCacheType : @(SDImageCacheTypeMemory)};
|
||||
NSURL *url = [NSURL URLWithString:kTestJPEGURL];
|
||||
NSURL *url = [NSURL URLWithString:kTestAPNGPURL];
|
||||
NSString *originalKey = [manager cacheKeyForURL:url];
|
||||
NSString *transformedKey = [manager cacheKeyForURL:url context:context];
|
||||
|
||||
[manager loadImageWithURL:url options:SDWebImageTransformAnimatedImage context:context progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||
expect(image).equal(transformer.testImage);
|
||||
// the transformed image should not inherite any attribute from original one
|
||||
expect(image.sd_imageFormat).equal(SDImageFormatJPEG);
|
||||
expect(image.sd_isAnimated).beFalsy();
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2*kMinDelayNanosecond), dispatch_get_main_queue(), ^{
|
||||
// original -> disk only
|
||||
[manager.imageCache containsImageForKey:originalKey cacheType:SDImageCacheTypeAll completion:^(SDImageCacheType originalCacheType) {
|
||||
expect(originalCacheType).equal(SDImageCacheTypeDisk);
|
||||
// transformed -> memory only
|
||||
[manager.imageCache containsImageForKey:transformedKey cacheType:SDImageCacheTypeAll completion:^(SDImageCacheType transformedCacheType) {
|
||||
expect(transformedCacheType).equal(SDImageCacheTypeMemory);
|
||||
[expectation fulfill];
|
||||
}];
|
||||
UIImage *originalImage = [cache imageFromMemoryCacheForKey:originalKey];
|
||||
expect(originalImage).beNil();
|
||||
NSData *originalData = [cache diskImageDataForKey:originalKey];
|
||||
expect(originalData).notTo.beNil();
|
||||
originalImage = [UIImage sd_imageWithData:originalData];
|
||||
expect(originalImage).notTo.beNil();
|
||||
expect(originalImage.sd_imageFormat).equal(SDImageFormatPNG);
|
||||
expect(originalImage.sd_isAnimated).beTruthy();
|
||||
// transformed -> memory only
|
||||
[manager.imageCache containsImageForKey:transformedKey cacheType:SDImageCacheTypeAll completion:^(SDImageCacheType transformedCacheType) {
|
||||
expect(transformedCacheType).equal(SDImageCacheTypeMemory);
|
||||
[cache clearDiskOnCompletion:nil];
|
||||
[expectation fulfill];
|
||||
}];
|
||||
});
|
||||
}];
|
||||
|
|
Loading…
Reference in New Issue