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

Side by Side Diff: third_party/ocmock/ocmock_extensions.mm

Issue 7004036: Added some enhancements to OCMock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed up protocol stuff Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « third_party/ocmock/ocmock_extensions.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <objc/runtime.h>
6
7 #include "third_party/ocmock/ocmock_extensions.h"
8
9 #define CR_OCMOCK_RETURN_IMPL(type_name, type) \
10 - (id)andReturn##type_name:(type)value { \
11 return [self andReturnValue:OCMOCK_VALUE(value)]; \
12 }
13
14 @implementation OCMockRecorder(CrExtensions)
15
16 CR_OCMOCK_RETURN_IMPL(Char, char);
17 CR_OCMOCK_RETURN_IMPL(UnsignedChar, unsigned char);
18 CR_OCMOCK_RETURN_IMPL(Short, short);
19 CR_OCMOCK_RETURN_IMPL(UnsignedShort, unsigned short);
20 CR_OCMOCK_RETURN_IMPL(Int, int);
21 CR_OCMOCK_RETURN_IMPL(UnsignedInt, unsigned int);
22 CR_OCMOCK_RETURN_IMPL(Long, long);
23 CR_OCMOCK_RETURN_IMPL(UnsignedLong, unsigned long);
24 CR_OCMOCK_RETURN_IMPL(LongLong, long long);
25 CR_OCMOCK_RETURN_IMPL(UnsignedLongLong, unsigned long long);
26 CR_OCMOCK_RETURN_IMPL(Float, float);
27 CR_OCMOCK_RETURN_IMPL(Double, double);
28 CR_OCMOCK_RETURN_IMPL(Bool, BOOL);
29 CR_OCMOCK_RETURN_IMPL(Integer, NSInteger);
30 CR_OCMOCK_RETURN_IMPL(UnsignedInteger, NSUInteger);
31
32 - (id)andReturnNSRect:(NSRect)rect {
33 return [self andReturnValue:[NSValue valueWithRect:rect]];
34 }
35
36 - (id)andReturnCGRect:(CGRect)rect {
37 return [self andReturnNSRect:NSRectFromCGRect(rect)];
38 }
39
40 - (id)andReturnNSPoint:(NSPoint)point {
41 return [self andReturnValue:[NSValue valueWithPoint:point]];
42 }
43
44 - (id)andReturnCGPoint:(CGPoint)point {
45 return [self andReturnNSPoint:NSPointFromCGPoint(point)];
46 }
47
48 @end
49
50 @implementation cr_OCMConformToProtocolConstraint
51
52 - (id)initWithProtocol:(Protocol*)protocol {
53 if (self == [super init]) {
54 protocol_ = protocol;
55 }
56 return self;
57 }
58
59 - (BOOL)evaluate:(id)value {
60 return protocol_conformsToProtocol(protocol_, value);
61 }
62
63 @end
64
65 @implementation OCMArg(CrExtensions)
66
67 + (id)conformsToProtocol:(Protocol*)protocol {
68 return [[[cr_OCMConformToProtocolConstraint alloc] initWithProtocol:protocol]
69 autorelease];
70 }
71
72 @end
OLDNEW
« no previous file with comments | « third_party/ocmock/ocmock_extensions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698