| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "device/bluetooth/test/mock_bluetooth_cbservice_mac.h" | 5 #include "device/bluetooth/test/mock_bluetooth_cbservice_mac.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "device/bluetooth/test/bluetooth_test.h" | 9 #include "device/bluetooth/test/bluetooth_test.h" |
| 10 | 10 |
| 11 using base::mac::ObjCCast; | 11 using base::mac::ObjCCast; |
| 12 using base::scoped_nsobject; | 12 using base::scoped_nsobject; |
| 13 | 13 |
| 14 @interface MockCBService () { | 14 @interface MockCBService () { |
| 15 CBUUID* _UUID; | 15 scoped_nsobject<CBUUID> _UUID; |
| 16 BOOL _primary; | 16 BOOL _primary; |
| 17 } | 17 } |
| 18 | 18 |
| 19 @end | 19 @end |
| 20 | 20 |
| 21 @implementation MockCBService | 21 @implementation MockCBService |
| 22 | 22 |
| 23 @synthesize UUID = _UUID; | |
| 24 @synthesize isPrimary = _primary; | 23 @synthesize isPrimary = _primary; |
| 25 | 24 |
| 26 - (instancetype)initWithCBUUID:(CBUUID*)uuid primary:(BOOL)isPrimary { | 25 - (instancetype)initWithCBUUID:(CBUUID*)uuid primary:(BOOL)isPrimary { |
| 27 self = [super init]; | 26 self = [super init]; |
| 28 if (self) { | 27 if (self) { |
| 29 _UUID = [uuid retain]; | 28 _UUID.reset([uuid retain]); |
| 30 _primary = isPrimary; | 29 _primary = isPrimary; |
| 31 } | 30 } |
| 32 return self; | 31 return self; |
| 33 } | 32 } |
| 34 | 33 |
| 35 - (void)dealloc { | |
| 36 [_UUID release]; | |
| 37 [super dealloc]; | |
| 38 } | |
| 39 | |
| 40 - (BOOL)isKindOfClass:(Class)aClass { | 34 - (BOOL)isKindOfClass:(Class)aClass { |
| 41 if (aClass == [CBService class] || | 35 if (aClass == [CBService class] || |
| 42 [aClass isSubclassOfClass:[CBService class]]) { | 36 [aClass isSubclassOfClass:[CBService class]]) { |
| 43 return YES; | 37 return YES; |
| 44 } | 38 } |
| 45 return [super isKindOfClass:aClass]; | 39 return [super isKindOfClass:aClass]; |
| 46 } | 40 } |
| 47 | 41 |
| 48 - (BOOL)isMemberOfClass:(Class)aClass { | 42 - (BOOL)isMemberOfClass:(Class)aClass { |
| 49 if (aClass == [CBService class] || | 43 if (aClass == [CBService class] || |
| 50 [aClass isSubclassOfClass:[CBService class]]) { | 44 [aClass isSubclassOfClass:[CBService class]]) { |
| 51 return YES; | 45 return YES; |
| 52 } | 46 } |
| 53 return [super isKindOfClass:aClass]; | 47 return [super isKindOfClass:aClass]; |
| 54 } | 48 } |
| 55 | 49 |
| 50 - (CBUUID*)UUID { |
| 51 return _UUID.get(); |
| 52 } |
| 53 |
| 56 - (CBService*)service { | 54 - (CBService*)service { |
| 57 return ObjCCast<CBService>(self); | 55 return ObjCCast<CBService>(self); |
| 58 } | 56 } |
| 59 | 57 |
| 60 @end | 58 @end |
| OLD | NEW |