Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added very basic support for mocking with OCMock.

  • Loading branch information...
commit b086576952a77132d3b097ed7880a21885c9112d 1 parent 4f75f7c
@Simbul authored
View
72 Baker.xcodeproj/project.pbxproj
@@ -25,6 +25,9 @@
BFBACF331274CD38009D9595 /* ios-icon-ipad72.png in Resources */ = {isa = PBXBuildFile; fileRef = BFBACF321274CD38009D9595 /* ios-icon-ipad72.png */; };
BFEC41E61309D9CA00628DF3 /* ios-icon-iphone57.png in Resources */ = {isa = PBXBuildFile; fileRef = BFEC41E51309D9CA00628DF3 /* ios-icon-iphone57.png */; };
BFEC41E81309D9CE00628DF3 /* ios-icon-iphone114.png in Resources */ = {isa = PBXBuildFile; fileRef = BFEC41E71309D9CE00628DF3 /* ios-icon-iphone114.png */; };
+ D21A0B86135CF1F2005D6E8A /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D21A0B85135CF1F2005D6E8A /* libOCMock.a */; };
+ D2700BD81355BC3100889DD8 /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2700BD71355BC3100889DD8 /* OCMock.framework */; };
+ D2700BDB1356048800889DD8 /* OCMock.framework in Copy OCMock */ = {isa = PBXBuildFile; fileRef = D2700BD71355BC3100889DD8 /* OCMock.framework */; };
D281D06913549EF4009F1B11 /* InterceptorWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = F4EC203712862D4D008E94D1 /* InterceptorWindow.m */; };
D281D06A13549EF4009F1B11 /* InterceptorWindowTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D281D02E13546BB1009F1B11 /* InterceptorWindowTests.m */; };
D281D06B13549F08009F1B11 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
@@ -34,6 +37,20 @@
F4EC203812862D4D008E94D1 /* InterceptorWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = F4EC203712862D4D008E94D1 /* InterceptorWindow.m */; };
/* End PBXBuildFile section */
+/* Begin PBXCopyFilesBuildPhase section */
+ D2700BDA1356041800889DD8 /* Copy OCMock */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "$(BUILT_PRODUCTS_DIR)";
+ dstSubfolderSpec = 0;
+ files = (
+ D2700BDB1356048800889DD8 /* OCMock.framework in Copy OCMock */,
+ );
+ name = "Copy OCMock";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
/* Begin PBXFileReference section */
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D3623240D0F684500981E51 /* BakerAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BakerAppDelegate.h; sourceTree = "<group>"; };
@@ -65,6 +82,8 @@
BFBACF321274CD38009D9595 /* ios-icon-ipad72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ios-icon-ipad72.png"; sourceTree = "<group>"; };
BFEC41E51309D9CA00628DF3 /* ios-icon-iphone57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ios-icon-iphone57.png"; sourceTree = "<group>"; };
BFEC41E71309D9CE00628DF3 /* ios-icon-iphone114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ios-icon-iphone114.png"; sourceTree = "<group>"; };
+ D21A0B85135CF1F2005D6E8A /* libOCMock.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libOCMock.a; sourceTree = "<group>"; };
+ D2700BD71355BC3100889DD8 /* OCMock.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = OCMock.framework; sourceTree = "<group>"; };
D281D02D13546BB1009F1B11 /* InterceptorWindowTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterceptorWindowTests.h; sourceTree = "<group>"; };
D281D02E13546BB1009F1B11 /* InterceptorWindowTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InterceptorWindowTests.m; sourceTree = "<group>"; };
D281D06313549EDC009F1B11 /* UnitTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -94,6 +113,8 @@
D281D06C13549F08009F1B11 /* UIKit.framework in Frameworks */,
D281D06D13549F08009F1B11 /* CoreGraphics.framework in Frameworks */,
D281D06E13549F08009F1B11 /* QuartzCore.framework in Frameworks */,
+ D2700BD81355BC3100889DD8 /* OCMock.framework in Frameworks */,
+ D21A0B86135CF1F2005D6E8A /* libOCMock.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -190,9 +211,19 @@
path = minizip;
sourceTree = "<group>";
};
+ D2700BD61355BC0800889DD8 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ D21A0B85135CF1F2005D6E8A /* libOCMock.a */,
+ D2700BD71355BC3100889DD8 /* OCMock.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
D281CE9B13545C0E009F1B11 /* Tests */ = {
isa = PBXGroup;
children = (
+ D2700BD61355BC0800889DD8 /* Frameworks */,
D281D02D13546BB1009F1B11 /* InterceptorWindowTests.h */,
D281D02E13546BB1009F1B11 /* InterceptorWindowTests.m */,
);
@@ -225,6 +256,7 @@
buildPhases = (
D281D05E13549EDC009F1B11 /* Resources */,
D281D05F13549EDC009F1B11 /* Sources */,
+ D2700BDA1356041800889DD8 /* Copy OCMock */,
D281D06013549EDC009F1B11 /* Frameworks */,
D281D06113549EDC009F1B11 /* ShellScript */,
);
@@ -251,6 +283,7 @@
Japanese,
French,
German,
+ en,
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
projectDirPath = "";
@@ -334,11 +367,16 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Baker_Prefix.pch;
INFOPLIST_FILE = "Baker-Info.plist";
+ OTHER_LDFLAGS = "";
PRODUCT_NAME = Baker;
SDKROOT = iphoneos;
};
@@ -349,9 +387,14 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = YES;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Baker_Prefix.pch;
INFOPLIST_FILE = "Baker-Info.plist";
+ OTHER_LDFLAGS = "";
PRODUCT_NAME = Baker;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
@@ -379,11 +422,16 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Baker_Prefix.pch;
INFOPLIST_FILE = "Baker-Info.plist";
+ OTHER_LDFLAGS = "";
PRODUCT_NAME = Baker;
SDKROOT = iphoneos;
};
@@ -429,13 +477,21 @@
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
+ "\"$(SRCROOT)\"",
);
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
INFOPLIST_FILE = "UnitTests-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_LDFLAGS = (
+ "-OjbC",
+ "-force_load",
+ "$(PROJECT_DIR)/libOCMock.a",
"-framework",
Foundation,
"-framework",
@@ -458,11 +514,19 @@
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
+ "\"$(SRCROOT)\"",
);
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
INFOPLIST_FILE = "UnitTests-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_LDFLAGS = (
+ "-OjbC",
+ "-force_load",
+ "$(PROJECT_DIR)/libOCMock.a",
"-framework",
Foundation,
"-framework",
@@ -487,11 +551,19 @@
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
+ "\"$(SRCROOT)\"",
);
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
INFOPLIST_FILE = "UnitTests-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_LDFLAGS = (
+ "-OjbC",
+ "-force_load",
+ "$(PROJECT_DIR)/libOCMock.a",
"-framework",
Foundation,
"-framework",
View
11 InterceptorWindowTests.m
@@ -29,6 +29,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
+#import <OCMock/OCMock.h>
#import "InterceptorWindowTests.h"
#import "InterceptorWindow.h"
@@ -39,6 +40,16 @@ - (void) testInitInterceptorWindow {
STAssertNotNil(iWindow, @"Failed to initialize InterceptorWindow");
}
+- (void)testReturnsStubbedReturnValue {
+ id returnValue;
+
+ id mock = [OCMockObject mockForClass:[UIViewController class]];
+ [[[mock stub] andReturn:@"megamock"] title];
+ returnValue = [mock title];
+
+ STAssertEqualObjects(@"megamock", returnValue, @"Should have returned stubbed value.");
+}
+
// Uncomment this to force a failure
//- (void) testFail {
// STFail(@"Must fail to succeed");
View
1  OCMock.framework/Headers
View
1  OCMock.framework/OCMock
View
1  OCMock.framework/Resources
View
15 OCMock.framework/Versions/A/Headers/NSNotificationCenter+OCMAdditions.h
@@ -0,0 +1,15 @@
+//---------------------------------------------------------------------------------------
+// $Id: NSNotificationCenter+OCMAdditions.h 57 2010-07-19 06:14:27Z erik $
+// Copyright (c) 2009 by Mulle Kybernetik. See License file for details.
+//---------------------------------------------------------------------------------------
+
+#import <Foundation/Foundation.h>
+
+@class OCMockObserver;
+
+
+@interface NSNotificationCenter(OCMAdditions)
+
+- (void)addMockObserver:(OCMockObserver *)notificationObserver name:(NSString *)notificationName object:(id)notificationSender;
+
+@end
View
33 OCMock.framework/Versions/A/Headers/OCMArg.h
@@ -0,0 +1,33 @@
+//---------------------------------------------------------------------------------------
+// $Id: OCMArg.h 65 2010-07-28 01:49:42Z erik $
+// Copyright (c) 2009-2010 by Mulle Kybernetik. See License file for details.
+//---------------------------------------------------------------------------------------
+
+#import <Foundation/Foundation.h>
+
+@interface OCMArg : NSObject
+
+// constraining arguments
+
++ (id)any;
++ (void *)anyPointer;
++ (id)isNil;
++ (id)isNotNil;
++ (id)isNotEqual:(id)value;
++ (id)checkWithSelector:(SEL)selector onObject:(id)anObject;
+#if NS_BLOCKS_AVAILABLE
++ (id)checkWithBlock:(BOOL (^)(id))block;
+#endif
+
+// manipulating arguments
+
++ (id *)setTo:(id)value;
+
+// internal use only
+
++ (id)resolveSpecialValues:(NSValue *)value;
+
+@end
+
+#define OCMOCK_ANY [OCMArg any]
+#define OCMOCK_VALUE(variable) [NSValue value:&variable withObjCType:@encode(__typeof__(variable))]
View
64 OCMock.framework/Versions/A/Headers/OCMConstraint.h
@@ -0,0 +1,64 @@
+//---------------------------------------------------------------------------------------
+// $Id: OCMConstraint.h 57 2010-07-19 06:14:27Z erik $
+// Copyright (c) 2007-2010 by Mulle Kybernetik. See License file for details.
+//---------------------------------------------------------------------------------------
+
+#import <Foundation/Foundation.h>
+
+
+@interface OCMConstraint : NSObject
+
++ (id)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
+
++ (id)constraintWithSelector:(SEL)aSelector onObject:(id)anObject;
++ (id)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
+
+#if NS_BLOCKS_AVAILABLE
+
+@interface OCMBlockConstraint : OCMConstraint
+{
+ BOOL (^block)(id);
+}
+
+- (id)initWithConstraintBlock:(BOOL (^)(id))block;
+
+@end
+
+#endif
+
+
+#define CONSTRAINT(aSelector) [OCMConstraint constraintWithSelector:aSelector onObject:self]
+#define CONSTRAINTV(aSelector, aValue) [OCMConstraint constraintWithSelector:aSelector onObject:self withValue:(aValue)]
View
10 OCMock.framework/Versions/A/Headers/OCMock.h
@@ -0,0 +1,10 @@
+//---------------------------------------------------------------------------------------
+// $Id: OCMock.h 39 2009-04-09 05:31:28Z erik $
+// Copyright (c) 2004-2008 by Mulle Kybernetik. See License file for details.
+//---------------------------------------------------------------------------------------
+
+#import <OCMock/OCMockObject.h>
+#import <OCMock/OCMockRecorder.h>
+#import <OCMock/OCMConstraint.h>
+#import <OCMock/OCMArg.h>
+#import <OCMock/NSNotificationCenter+OCMAdditions.h>
View
43 OCMock.framework/Versions/A/Headers/OCMockObject.h
@@ -0,0 +1,43 @@
+//---------------------------------------------------------------------------------------
+// $Id: OCMockObject.h 69 2010-08-20 16:05:58Z erik $
+// Copyright (c) 2004-2008 by Mulle Kybernetik. See License file for details.
+//---------------------------------------------------------------------------------------
+
+#import <Foundation/Foundation.h>
+
+@interface OCMockObject : NSProxy
+{
+ BOOL isNice;
+ BOOL expectationOrderMatters;
+ NSMutableArray *recorders;
+ NSMutableArray *expectations;
+ NSMutableArray *rejections;
+ NSMutableArray *exceptions;
+}
+
++ (id)mockForClass:(Class)aClass;
++ (id)mockForProtocol:(Protocol *)aProtocol;
++ (id)partialMockForObject:(NSObject *)anObject;
+
++ (id)niceMockForClass:(Class)aClass;
++ (id)niceMockForProtocol:(Protocol *)aProtocol;
+
++ (id)observerMock;
+
+- (id)init;
+
+- (void)setExpectationOrderMatters:(BOOL)flag;
+
+- (id)stub;
+- (id)expect;
+- (id)reject;
+
+- (void)verify;
+
+// internal use only
+
+- (id)getNewRecorder;
+- (BOOL)handleInvocation:(NSInvocation *)anInvocation;
+- (void)handleUnRecordedInvocation:(NSInvocation *)anInvocation;
+
+@end
View
32 OCMock.framework/Versions/A/Headers/OCMockRecorder.h
@@ -0,0 +1,32 @@
+//---------------------------------------------------------------------------------------
+// $Id: OCMockRecorder.h 68 2010-08-20 13:20:52Z erik $
+// Copyright (c) 2004-2010 by Mulle Kybernetik. See License file for details.
+//---------------------------------------------------------------------------------------
+
+#import <Foundation/Foundation.h>
+
+@interface OCMockRecorder : NSProxy
+{
+ id signatureResolver;
+ NSInvocation *recordedInvocation;
+ NSMutableArray *invocationHandlers;
+}
+
+- (id)initWithSignatureResolver:(id)anObject;
+
+- (BOOL)matchesInvocation:(NSInvocation *)anInvocation;
+- (void)releaseInvocation;
+
+- (id)andReturn:(id)anObject;
+- (id)andReturnValue:(NSValue *)aValue;
+- (id)andThrow:(NSException *)anException;
+- (id)andPost:(NSNotification *)aNotification;
+- (id)andCall:(SEL)selector onObject:(id)anObject;
+#if NS_BLOCKS_AVAILABLE
+- (id)andDo:(void (^)(NSInvocation *))block;
+#endif
+- (id)andForwardToRealObject;
+
+- (NSArray *)invocationHandlers;
+
+@end
View
BIN  OCMock.framework/Versions/A/OCMock
Binary file not shown
View
26 OCMock.framework/Versions/A/Resources/Info.plist
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>OCMock</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.mulle-kybernetik.OCMock</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>OCMock</string>
+ <key>CFBundlePackageType</key>
+ <string>FMWK</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.29</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2004-2009 Mulle Kybernetik.</string>
+</dict>
+</plist>
View
15 OCMock.framework/Versions/A/Resources/License.txt
@@ -0,0 +1,15 @@
+
+ Copyright (c) 2004-2011 by Mulle Kybernetik. All rights reserved.
+
+ Permission to use, copy, modify and distribute this software and its documentation
+ is hereby granted, provided that both the copyright notice and this permission
+ notice appear in all copies of the software, derivative works or modified versions,
+ and any portions thereof, and that both notices appear in supporting documentation,
+ and that credit is given to Mulle Kybernetik in all documents and publicity
+ pertaining to direct or indirect use of this code or its derivatives.
+
+ THIS IS EXPERIMENTAL SOFTWARE AND IT IS KNOWN TO HAVE BUGS, SOME OF WHICH MAY HAVE
+ SERIOUS CONSEQUENCES. THE COPYRIGHT HOLDER ALLOWS FREE USE OF THIS SOFTWARE IN ITS
+ "AS IS" CONDITION. THE COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY
+ DAMAGES WHATSOEVER RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE
+ OR OF ANY DERIVATIVE WORK.
View
1  OCMock.framework/Versions/Current
View
BIN  libOCMock.a
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.