Add test. case for HEIC animated imaged decoding && encoding
This commit is contained in:
parent
9b8712e04b
commit
1a32f90f9c
|
@ -32,6 +32,8 @@
|
|||
328BB6DE20825E9800760D6C /* SDWebImageTestCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 328BB6DC20825E9800760D6C /* SDWebImageTestCache.m */; };
|
||||
32905E64211D786E00460FCF /* TestImage.heif in Resources */ = {isa = PBXBuildFile; fileRef = 32905E63211D786E00460FCF /* TestImage.heif */; };
|
||||
32905E65211D786E00460FCF /* TestImage.heif in Resources */ = {isa = PBXBuildFile; fileRef = 32905E63211D786E00460FCF /* TestImage.heif */; };
|
||||
3297A09F23374D1700814590 /* TestImageAnimated.heic in Resources */ = {isa = PBXBuildFile; fileRef = 3297A09E23374D1600814590 /* TestImageAnimated.heic */; };
|
||||
3297A0A023374D1700814590 /* TestImageAnimated.heic in Resources */ = {isa = PBXBuildFile; fileRef = 3297A09E23374D1600814590 /* TestImageAnimated.heic */; };
|
||||
32A571562037DB2D002EDAAE /* SDAnimatedImageTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 32A571552037DB2D002EDAAE /* SDAnimatedImageTest.m */; };
|
||||
32B99E8B203AF8690017FD66 /* SDCategoriesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32B99E8A203AF8690017FD66 /* SDCategoriesTests.m */; };
|
||||
32B99E9B203B2EDD0017FD66 /* SDTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D7AF05F1F329763000083C2 /* SDTestCase.m */; };
|
||||
|
@ -93,6 +95,7 @@
|
|||
328BB6DB20825E9800760D6C /* SDWebImageTestCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageTestCache.h; sourceTree = "<group>"; };
|
||||
328BB6DC20825E9800760D6C /* SDWebImageTestCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageTestCache.m; sourceTree = "<group>"; };
|
||||
32905E63211D786E00460FCF /* TestImage.heif */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestImage.heif; sourceTree = "<group>"; };
|
||||
3297A09E23374D1600814590 /* TestImageAnimated.heic */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestImageAnimated.heic; sourceTree = "<group>"; };
|
||||
32A571552037DB2D002EDAAE /* SDAnimatedImageTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDAnimatedImageTest.m; sourceTree = "<group>"; };
|
||||
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; };
|
||||
|
@ -182,6 +185,7 @@
|
|||
327A418B211D660600495442 /* TestImage.heic */,
|
||||
32905E63211D786E00460FCF /* TestImage.heif */,
|
||||
327054E1206CEFF3006EA328 /* TestImageAnimated.apng */,
|
||||
3297A09E23374D1600814590 /* TestImageAnimated.heic */,
|
||||
);
|
||||
path = Images;
|
||||
sourceTree = "<group>";
|
||||
|
@ -360,6 +364,7 @@
|
|||
324047452271956F007C53E1 /* TestEXIF.png in Resources */,
|
||||
32B99EA4203B31360017FD66 /* TestImage.jpg in Resources */,
|
||||
32B99EA6203B31360017FD66 /* TestImage.png in Resources */,
|
||||
3297A0A023374D1700814590 /* TestImageAnimated.heic in Resources */,
|
||||
32B99EA2203B31360017FD66 /* MonochromeTestImage.jpg in Resources */,
|
||||
32905E65211D786E00460FCF /* TestImage.heif in Resources */,
|
||||
327A418D211D660600495442 /* TestImage.heic in Resources */,
|
||||
|
@ -379,6 +384,7 @@
|
|||
433BBBB71D7EF8200086B6E9 /* TestImage.gif in Resources */,
|
||||
DA248D61195472AA00390AB0 /* InfoPlist.strings in Resources */,
|
||||
433BBBB91D7EF8260086B6E9 /* TestImage.png in Resources */,
|
||||
3297A09F23374D1700814590 /* TestImageAnimated.heic in Resources */,
|
||||
327054E2206CEFF3006EA328 /* TestImageAnimated.apng in Resources */,
|
||||
326E69472334C0C300B7252C /* TestLoopCount.gif in Resources */,
|
||||
433BBBBB1D7EFA8B0086B6E9 /* MonochromeTestImage.jpg in Resources */,
|
||||
|
|
Binary file not shown.
|
@ -140,9 +140,33 @@
|
|||
expect([manager encodedDataWithImage:nil format:SDImageFormatUndefined options:nil]).beNil();
|
||||
}
|
||||
|
||||
- (void)test16ThatHEICAnimatedWorks {
|
||||
if (@available(iOS 11, macOS 10.13, *)) {
|
||||
NSURL *heicURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImageAnimated" withExtension:@"heic"];
|
||||
#if SD_UIKIT
|
||||
BOOL supportsEncoding = YES; // iPhone Simulator after Xcode 9.3 support HEIC encoding
|
||||
#else
|
||||
BOOL supportsEncoding = NO; // Travis-CI Mac env currently does not support HEIC encoding
|
||||
#endif
|
||||
[self verifyCoder:[SDImageHEICCoder sharedCoder]
|
||||
withLocalImageURL:heicURL
|
||||
supportsEncoding:supportsEncoding
|
||||
encodingFormat:SDImageFormatHEIC
|
||||
isAnimatedImage:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)verifyCoder:(id<SDImageCoder>)coder
|
||||
withLocalImageURL:(NSURL *)imageUrl
|
||||
supportsEncoding:(BOOL)supportsEncoding
|
||||
isAnimatedImage:(BOOL)isAnimated {
|
||||
[self verifyCoder:coder withLocalImageURL:imageUrl supportsEncoding:supportsEncoding encodingFormat:SDImageFormatUndefined isAnimatedImage:isAnimated];
|
||||
}
|
||||
|
||||
- (void)verifyCoder:(id<SDImageCoder>)coder
|
||||
withLocalImageURL:(NSURL *)imageUrl
|
||||
supportsEncoding:(BOOL)supportsEncoding
|
||||
encodingFormat:(SDImageFormat)encodingFormat
|
||||
isAnimatedImage:(BOOL)isAnimated {
|
||||
NSData *inputImageData = [NSData dataWithContentsOfURL:imageUrl];
|
||||
expect(inputImageData).toNot.beNil();
|
||||
|
@ -173,10 +197,13 @@
|
|||
|
||||
if (supportsEncoding) {
|
||||
// 3 - check if we can encode to the original format
|
||||
expect([coder canEncodeToFormat:inputImageFormat]).to.beTruthy();
|
||||
if (encodingFormat == SDImageFormatUndefined) {
|
||||
encodingFormat = inputImageFormat;
|
||||
}
|
||||
expect([coder canEncodeToFormat:encodingFormat]).to.beTruthy();
|
||||
|
||||
// 4 - encode from UIImage to NSData using the inputImageFormat and check it
|
||||
NSData *outputImageData = [coder encodedDataWithImage:inputImage format:inputImageFormat options:nil];
|
||||
NSData *outputImageData = [coder encodedDataWithImage:inputImage format:encodingFormat options:nil];
|
||||
expect(outputImageData).toNot.beNil();
|
||||
UIImage *outputImage = [coder decodedImageWithData:outputImageData options:nil];
|
||||
expect(outputImage.size).to.equal(inputImage.size);
|
||||
|
|
Loading…
Reference in New Issue