diff --git a/Support/HockeySDK.xcodeproj/project.pbxproj b/Support/HockeySDK.xcodeproj/project.pbxproj index 8d25f61236..c57c451b5b 100644 --- a/Support/HockeySDK.xcodeproj/project.pbxproj +++ b/Support/HockeySDK.xcodeproj/project.pbxproj @@ -33,6 +33,8 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 1B460AB11B8E64AF0000C344 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B460AB01B8E64AF0000C344 /* libOCMock.a */; }; + 1B460AB21B8E64AF0000C344 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B460AB01B8E64AF0000C344 /* libOCMock.a */; }; 1B87EFB51B8D0C540007C96B /* BITTelemetryManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B87EFB31B8D0C540007C96B /* BITTelemetryManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1B87EFB61B8D0C540007C96B /* BITTelemetryManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B87EFB41B8D0C540007C96B /* BITTelemetryManager.m */; }; 1B87EFB81B8D1F930007C96B /* BITTelemetryManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B87EFB31B8D0C540007C96B /* BITTelemetryManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -385,6 +387,16 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 1B460AA71B8E64A60000C344 /* NSNotificationCenter+OCMAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNotificationCenter+OCMAdditions.h"; sourceTree = ""; }; + 1B460AA81B8E64A60000C344 /* OCMArg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMArg.h; sourceTree = ""; }; + 1B460AA91B8E64A60000C344 /* OCMConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMConstraint.h; sourceTree = ""; }; + 1B460AAA1B8E64A60000C344 /* OCMLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMLocation.h; sourceTree = ""; }; + 1B460AAB1B8E64A60000C344 /* OCMMacroState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMMacroState.h; sourceTree = ""; }; + 1B460AAC1B8E64A60000C344 /* OCMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMock.h; sourceTree = ""; }; + 1B460AAD1B8E64A60000C344 /* OCMockObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMockObject.h; sourceTree = ""; }; + 1B460AAE1B8E64A60000C344 /* OCMRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMRecorder.h; sourceTree = ""; }; + 1B460AAF1B8E64A60000C344 /* OCMStubRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMStubRecorder.h; sourceTree = ""; }; + 1B460AB01B8E64AF0000C344 /* libOCMock.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libOCMock.a; sourceTree = ""; }; 1B87EFB31B8D0C540007C96B /* BITTelemetryManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITTelemetryManager.h; sourceTree = ""; }; 1B87EFB41B8D0C540007C96B /* BITTelemetryManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BITTelemetryManager.m; sourceTree = ""; }; 1B87EFB71B8D0F800007C96B /* BITTelemetryManagerPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BITTelemetryManagerPrivate.h; sourceTree = ""; }; @@ -617,6 +629,7 @@ 1EA1170016F4D32C001C015C /* libHockeySDK.a in Frameworks */, 1EA1170116F4D354001C015C /* CrashReporter.framework in Frameworks */, 1E5A459516F0DFC200B55C04 /* Foundation.framework in Frameworks */, + 1B460AB11B8E64AF0000C344 /* libOCMock.a in Frameworks */, 1E7A45FC16F54FB5005B08F1 /* OCHamcrestIOS.framework in Frameworks */, 1E7A45FD16F54FB5005B08F1 /* OCMockitoIOS.framework in Frameworks */, ); @@ -647,6 +660,7 @@ 1EB617D51B0A36AE0035A986 /* Foundation.framework in Frameworks */, 1EB6174A1B0A30480035A986 /* HockeySDK.framework in Frameworks */, 1EB617CC1B0A34040035A986 /* CrashReporter.framework in Frameworks */, + 1B460AB21B8E64AF0000C344 /* libOCMock.a in Frameworks */, 1EB617D31B0A34AB0035A986 /* OCHamcrestIOS.framework in Frameworks */, 1EB617D41B0A34AF0035A986 /* OCMockitoIOS.framework in Frameworks */, ); @@ -655,6 +669,22 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1B460AA61B8E64A60000C344 /* OCMock */ = { + isa = PBXGroup; + children = ( + 1B460AA71B8E64A60000C344 /* NSNotificationCenter+OCMAdditions.h */, + 1B460AA81B8E64A60000C344 /* OCMArg.h */, + 1B460AA91B8E64A60000C344 /* OCMConstraint.h */, + 1B460AAA1B8E64A60000C344 /* OCMLocation.h */, + 1B460AAB1B8E64A60000C344 /* OCMMacroState.h */, + 1B460AAC1B8E64A60000C344 /* OCMock.h */, + 1B460AAD1B8E64A60000C344 /* OCMockObject.h */, + 1B460AAE1B8E64A60000C344 /* OCMRecorder.h */, + 1B460AAF1B8E64A60000C344 /* OCMStubRecorder.h */, + ); + path = OCMock; + sourceTree = ""; + }; 1B87EFB21B8D0B260007C96B /* Telemetry */ = { isa = PBXGroup; children = ( @@ -742,6 +772,8 @@ 1E5A459716F0DFC200B55C04 /* Supporting Files */ = { isa = PBXGroup; children = ( + 1B460AB01B8E64AF0000C344 /* libOCMock.a */, + 1B460AA61B8E64A60000C344 /* OCMock */, 1E7A45FA16F54FB5005B08F1 /* OCHamcrestIOS.framework */, 1E7A45FB16F54FB5005B08F1 /* OCMockitoIOS.framework */, 1E5A459816F0DFC200B55C04 /* HockeySDKTests-Info.plist */, @@ -1789,13 +1821,44 @@ "$(inherited)", ); GCC_WARN_UNINITIALIZED_AUTOS = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/HockeySDKTests/", + ); INFOPLIST_FILE = "HockeySDKTests/HockeySDKTests-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/HockeySDKTests\"", + "$(PROJECT_DIR)/HockeySDKTests", ); ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + CoreText, + "-framework", + CoreGraphics, + "-framework", + Foundation, + "-framework", + QuartzCore, + "-framework", + SystemConfiguration, + "-framework", + UIKit, + "-framework", + Security, + "-framework", + AssetsLibrary, + "-framework", + MobileCoreServices, + "-framework", + QuickLook, + "-lc++", + "-ObjC", + ); PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -1821,13 +1884,44 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "HockeySDKTests/HockeySDKTests-Prefix.pch"; GCC_WARN_UNINITIALIZED_AUTOS = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/HockeySDKTests/", + ); INFOPLIST_FILE = "HockeySDKTests/HockeySDKTests-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/HockeySDKTests\"", + "$(PROJECT_DIR)/HockeySDKTests", ); ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + CoreText, + "-framework", + CoreGraphics, + "-framework", + Foundation, + "-framework", + QuartzCore, + "-framework", + SystemConfiguration, + "-framework", + UIKit, + "-framework", + Security, + "-framework", + AssetsLibrary, + "-framework", + MobileCoreServices, + "-framework", + QuickLook, + "-lc++", + "-ObjC", + ); PRODUCT_NAME = "$(TARGET_NAME)"; VALIDATE_PRODUCT = YES; }; @@ -1948,13 +2042,44 @@ ); GCC_WARN_UNINITIALIZED_AUTOS = YES; GENERATE_PROFILING_CODE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/HockeySDKTests/", + ); INFOPLIST_FILE = "HockeySDKTests/HockeySDKTests-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/HockeySDKTests\"", + "$(PROJECT_DIR)/HockeySDKTests", ); ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + CoreText, + "-framework", + CoreGraphics, + "-framework", + Foundation, + "-framework", + QuartzCore, + "-framework", + SystemConfiguration, + "-framework", + UIKit, + "-framework", + Security, + "-framework", + AssetsLibrary, + "-framework", + MobileCoreServices, + "-framework", + QuickLook, + "-lc++", + "-ObjC", + ); PRODUCT_NAME = "$(TARGET_NAME)"; }; name = CodeCoverage; @@ -2068,13 +2193,44 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "HockeySDKTests/HockeySDKTests-Prefix.pch"; GCC_WARN_UNINITIALIZED_AUTOS = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/HockeySDKTests/", + ); INFOPLIST_FILE = "HockeySDKTests/HockeySDKTests-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/HockeySDKTests\"", + "$(PROJECT_DIR)/HockeySDKTests", ); ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + CoreText, + "-framework", + CoreGraphics, + "-framework", + Foundation, + "-framework", + QuartzCore, + "-framework", + SystemConfiguration, + "-framework", + UIKit, + "-framework", + Security, + "-framework", + AssetsLibrary, + "-framework", + MobileCoreServices, + "-framework", + QuickLook, + "-lc++", + "-ObjC", + ); PRODUCT_NAME = "$(TARGET_NAME)"; VALIDATE_PRODUCT = YES; }; @@ -2326,10 +2482,44 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/HockeySDKTests/", + ); INFOPLIST_FILE = "HockeySDK FrameworkTests/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/HockeySDKTests", + ); MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + CoreText, + "-framework", + CoreGraphics, + "-framework", + Foundation, + "-framework", + QuartzCore, + "-framework", + SystemConfiguration, + "-framework", + UIKit, + "-framework", + Security, + "-framework", + AssetsLibrary, + "-framework", + MobileCoreServices, + "-framework", + QuickLook, + "-lc++", + "-ObjC", + ); PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -2363,10 +2553,44 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/HockeySDKTests/", + ); INFOPLIST_FILE = "HockeySDK FrameworkTests/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/HockeySDKTests", + ); MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + CoreText, + "-framework", + CoreGraphics, + "-framework", + Foundation, + "-framework", + QuartzCore, + "-framework", + SystemConfiguration, + "-framework", + UIKit, + "-framework", + Security, + "-framework", + AssetsLibrary, + "-framework", + MobileCoreServices, + "-framework", + QuickLook, + "-lc++", + "-ObjC", + ); PRODUCT_NAME = "$(TARGET_NAME)"; VALIDATE_PRODUCT = YES; }; @@ -2401,10 +2625,44 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/HockeySDKTests/", + ); INFOPLIST_FILE = "HockeySDK FrameworkTests/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/HockeySDKTests", + ); MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + CoreText, + "-framework", + CoreGraphics, + "-framework", + Foundation, + "-framework", + QuartzCore, + "-framework", + SystemConfiguration, + "-framework", + UIKit, + "-framework", + Security, + "-framework", + AssetsLibrary, + "-framework", + MobileCoreServices, + "-framework", + QuickLook, + "-lc++", + "-ObjC", + ); PRODUCT_NAME = "$(TARGET_NAME)"; VALIDATE_PRODUCT = YES; }; @@ -2439,10 +2697,44 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/HockeySDKTests/", + ); INFOPLIST_FILE = "HockeySDK FrameworkTests/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/HockeySDKTests", + ); MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + CoreText, + "-framework", + CoreGraphics, + "-framework", + Foundation, + "-framework", + QuartzCore, + "-framework", + SystemConfiguration, + "-framework", + UIKit, + "-framework", + Security, + "-framework", + AssetsLibrary, + "-framework", + MobileCoreServices, + "-framework", + QuickLook, + "-lc++", + "-ObjC", + ); PRODUCT_NAME = "$(TARGET_NAME)"; VALIDATE_PRODUCT = YES; }; diff --git a/Support/HockeySDKTests/OCMock/NSNotificationCenter+OCMAdditions.h b/Support/HockeySDKTests/OCMock/NSNotificationCenter+OCMAdditions.h new file mode 100644 index 0000000000..b54e2b784e --- /dev/null +++ b/Support/HockeySDKTests/OCMock/NSNotificationCenter+OCMAdditions.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2009-2015 Erik Doernenburg and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use these files 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 + +@class OCObserverMockObject; + + +@interface NSNotificationCenter(OCMAdditions) + +- (void)addMockObserver:(OCObserverMockObject *)notificationObserver name:(NSString *)notificationName object:(id)notificationSender; + +@end diff --git a/Support/HockeySDKTests/OCMock/OCMArg.h b/Support/HockeySDKTests/OCMock/OCMArg.h new file mode 100644 index 0000000000..a8bdf5508e --- /dev/null +++ b/Support/HockeySDKTests/OCMock/OCMArg.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2009-2015 Erik Doernenburg and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use these files 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 + +@interface OCMArg : NSObject + +// constraining arguments + ++ (id)any; ++ (SEL)anySelector; ++ (void *)anyPointer; ++ (id __autoreleasing *)anyObjectRef; ++ (id)isNil; ++ (id)isNotNil; ++ (id)isEqual:(id)value; ++ (id)isNotEqual:(id)value; ++ (id)isKindOfClass:(Class)cls; ++ (id)checkWithSelector:(SEL)selector onObject:(id)anObject; ++ (id)checkWithBlock:(BOOL (^)(id obj))block; + +// manipulating arguments + ++ (id *)setTo:(id)value; ++ (void *)setToValue:(NSValue *)value; + +// internal use only + ++ (id)resolveSpecialValues:(NSValue *)value; + +@end + +#define OCMOCK_ANY [OCMArg any] + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) + #define OCMOCK_VALUE(variable) \ + ({ __typeof__(variable) __v = (variable); [NSValue value:&__v withObjCType:@encode(__typeof__(__v))]; }) +#else + #define OCMOCK_VALUE(variable) [NSValue value:&variable withObjCType:@encode(__typeof__(variable))] +#endif diff --git a/Support/HockeySDKTests/OCMock/OCMConstraint.h b/Support/HockeySDKTests/OCMock/OCMConstraint.h new file mode 100644 index 0000000000..2164f321be --- /dev/null +++ b/Support/HockeySDKTests/OCMock/OCMConstraint.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2007-2015 Erik Doernenburg and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use these files 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 + + +@interface OCMConstraint : NSObject + ++ (instancetype)constraint; +- (BOOL)evaluate:(id)value; + +// if you are looking for any, isNil, etc, they have moved to OCMArg + +// try to use [OCMArg checkWith...] instead of the constraintWith... methods below + ++ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject; ++ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject withValue:(id)aValue; + + +@end + +@interface OCMAnyConstraint : OCMConstraint +@end + +@interface OCMIsNilConstraint : OCMConstraint +@end + +@interface OCMIsNotNilConstraint : OCMConstraint +@end + +@interface OCMIsNotEqualConstraint : OCMConstraint +{ + @public + id testValue; +} + +@end + +@interface OCMInvocationConstraint : OCMConstraint +{ + @public + NSInvocation *invocation; +} + +@end + +@interface OCMBlockConstraint : OCMConstraint +{ + BOOL (^block)(id); +} + +- (instancetype)initWithConstraintBlock:(BOOL (^)(id))block; + +@end + + +#define CONSTRAINT(aSelector) [OCMConstraint constraintWithSelector:aSelector onObject:self] +#define CONSTRAINTV(aSelector, aValue) [OCMConstraint constraintWithSelector:aSelector onObject:self withValue:(aValue)] diff --git a/Support/HockeySDKTests/OCMock/OCMLocation.h b/Support/HockeySDKTests/OCMock/OCMLocation.h new file mode 100644 index 0000000000..7a8231e16c --- /dev/null +++ b/Support/HockeySDKTests/OCMock/OCMLocation.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014-2015 Erik Doernenburg and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use these files 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 + +@interface OCMLocation : NSObject +{ + id testCase; + NSString *file; + NSUInteger line; +} + ++ (instancetype)locationWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine; + +- (instancetype)initWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine; + +- (id)testCase; +- (NSString *)file; +- (NSUInteger)line; + +@end + +extern OCMLocation *OCMMakeLocation(id testCase, const char *file, int line); diff --git a/Support/HockeySDKTests/OCMock/OCMMacroState.h b/Support/HockeySDKTests/OCMock/OCMMacroState.h new file mode 100644 index 0000000000..96dc5e225f --- /dev/null +++ b/Support/HockeySDKTests/OCMock/OCMMacroState.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014-2015 Erik Doernenburg and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use these files 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 + +@class OCMLocation; +@class OCMRecorder; +@class OCMStubRecorder; +@class OCMockObject; + + +@interface OCMMacroState : NSObject +{ + OCMRecorder *recorder; +} + ++ (void)beginStubMacro; ++ (OCMStubRecorder *)endStubMacro; + ++ (void)beginExpectMacro; ++ (OCMStubRecorder *)endExpectMacro; + ++ (void)beginVerifyMacroAtLocation:(OCMLocation *)aLocation; ++ (void)endVerifyMacro; + ++ (OCMMacroState *)globalState; + +- (OCMRecorder *)recorder; + +- (void)switchToClassMethod; + +@end diff --git a/Support/HockeySDKTests/OCMock/OCMRecorder.h b/Support/HockeySDKTests/OCMock/OCMRecorder.h new file mode 100644 index 0000000000..3496c77ce8 --- /dev/null +++ b/Support/HockeySDKTests/OCMock/OCMRecorder.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014-2015 Erik Doernenburg and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use these files 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 + +@class OCMockObject; +@class OCMInvocationMatcher; + + +@interface OCMRecorder : NSProxy +{ + OCMockObject *mockObject; + OCMInvocationMatcher *invocationMatcher; +} + +- (instancetype)init; +- (instancetype)initWithMockObject:(OCMockObject *)aMockObject; + +- (void)setMockObject:(OCMockObject *)aMockObject; + +- (OCMInvocationMatcher *)invocationMatcher; + +- (id)classMethod; +- (id)ignoringNonObjectArgs; + +@end diff --git a/Support/HockeySDKTests/OCMock/OCMStubRecorder.h b/Support/HockeySDKTests/OCMock/OCMStubRecorder.h new file mode 100644 index 0000000000..402586d04c --- /dev/null +++ b/Support/HockeySDKTests/OCMock/OCMStubRecorder.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2004-2015 Erik Doernenburg and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use these files 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 "OCMRecorder.h" +#import + +@interface OCMStubRecorder : OCMRecorder + +- (id)andReturn:(id)anObject; +- (id)andReturnValue:(NSValue *)aValue; +- (id)andThrow:(NSException *)anException; +- (id)andPost:(NSNotification *)aNotification; +- (id)andCall:(SEL)selector onObject:(id)anObject; +- (id)andDo:(void (^)(NSInvocation *invocation))block; +- (id)andForwardToRealObject; + +@end + + +@interface OCMStubRecorder (Properties) + +#define andReturn(aValue) _andReturn(({ \ + __typeof__(aValue) _val = (aValue); \ + NSValue *_nsval = [NSValue value:&_val withObjCType:@encode(__typeof__(_val))]; \ + if (__builtin_types_compatible_p(__typeof__(_val), id)) { \ + objc_setAssociatedObject(_nsval, "OCMAssociatedBoxedValue", *(__unsafe_unretained id *) (void *) &_val, OBJC_ASSOCIATION_RETAIN); \ + } \ + _nsval; \ +})) +@property (nonatomic, readonly) OCMStubRecorder *(^ _andReturn)(NSValue *); + +#define andThrow(anException) _andThrow(anException) +@property (nonatomic, readonly) OCMStubRecorder *(^ _andThrow)(NSException *); + +#define andPost(aNotification) _andPost(aNotification) +@property (nonatomic, readonly) OCMStubRecorder *(^ _andPost)(NSNotification *); + +#define andCall(anObject, aSelector) _andCall(anObject, aSelector) +@property (nonatomic, readonly) OCMStubRecorder *(^ _andCall)(id, SEL); + +#define andDo(aBlock) _andDo(aBlock) +@property (nonatomic, readonly) OCMStubRecorder *(^ _andDo)(void (^)(NSInvocation *)); + +#define andForwardToRealObject() _andForwardToRealObject() +@property (nonatomic, readonly) OCMStubRecorder *(^ _andForwardToRealObject)(void); + +@end + + + diff --git a/Support/HockeySDKTests/OCMock/OCMock.h b/Support/HockeySDKTests/OCMock/OCMock.h new file mode 100644 index 0000000000..0790594bee --- /dev/null +++ b/Support/HockeySDKTests/OCMock/OCMock.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2004-2015 Erik Doernenburg and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use these files 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 +#import +#import +#import +#import +#import +#import + + +#define OCMClassMock(cls) [OCMockObject niceMockForClass:cls] + +#define OCMStrictClassMock(cls) [OCMockObject mockForClass:cls] + +#define OCMProtocolMock(protocol) [OCMockObject niceMockForProtocol:protocol] + +#define OCMStrictProtocolMock(protocol) [OCMockObject mockForProtocol:protocol] + +#define OCMPartialMock(obj) [OCMockObject partialMockForObject:obj] + +#define OCMObserverMock() [OCMockObject observerMock] + + +#define OCMStub(invocation) \ +({ \ + _OCMSilenceWarnings( \ + [OCMMacroState beginStubMacro]; \ + invocation; \ + [OCMMacroState endStubMacro]; \ + ); \ +}) + +#define OCMExpect(invocation) \ +({ \ + _OCMSilenceWarnings( \ + [OCMMacroState beginExpectMacro]; \ + invocation; \ + [OCMMacroState endExpectMacro]; \ + ); \ +}) + +#define ClassMethod(invocation) \ + _OCMSilenceWarnings( \ + [[OCMMacroState globalState] switchToClassMethod]; \ + invocation; \ + ); + + +#define OCMVerifyAll(mock) [mock verifyAtLocation:OCMMakeLocation(self, __FILE__, __LINE__)] + +#define OCMVerifyAllWithDelay(mock, delay) [mock verifyWithDelay:delay atLocation:OCMMakeLocation(self, __FILE__, __LINE__)] + +#define OCMVerify(invocation) \ +({ \ + _OCMSilenceWarnings( \ + [OCMMacroState beginVerifyMacroAtLocation:OCMMakeLocation(self, __FILE__, __LINE__)]; \ + invocation; \ + [OCMMacroState endVerifyMacro]; \ + ); \ +}) + +#define _OCMSilenceWarnings(macro) \ +({ \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wunused-value\"") \ + _Pragma("clang diagnostic ignored \"-Wunused-getter-return-value\"") \ + macro \ + _Pragma("clang diagnostic pop") \ +}) diff --git a/Support/HockeySDKTests/OCMock/OCMockObject.h b/Support/HockeySDKTests/OCMock/OCMockObject.h new file mode 100644 index 0000000000..58df67d7e6 --- /dev/null +++ b/Support/HockeySDKTests/OCMock/OCMockObject.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2004-2015 Erik Doernenburg and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use these files 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 + +@class OCMLocation; +@class OCMInvocationStub; +@class OCMStubRecorder; +@class OCMInvocationMatcher; +@class OCMInvocationExpectation; + + +@interface OCMockObject : NSProxy +{ + BOOL isNice; + BOOL expectationOrderMatters; + NSMutableArray *stubs; + NSMutableArray *expectations; + NSMutableArray *exceptions; + NSMutableArray *invocations; +} + ++ (id)mockForClass:(Class)aClass; ++ (id)mockForProtocol:(Protocol *)aProtocol; ++ (id)partialMockForObject:(NSObject *)anObject; + ++ (id)niceMockForClass:(Class)aClass; ++ (id)niceMockForProtocol:(Protocol *)aProtocol; + ++ (id)observerMock; + +- (instancetype)init; + +- (void)setExpectationOrderMatters:(BOOL)flag; + +- (id)stub; +- (id)expect; +- (id)reject; + +- (id)verify; +- (id)verifyAtLocation:(OCMLocation *)location; + +- (void)verifyWithDelay:(NSTimeInterval)delay; +- (void)verifyWithDelay:(NSTimeInterval)delay atLocation:(OCMLocation *)location; + +- (void)stopMocking; + +// internal use only + +- (void)addStub:(OCMInvocationStub *)aStub; +- (void)addExpectation:(OCMInvocationExpectation *)anExpectation; + +- (BOOL)handleInvocation:(NSInvocation *)anInvocation; +- (void)handleUnRecordedInvocation:(NSInvocation *)anInvocation; +- (BOOL)handleSelector:(SEL)sel; + +- (void)verifyInvocation:(OCMInvocationMatcher *)matcher; +- (void)verifyInvocation:(OCMInvocationMatcher *)matcher atLocation:(OCMLocation *)location; + +@end + diff --git a/Support/HockeySDKTests/libOCMock.a b/Support/HockeySDKTests/libOCMock.a new file mode 100644 index 0000000000..842df8ed10 Binary files /dev/null and b/Support/HockeySDKTests/libOCMock.a differ