From c8df858f7516f5a43b917e6344c8fc4b5bf5300c Mon Sep 17 00:00:00 2001 From: Bogdan Poplauschi Date: Fri, 18 Jul 2014 16:56:32 +0300 Subject: [PATCH] Added test for the UIImage+MultiFormat crash --- .../project.pbxproj | 4 ++ Tests/Tests/UIImageMultiFormatTests.m | 46 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 Tests/Tests/UIImageMultiFormatTests.m diff --git a/Tests/SDWebImage Tests.xcodeproj/project.pbxproj b/Tests/SDWebImage Tests.xcodeproj/project.pbxproj index fd80a8e..3b16a84 100644 --- a/Tests/SDWebImage Tests.xcodeproj/project.pbxproj +++ b/Tests/SDWebImage Tests.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ DA248D61195472AA00390AB0 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DA248D5F195472AA00390AB0 /* InfoPlist.strings */; }; DA248D69195475D800390AB0 /* SDImageCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DA248D68195475D800390AB0 /* SDImageCacheTests.m */; }; DA248D6B195476AC00390AB0 /* SDWebImageManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DA248D6A195476AC00390AB0 /* SDWebImageManagerTests.m */; }; + DA91BEBC19795BC9006F2536 /* UIImageMultiFormatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DA91BEBB19795BC9006F2536 /* UIImageMultiFormatTests.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -27,6 +28,7 @@ DA248D64195472AA00390AB0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; DA248D68195475D800390AB0 /* SDImageCacheTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDImageCacheTests.m; sourceTree = ""; }; DA248D6A195476AC00390AB0 /* SDWebImageManagerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageManagerTests.m; sourceTree = ""; }; + DA91BEBB19795BC9006F2536 /* UIImageMultiFormatTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIImageMultiFormatTests.m; sourceTree = ""; }; EB0D107E6B4C4094BA2FEE29 /* libPods-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -80,6 +82,7 @@ DA248D5D195472AA00390AB0 /* Supporting Files */, DA248D68195475D800390AB0 /* SDImageCacheTests.m */, DA248D6A195476AC00390AB0 /* SDWebImageManagerTests.m */, + DA91BEBB19795BC9006F2536 /* UIImageMultiFormatTests.m */, ); path = Tests; sourceTree = ""; @@ -192,6 +195,7 @@ files = ( DA248D69195475D800390AB0 /* SDImageCacheTests.m in Sources */, DA248D6B195476AC00390AB0 /* SDWebImageManagerTests.m in Sources */, + DA91BEBC19795BC9006F2536 /* UIImageMultiFormatTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Tests/Tests/UIImageMultiFormatTests.m b/Tests/Tests/UIImageMultiFormatTests.m new file mode 100644 index 0000000..a757da8 --- /dev/null +++ b/Tests/Tests/UIImageMultiFormatTests.m @@ -0,0 +1,46 @@ +// +// UIImageMultiFormatTests.m +// SDWebImage Tests +// +// Created by Bogdan Poplauschi on 18/07/14. +// +// + +#define EXP_SHORTHAND // required by Expecta + + +#import +#import +#import + +#import "UIImage+MultiFormat.h" + + +@interface UIImageMultiFormatTests : XCTestCase + +@end + + +@implementation UIImageMultiFormatTests + +- (void)setUp +{ + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown +{ + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testImageOrientationFromImageDataWithInvalidData { + // sync download image + SEL selector = @selector(sd_imageOrientationFromImageData:); + + UIImageOrientation orientation = [[UIImage class] performSelector:selector withObject:nil]; + expect(orientation).to.equal(UIImageOrientationUp); +} + +@end