Update the PDF demo and test cases
This commit is contained in:
parent
8c6556e835
commit
eeec6de698
|
@ -75,6 +75,7 @@
|
|||
@"https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic",
|
||||
@"https://nokiatech.github.io/heif/content/image_sequences/starfield_animation.heic",
|
||||
@"https://s2.ax1x.com/2019/11/01/KHYIgJ.gif",
|
||||
@"https://raw.githubusercontent.com/icons8/flat-color-icons/master/pdf/stack_of_photos.pdf",
|
||||
@"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png",
|
||||
@"http://via.placeholder.com/200x200.jpg",
|
||||
nil];
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
322241802272F808002429DB /* SDUtilsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3222417E2272F808002429DB /* SDUtilsTests.m */; };
|
||||
3226ECBB20754F7700FAFACF /* SDWebImageTestDownloadOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 3226ECBA20754F7700FAFACF /* SDWebImageTestDownloadOperation.m */; };
|
||||
3226ECBC20754F7700FAFACF /* SDWebImageTestDownloadOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 3226ECBA20754F7700FAFACF /* SDWebImageTestDownloadOperation.m */; };
|
||||
3234306223E2BAC800C290C8 /* TestImage.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 3234306123E2BAC800C290C8 /* TestImage.pdf */; };
|
||||
3234306323E2BAC800C290C8 /* TestImage.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 3234306123E2BAC800C290C8 /* TestImage.pdf */; };
|
||||
3234306423E2BAC800C290C8 /* TestImage.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 3234306123E2BAC800C290C8 /* TestImage.pdf */; };
|
||||
323B8E1F20862322008952BE /* SDWebImageTestLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 323B8E1E20862322008952BE /* SDWebImageTestLoader.m */; };
|
||||
323B8E2020862322008952BE /* SDWebImageTestLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 323B8E1E20862322008952BE /* SDWebImageTestLoader.m */; };
|
||||
324047442271956F007C53E1 /* TestEXIF.png in Resources */ = {isa = PBXBuildFile; fileRef = 324047432271956F007C53E1 /* TestEXIF.png */; };
|
||||
|
@ -107,6 +110,7 @@
|
|||
3222417E2272F808002429DB /* SDUtilsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDUtilsTests.m; sourceTree = "<group>"; };
|
||||
3226ECB920754F7700FAFACF /* SDWebImageTestDownloadOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageTestDownloadOperation.h; sourceTree = "<group>"; };
|
||||
3226ECBA20754F7700FAFACF /* SDWebImageTestDownloadOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageTestDownloadOperation.m; sourceTree = "<group>"; };
|
||||
3234306123E2BAC800C290C8 /* TestImage.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = TestImage.pdf; sourceTree = "<group>"; };
|
||||
323B8E1D20862322008952BE /* SDWebImageTestLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageTestLoader.h; sourceTree = "<group>"; };
|
||||
323B8E1E20862322008952BE /* SDWebImageTestLoader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageTestLoader.m; sourceTree = "<group>"; };
|
||||
324047432271956F007C53E1 /* TestEXIF.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = TestEXIF.png; sourceTree = "<group>"; };
|
||||
|
@ -238,6 +242,7 @@
|
|||
433BBBB81D7EF8260086B6E9 /* TestImage.png */,
|
||||
327A418B211D660600495442 /* TestImage.heic */,
|
||||
32905E63211D786E00460FCF /* TestImage.heif */,
|
||||
3234306123E2BAC800C290C8 /* TestImage.pdf */,
|
||||
327054E1206CEFF3006EA328 /* TestImageAnimated.apng */,
|
||||
3297A09E23374D1600814590 /* TestImageAnimated.heic */,
|
||||
);
|
||||
|
@ -443,6 +448,7 @@
|
|||
3299228B2365DC6C00EAFD97 /* TestImage.heic in Resources */,
|
||||
329922872365DC6C00EAFD97 /* TestLoopCount.gif in Resources */,
|
||||
3299228C2365DC6C00EAFD97 /* TestImage.heif in Resources */,
|
||||
3234306423E2BAC800C290C8 /* TestImage.pdf in Resources */,
|
||||
329922892365DC6C00EAFD97 /* TestImageLarge.jpg in Resources */,
|
||||
3299228A2365DC6C00EAFD97 /* TestImage.png in Resources */,
|
||||
329922842365DC6C00EAFD97 /* MonochromeTestImage.jpg in Resources */,
|
||||
|
@ -461,6 +467,7 @@
|
|||
32B99EA3203B31360017FD66 /* TestImage.gif in Resources */,
|
||||
324047452271956F007C53E1 /* TestEXIF.png in Resources */,
|
||||
32B99EA4203B31360017FD66 /* TestImage.jpg in Resources */,
|
||||
3234306323E2BAC800C290C8 /* TestImage.pdf in Resources */,
|
||||
32B99EA6203B31360017FD66 /* TestImage.png in Resources */,
|
||||
3297A0A023374D1700814590 /* TestImageAnimated.heic in Resources */,
|
||||
32B99EA2203B31360017FD66 /* MonochromeTestImage.jpg in Resources */,
|
||||
|
@ -479,6 +486,7 @@
|
|||
5F7F38AD1AE2A77A00B0E330 /* TestImage.jpg in Resources */,
|
||||
32905E64211D786E00460FCF /* TestImage.heif in Resources */,
|
||||
43828A451DA67F9900000E62 /* TestImageLarge.jpg in Resources */,
|
||||
3234306223E2BAC800C290C8 /* TestImage.pdf in Resources */,
|
||||
433BBBB71D7EF8200086B6E9 /* TestImage.gif in Resources */,
|
||||
433BBBB91D7EF8260086B6E9 /* TestImage.png in Resources */,
|
||||
3297A09F23374D1700814590 /* TestImageAnimated.heic in Resources */,
|
||||
|
|
Binary file not shown.
|
@ -156,22 +156,34 @@
|
|||
withLocalImageURL:heicURL
|
||||
supportsEncoding:supportsEncoding
|
||||
encodingFormat:SDImageFormatHEIC
|
||||
isAnimatedImage:isAnimatedImage];
|
||||
isAnimatedImage:isAnimatedImage
|
||||
isVectorImage:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)test17ThatPDFWorks {
|
||||
NSURL *pdfURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"pdf"];
|
||||
[self verifyCoder:[SDImageIOCoder sharedCoder]
|
||||
withLocalImageURL:pdfURL
|
||||
supportsEncoding:NO
|
||||
encodingFormat:SDImageFormatUndefined
|
||||
isAnimatedImage:NO
|
||||
isVectorImage: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];
|
||||
[self verifyCoder:coder withLocalImageURL:imageUrl supportsEncoding:supportsEncoding encodingFormat:SDImageFormatUndefined isAnimatedImage:isAnimated isVectorImage:NO];
|
||||
}
|
||||
|
||||
- (void)verifyCoder:(id<SDImageCoder>)coder
|
||||
withLocalImageURL:(NSURL *)imageUrl
|
||||
supportsEncoding:(BOOL)supportsEncoding
|
||||
encodingFormat:(SDImageFormat)encodingFormat
|
||||
isAnimatedImage:(BOOL)isAnimated {
|
||||
isAnimatedImage:(BOOL)isAnimated
|
||||
isVectorImage:(BOOL)isVector {
|
||||
NSData *inputImageData = [NSData dataWithContentsOfURL:imageUrl];
|
||||
expect(inputImageData).toNot.beNil();
|
||||
SDImageFormat inputImageFormat = [NSData sd_imageFormatForImageData:inputImageData];
|
||||
|
@ -204,7 +216,18 @@ withLocalImageURL:(NSURL *)imageUrl
|
|||
CGFloat pixelHeight = inputImage.size.height;
|
||||
expect(pixelWidth).beGreaterThan(0);
|
||||
expect(pixelHeight).beGreaterThan(0);
|
||||
// check thumnail with scratch
|
||||
// check vector format supports thumbnail with screen size
|
||||
if (isVector) {
|
||||
#if SD_UIKIT
|
||||
CGFloat maxScreenSize = MAX(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height);
|
||||
#else
|
||||
CGFloat maxScreenSize = MAX(NSScreen.mainScreen.frame.size.width, NSScreen.mainScreen.frame.size.height);
|
||||
#endif
|
||||
expect(pixelWidth).equal(maxScreenSize);
|
||||
expect(pixelHeight).equal(maxScreenSize);
|
||||
}
|
||||
|
||||
// check thumbnail with scratch
|
||||
CGFloat thumbnailWidth = 50;
|
||||
CGFloat thumbnailHeight = 50;
|
||||
UIImage *thumbImage = [coder decodedImageWithData:inputImageData options:@{
|
||||
|
@ -213,7 +236,7 @@ withLocalImageURL:(NSURL *)imageUrl
|
|||
}];
|
||||
expect(thumbImage).toNot.beNil();
|
||||
expect(thumbImage.size).equal(CGSizeMake(thumbnailWidth, thumbnailHeight));
|
||||
// check thumnail with aspect ratio limit
|
||||
// check thumbnail with aspect ratio limit
|
||||
thumbImage = [coder decodedImageWithData:inputImageData options:@{
|
||||
SDImageCoderDecodeThumbnailPixelSize : @(CGSizeMake(thumbnailWidth, thumbnailHeight)),
|
||||
SDImageCoderDecodePreserveAspectRatio : @(YES)
|
||||
|
|
Loading…
Reference in New Issue