diff --git a/Example/AppDelegate.m b/Example/AppDelegate.m index 9ce3159..ee443f2 100644 --- a/Example/AppDelegate.m +++ b/Example/AppDelegate.m @@ -3,35 +3,36 @@ @implementation AppDelegate -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - CGRect frame = [[UIScreen mainScreen] bounds]; - - self.window = [[UIWindow alloc] initWithFrame:frame]; - self.window.backgroundColor = [UIColor lightGrayColor]; - - UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - button.frame = CGRectMake(CGRectGetMidX(frame) - 50, 40, 100, 40); - [self.window addSubview:button]; - - FTPDFAssetRenderer *renderer = [FTPDFAssetRenderer rendererForPDFNamed:@"restaurant-icon-mask"]; - [renderer fitSize:button.bounds.size]; - - renderer.targetColor = [UIColor blueColor]; - [button setImage:[renderer imageWithCacheIdentifier:@"normal"] forState:UIControlStateNormal]; - renderer.targetColor = [UIColor whiteColor]; - [button setImage:[renderer imageWithCacheIdentifier:@"highlighted"] forState:UIControlStateHighlighted]; - -// UIImage *image = [FTPDFAssetRenderer imageOfPDFNamed:@"restaurant-icon-mask" -// targetWidth:frame.size.width -// targetColor:[UIColor greenColor] -// withIdentifier:@"pink is always good"]; -// UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; -// imageView.frame = CGRectMake(0, 100, imageView.bounds.size.width, imageView.bounds.size.height); -// [self.window addSubview:imageView]; - - [self.window makeKeyAndVisible]; - return YES; + CGRect frame = [[UIScreen mainScreen] bounds]; + + self.window = [[UIWindow alloc] initWithFrame:frame]; + self.window.backgroundColor = [UIColor lightGrayColor]; + self.window.rootViewController = [UIViewController new]; + + UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + button.frame = CGRectMake(CGRectGetMidX(frame) - 50, 40, 100, 40); + [self.window addSubview:button]; + + FTPDFAssetRenderer *renderer = [FTPDFAssetRenderer rendererForPDFNamed:@"restaurant-icon-mask"]; + [renderer fitSize:button.bounds.size]; + + renderer.targetColor = [UIColor blueColor]; + [button setImage:[renderer imageWithCacheIdentifier:@"normal"] forState:UIControlStateNormal]; + renderer.targetColor = [UIColor whiteColor]; + [button setImage:[renderer imageWithCacheIdentifier:@"highlighted"] forState:UIControlStateHighlighted]; + + // UIImage *image = [FTPDFAssetRenderer imageOfPDFNamed:@"restaurant-icon-mask" + // targetWidth:frame.size.width + // targetColor:[UIColor greenColor] + // withIdentifier:@"pink is always good"]; + // UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; + // imageView.frame = CGRectMake(0, 100, imageView.bounds.size.width, imageView.bounds.size.height); + // [self.window addSubview:imageView]; + + [self.window makeKeyAndVisible]; + return YES; } @end diff --git a/Example/FTAssetRenderer.xcodeproj/project.pbxproj b/Example/FTAssetRenderer.xcodeproj/project.pbxproj index fe6d011..52dfc2b 100644 --- a/Example/FTAssetRenderer.xcodeproj/project.pbxproj +++ b/Example/FTAssetRenderer.xcodeproj/project.pbxproj @@ -16,28 +16,24 @@ 51C4098C1625F62900AF7C06 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 51C4098B1625F62900AF7C06 /* Default.png */; }; 51C4098E1625F62900AF7C06 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 51C4098D1625F62900AF7C06 /* Default@2x.png */; }; 51C409901625F62900AF7C06 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 51C4098F1625F62900AF7C06 /* Default-568h@2x.png */; }; - 51C409981625F62A00AF7C06 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51C409971625F62900AF7C06 /* SenTestingKit.framework */; }; - 51C409991625F62A00AF7C06 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51C409791625F62900AF7C06 /* UIKit.framework */; }; - 51C4099A1625F62A00AF7C06 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51C4097B1625F62900AF7C06 /* Foundation.framework */; }; - 51C409A21625F62A00AF7C06 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 51C409A01625F62A00AF7C06 /* InfoPlist.strings */; }; - 51C409A51625F62A00AF7C06 /* FTPDFAssetRendererTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 51C409A41625F62A00AF7C06 /* FTPDFAssetRendererTests.m */; }; 51C409BA1626014200AF7C06 /* FTPDFAssetRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 51C409B91626014200AF7C06 /* FTPDFAssetRenderer.m */; }; 51C409BD1626038900AF7C06 /* restaurant-icon-mask.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 51C409BC1626038900AF7C06 /* restaurant-icon-mask.pdf */; }; 51C409DB1627191600AF7C06 /* FTAssetRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 51C409DA1627191600AF7C06 /* FTAssetRenderer.m */; }; 51C409DF1627240D00AF7C06 /* FTImageAssetRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 51C409DE1627240D00AF7C06 /* FTImageAssetRenderer.m */; }; - 51C409E21627339300AF7C06 /* FTAssetRendererTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 51C409E11627339300AF7C06 /* FTAssetRendererTests.m */; }; - 51C409E51627353300AF7C06 /* FTImageAssetRendererTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 51C409E41627353300AF7C06 /* FTImageAssetRendererTests.m */; }; 51C409E7162C0C1000AF7C06 /* restaurant-icon-mask.png in Resources */ = {isa = PBXBuildFile; fileRef = 51C409E6162C0C1000AF7C06 /* restaurant-icon-mask.png */; }; 51C409E9162C0C8A00AF7C06 /* restaurant-icon-mask@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 51C409E8162C0C8A00AF7C06 /* restaurant-icon-mask@2x.png */; }; + 9B6203561CC7C228005020F4 /* FTAssetRendererTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B6203511CC7C228005020F4 /* FTAssetRendererTests.m */; }; + 9B6203571CC7C228005020F4 /* FTImageAssetRendererTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B6203531CC7C228005020F4 /* FTImageAssetRendererTests.m */; }; + 9B6203581CC7C228005020F4 /* FTPDFAssetRendererTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B6203551CC7C228005020F4 /* FTPDFAssetRendererTests.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 51C4099B1625F62A00AF7C06 /* PBXContainerItemProxy */ = { + 9B62034B1CC7C1FB005020F4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 51C4096C1625F62900AF7C06 /* Project object */; proxyType = 1; remoteGlobalIDString = 51C409741625F62900AF7C06; - remoteInfo = FTPDFIconRenderer; + remoteInfo = FTAssetRenderer; }; /* End PBXContainerItemProxy section */ @@ -55,12 +51,6 @@ 51C4098B1625F62900AF7C06 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 51C4098D1625F62900AF7C06 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 51C4098F1625F62900AF7C06 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; - 51C409961625F62900AF7C06 /* FTAssetRendererTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FTAssetRendererTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; - 51C409971625F62900AF7C06 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; - 51C4099F1625F62A00AF7C06 /* FTAssetRendererTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "FTAssetRendererTests-Info.plist"; sourceTree = ""; }; - 51C409A11625F62A00AF7C06 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - 51C409A31625F62A00AF7C06 /* FTPDFAssetRendererTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FTPDFAssetRendererTests.h; sourceTree = ""; }; - 51C409A41625F62A00AF7C06 /* FTPDFAssetRendererTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FTPDFAssetRendererTests.m; sourceTree = ""; }; 51C409B81626014200AF7C06 /* FTPDFAssetRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTPDFAssetRenderer.h; path = ../Source/FTPDFAssetRenderer.h; sourceTree = ""; }; 51C409B91626014200AF7C06 /* FTPDFAssetRenderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FTPDFAssetRenderer.m; path = ../Source/FTPDFAssetRenderer.m; sourceTree = ""; }; 51C409BC1626038900AF7C06 /* restaurant-icon-mask.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = "restaurant-icon-mask.pdf"; sourceTree = SOURCE_ROOT; }; @@ -68,12 +58,16 @@ 51C409DA1627191600AF7C06 /* FTAssetRenderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FTAssetRenderer.m; path = ../Source/FTAssetRenderer.m; sourceTree = ""; }; 51C409DD1627240D00AF7C06 /* FTImageAssetRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTImageAssetRenderer.h; path = ../Source/FTImageAssetRenderer.h; sourceTree = ""; }; 51C409DE1627240D00AF7C06 /* FTImageAssetRenderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FTImageAssetRenderer.m; path = ../Source/FTImageAssetRenderer.m; sourceTree = ""; }; - 51C409E01627339300AF7C06 /* FTAssetRendererTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FTAssetRendererTests.h; sourceTree = ""; }; - 51C409E11627339300AF7C06 /* FTAssetRendererTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FTAssetRendererTests.m; sourceTree = ""; }; - 51C409E31627353300AF7C06 /* FTImageAssetRendererTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FTImageAssetRendererTests.h; sourceTree = ""; }; - 51C409E41627353300AF7C06 /* FTImageAssetRendererTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FTImageAssetRendererTests.m; sourceTree = ""; }; 51C409E6162C0C1000AF7C06 /* restaurant-icon-mask.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "restaurant-icon-mask.png"; sourceTree = ""; }; 51C409E8162C0C8A00AF7C06 /* restaurant-icon-mask@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "restaurant-icon-mask@2x.png"; sourceTree = ""; }; + 9B6203461CC7C1FB005020F4 /* FTAssetRendererTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FTAssetRendererTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 9B62034A1CC7C1FB005020F4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../../FTAssetRendererTests/Info.plist; sourceTree = ""; }; + 9B6203501CC7C228005020F4 /* FTAssetRendererTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTAssetRendererTests.h; path = ../../FTAssetRendererTests/FTAssetRendererTests.h; sourceTree = ""; }; + 9B6203511CC7C228005020F4 /* FTAssetRendererTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FTAssetRendererTests.m; path = ../../FTAssetRendererTests/FTAssetRendererTests.m; sourceTree = ""; }; + 9B6203521CC7C228005020F4 /* FTImageAssetRendererTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTImageAssetRendererTests.h; path = ../../FTAssetRendererTests/FTImageAssetRendererTests.h; sourceTree = ""; }; + 9B6203531CC7C228005020F4 /* FTImageAssetRendererTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FTImageAssetRendererTests.m; path = ../../FTAssetRendererTests/FTImageAssetRendererTests.m; sourceTree = ""; }; + 9B6203541CC7C228005020F4 /* FTPDFAssetRendererTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTPDFAssetRendererTests.h; path = ../../FTAssetRendererTests/FTPDFAssetRendererTests.h; sourceTree = ""; }; + 9B6203551CC7C228005020F4 /* FTPDFAssetRendererTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FTPDFAssetRendererTests.m; path = ../../FTAssetRendererTests/FTPDFAssetRendererTests.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -87,13 +81,10 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 51C409921625F62900AF7C06 /* Frameworks */ = { + 9B6203431CC7C1FB005020F4 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 51C409981625F62A00AF7C06 /* SenTestingKit.framework in Frameworks */, - 51C409991625F62A00AF7C06 /* UIKit.framework in Frameworks */, - 51C4099A1625F62A00AF7C06 /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -105,7 +96,7 @@ children = ( 51C409C21626044E00AF7C06 /* Example */, 51C409B31626000A00AF7C06 /* Source */, - 51C4099D1625F62A00AF7C06 /* Tests */, + 9B6203471CC7C1FB005020F4 /* FTAssetRendererTests */, 51C409781625F62900AF7C06 /* Frameworks */, 51C409761625F62900AF7C06 /* Products */, ); @@ -115,7 +106,7 @@ isa = PBXGroup; children = ( 51C409751625F62900AF7C06 /* FTAssetRenderer.app */, - 51C409961625F62900AF7C06 /* FTAssetRendererTests.octest */, + 9B6203461CC7C1FB005020F4 /* FTAssetRendererTests.xctest */, ); name = Products; sourceTree = ""; @@ -126,26 +117,10 @@ 51C409791625F62900AF7C06 /* UIKit.framework */, 51C4097B1625F62900AF7C06 /* Foundation.framework */, 51C4097D1625F62900AF7C06 /* CoreGraphics.framework */, - 51C409971625F62900AF7C06 /* SenTestingKit.framework */, ); name = Frameworks; sourceTree = ""; }; - 51C4099D1625F62A00AF7C06 /* Tests */ = { - isa = PBXGroup; - children = ( - 51C409C5162619C100AF7C06 /* Supporting Files */, - 51C409E01627339300AF7C06 /* FTAssetRendererTests.h */, - 51C409E11627339300AF7C06 /* FTAssetRendererTests.m */, - 51C409A31625F62A00AF7C06 /* FTPDFAssetRendererTests.h */, - 51C409A41625F62A00AF7C06 /* FTPDFAssetRendererTests.m */, - 51C409E31627353300AF7C06 /* FTImageAssetRendererTests.h */, - 51C409E41627353300AF7C06 /* FTImageAssetRendererTests.m */, - ); - name = Tests; - path = ../Tests; - sourceTree = ""; - }; 51C409B31626000A00AF7C06 /* Source */ = { isa = PBXGroup; children = ( @@ -186,13 +161,18 @@ name = "Supporting Files"; sourceTree = ""; }; - 51C409C5162619C100AF7C06 /* Supporting Files */ = { + 9B6203471CC7C1FB005020F4 /* FTAssetRendererTests */ = { isa = PBXGroup; children = ( - 51C4099F1625F62A00AF7C06 /* FTAssetRendererTests-Info.plist */, - 51C409A01625F62A00AF7C06 /* InfoPlist.strings */, + 9B62034A1CC7C1FB005020F4 /* Info.plist */, + 9B6203501CC7C228005020F4 /* FTAssetRendererTests.h */, + 9B6203511CC7C228005020F4 /* FTAssetRendererTests.m */, + 9B6203521CC7C228005020F4 /* FTImageAssetRendererTests.h */, + 9B6203531CC7C228005020F4 /* FTImageAssetRendererTests.m */, + 9B6203541CC7C228005020F4 /* FTPDFAssetRendererTests.h */, + 9B6203551CC7C228005020F4 /* FTPDFAssetRendererTests.m */, ); - name = "Supporting Files"; + path = FTAssetRendererTests; sourceTree = ""; }; /* End PBXGroup section */ @@ -215,24 +195,23 @@ productReference = 51C409751625F62900AF7C06 /* FTAssetRenderer.app */; productType = "com.apple.product-type.application"; }; - 51C409951625F62900AF7C06 /* FTAssetRendererTests */ = { + 9B6203451CC7C1FB005020F4 /* FTAssetRendererTests */ = { isa = PBXNativeTarget; - buildConfigurationList = 51C409AB1625F62A00AF7C06 /* Build configuration list for PBXNativeTarget "FTAssetRendererTests" */; + buildConfigurationList = 9B62034D1CC7C1FC005020F4 /* Build configuration list for PBXNativeTarget "FTAssetRendererTests" */; buildPhases = ( - 51C409911625F62900AF7C06 /* Sources */, - 51C409921625F62900AF7C06 /* Frameworks */, - 51C409931625F62900AF7C06 /* Resources */, - 51C409941625F62900AF7C06 /* ShellScript */, + 9B6203421CC7C1FB005020F4 /* Sources */, + 9B6203431CC7C1FB005020F4 /* Frameworks */, + 9B6203441CC7C1FB005020F4 /* Resources */, ); buildRules = ( ); dependencies = ( - 51C4099C1625F62A00AF7C06 /* PBXTargetDependency */, + 9B62034C1CC7C1FB005020F4 /* PBXTargetDependency */, ); name = FTAssetRendererTests; - productName = FTPDFIconRendererTests; - productReference = 51C409961625F62900AF7C06 /* FTAssetRendererTests.octest */; - productType = "com.apple.product-type.bundle"; + productName = FTAssetRendererTests; + productReference = 9B6203461CC7C1FB005020F4 /* FTAssetRendererTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; }; /* End PBXNativeTarget section */ @@ -242,6 +221,12 @@ attributes = { LastUpgradeCheck = 0450; ORGANIZATIONNAME = "Fingertips BV"; + TargetAttributes = { + 9B6203451CC7C1FB005020F4 = { + CreatedOnToolsVersion = 7.3; + TestTargetID = 51C409741625F62900AF7C06; + }; + }; }; buildConfigurationList = 51C4096F1625F62900AF7C06 /* Build configuration list for PBXProject "FTAssetRenderer" */; compatibilityVersion = "Xcode 3.2"; @@ -256,7 +241,7 @@ projectRoot = ""; targets = ( 51C409741625F62900AF7C06 /* FTAssetRenderer */, - 51C409951625F62900AF7C06 /* FTAssetRendererTests */, + 9B6203451CC7C1FB005020F4 /* FTAssetRendererTests */, ); }; /* End PBXProject section */ @@ -276,32 +261,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 51C409931625F62900AF7C06 /* Resources */ = { + 9B6203441CC7C1FB005020F4 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 51C409A21625F62A00AF7C06 /* InfoPlist.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 51C409941625F62900AF7C06 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 51C409711625F62900AF7C06 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -315,23 +283,23 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 51C409911625F62900AF7C06 /* Sources */ = { + 9B6203421CC7C1FB005020F4 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 51C409A51625F62A00AF7C06 /* FTPDFAssetRendererTests.m in Sources */, - 51C409E21627339300AF7C06 /* FTAssetRendererTests.m in Sources */, - 51C409E51627353300AF7C06 /* FTImageAssetRendererTests.m in Sources */, + 9B6203561CC7C228005020F4 /* FTAssetRendererTests.m in Sources */, + 9B6203581CC7C228005020F4 /* FTPDFAssetRendererTests.m in Sources */, + 9B6203571CC7C228005020F4 /* FTImageAssetRendererTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 51C4099C1625F62A00AF7C06 /* PBXTargetDependency */ = { + 9B62034C1CC7C1FB005020F4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 51C409741625F62900AF7C06 /* FTAssetRenderer */; - targetProxy = 51C4099B1625F62A00AF7C06 /* PBXContainerItemProxy */; + targetProxy = 9B62034B1CC7C1FB005020F4 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -344,14 +312,6 @@ name = InfoPlist.strings; sourceTree = ""; }; - 51C409A01625F62A00AF7C06 /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 51C409A11625F62A00AF7C06 /* en */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -428,37 +388,69 @@ }; name = Release; }; - 51C409AC1625F62A00AF7C06 /* Debug */ = { + 9B62034E1CC7C1FC005020F4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/FTAssetRenderer.app/FTAssetRenderer"; - FRAMEWORK_SEARCH_PATHS = ( - "\"$(SDKROOT)/Developer/Library/Frameworks\"", - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", - ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "../Tests/FTAssetRendererTests-Info.plist"; + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = ../FTAssetRendererTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.fngtps.FTAssetRendererTests; PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FTAssetRenderer.app/FTAssetRenderer"; }; name = Debug; }; - 51C409AD1625F62A00AF7C06 /* Release */ = { + 9B62034F1CC7C1FC005020F4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/FTAssetRenderer.app/FTAssetRenderer"; - FRAMEWORK_SEARCH_PATHS = ( - "\"$(SDKROOT)/Developer/Library/Frameworks\"", - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", - ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = "../Tests/FTAssetRendererTests-Info.plist"; + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = ../FTAssetRendererTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = com.fngtps.FTAssetRendererTests; PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FTAssetRenderer.app/FTAssetRenderer"; }; name = Release; }; @@ -483,11 +475,11 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 51C409AB1625F62A00AF7C06 /* Build configuration list for PBXNativeTarget "FTAssetRendererTests" */ = { + 9B62034D1CC7C1FC005020F4 /* Build configuration list for PBXNativeTarget "FTAssetRendererTests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 51C409AC1625F62A00AF7C06 /* Debug */, - 51C409AD1625F62A00AF7C06 /* Release */, + 9B62034E1CC7C1FC005020F4 /* Debug */, + 9B62034F1CC7C1FC005020F4 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/FTAssetRendererTests/FTAssetRendererTests.h b/FTAssetRendererTests/FTAssetRendererTests.h new file mode 100644 index 0000000..84b540b --- /dev/null +++ b/FTAssetRendererTests/FTAssetRendererTests.h @@ -0,0 +1,8 @@ +#import +#import "FTAssetRenderer.h" + +@interface FTAssetRendererTests : XCTestCase + +@property (nonatomic) FTAssetRenderer *renderer; + +@end diff --git a/FTAssetRendererTests/FTAssetRendererTests.m b/FTAssetRendererTests/FTAssetRendererTests.m new file mode 100644 index 0000000..e822a79 --- /dev/null +++ b/FTAssetRendererTests/FTAssetRendererTests.m @@ -0,0 +1,53 @@ +#import "FTAssetRendererTests.h" + +@implementation FTAssetRendererTests + +- (void)setUp +{ + [super setUp]; + [[NSFileManager defaultManager] createDirectoryAtPath:[FTAssetRenderer cacheDirectory] + withIntermediateDirectories:YES + attributes:nil + error:NULL]; + self.renderer = [[FTAssetRenderer alloc] initWithURL:nil]; +} + +- (void)tearDown +{ + [super tearDown]; + self.renderer = nil; + [[NSFileManager defaultManager] removeItemAtPath:[FTAssetRenderer cacheDirectory] + error:NULL]; +} + +#pragma mark - caching + +- (void)testCachesInSpecificCacheDirectory +{ + NSString *expected = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0]; + expected = [expected stringByAppendingPathComponent:@"__FTAssetRenderer_Cache__"]; + XCTAssertEqualObjects(expected, [FTAssetRenderer cacheDirectory]); +} + +- (void)testChangesCachePathBasedOnIdentifier +{ + NSString *path = [self.renderer cachePathWithIdentifier:@"normal"]; + XCTAssertEqualObjects(path, [self.renderer cachePathWithIdentifier:@"normal"]); + + NSString *newPath = [self.renderer cachePathWithIdentifier:@"highlighted"]; + XCTAssertFalse([path isEqualToString:newPath]); + XCTAssertEqualObjects(newPath, [self.renderer cachePathWithIdentifier:@"highlighted"]); +} + +//- (void)testRaisesWhenUsedAsMaskAndCachingWithoutCacheIdentifier +//{ +//self.renderer.targetColor = [UIColor redColor]; + +//self.renderer.cache = NO; +//STAssertNoThrow([self.renderer imageWithCacheIdentifier:nil], nil); + +//self.renderer.cache = YES; +//STAssertThrowsSpecificNamed([self.renderer imageWithCacheIdentifier:nil], NSException, @"FTAssetRendererError", nil); +//} + +@end diff --git a/Tests/FTImageAssetRendererTests.h b/FTAssetRendererTests/FTImageAssetRendererTests.h similarity index 51% rename from Tests/FTImageAssetRendererTests.h rename to FTAssetRendererTests/FTImageAssetRendererTests.h index b88556f..7385e69 100644 --- a/Tests/FTImageAssetRendererTests.h +++ b/FTAssetRendererTests/FTImageAssetRendererTests.h @@ -1,7 +1,7 @@ -#import +#import #import "FTImageAssetRenderer.h" -@interface FTImageAssetRendererTests : SenTestCase +@interface FTImageAssetRendererTests : XCTestCase @property (nonatomic) FTImageAssetRenderer *renderer; diff --git a/FTAssetRendererTests/FTImageAssetRendererTests.m b/FTAssetRendererTests/FTImageAssetRendererTests.m new file mode 100644 index 0000000..19712df --- /dev/null +++ b/FTAssetRendererTests/FTImageAssetRendererTests.m @@ -0,0 +1,52 @@ +#import "FTImageAssetRendererTests.h" + +@implementation FTImageAssetRendererTests + +- (void)setUp +{ + [super setUp]; + [[NSFileManager defaultManager] createDirectoryAtPath:[FTAssetRenderer cacheDirectory] + withIntermediateDirectories:YES + attributes:nil + error:NULL]; + self.renderer = [FTAssetRenderer rendererForImageNamed:@"restaurant-icon-mask" withExtension:@"png"]; + self.renderer.targetColor = [UIColor redColor]; +} + +- (void)tearDown +{ + [super tearDown]; + self.renderer = nil; + [[NSFileManager defaultManager] removeItemAtPath:[FTAssetRenderer cacheDirectory] + error:NULL]; +} + +- (void)testConvenienceMethodLoadsImageAppropriateForScreenScale +{ + NSString *filename = [[self.renderer.URL lastPathComponent] stringByDeletingPathExtension]; + int scale = (int)[[UIScreen mainScreen] scale]; + if (scale > 1) { + XCTAssertTrue([filename hasSuffix:@"@2x"]); + } else { + XCTAssertFalse([filename hasSuffix:@"@2x"]); + } +} + +- (void)testReturnsImageOfExpectedSizeAndScale +{ + UIImage *result = [self.renderer imageWithCacheIdentifier:@"test"]; + XCTAssertTrue(CGSizeEqualToSize(self.renderer.sourceImage.size, result.size)); +} + +- (void)testCreatesExpectedSizeImageAtCachePath +{ + NSString *path = [self.renderer cachePathWithIdentifier:@"test"]; + [self.renderer imageWithCacheIdentifier:@"test"]; + sleep(1.5); // lame, should check if file exists with timeout + UIImage *result = [UIImage imageWithContentsOfFile:path]; + CGFloat scale = [[UIScreen mainScreen] scale]; + CGSize sourceSize = self.renderer.sourceImage.size; + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(sourceSize.width * scale, sourceSize.height * scale), result.size)); +} + +@end diff --git a/Tests/FTPDFAssetRendererTests.h b/FTAssetRendererTests/FTPDFAssetRendererTests.h similarity index 50% rename from Tests/FTPDFAssetRendererTests.h rename to FTAssetRendererTests/FTPDFAssetRendererTests.h index 417aed2..38acad3 100644 --- a/Tests/FTPDFAssetRendererTests.h +++ b/FTAssetRendererTests/FTPDFAssetRendererTests.h @@ -1,7 +1,7 @@ -#import +#import #import "FTPDFAssetRenderer.h" -@interface FTPDFAssetRendererTests : SenTestCase +@interface FTPDFAssetRendererTests : XCTestCase @property (nonatomic) FTPDFAssetRenderer *renderer; diff --git a/FTAssetRendererTests/FTPDFAssetRendererTests.m b/FTAssetRendererTests/FTPDFAssetRendererTests.m new file mode 100644 index 0000000..5d8ed0f --- /dev/null +++ b/FTAssetRendererTests/FTPDFAssetRendererTests.m @@ -0,0 +1,107 @@ +#import "FTPDFAssetRendererTests.h" + +// TODO +// * add portrait and landscape fixtures + +@implementation FTPDFAssetRendererTests + +- (void)setUp +{ + [super setUp]; + [[NSFileManager defaultManager] createDirectoryAtPath:[FTAssetRenderer cacheDirectory] + withIntermediateDirectories:YES + attributes:nil + error:NULL]; + self.renderer = [FTAssetRenderer rendererForPDFNamed:@"restaurant-icon-mask"]; +} + +- (void)tearDown +{ + [super tearDown]; + self.renderer = nil; + [[NSFileManager defaultManager] removeItemAtPath:[FTAssetRenderer cacheDirectory] + error:NULL]; +} + +#pragma - mark sizing + +- (void)testByDefaultUsesMediaBoxSizeAsTarget +{ + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(88, 88), self.renderer.targetSize)); +} + +- (void)testFitsPDFWithinGivenSizeFillingShortestEdge +{ + [self.renderer fitSize:CGSizeMake(100, 200)]; + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 100), self.renderer.targetSize)); + [self.renderer fitSize:CGSizeMake(300, 200)]; + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(200, 200), self.renderer.targetSize)); +} + +- (void)testFitsPDFWithinGivenTargetWidth +{ + [self.renderer fitWidth:100]; + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 100), self.renderer.targetSize)); +} + +- (void)testFitsPDFWithinGivenTargetHeight +{ + [self.renderer fitHeight:100]; + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 100), self.renderer.targetSize)); +} + +#pragma mark - caching + +- (void)testChangesCachePathBasedOnTargetSize +{ + NSString *path = [self.renderer cachePathWithIdentifier:nil]; + XCTAssertEqualObjects(path, [self.renderer cachePathWithIdentifier:nil]); + + self.renderer.targetSize = CGSizeMake(123, 456); + NSString *newPath = [self.renderer cachePathWithIdentifier:nil]; + XCTAssertFalse([path isEqualToString:newPath]); + XCTAssertEqualObjects(newPath, [self.renderer cachePathWithIdentifier:nil]); +} + +- (void)testChangesCachePathBasedOnSourcePageIndex +{ + NSString *path = [self.renderer cachePathWithIdentifier:nil]; + XCTAssertEqualObjects(path, [self.renderer cachePathWithIdentifier:nil]); + + self.renderer.sourcePageIndex = 2; + NSString *newPath = [self.renderer cachePathWithIdentifier:nil]; + XCTAssertFalse([path isEqualToString:newPath]); + XCTAssertEqualObjects(newPath, [self.renderer cachePathWithIdentifier:nil]); +} + +- (void)testRaisesWhenUsedAsMaskAndCachingWithoutCacheIdentifier +{ + self.renderer.targetColor = [UIColor redColor]; + + self.renderer.cache = NO; + XCTAssertNoThrow([self.renderer imageWithCacheIdentifier:nil]); + + self.renderer.cache = YES; + XCTAssertThrowsSpecificNamed([self.renderer imageWithCacheIdentifier:nil], NSException, @"FTAssetRendererError"); +} + +#pragma mark - drawing + +- (void)testReturnsImageOfExpectedSizeAndScale +{ + self.renderer.targetSize = CGSizeMake(100, 50); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), [self.renderer image].size)); +} + +- (void)testCreatesExpectedSizeImageAtCachePath +{ + self.renderer.targetSize = CGSizeMake(100, 50); + NSString *path = [self.renderer cachePathWithIdentifier:nil]; + [self.renderer image]; + sleep(1.5); // lame, should check if file exists with timeout + UIImage *image = [UIImage imageWithContentsOfFile:path]; + CGFloat scale = [[UIScreen mainScreen] scale]; + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100 * scale, 50 * scale), image.size)); +} + +@end diff --git a/Tests/FTAssetRendererTests-Info.plist b/FTAssetRendererTests/Info.plist similarity index 80% rename from Tests/FTAssetRendererTests-Info.plist rename to FTAssetRendererTests/Info.plist index 8f92ce5..ba72822 100644 --- a/Tests/FTAssetRendererTests-Info.plist +++ b/FTAssetRendererTests/Info.plist @@ -5,11 +5,13 @@ CFBundleDevelopmentRegion en CFBundleExecutable - ${EXECUTABLE_NAME} + $(EXECUTABLE_NAME) CFBundleIdentifier - com.fngtps.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 + CFBundleName + $(PRODUCT_NAME) CFBundlePackageType BNDL CFBundleShortVersionString diff --git a/Tests/FTAssetRendererTests.h b/Tests/FTAssetRendererTests.h deleted file mode 100644 index f14488d..0000000 --- a/Tests/FTAssetRendererTests.h +++ /dev/null @@ -1,8 +0,0 @@ -#import -#import "FTAssetRenderer.h" - -@interface FTAssetRendererTests : SenTestCase - -@property (nonatomic) FTAssetRenderer *renderer; - -@end diff --git a/Tests/FTAssetRendererTests.m b/Tests/FTAssetRendererTests.m deleted file mode 100644 index fb44ca5..0000000 --- a/Tests/FTAssetRendererTests.m +++ /dev/null @@ -1,53 +0,0 @@ -#import "FTAssetRendererTests.h" - -@implementation FTAssetRendererTests - -- (void)setUp; -{ - [super setUp]; - [[NSFileManager defaultManager] createDirectoryAtPath:[FTAssetRenderer cacheDirectory] - withIntermediateDirectories:YES - attributes:nil - error:NULL]; - self.renderer = [[FTAssetRenderer alloc] initWithURL:nil]; -} - -- (void)tearDown; -{ - [super tearDown]; - self.renderer = nil; - [[NSFileManager defaultManager] removeItemAtPath:[FTAssetRenderer cacheDirectory] - error:NULL]; -} - -#pragma mark - caching - -- (void)testCachesInSpecificCacheDirectory; -{ - NSString *expected = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0]; - expected = [expected stringByAppendingPathComponent:@"__FTAssetRenderer_Cache__"]; - STAssertEqualObjects(expected, [FTAssetRenderer cacheDirectory], nil); -} - -- (void)testChangesCachePathBasedOnIdentifier; -{ - NSString *path = [self.renderer cachePathWithIdentifier:@"normal"]; - STAssertEqualObjects(path, [self.renderer cachePathWithIdentifier:@"normal"], nil); - - NSString *newPath = [self.renderer cachePathWithIdentifier:@"highlighted"]; - STAssertFalse([path isEqualToString:newPath], nil); - STAssertEqualObjects(newPath, [self.renderer cachePathWithIdentifier:@"highlighted"], nil); -} - -//- (void)testRaisesWhenUsedAsMaskAndCachingWithoutCacheIdentifier; -//{ - //self.renderer.targetColor = [UIColor redColor]; - - //self.renderer.cache = NO; - //STAssertNoThrow([self.renderer imageWithCacheIdentifier:nil], nil); - - //self.renderer.cache = YES; - //STAssertThrowsSpecificNamed([self.renderer imageWithCacheIdentifier:nil], NSException, @"FTAssetRendererError", nil); -//} - -@end diff --git a/Tests/FTImageAssetRendererTests.m b/Tests/FTImageAssetRendererTests.m deleted file mode 100644 index 08e8e29..0000000 --- a/Tests/FTImageAssetRendererTests.m +++ /dev/null @@ -1,52 +0,0 @@ -#import "FTImageAssetRendererTests.h" - -@implementation FTImageAssetRendererTests - -- (void)setUp; -{ - [super setUp]; - [[NSFileManager defaultManager] createDirectoryAtPath:[FTAssetRenderer cacheDirectory] - withIntermediateDirectories:YES - attributes:nil - error:NULL]; - self.renderer = [FTAssetRenderer rendererForImageNamed:@"restaurant-icon-mask" withExtension:@"png"]; - self.renderer.targetColor = [UIColor redColor]; -} - -- (void)tearDown; -{ - [super tearDown]; - self.renderer = nil; - [[NSFileManager defaultManager] removeItemAtPath:[FTAssetRenderer cacheDirectory] - error:NULL]; -} - -- (void)testConvenienceMethodLoadsImageAppropriateForScreenScale; -{ - NSString *filename = [[self.renderer.URL lastPathComponent] stringByDeletingPathExtension]; - int scale = (int)[[UIScreen mainScreen] scale]; - if (scale > 1) { - STAssertTrue([filename hasSuffix:@"@2x"], nil); - } else { - STAssertFalse([filename hasSuffix:@"@2x"], nil); - } -} - -- (void)testReturnsImageOfExpectedSizeAndScale; -{ - UIImage *result = [self.renderer imageWithCacheIdentifier:@"test"]; - STAssertEquals(self.renderer.sourceImage.size, result.size, nil); -} - -- (void)testCreatesExpectedSizeImageAtCachePath; -{ - NSString *path = [self.renderer cachePathWithIdentifier:@"test"]; - [self.renderer imageWithCacheIdentifier:@"test"]; - sleep(1.5); // lame, should check if file exists with timeout - UIImage *result = [UIImage imageWithContentsOfFile:path]; - CGFloat scale = [[UIScreen mainScreen] scale]; - CGSize sourceSize = self.renderer.sourceImage.size; - STAssertEquals(CGSizeMake(sourceSize.width * scale, sourceSize.height * scale), result.size, nil); -} - -@end diff --git a/Tests/FTPDFAssetRendererTests.m b/Tests/FTPDFAssetRendererTests.m deleted file mode 100644 index 56fa6f3..0000000 --- a/Tests/FTPDFAssetRendererTests.m +++ /dev/null @@ -1,107 +0,0 @@ -#import "FTPDFAssetRendererTests.h" - -// TODO -// * add portrait and landscape fixtures - -@implementation FTPDFAssetRendererTests - -- (void)setUp; -{ - [super setUp]; - [[NSFileManager defaultManager] createDirectoryAtPath:[FTAssetRenderer cacheDirectory] - withIntermediateDirectories:YES - attributes:nil - error:NULL]; - self.renderer = [FTAssetRenderer rendererForPDFNamed:@"restaurant-icon-mask"]; -} - -- (void)tearDown; -{ - [super tearDown]; - self.renderer = nil; - [[NSFileManager defaultManager] removeItemAtPath:[FTAssetRenderer cacheDirectory] - error:NULL]; -} - -#pragma - mark sizing - -- (void)testByDefaultUsesMediaBoxSizeAsTarget; -{ - STAssertEquals(CGSizeMake(88, 88), self.renderer.targetSize, nil); -} - -- (void)testFitsPDFWithinGivenSizeFillingShortestEdge; -{ - [self.renderer fitSize:CGSizeMake(100, 200)]; - STAssertEquals(CGSizeMake(100, 100), self.renderer.targetSize, nil); - [self.renderer fitSize:CGSizeMake(300, 200)]; - STAssertEquals(CGSizeMake(200, 200), self.renderer.targetSize, nil); -} - -- (void)testFitsPDFWithinGivenTargetWidth; -{ - [self.renderer fitWidth:100]; - STAssertEquals(CGSizeMake(100, 100), self.renderer.targetSize, nil); -} - -- (void)testFitsPDFWithinGivenTargetHeight; -{ - [self.renderer fitHeight:100]; - STAssertEquals(CGSizeMake(100, 100), self.renderer.targetSize, nil); -} - -#pragma mark - caching - -- (void)testChangesCachePathBasedOnTargetSize; -{ - NSString *path = [self.renderer cachePathWithIdentifier:nil]; - STAssertEqualObjects(path, [self.renderer cachePathWithIdentifier:nil], nil); - - self.renderer.targetSize = CGSizeMake(123, 456); - NSString *newPath = [self.renderer cachePathWithIdentifier:nil]; - STAssertFalse([path isEqualToString:newPath], nil); - STAssertEqualObjects(newPath, [self.renderer cachePathWithIdentifier:nil], nil); -} - -- (void)testChangesCachePathBasedOnSourcePageIndex; -{ - NSString *path = [self.renderer cachePathWithIdentifier:nil]; - STAssertEqualObjects(path, [self.renderer cachePathWithIdentifier:nil], nil); - - self.renderer.sourcePageIndex = 2; - NSString *newPath = [self.renderer cachePathWithIdentifier:nil]; - STAssertFalse([path isEqualToString:newPath], nil); - STAssertEqualObjects(newPath, [self.renderer cachePathWithIdentifier:nil], nil); -} - -- (void)testRaisesWhenUsedAsMaskAndCachingWithoutCacheIdentifier; -{ - self.renderer.targetColor = [UIColor redColor]; - - self.renderer.cache = NO; - STAssertNoThrow([self.renderer imageWithCacheIdentifier:nil], nil); - - self.renderer.cache = YES; - STAssertThrowsSpecificNamed([self.renderer imageWithCacheIdentifier:nil], NSException, @"FTAssetRendererError", nil); -} - -#pragma mark - drawing - -- (void)testReturnsImageOfExpectedSizeAndScale; -{ - self.renderer.targetSize = CGSizeMake(100, 50); - STAssertEquals(CGSizeMake(100, 50), [self.renderer image].size, nil); -} - -- (void)testCreatesExpectedSizeImageAtCachePath; -{ - self.renderer.targetSize = CGSizeMake(100, 50); - NSString *path = [self.renderer cachePathWithIdentifier:nil]; - [self.renderer image]; - sleep(1.5); // lame, should check if file exists with timeout - UIImage *image = [UIImage imageWithContentsOfFile:path]; - CGFloat scale = [[UIScreen mainScreen] scale]; - STAssertEquals(CGSizeMake(100 * scale, 50 * scale), image.size, nil); -} - -@end diff --git a/Tests/en.lproj/InfoPlist.strings b/Tests/en.lproj/InfoPlist.strings deleted file mode 100644 index 477b28f..0000000 --- a/Tests/en.lproj/InfoPlist.strings +++ /dev/null @@ -1,2 +0,0 @@ -/* Localized versions of Info.plist keys */ -