Add new SDCategoriesTests for any other WebCache category tests
This commit is contained in:
parent
1f27d3c15f
commit
150affd201
|
@ -11,6 +11,7 @@
|
|||
2D7AF0601F329763000083C2 /* SDTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D7AF05F1F329763000083C2 /* SDTestCase.m */; };
|
||||
321259EC1F39E3240096FE0E /* TestImageStatic.webp in Resources */ = {isa = PBXBuildFile; fileRef = 321259EB1F39E3240096FE0E /* TestImageStatic.webp */; };
|
||||
321259EE1F39E4110096FE0E /* TestImageAnimated.webp in Resources */ = {isa = PBXBuildFile; fileRef = 321259ED1F39E4110096FE0E /* TestImageAnimated.webp */; };
|
||||
32B99E8B203AF8690017FD66 /* SDCategoriesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32B99E8A203AF8690017FD66 /* SDCategoriesTests.m */; };
|
||||
32E6F0321F3A1B4700A945E6 /* SDWebImageTestDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E6F0311F3A1B4700A945E6 /* SDWebImageTestDecoder.m */; };
|
||||
37D122881EC48B5E00D98CEB /* SDMockFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 37D122871EC48B5E00D98CEB /* SDMockFileManager.m */; };
|
||||
433BBBB51D7EF5C00086B6E9 /* SDWebImageDecoderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */; };
|
||||
|
@ -37,6 +38,7 @@
|
|||
2D7AF05F1F329763000083C2 /* SDTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDTestCase.m; sourceTree = "<group>"; };
|
||||
321259EB1F39E3240096FE0E /* TestImageStatic.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestImageStatic.webp; sourceTree = "<group>"; };
|
||||
321259ED1F39E4110096FE0E /* TestImageAnimated.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestImageAnimated.webp; sourceTree = "<group>"; };
|
||||
32B99E8A203AF8690017FD66 /* SDCategoriesTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDCategoriesTests.m; 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>"; };
|
||||
37D122861EC48B5E00D98CEB /* SDMockFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDMockFileManager.h; sourceTree = "<group>"; };
|
||||
|
@ -132,6 +134,7 @@
|
|||
433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */,
|
||||
4369C1D01D97F80F007E863A /* SDWebImagePrefetcherTests.m */,
|
||||
4369C2731D9804B1007E863A /* SDWebCacheCategoriesTests.m */,
|
||||
32B99E8A203AF8690017FD66 /* SDCategoriesTests.m */,
|
||||
37D122861EC48B5E00D98CEB /* SDMockFileManager.h */,
|
||||
37D122871EC48B5E00D98CEB /* SDMockFileManager.m */,
|
||||
2D7AF05E1F329763000083C2 /* SDTestCase.h */,
|
||||
|
@ -293,6 +296,7 @@
|
|||
4369C1D11D97F80F007E863A /* SDWebImagePrefetcherTests.m in Sources */,
|
||||
DA248D69195475D800390AB0 /* SDImageCacheTests.m in Sources */,
|
||||
DA248D6B195476AC00390AB0 /* SDWebImageManagerTests.m in Sources */,
|
||||
32B99E8B203AF8690017FD66 /* SDCategoriesTests.m in Sources */,
|
||||
433BBBB51D7EF5C00086B6E9 /* SDWebImageDecoderTests.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* This file is part of the SDWebImage package.
|
||||
* (c) Olivier Poitrey <rs@dailymotion.com>
|
||||
* (c) Matt Galloway
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
#import "SDTestCase.h"
|
||||
#import <SDWebImage/NSData+ImageContentType.h>
|
||||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
#import <SDWebImage/UIImage+MultiFormat.h>
|
||||
#import <SDWebImage/UIImage+GIF.h>
|
||||
#import <SDWebImage/UIImage+WebP.h>
|
||||
#import <SDWebImage/UIImage+ForceDecode.h>
|
||||
|
||||
@interface SDCategoriesTests : SDTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation SDCategoriesTests
|
||||
|
||||
- (void)test01NSDataImageContentTypeCategory {
|
||||
// Test invalid image data
|
||||
SDImageFormat format = [NSData sd_imageFormatForImageData:nil];
|
||||
expect(format == SDImageFormatUndefined);
|
||||
|
||||
// Test invalid format
|
||||
CFStringRef type = [NSData sd_UTTypeFromSDImageFormat:SDImageFormatUndefined];
|
||||
expect(CFStringCompare(kUTTypePNG, type, 0)).equal(kCFCompareEqualTo);
|
||||
}
|
||||
|
||||
- (void)test02UIImageMultiFormatCategory {
|
||||
// Test invalid image data
|
||||
UIImage *image = [UIImage sd_imageWithData:nil];
|
||||
expect(image).to.beNil();
|
||||
// Test image encode
|
||||
image = [UIImage imageWithContentsOfFile:[self testJPEGPath]];
|
||||
NSData *data = [image sd_imageData];
|
||||
expect(data).notTo.beNil();
|
||||
// Test image encode PNG
|
||||
data = [image sd_imageDataAsFormat:SDImageFormatPNG];
|
||||
expect(data).notTo.beNil();
|
||||
}
|
||||
|
||||
- (void)test03UIImageGIFCategory {
|
||||
// Test invalid image data
|
||||
UIImage *image = [UIImage sd_animatedGIFWithData:nil];
|
||||
expect(image).to.beNil();
|
||||
// Test valid image data
|
||||
NSData *data = [NSData dataWithContentsOfFile:[self testGIFPath]];
|
||||
image = [UIImage sd_animatedGIFWithData:data];
|
||||
expect(image).notTo.beNil();
|
||||
}
|
||||
|
||||
- (void)test04UIImageWebPCategory {
|
||||
// Test invalid image data
|
||||
UIImage *image = [UIImage sd_imageWithWebPData:nil];
|
||||
expect(image).to.beNil();
|
||||
// Test valid image data
|
||||
NSData *data = [NSData dataWithContentsOfFile:[self testWebPPath]];
|
||||
image = [UIImage sd_imageWithWebPData:data];
|
||||
expect(image).notTo.beNil();
|
||||
}
|
||||
|
||||
#pragma mark - Helper
|
||||
|
||||
- (NSString *)testJPEGPath {
|
||||
NSBundle *testBundle = [NSBundle bundleForClass:[self class]];
|
||||
return [testBundle pathForResource:@"TestImage" ofType:@"jpg"];
|
||||
}
|
||||
|
||||
- (NSString *)testGIFPath {
|
||||
NSBundle *testBundle = [NSBundle bundleForClass:[self class]];
|
||||
return [testBundle pathForResource:@"TestImage" ofType:@"gif"];
|
||||
}
|
||||
|
||||
- (NSString *)testWebPPath {
|
||||
NSBundle *testBundle = [NSBundle bundleForClass:[self class]];
|
||||
return [testBundle pathForResource:@"TestImageStatic" ofType:@"webp"];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue