Update the test for image coder renaming

This commit is contained in:
DreamPiggy 2018-04-26 22:59:04 +08:00
parent 6e5a0ea5f0
commit 0423cc2cf0
8 changed files with 39 additions and 39 deletions

View File

@ -10,8 +10,8 @@
#import "SDImageCoder.h"
/**
Built in coder using ImageIO that supports GIF encoding/decoding
@note `SDWebImageIOCoder` supports GIF but only as static (will use the 1st frame).
Built in coder using ImageIO that supports animated GIF encoding/decoding
@note `SDImageIOCoder` supports GIF but only as static (will use the 1st frame).
@note Use `SDImageGIFCoder` for fully animated GIFs. For `UIImageView`, it will produce animated `UIImage`(`NSImage` on macOS) for rendering. For `SDAnimatedImageView`, it will use `SDAnimatedImage` for rendering.
@note The recommended approach for animated GIFs is using `SDAnimatedImage` with `SDAnimatedImageView`. It's more performant than `UIImageView` for GIF displaying(especially on memory usage)
*/

View File

@ -29,7 +29,7 @@
32B99E8B203AF8690017FD66 /* SDCategoriesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32B99E8A203AF8690017FD66 /* SDCategoriesTests.m */; };
32B99E9B203B2EDD0017FD66 /* SDTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D7AF05F1F329763000083C2 /* SDTestCase.m */; };
32B99E9C203B2EE40017FD66 /* SDCategoriesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32B99E8A203AF8690017FD66 /* SDCategoriesTests.m */; };
32B99E9D203B2F7D0017FD66 /* SDWebImageTestDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6F0311F3A1B4700A945E6 /* SDWebImageTestDecoder.m */; };
32B99E9D203B2F7D0017FD66 /* SDWebImageTestCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6F0311F3A1B4700A945E6 /* SDWebImageTestCoder.m */; };
32B99E9E203B2F810017FD66 /* SDMockFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 37D122871EC48B5E00D98CEB /* SDMockFileManager.m */; };
32B99EA2203B31360017FD66 /* MonochromeTestImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 433BBBBA1D7EFA8B0086B6E9 /* MonochromeTestImage.jpg */; };
32B99EA3203B31360017FD66 /* TestImage.gif in Resources */ = {isa = PBXBuildFile; fileRef = 433BBBB61D7EF8200086B6E9 /* TestImage.gif */; };
@ -38,15 +38,15 @@
32B99EA6203B31360017FD66 /* TestImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 433BBBB81D7EF8260086B6E9 /* TestImage.png */; };
32B99EA7203B31360017FD66 /* TestImageAnimated.webp in Resources */ = {isa = PBXBuildFile; fileRef = 321259ED1F39E4110096FE0E /* TestImageAnimated.webp */; };
32B99EA8203B31360017FD66 /* TestImageStatic.webp in Resources */ = {isa = PBXBuildFile; fileRef = 321259EB1F39E3240096FE0E /* TestImageStatic.webp */; };
32B99EA9203B34B60017FD66 /* SDWebImageDecoderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */; };
32B99EA9203B34B60017FD66 /* SDImageCoderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 433BBBB41D7EF5C00086B6E9 /* SDImageCoderTests.m */; };
32B99EAA203B365F0017FD66 /* SDImageCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DA248D68195475D800390AB0 /* SDImageCacheTests.m */; };
32B99EAB203B36620017FD66 /* SDWebImageManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DA248D6A195476AC00390AB0 /* SDWebImageManagerTests.m */; };
32B99EAC203B36650017FD66 /* SDWebImageDownloaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E3C51E819B46E370092B5E6 /* SDWebImageDownloaderTests.m */; };
32B99EAD203B36690017FD66 /* SDWebImagePrefetcherTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4369C1D01D97F80F007E863A /* SDWebImagePrefetcherTests.m */; };
32B99EAE203B366C0017FD66 /* SDWebCacheCategoriesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4369C2731D9804B1007E863A /* SDWebCacheCategoriesTests.m */; };
32E6F0321F3A1B4700A945E6 /* SDWebImageTestDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6F0311F3A1B4700A945E6 /* SDWebImageTestDecoder.m */; };
32E6F0321F3A1B4700A945E6 /* SDWebImageTestCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6F0311F3A1B4700A945E6 /* SDWebImageTestCoder.m */; };
37D122881EC48B5E00D98CEB /* SDMockFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 37D122871EC48B5E00D98CEB /* SDMockFileManager.m */; };
433BBBB51D7EF5C00086B6E9 /* SDWebImageDecoderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */; };
433BBBB51D7EF5C00086B6E9 /* SDImageCoderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 433BBBB41D7EF5C00086B6E9 /* SDImageCoderTests.m */; };
433BBBB71D7EF8200086B6E9 /* TestImage.gif in Resources */ = {isa = PBXBuildFile; fileRef = 433BBBB61D7EF8200086B6E9 /* TestImage.gif */; };
433BBBB91D7EF8260086B6E9 /* TestImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 433BBBB81D7EF8260086B6E9 /* TestImage.png */; };
433BBBBB1D7EFA8B0086B6E9 /* MonochromeTestImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 433BBBBA1D7EFA8B0086B6E9 /* MonochromeTestImage.jpg */; };
@ -84,12 +84,12 @@
32B99E8A203AF8690017FD66 /* SDCategoriesTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDCategoriesTests.m; sourceTree = "<group>"; };
32B99E92203B2DF90017FD66 /* Tests Mac.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Tests Mac.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
32B99E96203B2DF90017FD66 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
32E6F0301F3A1B4700A945E6 /* SDWebImageTestDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageTestDecoder.h; sourceTree = "<group>"; };
32E6F0311F3A1B4700A945E6 /* SDWebImageTestDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageTestDecoder.m; sourceTree = "<group>"; };
32E6F0301F3A1B4700A945E6 /* SDWebImageTestCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageTestCoder.h; sourceTree = "<group>"; };
32E6F0311F3A1B4700A945E6 /* SDWebImageTestCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageTestCoder.m; sourceTree = "<group>"; };
37D122861EC48B5E00D98CEB /* SDMockFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDMockFileManager.h; sourceTree = "<group>"; };
37D122871EC48B5E00D98CEB /* SDMockFileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDMockFileManager.m; sourceTree = "<group>"; };
3B82F4E5C79656CB9C5667F6 /* Pods-Tests Mac.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests Mac.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Tests Mac/Pods-Tests Mac.debug.xcconfig"; sourceTree = "<group>"; };
433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageDecoderTests.m; sourceTree = "<group>"; };
433BBBB41D7EF5C00086B6E9 /* SDImageCoderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDImageCoderTests.m; sourceTree = "<group>"; };
433BBBB61D7EF8200086B6E9 /* TestImage.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = TestImage.gif; sourceTree = "<group>"; };
433BBBB81D7EF8260086B6E9 /* TestImage.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = TestImage.png; sourceTree = "<group>"; };
433BBBBA1D7EFA8B0086B6E9 /* MonochromeTestImage.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = MonochromeTestImage.jpg; sourceTree = "<group>"; };
@ -209,7 +209,7 @@
DA248D68195475D800390AB0 /* SDImageCacheTests.m */,
DA248D6A195476AC00390AB0 /* SDWebImageManagerTests.m */,
1E3C51E819B46E370092B5E6 /* SDWebImageDownloaderTests.m */,
433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */,
433BBBB41D7EF5C00086B6E9 /* SDImageCoderTests.m */,
4369C1D01D97F80F007E863A /* SDWebImagePrefetcherTests.m */,
3254C31F20641077008D1022 /* SDWebImageTransformerTests.m */,
4369C2731D9804B1007E863A /* SDWebCacheCategoriesTests.m */,
@ -223,8 +223,8 @@
328BB6DC20825E9800760D6C /* SDWebImageTestCache.m */,
3226ECB920754F7700FAFACF /* SDWebImageTestDownloadOperation.h */,
3226ECBA20754F7700FAFACF /* SDWebImageTestDownloadOperation.m */,
32E6F0301F3A1B4700A945E6 /* SDWebImageTestDecoder.h */,
32E6F0311F3A1B4700A945E6 /* SDWebImageTestDecoder.m */,
32E6F0301F3A1B4700A945E6 /* SDWebImageTestCoder.h */,
32E6F0311F3A1B4700A945E6 /* SDWebImageTestCoder.m */,
3264FF2D205D42CB00F6BD48 /* SDWebImageTestTransformer.h */,
3264FF2E205D42CB00F6BD48 /* SDWebImageTestTransformer.m */,
323B8E1D20862322008952BE /* SDWebImageTestLoader.h */,
@ -484,10 +484,10 @@
32B99EAA203B365F0017FD66 /* SDImageCacheTests.m in Sources */,
32B99EAD203B36690017FD66 /* SDWebImagePrefetcherTests.m in Sources */,
32B99EAE203B366C0017FD66 /* SDWebCacheCategoriesTests.m in Sources */,
32B99E9D203B2F7D0017FD66 /* SDWebImageTestDecoder.m in Sources */,
32B99E9D203B2F7D0017FD66 /* SDWebImageTestCoder.m in Sources */,
32B99E9E203B2F810017FD66 /* SDMockFileManager.m in Sources */,
32B99EAB203B36620017FD66 /* SDWebImageManagerTests.m in Sources */,
32B99EA9203B34B60017FD66 /* SDWebImageDecoderTests.m in Sources */,
32B99EA9203B34B60017FD66 /* SDImageCoderTests.m in Sources */,
3264FF30205D42CB00F6BD48 /* SDWebImageTestTransformer.m in Sources */,
320630412085A37C006E0FA4 /* SDAnimatedImageTest.m in Sources */,
32B99E9B203B2EDD0017FD66 /* SDTestCase.m in Sources */,
@ -500,7 +500,7 @@
buildActionMask = 2147483647;
files = (
323B8E1F20862322008952BE /* SDWebImageTestLoader.m in Sources */,
32E6F0321F3A1B4700A945E6 /* SDWebImageTestDecoder.m in Sources */,
32E6F0321F3A1B4700A945E6 /* SDWebImageTestCoder.m in Sources */,
3226ECBB20754F7700FAFACF /* SDWebImageTestDownloadOperation.m in Sources */,
3254C32020641077008D1022 /* SDWebImageTransformerTests.m in Sources */,
32A571562037DB2D002EDAAE /* SDAnimatedImageTest.m in Sources */,
@ -514,7 +514,7 @@
DA248D6B195476AC00390AB0 /* SDWebImageManagerTests.m in Sources */,
32B99E8B203AF8690017FD66 /* SDCategoriesTests.m in Sources */,
3264FF2F205D42CB00F6BD48 /* SDWebImageTestTransformer.m in Sources */,
433BBBB51D7EF5C00086B6E9 /* SDWebImageDecoderTests.m in Sources */,
433BBBB51D7EF5C00086B6E9 /* SDImageCoderTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -62,7 +62,7 @@ static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop coun
- (void)test03AnimatedImageInitWithAnimatedCoder {
NSData *validData = [self testGIFData];
SDWebImageGIFCoder *coder = [[SDWebImageGIFCoder alloc] initWithAnimatedImageData:validData options:nil];
SDImageGIFCoder *coder = [[SDImageGIFCoder alloc] initWithAnimatedImageData:validData options:nil];
SDAnimatedImage *image = [[SDAnimatedImage alloc] initWithAnimatedCoder:coder scale:1];
expect(image).notTo.beNil();
// enough, other can be test with InitWithData
@ -154,7 +154,7 @@ static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop coun
- (void)test09AnimatedImageViewSetProgressiveAnimatedImage {
NSData *gifData = [self testGIFData];
SDWebImageGIFCoder *progressiveCoder = [[SDWebImageGIFCoder alloc] initIncrementalWithOptions:nil];
SDImageGIFCoder *progressiveCoder = [[SDImageGIFCoder alloc] initIncrementalWithOptions:nil];
// simulate progressive decode, pass partial data
NSData *partialData = [gifData subdataWithRange:NSMakeRange(0, gifData.length - 1)];
[progressiveCoder updateIncrementalData:partialData finished:NO];

View File

@ -7,7 +7,7 @@
*/
#import "SDTestCase.h"
#import "SDWebImageTestDecoder.h"
#import "SDWebImageTestCoder.h"
#import "SDMockFileManager.h"
#import "SDWebImageTestCache.h"
@ -275,8 +275,8 @@ static NSString *kTestImageKeyPNG = @"TestImageKey.png";
- (void)test41ThatCustomDecoderWorksForImageCache {
XCTestExpectation *expectation = [self expectationWithDescription:@"Custom decoder for SDImageCache not works"];
SDImageCache *cache = [[SDImageCache alloc] initWithNamespace:@"TestDecode"];
SDWebImageTestDecoder *testDecoder = [[SDWebImageTestDecoder alloc] init];
[[SDWebImageCodersManager sharedManager] addCoder:testDecoder];
SDWebImageTestCoder *testDecoder = [[SDWebImageTestCoder alloc] init];
[[SDImageCodersManager sharedManager] addCoder:testDecoder];
NSString * testImagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestImage" ofType:@"png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:testImagePath];
NSString *key = @"TestPNGImageEncodedToDataAndRetrieveToJPEG";
@ -310,7 +310,7 @@ static NSString *kTestImageKeyPNG = @"TestImageKey.png";
XCTFail(@"Custom decoder not work for SDImageCache, check -[SDWebImageTestDecoder decodedImageWithData:]");
}
[[SDWebImageCodersManager sharedManager] removeCoder:testDecoder];
[[SDImageCodersManager sharedManager] removeCoder:testDecoder];
[[SDImageCache sharedImageCache] removeImageForKey:key withCompletion:^{
[expectation fulfill];

View File

@ -81,33 +81,33 @@
- (void)test09ThatStaticWebPCoderWorks {
NSURL *staticWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageStatic" withExtension:@"webp"];
[self verifyCoder:[SDWebImageWebPCoder sharedCoder]
[self verifyCoder:[SDImageWebPCoder sharedCoder]
withLocalImageURL:staticWebPURL
isAnimatedImage:NO];
}
- (void)test10ThatAnimatedWebPCoderWorks {
NSURL *animatedWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"webp"];
[self verifyCoder:[SDWebImageWebPCoder sharedCoder]
[self verifyCoder:[SDImageWebPCoder sharedCoder]
withLocalImageURL:animatedWebPURL
isAnimatedImage:YES];
}
- (void)test11ThatAPNGPCoderWorks {
NSURL *animatedWebPURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"apng"];
[self verifyCoder:[SDWebImageAPNGCoder sharedCoder]
[self verifyCoder:[SDImageAPNGCoder sharedCoder]
withLocalImageURL:animatedWebPURL
isAnimatedImage:YES];
}
- (void)test20ThatOurGIFCoderWorksNotFLAnimatedImage {
NSURL *gifURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"gif"];
[self verifyCoder:[SDWebImageGIFCoder sharedCoder]
[self verifyCoder:[SDImageGIFCoder sharedCoder]
withLocalImageURL:gifURL
isAnimatedImage:YES];
}
- (void)verifyCoder:(id<SDWebImageCoder>)coder
- (void)verifyCoder:(id<SDImageCoder>)coder
withLocalImageURL:(NSURL *)imageUrl
isAnimatedImage:(BOOL)isAnimated {
NSData *inputImageData = [NSData dataWithContentsOfURL:imageUrl];

View File

@ -9,7 +9,7 @@
#import "SDTestCase.h"
#import "SDWebImageTestDownloadOperation.h"
#import "SDWebImageTestDecoder.h"
#import "SDWebImageTestCoder.h"
#import "SDWebImageTestLoader.h"
/**
@ -346,8 +346,8 @@
- (void)test22ThatCustomDecoderWorksForImageDownload {
XCTestExpectation *expectation = [self expectationWithDescription:@"Custom decoder for SDWebImageDownloader not works"];
SDWebImageDownloader *downloader = [[SDWebImageDownloader alloc] init];
SDWebImageTestDecoder *testDecoder = [[SDWebImageTestDecoder alloc] init];
[[SDWebImageCodersManager sharedManager] addCoder:testDecoder];
SDWebImageTestCoder *testDecoder = [[SDWebImageTestCoder alloc] init];
[[SDImageCodersManager sharedManager] addCoder:testDecoder];
NSURL * testImageURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"png"];
// Decoded result is JPEG
@ -360,7 +360,7 @@
if (![data1 isEqualToData:data2]) {
XCTFail(@"The image data is not equal to cutom decoder, check -[SDWebImageTestDecoder decodedImageWithData:]");
}
[[SDWebImageCodersManager sharedManager] removeCoder:testDecoder];
[[SDImageCodersManager sharedManager] removeCoder:testDecoder];
[expectation fulfill];
}];

View File

@ -8,8 +8,8 @@
*/
#import <Foundation/Foundation.h>
#import <SDWebImage/SDWebImageCoder.h>
#import <SDWebImage/SDImageCoder.h>
@interface SDWebImageTestDecoder : NSObject <SDWebImageProgressiveCoder>
@interface SDWebImageTestCoder : NSObject <SDProgressiveImageCoder>
@end

View File

@ -7,9 +7,9 @@
* file that was distributed with this source code.
*/
#import "SDWebImageTestDecoder.h"
#import "SDWebImageTestCoder.h"
@implementation SDWebImageTestDecoder
@implementation SDWebImageTestCoder
- (BOOL)canDecodeFromData:(nullable NSData *)data {
return YES;
@ -19,13 +19,13 @@
return YES;
}
- (UIImage *)decodedImageWithData:(NSData *)data options:(nullable SDWebImageCoderOptions *)options {
- (UIImage *)decodedImageWithData:(NSData *)data options:(nullable SDImageCoderOptions *)options {
NSString * testImagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestImage" ofType:@"jpg"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:testImagePath];
return image;
}
- (instancetype)initIncrementalWithOptions:(nullable SDWebImageCoderOptions *)options
- (instancetype)initIncrementalWithOptions:(nullable SDImageCoderOptions *)options
{
self = [super init];
if (self) {
@ -37,7 +37,7 @@
return;
}
- (UIImage *)incrementalDecodedImageWithOptions:(SDWebImageCoderOptions *)options {
- (UIImage *)incrementalDecodedImageWithOptions:(SDImageCoderOptions *)options {
NSString * testImagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestImage" ofType:@"gif"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:testImagePath];
return image;
@ -47,7 +47,7 @@
return YES;
}
- (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format options:(nullable SDWebImageCoderOptions *)options {
- (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format options:(nullable SDImageCoderOptions *)options {
NSString *testString = @"TestEncode";
NSData *data = [testString dataUsingEncoding:NSUTF8StringEncoding];
return data;