Chromium Code Reviews| Index: device/bluetooth/test/mock_bluetooth_cbservice_mac.mm |
| diff --git a/device/bluetooth/test/mock_bluetooth_cbservice_mac.mm b/device/bluetooth/test/mock_bluetooth_cbservice_mac.mm |
| index 48337c8e95a47e31605d4d70dc1e1dd502f15133..bb37e0d4950a9b321d219426d9ee41b65eb2ad1f 100644 |
| --- a/device/bluetooth/test/mock_bluetooth_cbservice_mac.mm |
| +++ b/device/bluetooth/test/mock_bluetooth_cbservice_mac.mm |
| @@ -7,13 +7,17 @@ |
| #include "base/mac/foundation_util.h" |
| #include "base/mac/scoped_nsobject.h" |
| #include "device/bluetooth/test/bluetooth_test.h" |
| +#include "device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h" |
| using base::mac::ObjCCast; |
| using base::scoped_nsobject; |
| @interface MockCBService () { |
| + // Owner of this instance. |
| + CBPeripheral* _peripheral; |
|
msarda
2016/06/14 09:15:05
Consider using a WeakNSObject for this.
jlebel
2016/06/15 16:16:37
WeakNSObject is defined in base/ios/weak_nsobject.
|
| scoped_nsobject<CBUUID> _UUID; |
| BOOL _primary; |
| + scoped_nsobject<NSMutableArray> _characteristics; |
| } |
| @end |
| @@ -22,11 +26,15 @@ using base::scoped_nsobject; |
| @synthesize isPrimary = _primary; |
| -- (instancetype)initWithCBUUID:(CBUUID*)uuid primary:(BOOL)isPrimary { |
| +- (instancetype)initWithPeripheral:(CBPeripheral*)peripheral |
| + CBUUID:(CBUUID*)uuid |
| + primary:(BOOL)isPrimary { |
| self = [super init]; |
| if (self) { |
| _UUID.reset([uuid retain]); |
| _primary = isPrimary; |
| + _peripheral = peripheral; |
| + _characteristics.reset([[NSMutableArray alloc] init]); |
| } |
| return self; |
| } |
| @@ -47,12 +55,27 @@ using base::scoped_nsobject; |
| return [super isKindOfClass:aClass]; |
| } |
| +- (CBPeripheral*)peripheral { |
| + return _peripheral; |
| +} |
| + |
| - (CBUUID*)UUID { |
| return _UUID.get(); |
| } |
| +- (void)addCharacteristicWithUUID:(CBUUID*)cb_uuid properties:(int)properties { |
| + scoped_nsobject<MockCBCharacteristic> characteristic_mock( |
| + [[MockCBCharacteristic alloc] initWithCBUUID:cb_uuid |
| + properties:properties]); |
| + [_characteristics.get() addObject:characteristic_mock]; |
| +} |
| + |
| - (CBService*)service { |
| return ObjCCast<CBService>(self); |
| } |
| +- (NSArray*)characteristics { |
| + return _characteristics.get(); |
| +} |
| + |
| @end |