OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <objc/runtime.h> | 5 #include <objc/runtime.h> |
6 | 6 |
7 #include "third_party/ocmock/ocmock_extensions.h" | 7 #include "third_party/ocmock/ocmock_extensions.h" |
8 | 8 |
9 #define CR_OCMOCK_RETURN_IMPL(type_name, type) \ | 9 #define CR_OCMOCK_RETURN_IMPL(type_name, type) \ |
10 - (id)andReturn##type_name:(type)value { \ | 10 - (id)andReturn##type_name:(type)value { \ |
(...skipping 11 matching lines...) Expand all Loading... |
22 CR_OCMOCK_RETURN_IMPL(Long, long); | 22 CR_OCMOCK_RETURN_IMPL(Long, long); |
23 CR_OCMOCK_RETURN_IMPL(UnsignedLong, unsigned long); | 23 CR_OCMOCK_RETURN_IMPL(UnsignedLong, unsigned long); |
24 CR_OCMOCK_RETURN_IMPL(LongLong, long long); | 24 CR_OCMOCK_RETURN_IMPL(LongLong, long long); |
25 CR_OCMOCK_RETURN_IMPL(UnsignedLongLong, unsigned long long); | 25 CR_OCMOCK_RETURN_IMPL(UnsignedLongLong, unsigned long long); |
26 CR_OCMOCK_RETURN_IMPL(Float, float); | 26 CR_OCMOCK_RETURN_IMPL(Float, float); |
27 CR_OCMOCK_RETURN_IMPL(Double, double); | 27 CR_OCMOCK_RETURN_IMPL(Double, double); |
28 CR_OCMOCK_RETURN_IMPL(Bool, BOOL); | 28 CR_OCMOCK_RETURN_IMPL(Bool, BOOL); |
29 CR_OCMOCK_RETURN_IMPL(Integer, NSInteger); | 29 CR_OCMOCK_RETURN_IMPL(Integer, NSInteger); |
30 CR_OCMOCK_RETURN_IMPL(UnsignedInteger, NSUInteger); | 30 CR_OCMOCK_RETURN_IMPL(UnsignedInteger, NSUInteger); |
31 | 31 |
| 32 #if !TARGET_OS_IPHONE |
32 - (id)andReturnNSRect:(NSRect)rect { | 33 - (id)andReturnNSRect:(NSRect)rect { |
33 return [self andReturnValue:[NSValue valueWithRect:rect]]; | 34 return [self andReturnValue:[NSValue valueWithRect:rect]]; |
34 } | 35 } |
35 | 36 |
36 - (id)andReturnCGRect:(CGRect)rect { | 37 - (id)andReturnCGRect:(CGRect)rect { |
37 return [self andReturnNSRect:NSRectFromCGRect(rect)]; | 38 return [self andReturnNSRect:NSRectFromCGRect(rect)]; |
38 } | 39 } |
39 | 40 |
40 - (id)andReturnNSPoint:(NSPoint)point { | 41 - (id)andReturnNSPoint:(NSPoint)point { |
41 return [self andReturnValue:[NSValue valueWithPoint:point]]; | 42 return [self andReturnValue:[NSValue valueWithPoint:point]]; |
42 } | 43 } |
43 | 44 |
44 - (id)andReturnCGPoint:(CGPoint)point { | 45 - (id)andReturnCGPoint:(CGPoint)point { |
45 return [self andReturnNSPoint:NSPointFromCGPoint(point)]; | 46 return [self andReturnNSPoint:NSPointFromCGPoint(point)]; |
46 } | 47 } |
| 48 #endif // !TARGET_OS_IPHONE |
47 | 49 |
48 @end | 50 @end |
49 | 51 |
50 @implementation cr_OCMConformToProtocolConstraint | 52 @implementation cr_OCMConformToProtocolConstraint |
51 | 53 |
52 - (id)initWithProtocol:(Protocol*)protocol { | 54 - (id)initWithProtocol:(Protocol*)protocol { |
53 if (self == [super init]) { | 55 if (self == [super init]) { |
54 protocol_ = protocol; | 56 protocol_ = protocol; |
55 } | 57 } |
56 return self; | 58 return self; |
57 } | 59 } |
58 | 60 |
59 - (BOOL)evaluate:(id)value { | 61 - (BOOL)evaluate:(id)value { |
60 return protocol_conformsToProtocol(protocol_, value); | 62 return protocol_conformsToProtocol(protocol_, value); |
61 } | 63 } |
62 | 64 |
63 @end | 65 @end |
64 | 66 |
65 @implementation OCMArg(CrExtensions) | 67 @implementation OCMArg(CrExtensions) |
66 | 68 |
67 + (id)conformsToProtocol:(Protocol*)protocol { | 69 + (id)conformsToProtocol:(Protocol*)protocol { |
68 return [[[cr_OCMConformToProtocolConstraint alloc] initWithProtocol:protocol] | 70 return [[[cr_OCMConformToProtocolConstraint alloc] initWithProtocol:protocol] |
69 autorelease]; | 71 autorelease]; |
70 } | 72 } |
71 | 73 |
72 @end | 74 @end |
OLD | NEW |