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

Side by Side Diff: third_party/ocmock/OCMock/OCMRealObjectForwarder.m

Issue 2410583002: Test update OCMock (Closed)
Patch Set: Patch in exactly 3.1.5 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 unified diff | Download patch
OLDNEW
1 //------------------------------------------------------------------------------ --------- 1 /*
2 // $Id$ 2 * Copyright (c) 2010-2015 Erik Doernenburg and contributors
3 // Copyright (c) 2010 by Mulle Kybernetik. See License file for details. 3 *
4 //------------------------------------------------------------------------------ --------- 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may
5 * not use these files except in compliance with the License. You may obtain
6 * a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
5 16
6 #import <objc/runtime.h> 17 #import <objc/runtime.h>
7 #import "OCPartialMockObject.h" 18 #import "OCPartialMockObject.h"
8 #import "OCMRealObjectForwarder.h" 19 #import "OCMRealObjectForwarder.h"
9 20 #import "OCMFunctions.h"
10 21
11 @implementation OCMRealObjectForwarder 22 @implementation OCMRealObjectForwarder
12 23
13 - (void)handleInvocation:(NSInvocation *)anInvocation 24 - (void)handleInvocation:(NSInvocation *)anInvocation
14 { 25 {
15 id invocationTarget = [anInvocation target]; 26 id invocationTarget = [anInvocation target];
16 » SEL invocationSelector = [anInvocation selector]; 27
17 » SEL aliasedSelector = NSSelectorFromString([OCMRealMethodAliasPrefix str ingByAppendingString:NSStringFromSelector(invocationSelector)]); 28 [anInvocation
18 » 29 setSelector:OCMAliasForOriginalSelector([anInvocation selector])];
19 » [anInvocation setSelector:aliasedSelector]; 30 if ([invocationTarget isProxy]) {
20 » if([invocationTarget isProxy] && (class_getInstanceMethod([invocationTar get class], @selector(realObject)))) 31 if (class_getInstanceMethod([invocationTarget mockObjectClass],
21 » { 32 @selector(realObject))) {
22 » » // the method has been invoked on the mock, we need to change th e target to the real object 33 // the method has been invoked on the mock, we need to change the
23 » » [anInvocation setTarget:[(OCPartialMockObject *)invocationTarget realObject]]; 34 // target to the real object
24 » } 35 [anInvocation
25 » [anInvocation invoke]; 36 setTarget:[(OCPartialMockObject*)invocationTarget realObject]];
37 } else {
38 [NSException raise:NSInternalInconsistencyException
39 format:@"Method andForwardToRealObject can only be "
40 @"used with partial mocks and class methods."];
41 }
42 }
43
44 [anInvocation invoke];
26 } 45 }
27 46
28 47
29 @end 48 @end
OLDNEW
« no previous file with comments | « third_party/ocmock/OCMock/OCMRealObjectForwarder.h ('k') | third_party/ocmock/OCMock/OCMRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698