Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: third_party/ocmock/OCMock/OCMockRecorder.m

Issue 2626723004: Update OCMock to 3e193f3c2d4ea4ada63df54c8ce98e7ea4cf768f (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/ocmock/OCMock/OCMockRecorder.h ('k') | third_party/ocmock/OCMock/OCObserverMockObject.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/ocmock/OCMock/OCMockRecorder.m
diff --git a/third_party/ocmock/OCMock/OCMockRecorder.m b/third_party/ocmock/OCMock/OCMockRecorder.m
deleted file mode 100644
index 5cd63d2b4c84ae3cf84f4cc81f9687a2b680e533..0000000000000000000000000000000000000000
--- a/third_party/ocmock/OCMock/OCMockRecorder.m
+++ /dev/null
@@ -1,187 +0,0 @@
-//---------------------------------------------------------------------------------------
-// $Id$
-// Copyright (c) 2004-2011 by Mulle Kybernetik. See License file for details.
-//---------------------------------------------------------------------------------------
-
-#import <objc/runtime.h>
-#import <OCMock/OCMockRecorder.h>
-#import <OCMock/OCMArg.h>
-#import <OCMock/OCMConstraint.h>
-#import "OCMPassByRefSetter.h"
-#import "OCMReturnValueProvider.h"
-#import "OCMBoxedReturnValueProvider.h"
-#import "OCMExceptionReturnValueProvider.h"
-#import "OCMIndirectReturnValueProvider.h"
-#import "OCMNotificationPoster.h"
-#import "OCMBlockCaller.h"
-#import "NSInvocation+OCMAdditions.h"
-
-@interface NSObject(HCMatcherDummy)
-- (BOOL)matches:(id)item;
-@end
-
-#pragma mark -
-
-
-@implementation OCMockRecorder
-
-#pragma mark Initialisers, description, accessors, etc.
-
-- (id)initWithSignatureResolver:(id)anObject
-{
- signatureResolver = anObject;
- invocationHandlers = [[NSMutableArray alloc] init];
- return self;
-}
-
-- (void)dealloc
-{
- [recordedInvocation release];
- [invocationHandlers release];
- [super dealloc];
-}
-
-- (NSString *)description
-{
- return [recordedInvocation invocationDescription];
-}
-
-- (void)releaseInvocation
-{
- [recordedInvocation release];
- recordedInvocation = nil;
-}
-
-
-#pragma mark Recording invocation handlers
-
-- (id)andReturn:(id)anObject
-{
- [invocationHandlers addObject:[[[OCMReturnValueProvider alloc] initWithValue:anObject] autorelease]];
- return self;
-}
-
-- (id)andReturnValue:(NSValue *)aValue
-{
- [invocationHandlers addObject:[[[OCMBoxedReturnValueProvider alloc] initWithValue:aValue] autorelease]];
- return self;
-}
-
-- (id)andThrow:(NSException *)anException
-{
- [invocationHandlers addObject:[[[OCMExceptionReturnValueProvider alloc] initWithValue:anException] autorelease]];
- return self;
-}
-
-- (id)andPost:(NSNotification *)aNotification
-{
- [invocationHandlers addObject:[[[OCMNotificationPoster alloc] initWithNotification:aNotification] autorelease]];
- return self;
-}
-
-- (id)andCall:(SEL)selector onObject:(id)anObject
-{
- [invocationHandlers addObject:[[[OCMIndirectReturnValueProvider alloc] initWithProvider:anObject andSelector:selector] autorelease]];
- return self;
-}
-
-#if NS_BLOCKS_AVAILABLE
-
-- (id)andDo:(void (^)(NSInvocation *))aBlock
-{
- [invocationHandlers addObject:[[[OCMBlockCaller alloc] initWithCallBlock:aBlock] autorelease]];
- return self;
-}
-
-#endif
-
-- (id)andForwardToRealObject
-{
- [NSException raise:NSInternalInconsistencyException format:@"Method %@ can only be used with partial mocks.",
- NSStringFromSelector(_cmd)];
- return self; // keep compiler happy
-}
-
-
-- (NSArray *)invocationHandlers
-{
- return invocationHandlers;
-}
-
-
-#pragma mark Recording the actual invocation
-
-- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
-{
- return [signatureResolver methodSignatureForSelector:aSelector];
-}
-
-- (void)forwardInvocation:(NSInvocation *)anInvocation
-{
- if(recordedInvocation != nil)
- [NSException raise:NSInternalInconsistencyException format:@"Recorder received two methods to record."];
- [anInvocation setTarget:nil];
- [anInvocation retainArguments];
- recordedInvocation = [anInvocation retain];
-}
-
-
-
-#pragma mark Checking the invocation
-
-- (BOOL)matchesInvocation:(NSInvocation *)anInvocation
-{
- id recordedArg, passedArg;
- int i, n;
-
- if([anInvocation selector] != [recordedInvocation selector])
- return NO;
-
- n = (int)[[recordedInvocation methodSignature] numberOfArguments];
- for(i = 2; i < n; i++)
- {
- recordedArg = [recordedInvocation getArgumentAtIndexAsObject:i];
- passedArg = [anInvocation getArgumentAtIndexAsObject:i];
-
- if([recordedArg isProxy])
- {
- if(![recordedArg isEqual:passedArg])
- return NO;
- continue;
- }
-
- if([recordedArg isKindOfClass:[NSValue class]])
- recordedArg = [OCMArg resolveSpecialValues:recordedArg];
-
- if([recordedArg isKindOfClass:[OCMConstraint class]])
- {
- if([recordedArg evaluate:passedArg] == NO)
- return NO;
- }
- else if([recordedArg isKindOfClass:[OCMPassByRefSetter class]])
- {
- // side effect but easier to do here than in handleInvocation
- *(id *)[passedArg pointerValue] = [(OCMPassByRefSetter *)recordedArg value];
- }
- else if([recordedArg conformsToProtocol:objc_getProtocol("HCMatcher")])
- {
- if([recordedArg matches:passedArg] == NO)
- return NO;
- }
- else
- {
- if(([recordedArg class] == [NSNumber class]) &&
- ([(NSNumber*)recordedArg compare:(NSNumber*)passedArg] != NSOrderedSame))
- return NO;
- if(([recordedArg isEqual:passedArg] == NO) &&
- !((recordedArg == nil) && (passedArg == nil)))
- return NO;
- }
- }
- return YES;
-}
-
-
-
-
-@end
« no previous file with comments | « third_party/ocmock/OCMock/OCMockRecorder.h ('k') | third_party/ocmock/OCMock/OCObserverMockObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698