diff --git a/ARCMacros.h b/ARCMacros.h new file mode 100644 index 0000000..166d72d --- /dev/null +++ b/ARCMacros.h @@ -0,0 +1,62 @@ +// +// ARCMacros.h +// +// Created by John Blanco on 1/28/2011. +// Rapture In Venice releases all rights to this code. Feel free use and/or copy it openly and freely! +// + +#define FP_DEBUG + +#if !defined(__clang__) || __clang_major__ < 3 + #ifndef __bridge + #define __bridge + #endif + + #ifndef __bridge_retain + #define __bridge_retain + #endif + + #ifndef __bridge_retained + #define __bridge_retained + #endif + + #ifndef __autoreleasing + #define __autoreleasing + #endif + + #ifndef __strong + #define __strong + #endif + + #ifndef __unsafe_unretained + #define __unsafe_unretained + #endif + + #ifndef __weak + #define __weak + #endif +#endif + +#if __has_feature(objc_arc) + #define SAFE_ARC_PROP_RETAIN strong + #define SAFE_ARC_RETAIN(x) (x) + #define SAFE_ARC_RELEASE(x) + #define SAFE_ARC_AUTORELEASE(x) (x) + #define SAFE_ARC_BLOCK_COPY(x) (x) + #define SAFE_ARC_BLOCK_RELEASE(x) + #define SAFE_ARC_SUPER_DEALLOC() + #define SAFE_ARC_AUTORELEASE_POOL_START() @autoreleasepool { + #define SAFE_ARC_AUTORELEASE_POOL_END() } +#else + #define SAFE_ARC_PROP_RETAIN retain + #define SAFE_ARC_RETAIN(x) ([(x) retain]) + #define SAFE_ARC_RELEASE(x) ([(x) release]) + #define SAFE_ARC_AUTORELEASE(x) ([(x) autorelease]) + #define SAFE_ARC_BLOCK_COPY(x) (Block_copy(x)) + #define SAFE_ARC_BLOCK_RELEASE(x) (Block_release(x)) + #define SAFE_ARC_SUPER_DEALLOC() ([super dealloc]) + #define SAFE_ARC_AUTORELEASE_POOL_START() NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + #define SAFE_ARC_AUTORELEASE_POOL_END() [pool release]; +#endif + + diff --git a/FPPopoverController.h b/FPPopoverController.h index e734147..ac39803 100644 --- a/FPPopoverController.h +++ b/FPPopoverController.h @@ -9,9 +9,12 @@ #import #import +#import "ARCMacros.h" + #import "FPPopoverView.h" #import "FPTouchView.h" + @class FPPopoverController; @protocol FPPopoverControllerDelegate @@ -22,19 +25,14 @@ @end @interface FPPopoverController : UIViewController -{ - FPTouchView *_touchView; - FPPopoverView *_contentView; - UIViewController *_viewController; - UIWindow *_window; - UIView *_parentView; - UIView *_fromView; - UIDeviceOrientation _deviceOrientation; - - BOOL _shadowsHidden; - CGColorRef _shadowColor; -} -@property(nonatomic,weak) id delegate; + +//ARC-enable and disable support +#if __has_feature(objc_arc) + @property(nonatomic,weak) id delegate; +#else + @property(nonatomic,assign) id delegate; +#endif + /** @brief FPPopoverArrowDirectionAny, FPPopoverArrowDirectionVertical or FPPopoverArrowDirectionHorizontal for automatic arrow direction. **/ diff --git a/FPPopoverController.m b/FPPopoverController.m index 7c25314..ba3df93 100644 --- a/FPPopoverController.m +++ b/FPPopoverController.m @@ -9,6 +9,24 @@ #import "FPPopoverController.h" +//ivars +@interface FPPopoverController() +{ + FPTouchView *_touchView; + FPPopoverView *_contentView; + UIViewController *_viewController; + UIWindow *_window; + UIView *_parentView; + UIView *_fromView; + UIDeviceOrientation _deviceOrientation; + + BOOL _shadowsHidden; + CGColorRef _shadowColor; +} +@end + + +//private methods @interface FPPopoverController(Private) -(CGPoint)originFromView:(UIView*)fromView; @@ -66,6 +84,17 @@ -(void)dealloc { [self removeObservers]; if(_shadowColor) CGColorRelease(_shadowColor); + +#ifdef FP_DEBUG + NSLog(@"FPPopoverController dealloc"); +#endif + + SAFE_ARC_RELEASE(_contentView); + SAFE_ARC_RELEASE(_touchView); + self.delegate = nil; + _viewController = nil; + + SAFE_ARC_SUPER_DEALLOC(); } -(id)initWithViewController:(UIViewController*)viewController { @@ -89,7 +118,8 @@ -(id)initWithViewController:(UIViewController*)viewController _touchView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _touchView.clipsToBounds = NO; [self.view addSubview:_touchView]; - + + __block typeof (self) bself = self; [_touchView setTouchedOutsideBlock:^{ [bself dismissPopoverAnimated:YES]; diff --git a/FPPopoverDemo.xcodeproj/project.pbxproj b/FPPopoverDemo.xcodeproj/project.pbxproj index 116d901..734d3a2 100644 --- a/FPPopoverDemo.xcodeproj/project.pbxproj +++ b/FPPopoverDemo.xcodeproj/project.pbxproj @@ -8,6 +8,12 @@ /* Begin PBXBuildFile section */ 1851C5EA16C972A000CCCDB3 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1851C5E916C972A000CCCDB3 /* Default-568h@2x.png */; }; + 1855E91416D9750700154B42 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 186C43731538512100502D64 /* UIKit.framework */; }; + 1855E91516D9750700154B42 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 186C43751538512100502D64 /* Foundation.framework */; }; + 1855E91616D9750700154B42 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 186C43771538512100502D64 /* CoreGraphics.framework */; }; + 1855E93616D9754400154B42 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1855E93016D9754300154B42 /* Default.png */; }; + 1855E93716D9754400154B42 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1855E93116D9754300154B42 /* Default@2x.png */; }; + 1855E93916D9754400154B42 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1855E93416D9754300154B42 /* main.m */; }; 186C43741538512100502D64 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 186C43731538512100502D64 /* UIKit.framework */; }; 186C43761538512100502D64 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 186C43751538512100502D64 /* Foundation.framework */; }; 186C43781538512100502D64 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 186C43771538512100502D64 /* CoreGraphics.framework */; }; @@ -29,6 +35,13 @@ 18D8FA4315505122005E2222 /* libfppopover.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 18D8FA30155050F0005E2222 /* libfppopover.a */; }; 18D8FA45155051BA005E2222 /* background_iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = 18D8FA44155051BA005E2222 /* background_iPad.png */; }; 18DF90A616C97B50006FFF28 /* alpha_popover.png in Resources */ = {isa = PBXBuildFile; fileRef = 18DF90A516C97B50006FFF28 /* alpha_popover.png */; }; + 18E1272316D9756F00FB6CD0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 18E1272216D9756F00FB6CD0 /* Default-568h@2x.png */; }; + 18E1272516D9765A00FB6CD0 /* GHUnitIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18E1272416D9765A00FB6CD0 /* GHUnitIOS.framework */; }; + 18E1272816D9771200FB6CD0 /* MemoryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18E1272716D9771200FB6CD0 /* MemoryTests.m */; }; + 18E1272916D977D000FB6CD0 /* FPPopoverController.m in Sources */ = {isa = PBXBuildFile; fileRef = 186C43951538513B00502D64 /* FPPopoverController.m */; }; + 18E1272A16D977D000FB6CD0 /* FPPopoverView.m in Sources */ = {isa = PBXBuildFile; fileRef = 186C43971538513B00502D64 /* FPPopoverView.m */; }; + 18E1272B16D977D000FB6CD0 /* FPTouchView.m in Sources */ = {isa = PBXBuildFile; fileRef = 186C43AB153CAD1000502D64 /* FPTouchView.m */; }; + 18E1272E16D9791800FB6CD0 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18E1272D16D9791800FB6CD0 /* QuartzCore.framework */; }; 18EF6DEB154ED27D005AB1DD /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = 18EF6DE9154ED27D005AB1DD /* background.png */; }; 18EF6DEC154ED27D005AB1DD /* background@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 18EF6DEA154ED27D005AB1DD /* background@2x.png */; }; 18F357271584E6E700AD4F07 /* FPDemoTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F357261584E6E700AD4F07 /* FPDemoTableViewController.m */; }; @@ -46,6 +59,12 @@ /* Begin PBXFileReference section */ 1851C5E916C972A000CCCDB3 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 1855E91316D9750700154B42 /* FPPopoverTests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FPPopoverTests.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1855E93016D9754300154B42 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + 1855E93116D9754300154B42 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + 1855E93216D9754300154B42 /* FPPopoverTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "FPPopoverTests-Info.plist"; sourceTree = ""; }; + 1855E93316D9754300154B42 /* FPPopoverTests-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FPPopoverTests-Prefix.pch"; sourceTree = ""; }; + 1855E93416D9754300154B42 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 186C436F1538512100502D64 /* FPPopoverDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FPPopoverDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 186C43731538512100502D64 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 186C43751538512100502D64 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -74,6 +93,11 @@ 18D8FA44155051BA005E2222 /* background_iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background_iPad.png; sourceTree = ""; }; 18D8FA4815505DFD005E2222 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 18DF90A516C97B50006FFF28 /* alpha_popover.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = alpha_popover.png; sourceTree = ""; }; + 18E1272216D9756F00FB6CD0 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 18E1272416D9765A00FB6CD0 /* GHUnitIOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GHUnitIOS.framework; path = FPPopoverTests/GHUnitIOS.framework; sourceTree = ""; }; + 18E1272716D9771200FB6CD0 /* MemoryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MemoryTests.m; sourceTree = ""; }; + 18E1272D16D9791800FB6CD0 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + 18E1272F16D97A6500FB6CD0 /* ARCMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ARCMacros.h; sourceTree = ""; }; 18EF6DE9154ED27D005AB1DD /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = ""; }; 18EF6DEA154ED27D005AB1DD /* background@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "background@2x.png"; sourceTree = ""; }; 18F357251584E6E700AD4F07 /* FPDemoTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FPDemoTableViewController.h; sourceTree = ""; }; @@ -81,6 +105,18 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 1855E91016D9750700154B42 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 18E1272E16D9791800FB6CD0 /* QuartzCore.framework in Frameworks */, + 1855E91416D9750700154B42 /* UIKit.framework in Frameworks */, + 1855E91516D9750700154B42 /* Foundation.framework in Frameworks */, + 1855E91616D9750700154B42 /* CoreGraphics.framework in Frameworks */, + 18E1272516D9765A00FB6CD0 /* GHUnitIOS.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 186C436C1538512100502D64 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -103,9 +139,32 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1855E91716D9750700154B42 /* FPPopoverTests */ = { + isa = PBXGroup; + children = ( + 18E1272C16D977DA00FB6CD0 /* Tests */, + 1855E91816D9750700154B42 /* Supporting Files */, + ); + path = FPPopoverTests; + sourceTree = ""; + }; + 1855E91816D9750700154B42 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 1855E93016D9754300154B42 /* Default.png */, + 1855E93116D9754300154B42 /* Default@2x.png */, + 18E1272216D9756F00FB6CD0 /* Default-568h@2x.png */, + 1855E93216D9754300154B42 /* FPPopoverTests-Info.plist */, + 1855E93316D9754300154B42 /* FPPopoverTests-Prefix.pch */, + 1855E93416D9754300154B42 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; 186C43641538512100502D64 = { isa = PBXGroup; children = ( + 18E1272D16D9791800FB6CD0 /* QuartzCore.framework */, 18DF90A316C9792F006FFF28 /* images */, 1851C5E916C972A000CCCDB3 /* Default-568h@2x.png */, 18D8FA4815505DFD005E2222 /* LICENSE */, @@ -113,6 +172,7 @@ 186C43931538512A00502D64 /* FPPopover */, 186C43791538512100502D64 /* FPPopoverDemo */, 18D8FA32155050F0005E2222 /* fppopover */, + 1855E91716D9750700154B42 /* FPPopoverTests */, 186C43721538512100502D64 /* Frameworks */, 186C43701538512100502D64 /* Products */, ); @@ -123,6 +183,7 @@ children = ( 186C436F1538512100502D64 /* FPPopoverDemo.app */, 18D8FA30155050F0005E2222 /* libfppopover.a */, + 1855E91316D9750700154B42 /* FPPopoverTests.app */, ); name = Products; sourceTree = ""; @@ -130,6 +191,7 @@ 186C43721538512100502D64 /* Frameworks */ = { isa = PBXGroup; children = ( + 18E1272416D9765A00FB6CD0 /* GHUnitIOS.framework */, 186C43731538512100502D64 /* UIKit.framework */, 186C43751538512100502D64 /* Foundation.framework */, 186C43771538512100502D64 /* CoreGraphics.framework */, @@ -170,6 +232,7 @@ 186C43931538512A00502D64 /* FPPopover */ = { isa = PBXGroup; children = ( + 18E1272F16D97A6500FB6CD0 /* ARCMacros.h */, 186C43941538513B00502D64 /* FPPopoverController.h */, 186C43951538513B00502D64 /* FPPopoverController.m */, 186C43961538513B00502D64 /* FPPopoverView.h */, @@ -204,6 +267,14 @@ name = images; sourceTree = ""; }; + 18E1272C16D977DA00FB6CD0 /* Tests */ = { + isa = PBXGroup; + children = ( + 18E1272716D9771200FB6CD0 /* MemoryTests.m */, + ); + name = Tests; + sourceTree = ""; + }; 18EF6DD9154ECC72005AB1DD /* Resources */ = { isa = PBXGroup; children = ( @@ -238,6 +309,23 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + 1855E91216D9750700154B42 /* FPPopoverTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1855E92916D9750700154B42 /* Build configuration list for PBXNativeTarget "FPPopoverTests" */; + buildPhases = ( + 1855E90F16D9750700154B42 /* Sources */, + 1855E91016D9750700154B42 /* Frameworks */, + 1855E91116D9750700154B42 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = FPPopoverTests; + productName = FPPopoverTests; + productReference = 1855E91316D9750700154B42 /* FPPopoverTests.app */; + productType = "com.apple.product-type.application"; + }; 186C436E1538512100502D64 /* FPPopoverDemo */ = { isa = PBXNativeTarget; buildConfigurationList = 186C43901538512200502D64 /* Build configuration list for PBXNativeTarget "FPPopoverDemo" */; @@ -297,11 +385,22 @@ targets = ( 186C436E1538512100502D64 /* FPPopoverDemo */, 18D8FA2F155050F0005E2222 /* fppopover */, + 1855E91216D9750700154B42 /* FPPopoverTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 1855E91116D9750700154B42 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1855E93616D9754400154B42 /* Default.png in Resources */, + 1855E93716D9754400154B42 /* Default@2x.png in Resources */, + 18E1272316D9756F00FB6CD0 /* Default-568h@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 186C436D1538512100502D64 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -321,6 +420,18 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 1855E90F16D9750700154B42 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1855E93916D9754400154B42 /* main.m in Sources */, + 18E1272816D9771200FB6CD0 /* MemoryTests.m in Sources */, + 18E1272916D977D000FB6CD0 /* FPPopoverController.m in Sources */, + 18E1272A16D977D000FB6CD0 /* FPPopoverView.m in Sources */, + 18E1272B16D977D000FB6CD0 /* FPTouchView.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 186C436B1538512100502D64 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -381,6 +492,63 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 1855E92A16D9750700154B42 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/FPPopoverTests\"", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "FPPopoverTests/FPPopoverTests-Prefix.pch"; + INFOPLIST_FILE = "FPPopoverTests/FPPopoverTests-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "-all_load", + "-ObjC", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 1855E92B16D9750700154B42 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/FPPopoverTests\"", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "FPPopoverTests/FPPopoverTests-Prefix.pch"; + INFOPLIST_FILE = "FPPopoverTests/FPPopoverTests-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + OTHER_LDFLAGS = ( + "-all_load", + "-ObjC", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; 186C438E1538512200502D64 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -429,7 +597,7 @@ 186C43911538512200502D64 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_ARC = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "FPPopoverDemo/FPPopoverDemo-Prefix.pch"; INFOPLIST_FILE = "FPPopoverDemo/FPPopoverDemo-Info.plist"; @@ -442,7 +610,7 @@ 186C43921538512200502D64 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_ARC = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "FPPopoverDemo/FPPopoverDemo-Prefix.pch"; INFOPLIST_FILE = "FPPopoverDemo/FPPopoverDemo-Info.plist"; @@ -455,7 +623,7 @@ 18D8FA39155050F0005E2222 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_ARC = NO; DSTROOT = /tmp/fppopover.dst; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "fppopover/fppopover-Prefix.pch"; @@ -469,7 +637,7 @@ 18D8FA3A155050F0005E2222 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_ARC = NO; DSTROOT = /tmp/fppopover.dst; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "fppopover/fppopover-Prefix.pch"; @@ -483,6 +651,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 1855E92916D9750700154B42 /* Build configuration list for PBXNativeTarget "FPPopoverTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1855E92A16D9750700154B42 /* Debug */, + 1855E92B16D9750700154B42 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 186C43691538512100502D64 /* Build configuration list for PBXProject "FPPopoverDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/FPPopoverDemo.xcodeproj/project.xcworkspace/xcuserdata/alvise.xcuserdatad/UserInterfaceState.xcuserstate b/FPPopoverDemo.xcodeproj/project.xcworkspace/xcuserdata/alvise.xcuserdatad/UserInterfaceState.xcuserstate index 48ff933..b651ba1 100644 Binary files a/FPPopoverDemo.xcodeproj/project.xcworkspace/xcuserdata/alvise.xcuserdatad/UserInterfaceState.xcuserstate and b/FPPopoverDemo.xcodeproj/project.xcworkspace/xcuserdata/alvise.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/FPPopoverDemo.xcodeproj/xcuserdata/alvise.xcuserdatad/xcschemes/xcschememanagement.plist b/FPPopoverDemo.xcodeproj/xcuserdata/alvise.xcuserdatad/xcschemes/xcschememanagement.plist index 6865a50..18536d9 100644 --- a/FPPopoverDemo.xcodeproj/xcuserdata/alvise.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/FPPopoverDemo.xcodeproj/xcuserdata/alvise.xcuserdatad/xcschemes/xcschememanagement.plist @@ -5,6 +5,11 @@ SchemeUserState FPPopoverDemo.xcscheme + + orderHint + 0 + + FPPopoverTests.xcscheme orderHint 2 @@ -12,7 +17,7 @@ fppopover.xcscheme orderHint - 4 + 1 SuppressBuildableAutocreation @@ -27,6 +32,16 @@ primary + 1855E8FC16D973D000154B42 + + primary + + + 1855E91216D9750700154B42 + + primary + + 186C436E1538512100502D64 primary diff --git a/FPPopoverDemo/FPViewController.h b/FPPopoverDemo/FPViewController.h index 7440a93..5adb8ef 100644 --- a/FPPopoverDemo/FPViewController.h +++ b/FPPopoverDemo/FPViewController.h @@ -8,13 +8,19 @@ #import #import "FPPopoverController.h" - +#import "ARCMacros.h" @interface FPViewController : UIViewController { FPPopoverController *popover; } -@property (weak, nonatomic) IBOutlet UIButton *noArrow; -@property (weak, nonatomic) IBOutlet UIButton *transparentPopover; +//ARC-enable and disable support +#if __has_feature(objc_arc) + @property (weak, nonatomic) IBOutlet UIButton *noArrow; + @property (weak, nonatomic) IBOutlet UIButton *transparentPopover; +#else + @property (assign, nonatomic) IBOutlet UIButton *noArrow; + @property (assign, nonatomic) IBOutlet UIButton *transparentPopover; +#endif -(IBAction)topLeft:(id)sender; -(IBAction)topCenter:(id)sender; diff --git a/FPPopoverDemo/FPViewController.m b/FPPopoverDemo/FPViewController.m index 4fca63a..dae6861 100644 --- a/FPPopoverDemo/FPViewController.m +++ b/FPPopoverDemo/FPViewController.m @@ -52,11 +52,15 @@ - (NSUInteger)supportedInterfaceOrientations -(IBAction)popover:(id)sender { + //NSLog(@"popover retain count: %d",[popover retainCount]); + + SAFE_ARC_RELEASE(popover); popover=nil; + //the controller we want to present as a popover DemoTableController *controller = [[DemoTableController alloc] initWithStyle:UITableViewStylePlain]; controller.delegate = self; popover = [[FPPopoverController alloc] initWithViewController:controller]; - + popover.tint = FPPopoverDefaultTint; diff --git a/FPPopoverTests/Default-568h@2x.png b/FPPopoverTests/Default-568h@2x.png new file mode 100644 index 0000000..0891b7a Binary files /dev/null and b/FPPopoverTests/Default-568h@2x.png differ diff --git a/FPPopoverTests/Default.png b/FPPopoverTests/Default.png new file mode 100644 index 0000000..4c8ca6f Binary files /dev/null and b/FPPopoverTests/Default.png differ diff --git a/FPPopoverTests/Default@2x.png b/FPPopoverTests/Default@2x.png new file mode 100644 index 0000000..35b84cf Binary files /dev/null and b/FPPopoverTests/Default@2x.png differ diff --git a/FPPopoverTests/FPPopoverTests-Info.plist b/FPPopoverTests/FPPopoverTests-Info.plist new file mode 100644 index 0000000..3c87758 --- /dev/null +++ b/FPPopoverTests/FPPopoverTests-Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.50pixels.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/FPPopoverTests/FPPopoverTests-Prefix.pch b/FPPopoverTests/FPPopoverTests-Prefix.pch new file mode 100644 index 0000000..4fea04b --- /dev/null +++ b/FPPopoverTests/FPPopoverTests-Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'FPPopoverTests' target in the 'FPPopoverTests' project +// + +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iOS SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/FPPopoverTests/GHUnitIOS.framework/GHUnitIOS b/FPPopoverTests/GHUnitIOS.framework/GHUnitIOS new file mode 120000 index 0000000..a82b1bb --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/GHUnitIOS @@ -0,0 +1 @@ +Versions/Current/GHUnitIOS \ No newline at end of file diff --git a/FPPopoverTests/GHUnitIOS.framework/Headers b/FPPopoverTests/GHUnitIOS.framework/Headers new file mode 120000 index 0000000..a177d2a --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Headers @@ -0,0 +1 @@ +Versions/Current/Headers \ No newline at end of file diff --git a/FPPopoverTests/GHUnitIOS.framework/Resources b/FPPopoverTests/GHUnitIOS.framework/Resources new file mode 120000 index 0000000..953ee36 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Resources @@ -0,0 +1 @@ +Versions/Current/Resources \ No newline at end of file diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/GHUnitIOS b/FPPopoverTests/GHUnitIOS.framework/Versions/A/GHUnitIOS new file mode 100644 index 0000000..c7ba008 Binary files /dev/null and b/FPPopoverTests/GHUnitIOS.framework/Versions/A/GHUnitIOS differ diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHAsyncTestCase.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHAsyncTestCase.h new file mode 100644 index 0000000..ff60ff0 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHAsyncTestCase.h @@ -0,0 +1,163 @@ +// +// GHAsyncTestCase.h +// GHUnit +// +// Created by Gabriel Handford on 4/8/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import "GHTestCase.h" + +/*! + Common wait statuses to use with waitForStatus:timeout:. + */ +enum { + kGHUnitWaitStatusUnknown = 0, // Unknown wait status + kGHUnitWaitStatusSuccess, // Wait status success + kGHUnitWaitStatusFailure, // Wait status failure + kGHUnitWaitStatusCancelled // Wait status cancelled +}; + +/*! + Asynchronous test case with wait and notify. + + If notify occurs before wait has started (if it was a synchronous call), this test + case will still work. + + Be sure to call prepare before the asynchronous method (otherwise an exception will raise). + + @interface MyAsyncTest : GHAsyncTestCase { } + @end + + @implementation MyAsyncTest + + - (void)testSuccess { + // Prepare for asynchronous call + [self prepare]; + + // Do asynchronous task here + [self performSelector:@selector(_succeed) withObject:nil afterDelay:0.1]; + + // Wait for notify + [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0]; + } + + - (void)_succeed { + // Notify the wait. Notice the forSelector points to the test above. + // This is so that stray notifies don't error or falsely succeed other tests. + // To ignore the check, forSelector can be NULL. + [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testSuccess)]; + } + + @end + + */ +@interface GHAsyncTestCase : GHTestCase { + + NSInteger waitForStatus_; + NSInteger notifiedStatus_; + + BOOL prepared_; // Whether prepared was called before waitForStatus:timeout: + NSRecursiveLock *lock_; // Lock to synchronize on + SEL waitSelector_; // The selector we are waiting on + + NSArray *_runLoopModes; +} + +/*! + Run loop modes to run while waiting; + Defaults to NSDefaultRunLoopMode, NSRunLoopCommonModes, NSConnectionReplyMode + */ +@property (strong, nonatomic) NSArray *runLoopModes; + +/*! + Prepare before calling the asynchronous method. + */ +- (void)prepare; + +/*! + Prepare and specify the selector we will use in notify. + + @param selector Selector + */ +- (void)prepare:(SEL)selector; + +/*! + Wait for notification of status or timeout. + + Be sure to prepare before calling your asynchronous method. + For example, + + - (void)testFoo { + [self prepare]; + + // Do asynchronous task here + + [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0]; + } + + @param status kGHUnitWaitStatusSuccess, kGHUnitWaitStatusFailure or custom status + @param timeout Timeout in seconds + */ +- (void)waitForStatus:(NSInteger)status timeout:(NSTimeInterval)timeout; + +/*! + @param status kGHUnitWaitStatusSuccess, kGHUnitWaitStatusFailure or custom status + @param timeout Timeout in seconds + @deprecated Use waitForTimeout: + */ +- (void)waitFor:(NSInteger)status timeout:(NSTimeInterval)timeout; + +/*! + Wait for timeout to occur. + Fails if we did _NOT_ timeout. + + @param timeout Timeout + */ +- (void)waitForTimeout:(NSTimeInterval)timeout; + +/*! + Notify waiting of status for test selector. + + @param status Status, for example, kGHUnitWaitStatusSuccess + @param selector If not NULL, then will verify this selector is where we are waiting. This prevents stray asynchronous callbacks to fail a later test. + */ +- (void)notify:(NSInteger)status forSelector:(SEL)selector; + +/*! + Notify waiting of status for any selector. + + @param status Status, for example, kGHUnitWaitStatusSuccess + */ +- (void)notify:(NSInteger)status; + +/*! + Run the run loops for the specified interval. + + @param interval Interval + @author Adapted from Robert Palmer, pauseForTimeout + */ +- (void)runForInterval:(NSTimeInterval)interval; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHImageDiffView.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHImageDiffView.h new file mode 100644 index 0000000..bdcc2b2 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHImageDiffView.h @@ -0,0 +1,49 @@ +// +// GHImageDiffView.h +// GHUnitIOS +// +// Created by John Boiles on 10/27/11. +// Copyright (c) 2011. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import + +@interface GHImageDiffView : UIView { + UIScrollView *scrollView_; + UISegmentedControl *segmentedControl_; + + UIImageView *savedImageView_; + UIImageView *renderedImageView_; + UIImageView *diffImageView_; +} + +- (void)setSavedImage:(UIImage *)savedImage renderedImage:(UIImage *)renderedImage diffImage:(UIImage *)diffImage; + +- (void)showSavedImage; + +- (void)showRenderedImage; + +- (void)showDiffImage; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHMockNSHTTPURLResponse.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHMockNSHTTPURLResponse.h new file mode 100644 index 0000000..837c615 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHMockNSHTTPURLResponse.h @@ -0,0 +1,46 @@ +// +// GHMockNSHTTPURLResponse.h +// GHUnit +// +// Created by Gabriel Handford on 4/9/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import + +/* + NSHTTPURLResponse subclass for use with mocking. + Allows us to manually set the status code and headers in the response. + */ +@interface GHMockNSHTTPURLResponse : NSHTTPURLResponse { + NSInteger statusCode_; + NSDictionary *headers_; +} + +- (id)initWithStatusCode:(NSInteger)statusCode headers:(NSDictionary *)headers; + +- (void)setStatusCode:(NSInteger)code; +- (void)setHeaders:(NSDictionary *)headers; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHMockNSURLConnection.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHMockNSURLConnection.h new file mode 100644 index 0000000..5f1e580 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHMockNSURLConnection.h @@ -0,0 +1,167 @@ +// +// GHMockNSURLConnection.h +// GHUnit +// +// Created by Gabriel Handford on 4/9/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import + +extern NSString *const GHMockNSURLConnectionException; + +/*! + NSURLConnection for mocking. + + Use with GHAsyncTestCase to mock out connections. + + @interface GHNSURLConnectionMockTest : GHAsyncTestCase {} + @end + + @implementation GHNSURLConnectionMockTest + + - (void)testMock { + [self prepare]; + GHMockNSURLConnection *connection = [[GHMockNSURLConnection alloc] initWithRequest:nil delegate:self]; + [connection receiveHTTPResponseWithStatusCode:204 headers:testHeaders_ afterDelay:0.1]; + [connection receiveData:testData_ afterDelay:0.2]; + [connection finishAfterDelay:0.3]; + [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0]; + } + + - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { + GHAssertEquals([(NSHTTPURLResponse *)response statusCode], 204, nil); + GHAssertEqualObjects([(NSHTTPURLResponse *)response allHeaderFields], testHeaders_, nil); + } + + - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { + GHAssertEqualObjects(data, testData_, nil); + } + + - (void)connectionDidFinishLoading:(NSURLConnection *)connection { + [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testMock)]; + } + @end + + */ +@interface GHMockNSURLConnection : NSObject { + NSURLRequest *request_; + id delegate_; // weak + + BOOL cancelled_; + BOOL started_; +} + +@property (readonly, nonatomic, getter=isStarted) BOOL started; +@property (readonly, nonatomic, getter=isCancelled) BOOL cancelled; + +// Mocked version of NSURLConnection#initWithRequest:delegate: +- (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate; + +// Mocked version of NSURLConnection#initWithRequest:delegate:startImmediately: +- (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate startImmediately:(BOOL)startImmediately; + +// Mocked version of NSURLConnection#scheduleInRunLoop:forMode: (NOOP) +- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; + +// Mocked version of NSURLConnection#start (NOOP) +- (void)start; + +/*! + Send generic response to delegate after delay. + (For asynchronous requests) + @param response Response + @param afterDelay Delay in seconds (if < 0, there is no delay) + */ +- (void)receiveResponse:(NSURLResponse *)response afterDelay:(NSTimeInterval)afterDelay; + +/*! + Send HTTP response to delegate with status code, headers, after delay. + This is only the HTTP response (and not data or finished). + (For asynchronous requests) + @param statusCode HTTP status code + @param headers Headers + @param afterDelay Delay in seconds (if < 0, there is no delay) + */ +- (void)receiveHTTPResponseWithStatusCode:(int)statusCode headers:(NSDictionary *)headers afterDelay:(NSTimeInterval)afterDelay; + +/*! + Send data to connection delegate after delay. + @param data Data to send + @param afterDelay Delay in seconds + */ +- (void)receiveData:(NSData *)data afterDelay:(NSTimeInterval)afterDelay; + +/*! + Send data to connection delegate. + @param data Data to send + @param statusCode HTTP status code + @param MIMEType Mime type + @param afterDelay Delay + */ +- (void)receiveData:(NSData *)data statusCode:(NSInteger)statusCode MIMEType:(NSString *)MIMEType afterDelay:(NSTimeInterval)afterDelay; + +/*! + Send data (from file in bundle resource) to connection delegate after delay. + (For asynchronous requests) + @param path Path to file + @param afterDelay Delay in seconds + */ +- (void)receiveDataFromPath:(NSString *)path afterDelay:(NSTimeInterval)afterDelay; + +/*! + Calls connectionDidFinish: delegate after delay. + (For asynchronous requests) + @param delay Delay in seconds (if < 0, there is no delay) + */ +- (void)finishAfterDelay:(NSTimeInterval)delay; + +/*! + Sends mock response, sends data, and then calls finish. + (For asynchronous requests) + @param path Path to load data from. File should be available in Test target (bundle) + @param statusCode Status code for response + @param MIMEType Content type for response header + @param afterDelay Delay before responding (if < 0, there is no delay) + */ +- (void)receiveFromPath:(NSString *)path statusCode:(NSInteger)statusCode MIMEType:(NSString *)MIMEType afterDelay:(NSTimeInterval)afterDelay; + +/*! + Sends mock response, sends data, and then calls finish. + (For asynchronous requests) + @param data Data to load. File should be available in Test target (bundle) + @param statusCode Status code for response + @param MIMEType Content type for response header + @param afterDelay Delay before responding (if < 0, there is no delay) + */ +- (void)receiveData:(NSData *)data statusCode:(NSInteger)statusCode MIMEType:(NSString *)MIMEType afterDelay:(NSTimeInterval)afterDelay; + +/*! + Calls connection:didFailWithError: on delegate after specified delay. + @param error The error to pass to the delegate. + @param afterDelay Delay before responding (if < 0, there is no delay) + */ +- (void)failWithError:(NSError *)error afterDelay:(NSTimeInterval)afterDelay; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTest+JUnitXML.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTest+JUnitXML.h new file mode 100644 index 0000000..135740c --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTest+JUnitXML.h @@ -0,0 +1,44 @@ +// +// GHTest+JUnitXML.h +// GHUnit +// +// Created by Gabriel Handford on 6/4/10. +// Copyright 2010. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +//! @cond DEV + +#import "GHTest.h" + +@interface GHTest(JUnitXML) + +/*! + Return test results in JUnit XML format for external parsing use + (such as a Continuous Integration system like Jenkins). + */ +- (NSString *)JUnitXML; + +@end + +//! @endcond diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTest.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTest.h new file mode 100644 index 0000000..42c9fd4 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTest.h @@ -0,0 +1,272 @@ +// +// GHTest.h +// GHUnit +// +// Created by Gabriel Handford on 1/18/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import + + +/*! + Test status. + */ +typedef enum { + GHTestStatusNone = 0, + GHTestStatusRunning, //! Test is running + GHTestStatusCancelling, //! Test is being cancelled + GHTestStatusCancelled, //! Test was cancelled + GHTestStatusSucceeded, //! Test finished and succeeded + GHTestStatusErrored, //! Test finished and errored +} GHTestStatus; + +enum { + GHTestOptionReraiseExceptions = 1 << 0, // Allows exceptions to be raised (so you can trigger the debugger) + GHTestOptionForceSetUpTearDownClass = 1 << 1, // Runs setUpClass/tearDownClass for this (each) test; Used when re-running a single test in a group +}; +typedef NSInteger GHTestOptions; + +/*! + Generate string from GHTestStatus + @param status + */ +extern NSString *NSStringFromGHTestStatus(GHTestStatus status); + +/*! + Check if test is running (or trying to cancel). + */ +extern BOOL GHTestStatusIsRunning(GHTestStatus status); + +/*! + Check if test has succeeded, errored or cancelled. + */ +extern BOOL GHTestStatusEnded(GHTestStatus status); + +/*! + Test stats. + */ +typedef struct { + NSInteger succeedCount; // Number of succeeded tests + NSInteger failureCount; // Number of failed tests + NSInteger cancelCount; // Number of aborted tests + NSInteger testCount; // Total number of tests +} GHTestStats; + +/*! + Create GHTestStats. + */ +extern GHTestStats GHTestStatsMake(NSInteger succeedCount, NSInteger failureCount, NSInteger cancelCount, NSInteger testCount); + +extern const GHTestStats GHTestStatsEmpty; + +/*! + Description from test stats. + */ +extern NSString *NSStringFromGHTestStats(GHTestStats stats); + +@protocol GHTestDelegate; + +/*! + The base interface for a runnable test. + + A runnable with a unique identifier, display name, stats, timer, delegate, log and error handling. + */ +@protocol GHTest + +/*! + Unique identifier for test. + */ +@property (readonly, nonatomic) NSString *identifier; + +/*! + Name (readable) for test. + */ +@property (readonly, nonatomic) NSString *name; + +/*! + How long the test took to run. Defaults to -1, if not run. + */ +@property (assign, nonatomic) NSTimeInterval interval; + +/*! + Test status. + */ +@property (assign, nonatomic) GHTestStatus status; + +/*! + Test stats. + */ +@property (readonly, nonatomic) GHTestStats stats; + +/*! + Exception that occurred. + */ +@property (retain, nonatomic) NSException *exception; + +/*! + Whether test is disabled. + */ +@property (assign, nonatomic, getter=isDisabled) BOOL disabled; + +/*! + Whether test is hidden. + */ +@property (assign, nonatomic, getter=isHidden) BOOL hidden; + +/*! + Delegate for test. + */ +@property (assign, nonatomic) id delegate; // weak + +/*! + Run the test. + @param options Options + */ +- (void)run:(GHTestOptions)options; + +/*! + @result Messages logged during this test run + */ +- (NSArray *)log; + +/*! + Reset the test. + */ +- (void)reset; + +/*! + Cancel the test. + */ +- (void)cancel; + +/*! + @result The number of disabled tests + */ +- (NSInteger)disabledCount; + +@end + +/*! + Test delegate for notification when a test starts and ends. + */ +@protocol GHTestDelegate + +/*! + Test started. + @param test Test + @param source If tests are nested, than source corresponds to the originator of the delegate call + */ +- (void)testDidStart:(id)test source:(id)source; + +/*! + Test updated. + @param test Test + @param source If tests are nested, than source corresponds to the originator of the delegate call + */ +- (void)testDidUpdate:(id)test source:(id)source; + +/*! + Test ended. + @param test Test + @param source If tests are nested, than source corresponds to the originator of the delegate call + */ +- (void)testDidEnd:(id)test source:(id)source; + +/*! + Test logged a message. + @param test Test + @param didLog Message + @param source If tests are nested, than source corresponds to the originator of the delegate call + */ +- (void)test:(id)test didLog:(NSString *)didLog source:(id)source; + +@end + +/*! + Delegate which is notified of log messages from inside a test case. + */ +@protocol GHTestCaseLogWriter + +/*! + Log message. + @param message Message + @param testCase Test case + */ +- (void)log:(NSString *)message testCase:(id)testCase; + +@end + +/*! + Default test implementation with a target/selector pair. + + - Tests a target and selector + - Notifies a test delegate + - Keeps track of status, running time and failures + - Stores any test specific logging + + */ +@interface GHTest : NSObject { + + id target_; + SEL selector_; + + NSString *identifier_; + NSString *name_; + GHTestStatus status_; + NSTimeInterval interval_; + BOOL disabled_; + BOOL hidden_; + NSException *exception_; // If failed + + NSMutableArray *log_; + +} + +@property (readonly, strong, nonatomic) id target; +@property (readonly, nonatomic) SEL selector; +@property (readonly, strong, nonatomic) NSArray *log; + +/*! + Create test with identifier, name. + @param identifier Unique identifier + @param name Name + */ +- (id)initWithIdentifier:(NSString *)identifier name:(NSString *)name; + +/*! + Create test with target/selector. + @param target Target (usually a test case) + @param selector Selector (usually a test method) + */ +- (id)initWithTarget:(id)target selector:(SEL)selector; + +/*! + Create autoreleased test with target/selector. + @param target Target (usually a test case) + @param selector Selector (usually a test method) + */ ++ (id)testWithTarget:(id)target selector:(SEL)selector; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestCase.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestCase.h new file mode 100644 index 0000000..9ebf280 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestCase.h @@ -0,0 +1,161 @@ +// +// GHTestCase.h +// GHUnit +// +// Created by Gabriel Handford on 1/21/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +// +// Portions of this file fall under the following license, marked with: +// GTM_BEGIN : GTM_END +// +// Copyright 2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#import "GHTestMacros.h" +#import "GHTest.h" + +/*! + Log to your test case logger. For example, + + GHTestLog(@"Some debug info, %@", obj); + + */ +#define GHTestLog(...) [self log:[NSString stringWithFormat:__VA_ARGS__, nil]] + +/*! + The base class for a test case. + + @interface MyTest : GHTestCase {} + @end + + @implementation MyTest + + // Run before each test method + - (void)setUp { } + + // Run after each test method + - (void)tearDown { } + + // Run before the tests are run for this class + - (void)setUpClass { } + + // Run before the tests are run for this class + - (void)tearDownClass { } + + // Tests are prefixed by 'test' and contain no arguments and no return value + - (void)testA { + GHTestLog(@"Log with a test with the GHTestLog(...) for test specific logging."); + } + + // Another test; Tests are run in lexical order + - (void)testB { } + + // Override any exceptions; By default exceptions are raised, causing a test failure + - (void)failWithException:(NSException *)exception { } + + @end + + */ +@interface GHTestCase : NSObject { + id __unsafe_unretained logWriter_; // weak + + SEL currentSelector_; +} + +//! The current test selector +@property (assign, nonatomic) SEL currentSelector; +@property (unsafe_unretained, nonatomic) id logWriter; + +// GTM_BEGIN +//! Run before each test method +- (void)setUp; + +//! Run after each test method +- (void)tearDown; + +/*! + By default exceptions are raised, causing a test failure + + @param exception Exception that was raised by test + */ +- (void)failWithException:(NSException*)exception; +// GTM_END + +/*! + Run before the tests (once per test case). + */ +- (void)setUpClass; + +/*! + Run after the tests (once per test case). + */ +- (void)tearDownClass; + +/*! + Whether to run the tests on a separate thread. Override this method in your + test case to override the default. + Default is NO, tests are run on a separate thread by default. + + @result If YES, the test will run on the main thread + */ +- (BOOL)shouldRunOnMainThread; + +/*! + Any special handling of exceptions after they are thrown; By default logs stack trace to standard out. + @param exception Exception + */ +- (void)handleException:(NSException *)exception; + +/*! + Log a message, which notifies the log delegate. + This is not meant to be used directly, see GHTestLog(...) macro. + + @param message Message to log + */ +- (void)log:(NSString *)message; + +/*! + Whether the test class should be run as a part of command line tests. + By default this is NO. Subclasses can override this method to disable + test classes that are problematic at the command line. + + @result YES if this test class is disabled for command line tests + */ +- (BOOL)isCLIDisabled; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestGroup+JUnitXML.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestGroup+JUnitXML.h new file mode 100644 index 0000000..ed4b4e7 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestGroup+JUnitXML.h @@ -0,0 +1,42 @@ +// +// GHTestGroup+JUnitXML.h +// GHUnit +// +// Created by Gabriel Handford on 6/4/10. +// Copyright 2010. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +//! @cond DEV + +#import "GHTestGroup.h" + +@interface GHTestGroup(JUnitXML) + +- (NSString *)JUnitXML; + +- (BOOL)writeJUnitXMLAtPath:(NSString *)documentsPath error:(NSError **)error; + +@end + +//! @endcond diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestGroup.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestGroup.h new file mode 100644 index 0000000..d185971 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestGroup.h @@ -0,0 +1,186 @@ +// +// GHTestGroup.h +// +// Created by Gabriel Handford on 1/16/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +//! @cond DEV + +#import "GHTest.h" +#import "GHTestCase.h" + +/*! + Interface for a group of tests. + + This group conforms to the GHTest protocol as well (see Composite pattern). + */ +@protocol GHTestGroup + +/*! + Name. + */ +- (NSString *)name; + +/*! + Parent for test group. + */ +- (id)parent; + +/*! + Children for test group. + */ +- (NSArray *)children; + +@end + +/*! + A collection of tests (or test groups). + + A test group is a collection of `id`, that may represent a set of test case methods. + + For example, if you had the following GHTestCase. + + @interface FooTest : GHTestCase {} + - (void)testFoo; + - (void)testBar; + @end + + The GHTestGroup would consist of and array of GHTest: FooTest#testFoo, FooTest#testBar, + each test being a target and selector pair. + + A test group may also consist of a group of groups (since GHTestGroup conforms to GHTest), + and this might represent a GHTestSuite. + */ +@interface GHTestGroup : NSObject { + + id __unsafe_unretained parent_; // weak + + NSMutableArray */*of id*/children_; + + NSString *name_; // The name of the test group (usually the class name of the test case + NSTimeInterval interval_; // Total time of child tests + GHTestStatus status_; // Current status of the group (current status of running or completed child tests) + GHTestStats stats_; // Current stats for the group (aggregate of child test stats) + + BOOL didSetUpClass_; + + GHTestOptions options_; + + // Set if test is created from initWithTestCase:delegate: + // Allows use to perform setUpClass and tearDownClass (once per test case run) + id testCase_; + + NSException *exception_; // If exception happens in group setUpClass/tearDownClass +} + +@property (readonly, strong, nonatomic) NSArray */*of id*/children; +@property (unsafe_unretained, nonatomic) id parent; +@property (readonly, strong, nonatomic) id testCase; +@property (assign, nonatomic) GHTestOptions options; + +/*! + Create an empty test group. + @param name The name of the test group + @param delegate Delegate, notifies of test start and end + @result New test group + */ +- (id)initWithName:(NSString *)name delegate:(id)delegate; + +/*! + Create test group from a test case. + @param testCase Test case, could be a subclass of SenTestCase or GHTestCase + @param delegate Delegate, notifies of test start and end + @result New test group + */ +- (id)initWithTestCase:(id)testCase delegate:(id)delegate; + +/*! + Create test group from a single test. + @param testCase Test case, could be a subclass of SenTestCase or GHTestCase + @param selector Test to run + @param delegate Delegate, notifies of test start and end + */ +- (id)initWithTestCase:(id)testCase selector:(SEL)selector delegate:(id)delegate; + +/*! + Create test group from a test case. + @param testCase Test case, could be a subclass of SenTestCase or GHTestCase + @param delegate Delegate, notifies of test start and end + @result New test group + */ ++ (GHTestGroup *)testGroupFromTestCase:(id)testCase delegate:(id)delegate; + +/*! + Add a test case (or test group) to this test group. + @param testCase Test case, could be a subclass of SenTestCase or GHTestCase + */ +- (void)addTestCase:(id)testCase; + +/*! + Add a test group to this test group. + @param testGroup Test group to add + */ +- (void)addTestGroup:(GHTestGroup *)testGroup; + +/*! + Add tests to this group. + @param tests Tests to add + */ +- (void)addTests:(NSArray */*of id*/)tests; + +/*! + Add test to this group. + @param test Test to add + */ +- (void)addTest:(id)test; + +/*! + Whether the test group should run on the main thread. + Call passes to test case instance if enabled. + */ +- (BOOL)shouldRunOnMainThread; + +/*! + @result YES if we have any enabled chilren, NO if all children have been disabled. + */ +- (BOOL)hasEnabledChildren; + +/*! + Get list of failed tests. + @result Failed tests + */ +- (NSArray */*of id*/)failedTests; + +/*! + Run in operation queue. + Tests from the group are added and will block until they have completed. + @param operationQueue If nil, then runs as is + @param options Options + */ +- (void)runInOperationQueue:(NSOperationQueue *)operationQueue options:(GHTestOptions)options; + +@end + +//! @endcond diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestMacros.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestMacros.h new file mode 100644 index 0000000..40485bb --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestMacros.h @@ -0,0 +1,1049 @@ +// +// GHTestMacros.h +// +// Created by Gabriel Handford on 1/17/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +// +// Portions of this file fall under the following license, marked with +// SENTE_BEGIN - SENTE_END +// +// Copyright (c) 1997-2005, Sen:te (Sente SA). All rights reserved. +// +// Use of this source code is governed by the following license: +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// (1) Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// (2) Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL Sente SA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Note: this license is equivalent to the FreeBSD license. +// +// This notice may not be removed from this file. + +// +// Portions of this file fall under the following license, marked with: +// GTM_BEGIN : GTM_END +// +// Copyright 2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#import + +#import "NSException+GHTestFailureExceptions.h" +#import "NSValue+GHValueFormatter.h" + +// GTM_BEGIN + +extern NSString *const GHTestFilenameKey; +extern NSString *const GHTestLineNumberKey; +extern NSString *const GHTestFailureException; + +#if defined(__cplusplus) +extern "C" +#endif + +NSString *GHComposeString(NSString *, ...); + + +/*! + Generates a failure when a1 != noErr + + @param a1 Should be either an OSErr or an OSStatus + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ...: A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertNoErr(a1, description, ...) \ +do { \ +@try {\ +OSStatus a1value = (a1); \ +if (a1value != noErr) { \ +NSString *_expression = [NSString stringWithFormat:@"Expected noErr, got %ld for (%s)", a1value, #a1]; \ +if (description) { \ +_expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ +} \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:_expression]]; \ +} \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) == noErr fails", #a1] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +/*! + Generates a failure when a1 != a2 + + @param a1 Rreceived value. Should be either an OSErr or an OSStatus + @param a2 Expected value. Should be either an OSErr or an OSStatus + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertErr(a1, a2, description, ...) \ +do { \ +@try {\ +OSStatus a1value = (a1); \ +OSStatus a2value = (a2); \ +if (a1value != a2value) { \ +NSString *_expression = [NSString stringWithFormat:@"Expected %s(%ld) but got %ld for (%s)", #a2, a2value, a1value, #a1]; \ +if (description) { \ +_expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ +} \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:_expression]]; \ +} \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) == (%s) fails", #a1, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + + +/*! + Generates a failure when a1 is NULL + + @param a1 Should be a pointer (use GHAssertNotNil for an object) + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertNotNULL(a1, description, ...) \ +do { \ +@try {\ +const void* a1value = (a1); \ +if (a1value == NULL) { \ +NSString *_expression = [NSString stringWithFormat:@"(%s) != NULL", #a1]; \ +if (description) { \ +_expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ +} \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:_expression]]; \ +} \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) != NULL fails", #a1] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +/*! + Generates a failure when a1 is not NULL + + @param a1 should be a pointer (use GHAssertNil for an object) + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertNULL(a1, description, ...) \ +do { \ +@try {\ +const void* a1value = (a1); \ +if (a1value != NULL) { \ +NSString *_expression = [NSString stringWithFormat:@"(%s) == NULL", #a1]; \ +if (description) { \ +_expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ +} \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:_expression]]; \ +} \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) == NULL fails", #a1] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +/*! + Generates a failure when a1 is equal to a2. This test is for C scalars, structs and unions. + + @param a1 Argument 1 + @param a2 Argument 2 + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertNotEquals(a1, a2, description, ...) \ +do { \ +@try {\ +if (strcmp(@encode(__typeof__(a1)), @encode(__typeof__(a2))) != 0) { \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ +} else { \ +__typeof__(a1) a1value = (a1); \ +__typeof__(a2) a2value = (a2); \ +NSValue *a1encoded = [NSValue value:&a1value withObjCType:@encode(__typeof__(a1))]; \ +NSValue *a2encoded = [NSValue value:&a2value withObjCType:@encode(__typeof__(a2))]; \ +if ([a1encoded isEqualToValue:a2encoded]) { \ +NSString *_expression = [NSString stringWithFormat:@"(%s) != (%s)", #a1, #a2]; \ +if (description) { \ +_expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ +} \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:_expression]]; \ +} \ +} \ +} \ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) != (%s)", #a1, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +/*! + Generates a failure when a1 is equal to a2. This test is for objects. + + @param a1 Argument 1. object. + @param a2 Argument 2. object. + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertNotEqualObjects(a1, a2, desc, ...) \ +do { \ +@try {\ +id a1value = (a1); \ +id a2value = (a2); \ +if ( (strcmp(@encode(__typeof__(a1value)), @encode(id)) == 0) && \ +(strcmp(@encode(__typeof__(a2value)), @encode(id)) == 0) && \ +![(id)a1value isEqual:(id)a2value] ) continue; \ +NSString *_expression = [NSString stringWithFormat:@"%s('%@') != %s('%@')", #a1, [a1 description], #a2, [a2 description]]; \ +if (desc) { \ +_expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(desc, ##__VA_ARGS__)]; \ +} \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:_expression]]; \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(desc, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +/*! + Generates a failure when a1 is not 'op' to a2. This test is for C scalars. + + @param a1 Argument 1 + @param a2 Argument 2 + @param op Operation + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertOperation(a1, a2, op, description, ...) \ +do { \ +@try {\ +if (strcmp(@encode(__typeof__(a1)), @encode(__typeof__(a2))) != 0) { \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ +} else { \ +__typeof__(a1) a1value = (a1); \ +__typeof__(a2) a2value = (a2); \ +if (!(a1value op a2value)) { \ +double a1DoubleValue = a1value; \ +double a2DoubleValue = a2value; \ +NSString *_expression = [NSString stringWithFormat:@"%s (%lg) %s %s (%lg)", #a1, a1DoubleValue, #op, #a2, a2DoubleValue]; \ +if (description) { \ +_expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ +} \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:_expression]]; \ +} \ +} \ +} \ +@catch (id anException) {\ +[self failWithException:[NSException \ +ghu_failureInRaise:[NSString stringWithFormat:@"(%s) %s (%s)", #a1, #op, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +/*! + Generates a failure when a1 is not > a2. This test is for C scalars. + + @param a1 argument 1 + @param a2 argument 2 + @param op operation + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertGreaterThan(a1, a2, description, ...) \ +GHAssertOperation(a1, a2, >, description, ##__VA_ARGS__) + +/*! + Generates a failure when a1 is not >= a2. This test is for C scalars. + + @param a1 argument 1 + @param a2 argument 2 + @param op operation + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertGreaterThanOrEqual(a1, a2, description, ...) \ +GHAssertOperation(a1, a2, >=, description, ##__VA_ARGS__) + +/*! + Generates a failure when a1 is not < a2. This test is for C scalars. + + @param a1 argument 1 + @param a2 argument 2 + @param op operation + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertLessThan(a1, a2, description, ...) \ +GHAssertOperation(a1, a2, <, description, ##__VA_ARGS__) + +/*! Generates a failure when a1 is not <= a2. This test is for C scalars. + + @param a1 argument 1 + @param a2 argument 2 + @param op operation + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertLessThanOrEqual(a1, a2, description, ...) \ +GHAssertOperation(a1, a2, <=, description, ##__VA_ARGS__) + +/*! + Generates a failure when string a1 is not equal to string a2. This call + differs from GHAssertEqualObjects in that strings that are different in + composition (precomposed vs decomposed) will compare equal if their final + representation is equal. + ex O + umlaut decomposed is the same as O + umlaut composed. + + @param a1 string 1 + @param a2 string 2 + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertEqualStrings(a1, a2, description, ...) \ +do { \ +@try {\ +id a1value = (a1); \ +id a2value = (a2); \ +if (a1value == a2value) continue; \ +if ([a1value isKindOfClass:[NSString class]] && \ +[a2value isKindOfClass:[NSString class]] && \ +[a1value compare:a2value options:0] == NSOrderedSame) continue; \ +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \ +andObject: a2value \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +/*! + Generates a failure when string a1 is equal to string a2. This call + differs from GHAssertEqualObjects in that strings that are different in + composition (precomposed vs decomposed) will compare equal if their final + representation is equal. + ex O + umlaut decomposed is the same as O + umlaut composed. + + @param a1 string 1 + @param a2 string 2 + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertNotEqualStrings(a1, a2, description, ...) \ +do { \ +@try {\ +id a1value = (a1); \ +id a2value = (a2); \ +if (([a1value isKindOfClass:[NSString class]] && \ +[a2value isKindOfClass:[NSString class]] && \ +[a1value compare:a2value options:0] != NSOrderedSame) || \ +(a1value == nil && [a2value isKindOfClass:[NSString class]]) || \ +(a2value == nil && [a1value isKindOfClass:[NSString class]]) \ +) continue; \ +[self failWithException:[NSException ghu_failureInInequalityBetweenObject: a1value \ +andObject: a2value \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +/*! + Generates a failure when c-string a1 is not equal to c-string a2. + + @param a1 string 1 + @param a2 string 2 + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertEqualCStrings(a1, a2, description, ...) \ +do { \ +@try {\ +const char* a1value = (a1); \ +const char* a2value = (a2); \ +if (a1value == a2value) continue; \ +if (strcmp(a1value, a2value) == 0) continue; \ +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: [NSString stringWithUTF8String:a1value] \ +andObject: [NSString stringWithUTF8String:a2value] \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +/*! + Generates a failure when c-string a1 is equal to c-string a2. + + @param a1 string 1 + @param a2 string 2 + @param description A format string as in the printf() function. Can be nil or an empty string but must be present. + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertNotEqualCStrings(a1, a2, description, ...) \ +do { \ +@try {\ +const char* a1value = (a1); \ +const char* a2value = (a2); \ +if (strcmp(a1value, a2value) != 0) continue; \ +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: [NSString stringWithUTF8String:a1value] \ +andObject: [NSString stringWithUTF8String:a2value] \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +// GTM_END + +// SENTE_BEGIN +/*! Generates a failure when !{ [a1 isEqualTo:a2] } is false + (or one is nil and the other is not). + + @param a1 The object on the left + @param a2 The object on the right + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertEqualObjects(a1, a2, description, ...) \ +do { \ +@try {\ +id a1value = (a1); \ +id a2value = (a2); \ +if (a1value == a2value) continue; \ +if ( (strcmp(@encode(__typeof__(a1value)), @encode(id)) == 0) && \ +(strcmp(@encode(__typeof__(a2value)), @encode(id)) == 0) && \ +[(id)a1value isEqual: (id)a2value] ) continue; \ +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \ +andObject: a2value \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + + +/*! Generates a failure when a1 is not equal to a2. This test is for + C scalars, structs and unions. + + @param a1 The argument on the left + @param a2 The argument on the right + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertEquals(a1, a2, description, ...) \ +do { \ +@try {\ +if ( strcmp(@encode(__typeof__(a1)), @encode(__typeof__(a2))) != 0 ) { \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ +} else { \ +__typeof__(a1) a1value = (a1); \ +__typeof__(a2) a2value = (a2); \ +NSValue *a1encoded = [NSValue value:&a1value withObjCType: @encode(__typeof__(a1))]; \ +NSValue *a2encoded = [NSValue value:&a2value withObjCType: @encode(__typeof__(a2))]; \ +if (![a1encoded isEqualToValue:a2encoded]) { \ +[self failWithException:[NSException ghu_failureInEqualityBetweenValue: a1encoded \ +andValue: a2encoded \ +withAccuracy: nil \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +} \ +} \ +} \ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + +//! Absolute difference +#define GHAbsoluteDifference(left,right) (MAX(left,right)-MIN(left,right)) + + +/*! + Generates a failure when a1 is not equal to a2 within + or - accuracy is false. + This test is for scalars such as floats and doubles where small differences + could make these items not exactly equal, but also works for all scalars. + + @param a1 The scalar on the left + @param a2 The scalar on the right + @param accuracy The maximum difference between a1 and a2 for these values to be considered equal + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertEqualsWithAccuracy(a1, a2, accuracy, description, ...) \ +do { \ +@try {\ +if (strcmp(@encode(__typeof__(a1)), @encode(__typeof__(a2))) != 0) { \ +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ +} else { \ +__typeof__(a1) a1value = (a1); \ +__typeof__(a2) a2value = (a2); \ +__typeof__(accuracy) accuracyvalue = (accuracy); \ +if (GHAbsoluteDifference(a1value, a2value) > accuracyvalue) { \ +NSValue *a1encoded = [NSValue value:&a1value withObjCType:@encode(__typeof__(a1))]; \ +NSValue *a2encoded = [NSValue value:&a2value withObjCType:@encode(__typeof__(a2))]; \ +NSValue *accuracyencoded = [NSValue value:&accuracyvalue withObjCType:@encode(__typeof__(accuracy))]; \ +[self failWithException:[NSException ghu_failureInEqualityBetweenValue: a1encoded \ +andValue: a2encoded \ +withAccuracy: accuracyencoded \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +} \ +} \ +} \ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + + + +/*! + Generates a failure unconditionally. + + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHFail(description, ...) \ +[self failWithException:[NSException ghu_failureInFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]] + + + +/*! + Generates a failure when a1 is not nil. + + @param a1 An object + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertNil(a1, description, ...) \ +do { \ +@try {\ +id a1value = (a1); \ +if (a1value != nil) { \ +NSString *_a1 = [NSString stringWithUTF8String: #a1]; \ +NSString *_expression = [NSString stringWithFormat:@"((%@) == nil)", _a1]; \ +[self failWithException:[NSException ghu_failureInCondition: _expression \ +isTrue: NO \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +} \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == nil fails", #a1] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + + +/*! + Generates a failure when a1 is nil. + + @param a1 An object + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertNotNil(a1, description, ...) \ +do { \ +@try {\ +id a1value = (a1); \ +if (a1value == nil) { \ +NSString *_a1 = [NSString stringWithUTF8String: #a1]; \ +NSString *_expression = [NSString stringWithFormat:@"((%@) != nil)", _a1]; \ +[self failWithException:[NSException ghu_failureInCondition: _expression \ +isTrue: NO \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +} \ +}\ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != nil fails", #a1] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while(0) + + +/*! + Generates a failure when expression evaluates to false. + + @param expr The expression that is tested + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertTrue(expr, description, ...) \ +do { \ +BOOL _evaluatedExpression = (expr);\ +if (!_evaluatedExpression) {\ +NSString *_expression = [NSString stringWithUTF8String: #expr];\ +[self failWithException:[NSException ghu_failureInCondition: _expression \ +isTrue: YES \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +} \ +} while (0) + + +/*! + Generates a failure when expression evaluates to false and in addition will + generate error messages if an exception is encountered. + + @param expr The expression that is tested + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertTrueNoThrow(expr, description, ...) \ +do { \ +@try {\ +BOOL _evaluatedExpression = (expr);\ +if (!_evaluatedExpression) {\ +NSString *_expression = [NSString stringWithUTF8String: #expr];\ +[self failWithException:[NSException ghu_failureInCondition: _expression \ +isTrue: NO \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +} \ +} \ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) ", #expr] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while (0) + + +/*! + Generates a failure when the expression evaluates to true. + + @param expr The expression that is tested + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertFalse(expr, description, ...) \ +do { \ +BOOL _evaluatedExpression = (expr);\ +if (_evaluatedExpression) {\ +NSString *_expression = [NSString stringWithUTF8String: #expr];\ +[self failWithException:[NSException ghu_failureInCondition: _expression \ +isTrue: NO \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +} \ +} while (0) + + +/*! + Generates a failure when the expression evaluates to true and in addition + will generate error messages if an exception is encountered. + + @param expr The expression that is tested + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertFalseNoThrow(expr, description, ...) \ +do { \ +@try {\ +BOOL _evaluatedExpression = (expr);\ +if (_evaluatedExpression) {\ +NSString *_expression = [NSString stringWithUTF8String: #expr];\ +[self failWithException:[NSException ghu_failureInCondition: _expression \ +isTrue: YES \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +} \ +} \ +@catch (id anException) {\ +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"!(%s) ", #expr] \ +exception:anException \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while (0) + + +/*! + Generates a failure when expression does not throw an exception. + + @param expression The expression that is evaluated + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent. + */ +#define GHAssertThrows(expr, description, ...) \ +do { \ +@try { \ +(expr);\ +} \ +@catch (id anException) { \ +continue; \ +}\ +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \ +exception: nil \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +} while (0) + + +/*! + Generates a failure when expression does not throw an exception of a + specific class. + + @param expression The expression that is evaluated + @param specificException The specified class of the exception + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertThrowsSpecific(expr, specificException, description, ...) \ +do { \ +@try { \ +(expr);\ +} \ +@catch (specificException *anException) { \ +continue; \ +}\ +@catch (id anException) {\ +NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \ +exception: anException \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \ +continue; \ +}\ +NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \ +exception: nil \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \ +} while (0) + + +/*! Generates a failure when expression does not throw an exception of a + specific class with a specific name. Useful for those frameworks like + AppKit or Foundation that throw generic NSException w/specific names + (NSInvalidArgumentException, etc). + + @param expression The expression that is evaluated + @param specificException The specified class of the exception + @param aName The name of the specified exception + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertThrowsSpecificNamed(expr, specificException, aName, description, ...) \ +do { \ +@try { \ +(expr);\ +} \ +@catch (specificException *anException) { \ +if ([aName isEqualToString: [anException name]]) continue; \ +NSString *_descrip = GHComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description);\ +[self failWithException: \ +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \ +exception: anException \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \ +continue; \ +}\ +@catch (id anException) {\ +NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ +[self failWithException: \ +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \ +exception: anException \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \ +continue; \ +}\ +NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ +[self failWithException: \ +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \ +exception: nil \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \ +} while (0) + + +/*! + Generates a failure when expression does throw an exception. + + @param expression The expression that is evaluated + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertNoThrow(expr, description, ...) \ +do { \ +@try { \ +(expr);\ +} \ +@catch (id anException) { \ +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \ +exception: anException \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +} while (0) + + +/*! + Generates a failure when expression does throw an exception of the specitied + class. Any other exception is okay (i.e. does not generate a failure). + + @param expression The expression that is evaluated + @param specificException The specified class of the exception + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertNoThrowSpecific(expr, specificException, description, ...) \ +do { \ +@try { \ +(expr);\ +} \ +@catch (specificException *anException) { \ +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \ +exception: anException \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ +}\ +@catch (id anythingElse) {\ +; \ +}\ +} while (0) + + +/*! + Generates a failure when expression does throw an exception of a + specific class with a specific name. Useful for those frameworks like + AppKit or Foundation that throw generic NSException w/specific names + (NSInvalidArgumentException, etc). + + @param expression The expression that is evaluated. + @param specificException The specified class of the exception + @param aName The name of the specified exception + @param description A format string as in the printf() function. Can be nil or an empty string but must be present + @param ... A variable number of arguments to the format string. Can be absent + */ +#define GHAssertNoThrowSpecificNamed(expr, specificException, aName, description, ...) \ +do { \ +@try { \ +(expr);\ +} \ +@catch (specificException *anException) { \ +if ([aName isEqualToString: [anException name]]) { \ +NSString *_descrip = GHComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description);\ +[self failWithException: \ +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \ +exception: anException \ +inFile: [NSString stringWithUTF8String:__FILE__] \ +atLine: __LINE__ \ +withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \ +} \ +continue; \ +}\ +@catch (id anythingElse) {\ +; \ +}\ +} while (0) + + +@interface NSException(GHTestMacros_GTMSenTestAdditions) ++ (NSException *)ghu_failureInFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInCondition:(NSString *)condition + isTrue:(BOOL)isTrue + inFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInEqualityBetweenObject:(id)left + andObject:(id)right + inFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInInequalityBetweenObject:(id)left + andObject:(id)right + inFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left + andValue:(NSValue *)right + withAccuracy:(NSValue *)accuracy + inFile:(NSString *)filename + atLine:(int) ineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInRaise:(NSString *)expression + inFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInRaise:(NSString *)expression + exception:(NSException *)exception + inFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureWithName:(NSString *)name + inFile:(NSString *)filename + atLine:(int)lineNumber + reason:(NSString *)reason; +@end + +// SENTE_END diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestOperation.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestOperation.h new file mode 100644 index 0000000..3000ed7 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestOperation.h @@ -0,0 +1,47 @@ +// +// GHTestOperation.h +// GHUnit +// +// Created by Gabriel Handford on 6/4/10. +// Copyright 2010. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import "GHTest.h" + +/*! + Test for running in the context of an NSOperationQueue. + */ +@interface GHTestOperation : NSOperation { + id test_; + GHTestOptions options_; +} + +/*! + Create operation that wraps a GHTest instance. + @param test Test + @param options Options + */ +- (id)initWithTest:(id)test options:(GHTestOptions)options; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestRunner.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestRunner.h new file mode 100644 index 0000000..10d00aa --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestRunner.h @@ -0,0 +1,221 @@ +// +// GHTestRunner.h +// +// Created by Gabriel Handford on 1/16/09. +// Copyright 2008 Gabriel Handford +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +//! @cond DEV + +// +// Portions of this file fall under the following license, marked with: +// GTM_BEGIN : GTM_END +// +// Copyright 2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#import "GHTestGroup.h" +#import "GHTestSuite.h" + +@class GHTestRunner; + +/*! + Notifies about the test run. + Delegates can be guaranteed to be notified on the main thread. + */ +@protocol GHTestRunnerDelegate +@optional + +/*! + Test run started. + @param runner Runner + */ +- (void)testRunnerDidStart:(GHTestRunner *)runner; + +/*! + Test run did start test. + @param runner Runner + @param test Test + */ +- (void)testRunner:(GHTestRunner *)runner didStartTest:(id)test; + +/*! + Test run did update test. + @param runner Runner + @param test Test + */ +- (void)testRunner:(GHTestRunner *)runner didUpdateTest:(id)test; + +/*! + Test run did end test. + @param runner Runner + @param test Test + */ +- (void)testRunner:(GHTestRunner *)runner didEndTest:(id)test; + +/*! + Test run did cancel. + @param runner Runner + */ +- (void)testRunnerDidCancel:(GHTestRunner *)runner; + +/*! + Test run did end. + @param runner Runner + */ +- (void)testRunnerDidEnd:(GHTestRunner *)runner; + +/*! + Test run did log message. + @param runner Runner + @param didLog Message + */ +- (void)testRunner:(GHTestRunner *)runner didLog:(NSString *)didLog; + +/*! + Test run test did log message. + @param runner Runner + @param test Test + @param didLog Message + */ +- (void)testRunner:(GHTestRunner *)runner test:(id)test didLog:(NSString *)didLog; + +@end + +/*! + Runs the tests. + Tests are run a separate thread though delegates are called on the main thread by default. + + For example, + + GHTestRunner *runner = [[GHTestRunner alloc] initWithTest:suite]; + runner.delegate = self; + [runner runTests]; + + */ +@interface GHTestRunner : NSObject { + + id test_; // The test to run; Could be a GHTestGroup (suite), GHTestGroup (test case), or GHTest (target/selector) + + NSObject *__unsafe_unretained delegate_; // weak + + GHTestOptions options_; + + BOOL running_; + BOOL cancelling_; + + NSTimeInterval startInterval_; + + NSOperationQueue *operationQueue_; //! If running a suite in operation queue +} + +@property (strong) id test; +@property (unsafe_unretained) NSObject *delegate; +@property (assign) GHTestOptions options; +@property (readonly) GHTestStats stats; +@property (readonly, getter=isRunning) BOOL running; +@property (readonly, getter=isCancelling) BOOL cancelling; +@property (readonly) NSTimeInterval interval; +@property (strong, nonatomic) NSOperationQueue *operationQueue; +@property (assign, nonatomic, getter=isInParallel) BOOL inParallel; + +/*! + Create runner for test. + @param test Test + */ +- (id)initWithTest:(id)test; + +/*! + Create runner for all tests. + @see [GHTesting loadAllTestCases]. + @result Runner + */ ++ (GHTestRunner *)runnerForAllTests; + +/*! + Create runner for test suite. + @param suite Suite + @result Runner + */ ++ (GHTestRunner *)runnerForSuite:(GHTestSuite *)suite; + +/*! + Create runner for class and method. + @param testClassName Test class name + @param methodName Test method + @result Runner + */ ++ (GHTestRunner *)runnerForTestClassName:(NSString *)testClassName methodName:(NSString *)methodName; + +/*! + Get the runner from the environment. + If the TEST env is set, then we will only run that test case or test method. + */ ++ (GHTestRunner *)runnerFromEnv; + +/*! + Run the test runner. Usually called from the test main. + Reads the TEST environment variable and filters on that; or all tests are run. + @result 0 is success, otherwise the failure count + */ ++ (int)run; + +/*! + Run in the background. + */ +- (void)runInBackground; + +/*! + Start the test runner. + @result 0 is success, otherwise the failure count + */ +- (int)runTests; + +/*! + Cancel test run. + */ +- (void)cancel; + +/*! + Write message to console. + @param message Message to log + */ +- (void)log:(NSString *)message; + +@end + +//! @endcond + diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestSuite.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestSuite.h new file mode 100644 index 0000000..d35cc11 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestSuite.h @@ -0,0 +1,118 @@ +// +// GHTestSuite.h +// GHUnit +// +// Created by Gabriel Handford on 1/25/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +//! @cond DEV + +#import "GHTestGroup.h" + +/*! + If set, will run it as a "test filter" like the env variable TEST. + */ +extern NSString *GHUnitTest; + + +/*! + Test suite is an alias for test group. + + A test case is an instance of a test case class with test methods. + A test is a id which represents a target and a selector. + A test group is a collection of tests; A collection of id (GHTest or GHTestGroup). + + For example, if you have 2 test cases, GHTestCase1 (with some test methods) and GHTestCase2 (with some test methods), + your test suite might look like: + +"Tests" (GHTestSuite) + GHTestGroup (collection of tests from GHTestCase1) + - (void)testA1 (GHTest with target GHTestCase1 + testA1) + - (void)testA2 (GHTest with target GHTestCase1 + testA2) + GHTestGroup (collection of tests from GHTestCase2) + - (void)testB1; (GHTest with target GHTestCase2 + testB1) + - (void)testB2; (GHTest with target GHTestCase2 + testB2) + + */ +@interface GHTestSuite : GHTestGroup { } + +/*! + Create test suite with test cases. + @param name Label to give the suite + @param testCases Array of init'ed test case classes + @param delegate Delegate + */ +- (id)initWithName:(NSString *)name testCases:(NSArray *)testCases delegate:(id)delegate; + +/*! + Creates a suite of all tests. + Will load all classes that subclass from GHTestCase, SenTestCase or GTMTestCase (or register test case class). + @result Suite + */ ++ (GHTestSuite *)allTests; + +/*! + Create suite of tests with filter. + This is useful for running a single test or all tests in a single test case. + + For example, + 'GHSlowTest' -- Runs all test method in GHSlowTest + 'GHSlowTest/testSlowA -- Only runs the test method testSlowA in GHSlowTest + + @param testFilter Test filter + @result Suite + */ ++ (GHTestSuite *)suiteWithTestFilter:(NSString *)testFilter; + +/*! + Create suite of tests that start with prefix. + @param prefix If test case class starts with the prefix; If nil or empty string, returns all tests + @param options Compare options + */ ++ (GHTestSuite *)suiteWithPrefix:(NSString *)prefix options:(NSStringCompareOptions)options; + +/*! + Suite for a single test/method. + @param testCaseClass Test case class + @param method Method + @result Suite + */ ++ (GHTestSuite *)suiteWithTestCaseClass:(Class)testCaseClass method:(SEL)method; + +/*! + Return test suite based on environment (TEST=TestFoo/foo) + @result Suite + */ ++ (GHTestSuite *)suiteFromEnv; + +@end + +@interface GHTestSuite (JUnitXML) + +- (BOOL)writeJUnitXMLToDirectory:(NSString *)directory error:(NSError **)error; + +@end + +//! @endcond diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestUtils.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestUtils.h new file mode 100644 index 0000000..9d55c5e --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestUtils.h @@ -0,0 +1,51 @@ +// +// GHTestUtils.h +// GHUnitIOS +// +// Created by John Boiles on 10/22/12. +// Copyright 2012. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import + +#define GHRunWhile(__CONDITION__) GHRunUntilTimeoutWhileBlock(10.0, ^BOOL{ return (__CONDITION__); }) + +/*! + Run the main run loop for a period of time. This is useful to give views time to + render any asynchronously rendered views. However when possible, GHRunUntilTimeoutWhileBlock + should be used instead since it will provide more determinate output. + + @param interval Interval for the main loop to run + */ +void GHRunForInterval(CFTimeInterval interval); + +/*! + Keep running the main runloop until whileBlock returns NO or timeout is reached. + This is useful for waiting until certain parts of views render. This method should be + used instead of putting GHRunForInterval in a while loop. + + @param timeout Maximum time to run the main loop before giving up + @param whileBlock Block that returns YES if the main runloop should keep running + */ +void GHRunUntilTimeoutWhileBlock(CFTimeInterval timeout, BOOL(^whileBlock)()); diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestViewModel.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestViewModel.h new file mode 100644 index 0000000..97469a0 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestViewModel.h @@ -0,0 +1,218 @@ +// +// GHTest.h +// GHUnit +// +// Created by Gabriel Handford on 1/17/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +//! @cond DEV + +#import "GHTestGroup.h" +#import "GHTestSuite.h" +#import "GHTestRunner.h" + +@class GHTestNode; + +@protocol GHTestNodeDelegate +- (void)testNodeDidChange:(GHTestNode *)node; +@end + +typedef enum { + GHTestNodeFilterNone = 0, + GHTestNodeFilterFailed = 1 +} GHTestNodeFilter; + +/*! + Test view model for use in a tree view. + */ +@interface GHTestViewModel : NSObject { + + NSString *identifier_; + GHTestSuite *suite_; + GHTestNode *root_; + + GHTestRunner *runner_; + + NSMutableDictionary *map_; // id#identifier -> GHTestNode + + BOOL editing_; + + NSMutableDictionary *defaults_; +} + +@property (readonly, nonatomic) GHTestNode *root; +@property (assign, nonatomic, getter=isEditing) BOOL editing; + +/*! + Create view model with root test group node. + + @param identifier Unique identifier for test model (used to load defaults) + @param suite Suite + */ +- (id)initWithIdentifier:(NSString *)identifier suite:(GHTestSuite *)suite; + +/*! + @result Name of test suite. + */ +- (NSString *)name; + +/*! + Status description. + + @param prefix Prefix to append + @result Current status string + */ +- (NSString *)statusString:(NSString *)prefix; + +/*! + Find the test node from the test. + + @param test Find test + */ +- (GHTestNode *)findTestNodeForTest:(id)test; + +/*! + Find the first failure. + + @result The first failure + */ +- (GHTestNode *)findFailure; + +/*! + Find the next failure starting from node. + + @param node Node to start from + */ +- (GHTestNode *)findFailureFromNode:(GHTestNode *)node; + +/*! + Register node, so that we can do a lookup later. See findTestNodeForTest:. + + @param node Node to register + */ +- (void)registerNode:(GHTestNode *)node; + +/*! + @result Returns the number of test groups. + */ +- (NSInteger)numberOfGroups; + +/*! + Returns the number of tests in group. + @param group Group number + @result The number of tests in group. + */ +- (NSInteger)numberOfTestsInGroup:(NSInteger)group; + +/*! + Search for path to test. + @param test Test + @result Index path + */ +- (NSIndexPath *)indexPathToTest:(id)test; + +/*! + Load defaults (user settings saved with saveDefaults). + */ +- (void)loadDefaults; + +/*! + Save defaults (user settings to be loaded with loadDefaults). + */ +- (void)saveDefaults; + +/*! + Run with current test suite. + + @param delegate Callback + @param inParallel If YES, will run tests in operation queue + @param options Options + */ +- (void)run:(id)delegate inParallel:(BOOL)inParallel options:(GHTestOptions)options; + +/*! + Cancel test run. + */ +- (void)cancel; + +/*! + Check if running. + + @result YES if running. + */ +- (BOOL)isRunning; + +@end + + +@interface GHTestNode : NSObject { + + id test_; + NSMutableArray */*of GHTestNode*/children_; + NSMutableArray */* of GHTestNode*/filteredChildren_; + + id __unsafe_unretained delegate_; + GHTestNodeFilter filter_; + NSString *textFilter_; +} + +@property (readonly, strong, nonatomic) NSArray */* of GHTestNode*/children; +@property (readonly, strong, nonatomic) id test; +@property (unsafe_unretained, nonatomic) id delegate; +@property (assign, nonatomic) GHTestNodeFilter filter; +@property (strong, nonatomic) NSString *textFilter; + +- (id)initWithTest:(id)test children:(NSArray */*of id*/)children source:(GHTestViewModel *)source; ++ (GHTestNode *)nodeWithTest:(id)test children:(NSArray */*of id*/)children source:(GHTestViewModel *)source; + +- (NSString *)identifier; +- (NSString *)name; +- (NSString *)nameWithStatus; + +- (GHTestStatus)status; +- (NSString *)statusString; +- (NSString *)stackTrace; +- (NSString *)exceptionFilename; +- (NSInteger)exceptionLineNumber; +- (NSString *)log; +- (BOOL)isRunning; +- (BOOL)isDisabled; +- (BOOL)isHidden; +- (BOOL)isEnded; +- (BOOL)isGroupTest; // YES if test has "sub tests" + +- (BOOL)isSelected; +- (void)setSelected:(BOOL)selected; + +- (BOOL)hasChildren; +- (BOOL)failed; + +- (void)notifyChanged; + +- (void)setFilter:(GHTestNodeFilter)filter textFilter:(NSString *)textFilter; + +@end + +//! @endcond diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTesting.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTesting.h new file mode 100644 index 0000000..5926761 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTesting.h @@ -0,0 +1,153 @@ +// +// GHTesting.h +// GHUnit +// +// Created by Gabriel Handford on 1/30/09. +// Copyright 2008 Gabriel Handford +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +//! @cond DEV + +// +// Portions of this file fall under the following license, marked with: +// GTM_BEGIN : GTM_END +// +// Copyright 2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#import +#import "GHUnit.h" + + +// GTM_BEGIN +BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); +// GTM_END + +/*! + Utility test for loading and running tests. + + Much of this is borrowed from GTM/UnitTesting. + */ +@interface GHTesting : NSObject { + + NSMutableArray/* of NSString*/ *testCaseClassNames_; + +} + +/*! + The shared testing instance. + */ ++ (GHTesting *)sharedInstance; + +/*! + Load all test classes that we can "see". + @result Array of initialized (and autoreleased) test case classes in an autoreleased array. + */ +- (NSArray *)loadAllTestCases; + +/*! + Load tests from target. + @param target Target + @result Array of id + */ +- (NSArray *)loadTestsFromTarget:(id)target; + +/*! + See if class is of a registered test case class. + @param aClass Class + */ +- (BOOL)isTestCaseClass:(Class)aClass; + +/*! + Register test case class. + @param aClass Class + */ +- (void)registerClass:(Class)aClass; + +/*! + Register test case class by name. + @param className Class name (via NSStringFromClass(aClass) + */ +- (void)registerClassName:(NSString *)className; + +/*! + Format test exception. + @param exception Exception + @result Description + */ ++ (NSString *)descriptionForException:(NSException *)exception; + +/*! + Filename for cause of test exception. + @param test Test + @result Filename + */ ++ (NSString *)exceptionFilenameForTest:(id)test; + +/*! + Line number for cause of test exception. + @param test Test + @result Line number + */ ++ (NSInteger)exceptionLineNumberForTest:(id)test; + +/*! + Run test. + @param target Target + @param selector Selector + @param exception Exception, if set, is retained and should be released by the caller. + @param interval Time to run the test + @param reraiseExceptions If YES, will re-raise exceptions + */ ++ (BOOL)runTestWithTarget:(id)target selector:(SEL)selector exception:(NSException **)exception + interval:(NSTimeInterval *)interval reraiseExceptions:(BOOL)reraiseExceptions; + +/*! + Same as normal runTest without catching exceptions. + @param target Target + @param selector Selector + @param exception Exception, if set, is retained and should be released by the caller. + @param interval Time to run the test + */ ++ (BOOL)runTestOrRaiseWithTarget:(id)target selector:(SEL)selector exception:(NSException **)exception interval:(NSTimeInterval *)interval; + +@end + +@protocol GHSenTestCase +- (void)raiseAfterFailure; +@end + +//! @endcond diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUIImageViewControl.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUIImageViewControl.h new file mode 100644 index 0000000..ef6b1ec --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUIImageViewControl.h @@ -0,0 +1,41 @@ +// +// GHUIImageViewControl.h +// GHUnitIOS +// +// Created by Gabriel Handford on 4/1/11. +// Copyright 2011. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import + +@interface GHUIImageViewControl : UIControl { + UIImageView *_imageView; +} + +@property (readonly, nonatomic) UIImageView *imageView; +@property (nonatomic) UIImage *image; + +- (id)initWithFrame:(CGRect)frame image:(UIImage *)image highlightedImage:(UIImage *)highlightedImage; + +@end \ No newline at end of file diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnit.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnit.h new file mode 100644 index 0000000..7585c39 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnit.h @@ -0,0 +1,57 @@ +// +// GHUnit.h +// GHUnit +// +// Created by Gabriel Handford on 1/19/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import "GHTestCase.h" +#import "GHAsyncTestCase.h" +#import "GHTestSuite.h" +#import "GHTestMacros.h" +#import "GHTestRunner.h" + +#import "GHTest.h" +#import "GHTesting.h" +#import "GHTestOperation.h" +#import "GHTestGroup.h" +#import "GHTest+JUnitXML.h" +#import "GHTestGroup+JUnitXML.h" +#import "GHTestUtils.h" +#import "NSException+GHTestFailureExceptions.h" +#import "NSValue+GHValueFormatter.h" + +#if TARGET_OS_IPHONE +#import "GHUnitIOSAppDelegate.h" +#import "GHViewTestCase.h" +#endif + +#ifdef DEBUG +#define GHUDebug(fmt, ...) do { \ +fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@"\n"] UTF8String], stdout); \ +} while(0) +#else +#define GHUDebug(fmt, ...) do {} while(0) +#endif diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSAppDelegate.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSAppDelegate.h new file mode 100644 index 0000000..da0c692 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSAppDelegate.h @@ -0,0 +1,42 @@ +// +// GHUnitIOSAppDelegate.h +// GHUnitIOS +// +// Created by Gabriel Handford on 1/25/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import + +/*! + Application delegate for the iOS test application. + */ +@interface GHUnitIOSAppDelegate : NSObject { + UIWindow *window_; + + UINavigationController *navigationController_; +} + +@end + diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTableViewDataSource.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTableViewDataSource.h new file mode 100644 index 0000000..9f75d5d --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTableViewDataSource.h @@ -0,0 +1,44 @@ +// +// GHUnitIOSTableViewDataSource.h +// GHUnitIOS +// +// Created by Gabriel Handford on 5/5/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import +#import "GHTestViewModel.h" + +/* + Table view data source for iOS test application. + */ +@interface GHUnitIOSTableViewDataSource : GHTestViewModel { + +} + +- (GHTestNode *)nodeForIndexPath:(NSIndexPath *)indexPath; + +- (void)setSelectedForAllNodes:(BOOL)selected; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTestView.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTestView.h new file mode 100644 index 0000000..e2dbac7 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTestView.h @@ -0,0 +1,59 @@ +// +// GHUnitIOSTestView.h +// GHUnitIOS +// +// Created by John Boiles on 8/8/11. +// Copyright 2011. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import +#import "GHUIImageViewControl.h" + +@class GHUnitIOSTestView; + +@protocol GHUnitIOSTestViewDelegate +- (void)testViewDidSelectSavedImage:(GHUnitIOSTestView *)testView; +- (void)testViewDidSelectRenderedImage:(GHUnitIOSTestView *)testView; +- (void)testViewDidApproveChange:(GHUnitIOSTestView *)testView; +@end + +@interface GHUnitIOSTestView : UIScrollView { + id __unsafe_unretained controlDelegate_; + + // TODO(johnb): Perhaps hold a scrollview here as subclassing UIViews can be weird. + + GHUIImageViewControl *savedImageView_; + GHUIImageViewControl *renderedImageView_; + + UIButton *approveButton_; + + UILabel *textLabel_; +} +@property(unsafe_unretained, nonatomic) id controlDelegate; + +- (void)setSavedImage:(UIImage *)savedImage renderedImage:(UIImage *)renderedImage text:(NSString *)text; + +- (void)setText:(NSString *)text; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTestViewController.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTestViewController.h new file mode 100644 index 0000000..597f4d9 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTestViewController.h @@ -0,0 +1,49 @@ +// +// GHUnitIOSTestViewController.h +// GHUnitIOS +// +// Created by Gabriel Handford on 2/20/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import +#import "GHTestViewModel.h" +#import "GHUnitIOSTestView.h" +#import "GHImageDiffView.h" + +/* + View controller for a test. + */ +@interface GHUnitIOSTestViewController : UIViewController { + GHUnitIOSTestView *testView_; + GHImageDiffView *imageDiffView_; + + GHTestNode *testNode_; + + GHTestRunner *runner_; +} + +- (void)setTest:(id)test; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSView.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSView.h new file mode 100644 index 0000000..7d4d06a --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSView.h @@ -0,0 +1,57 @@ +// +// GHUnitIOSView.h +// GHUnitIOS +// +// Created by Gabriel Handford on 4/12/10. +// Copyright 2010. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import +#import + +/* + Main view for iOS test application. + */ +@interface GHUnitIOSView : UIView { + UISearchBar *searchBar_; + + UITableView *tableView_; + + //! Status label at bottom of the view + UILabel *statusLabel_; + + UISegmentedControl *filterControl_; + + UIToolbar *runToolbar_; + + UIView *footerView_; +} + +@property (readonly, nonatomic) UILabel *statusLabel; +@property (readonly, nonatomic) UISegmentedControl *filterControl; +@property (readonly, nonatomic) UISearchBar *searchBar; +@property (readonly, nonatomic) UITableView *tableView; + + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSViewController.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSViewController.h new file mode 100644 index 0000000..bbf7a1d --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSViewController.h @@ -0,0 +1,73 @@ +// +// GHUnitIOSViewController.h +// GHUnitIOS +// +// Created by Gabriel Handford on 1/25/09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import "GHUnitIOSView.h" + +#import "GHUnitIOSTableViewDataSource.h" +#import "GHUnitIOSTestViewController.h" + +/* + Main view controller for the iOS test application. + */ +@interface GHUnitIOSViewController : UIViewController { + + GHUnitIOSView *view_; + + GHUnitIOSTableViewDataSource *dataSource_; + GHTestSuite *suite_; + + UIBarButtonItem *runButton_; + + // If set then we will no longer auto scroll as tests are run + BOOL userDidDrag_; + +} + +@property (strong, nonatomic) GHTestSuite *suite; + +- (void)reloadTest:(id)test; + +- (void)scrollToTest:(id)test; +- (void)scrollToBottom; + +- (void)setStatusText:(NSString *)message; + +- (void)runTests; + +- (void)cancel; + +- (void)reload; + +- (void)loadDefaults; +- (void)saveDefaults; + +- (GHUnitIOSTableViewDataSource *)dataSource; + +@end + diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIPhoneAppDelegate.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIPhoneAppDelegate.h new file mode 100644 index 0000000..0e7ec81 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHUnitIPhoneAppDelegate.h @@ -0,0 +1,36 @@ +// +// GHUnitIPhoneAppDelegate.h +// GHUnitIOS +// +// Created by Gabriel Handford on 6/28/11. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import "GHUnitIOSAppDelegate.h" + +// For backwards compatibility (see GHUnitIOSAppDelegate) +@interface GHUnitIPhoneAppDelegate : GHUnitIOSAppDelegate { + +} + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHViewTestCase.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHViewTestCase.h new file mode 100644 index 0000000..83f0d60 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHViewTestCase.h @@ -0,0 +1,136 @@ +// +// GHViewTestCase.h +// GHUnitIOS +// +// Created by John Boiles on 10/20/11. +// Copyright (c) 2011. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +#import "GHTestCase.h" +#import + +/*! + Assert that a view has not changed. Raises exception if the view has changed or if + no image exists from previous test runs. + + @param view The view to verify + */ +#define GHVerifyView(view) \ +do { \ +if (![self isKindOfClass:[GHViewTestCase class]]) \ +[[NSException ghu_failureWithName:@"GHInvalidTestException" \ +inFile:[NSString stringWithUTF8String:__FILE__] \ +atLine:__LINE__ \ +reason:@"GHVerifyView can only be called from within a GHViewTestCase class"] raise]; \ +[self verifyView:view filename:[NSString stringWithUTF8String:__FILE__] lineNumber:__LINE__]; \ +} while (0) + +/*! + View verification test case. + + Supports GHVerifyView, which renders a view and compares it against a saved + image from a previous test run. + + @interface MyViewTest : GHViewTestCase { } + @end + + @implementation MyViewTest + + - (void)testMyView { + MyView *myView = [[MyView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; + GHVerifyView(myView); + } + + @end + + In order to record results across test runs, the PrepareUITests.sh script needs + to be run as a build step. This script copies any test images (saved locally in + $PROJECT_DIR/TestImages) to the app bundle so that calls to GHVerifyView have + images from previous runs with which to compare. + + After changes to views are approved in the simulator, the CopyTestImages.sh script + should be run manually in Terminal. This script copies any approved view changes + back to the project directory. Images are saved with filenames of the following format: + + [test class name]-[test selector name]-[UIScreen scale]-[# of call to GHVerifyView in selector]-[view class name].png + + Note that because of differences in text rendering between retina and non-retina + devices/simulators, different images are saved for test runs using retina then + non-retina. + + Also note that there are commonly rendering differences across iOS versions. + Therefore it is common for tests to fail when they are run using a different iOS + version then the one that created the saved test image. This also applies to tests + that are run at the command line (the xcodebuild flag '-sdk iphonesimulator' + usually corresponds to the latest iOS simulator available). + */ +@interface GHViewTestCase : GHTestCase { + NSInteger imageVerifyCount_; +} + +/*! + Clear all test images in the documents directory. + */ ++ (void)clearTestImages; + +/*! + Creates a UIImage from the passed in view. This can be useful for testing + views that require images. + + @param view UIView to render + @result UIImage of the rendered UIView + */ ++ (UIImage *)imageWithView:(UIView *)view; + +/*! + Save an approved view test image to the view test images directory. + + @param image Image to save + @param filename Filename for the saved image + */ ++ (void)saveApprovedViewTestImage:(UIImage *)image filename:(NSString *)filename; + +/*! + Size for a given view. Subclasses can override this to provide custom sizes + for views before rendering. The default implementation returns contentSize + for scrollviews and returns self.frame.size for all other views. + + @param view View for which to calculate the size + @result Size at which the view should be rendered + */ +- (CGSize)sizeForView:(UIView *)view; + +/*! + Called from the GHVerifyView macro. This method should not be called manually. + Verifies that a view hasn't changed since the last time it was approved. Raises + a GHViewChangeException if the view has changed. Raises a GHViewUnavailableException + if there is no image from a previous run. + + @param view View to verify + @param filename Filename of the call to GHVerifyView + @param lineNumber Line number of the call to GHVerifyView + */ +- (void)verifyView:(UIView *)view filename:(NSString *)filename lineNumber:(int)lineNumber; + +@end diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/NSException+GHTestFailureExceptions.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/NSException+GHTestFailureExceptions.h new file mode 100644 index 0000000..214bcc5 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/NSException+GHTestFailureExceptions.h @@ -0,0 +1,97 @@ +// +// NSException+GHTestFailureExceptions.h +// +// Created by Johannes Rudolph on 23.09.09. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +//! @cond DEV + +// +// Portions of this file fall under the following license, marked with: +// GTM_BEGIN : GTM_END +// +// Copyright 2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +extern NSString *const GHTestFilenameKey; +extern NSString *const GHTestLineNumberKey; +extern NSString *const GHTestFailureException; + + +// GTM_BEGIN + +#import + +@interface NSException(GHUTestFailureExceptions) ++ (NSException *)ghu_failureInFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInCondition:(NSString *)condition + isTrue:(BOOL)isTrue + inFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInEqualityBetweenObject:(id)left + andObject:(id)right + inFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInInequalityBetweenObject:(id)left + andObject:(id)right + inFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left + andValue:(NSValue *)right + withAccuracy:(NSValue *)accuracy + inFile:(NSString *)filename + atLine:(int) ineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInRaise:(NSString *)expression + inFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; ++ (NSException *)ghu_failureInRaise:(NSString *)expression + exception:(NSException *)exception + inFile:(NSString *)filename + atLine:(int)lineNumber + withDescription:(NSString *)formatString, ...; +@end + +// GTM_END + +//! @endcond diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/NSValue+GHValueFormatter.h b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/NSValue+GHValueFormatter.h new file mode 100644 index 0000000..268571a --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/NSValue+GHValueFormatter.h @@ -0,0 +1,71 @@ +// +// NSValue+GHValueFormatter.h +// +// Created by Johannes Rudolph on 23.9.2009. +// Copyright 2009. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +//! @cond DEV + +// +// Portions of this file fall under the following license, marked with +// SENTE_BEGIN - SENTE_END +// +// Copyright (c) 1997-2005, Sen:te (Sente SA). All rights reserved. +// +// Use of this source code is governed by the following license: +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// (1) Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// (2) Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL Sente SA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Note: this license is equivalent to the FreeBSD license. +// +// This notice may not be removed from this file. + +#import + +// SENTE_BEGIN +@interface NSValue(GHValueFormatter) +- (NSString *)ghu_contentDescription; +@end +// SENTE_END + +//! @endcond diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/A/Resources/Info.plist b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Resources/Info.plist new file mode 100644 index 0000000..0ba43d4 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/A/Resources/Info.plist @@ -0,0 +1,18 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + me.rel.ghunit + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + $(GHUNIT_VERSION) + + diff --git a/FPPopoverTests/GHUnitIOS.framework/Versions/Current b/FPPopoverTests/GHUnitIOS.framework/Versions/Current new file mode 120000 index 0000000..8c7e5a6 --- /dev/null +++ b/FPPopoverTests/GHUnitIOS.framework/Versions/Current @@ -0,0 +1 @@ +A \ No newline at end of file diff --git a/FPPopoverTests/MemoryTests.m b/FPPopoverTests/MemoryTests.m new file mode 100644 index 0000000..733a242 --- /dev/null +++ b/FPPopoverTests/MemoryTests.m @@ -0,0 +1,27 @@ +// +// MemoryTests.m +// FPPopoverDemo +// +// Created by Alvise Susmel on 23/02/2013. +// Copyright (c) 2013 Fifty Pixels Ltd. All rights reserved. +// + +/** Tests on memory allocation, deallocation **/ + +#import +#import "FPPopoverController.h" + +@interface MemoryTests : GHTestCase + +@end + + +@implementation MemoryTests + + +-(void)testAllocDeallocOfFPPopoverController +{ + +} + +@end diff --git a/FPPopoverTests/en.lproj/InfoPlist.strings b/FPPopoverTests/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/FPPopoverTests/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/FPPopoverTests/main.m b/FPPopoverTests/main.m new file mode 100644 index 0000000..90208d5 --- /dev/null +++ b/FPPopoverTests/main.m @@ -0,0 +1,18 @@ +// +// main.m +// FPPopoverTests +// +// Created by Alvise Susmel on 23/02/2013. +// Copyright (c) 2013 Fifty Pixels Ltd. All rights reserved. +// + +#import + +#import "FPAppDelegate.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, @"GHUnitIOSAppDelegate"); + } +} diff --git a/FPPopoverView.h b/FPPopoverView.h index 8a6c24c..cf6736c 100644 --- a/FPPopoverView.h +++ b/FPPopoverView.h @@ -42,12 +42,7 @@ typedef enum { } FPPopoverTint; @interface FPPopoverView : UIView -{ - //default FPPopoverArrowDirectionUp - FPPopoverArrowDirection _arrowDirection; - UIView *_contentView; - UILabel *_titleLabel; -} + @property(nonatomic,strong) NSString *title; @property(nonatomic,assign) CGPoint relativeOrigin; @property(nonatomic,assign) FPPopoverTint tint; diff --git a/FPPopoverView.m b/FPPopoverView.m index 38c541c..5ffc6ea 100644 --- a/FPPopoverView.m +++ b/FPPopoverView.m @@ -8,11 +8,22 @@ #import "FPPopoverView.h" +#import "ARCMacros.h" #define FP_POPOVER_ARROW_HEIGHT 20.0 #define FP_POPOVER_ARROW_BASE 20.0 #define FP_POPOVER_RADIUS 10.0 +//iVars +@interface FPPopoverView() +{ + //default FPPopoverArrowDirectionUp + FPPopoverArrowDirection _arrowDirection; + UIView *_contentView; + UILabel *_titleLabel; +} +@end + @interface FPPopoverView(Private) -(void)setupViews; @@ -25,6 +36,17 @@ @implementation FPPopoverView @synthesize tint = _tint; @synthesize draw3dBorder = _draw3dBorder; +-(void)dealloc +{ +#ifdef FP_DEBUG + NSLog(@"FPPopoverView dealloc"); +#endif + + SAFE_ARC_RELEASE(_titleLabel); + SAFE_ARC_SUPER_DEALLOC(); +} + + - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; diff --git a/FPTouchView.m b/FPTouchView.m index dd30cb5..a5f34b9 100644 --- a/FPTouchView.m +++ b/FPTouchView.m @@ -7,18 +7,38 @@ // https://github.com/50pixels/FPPopover #import "FPTouchView.h" +#import "ARCMacros.h" @implementation FPTouchView +-(void)dealloc +{ +#ifdef FP_DEBUG + NSLog(@"FPTouchView dealloc"); +#endif + + SAFE_ARC_RELEASE(_insideBlock); + SAFE_ARC_RELEASE(_outsideBlock); + SAFE_ARC_SUPER_DEALLOC(); +} -(void)setTouchedOutsideBlock:(FPTouchedOutsideBlock)outsideBlock { +#if __has_feature(objc_arc) _outsideBlock = outsideBlock; +#else + _outsideBlock = [outsideBlock copy]; +#endif } -(void)setTouchedInsideBlock:(FPTouchedInsideBlock)insideBlock { +#if __has_feature(objc_arc) _insideBlock = insideBlock; +#else + _insideBlock = [insideBlock copy]; +#endif + } -(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event