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..4e06976fdb7707782d6708ce8a7cdde01f75a3c8 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; |
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,31 @@ 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]; |
+} |
+ |
+- (void)removeCharacteristicMock:(MockCBCharacteristic*)characteristic_mock { |
+ [_characteristics.get() removeObject:characteristic_mock]; |
+} |
+ |
- (CBService*)service { |
return ObjCCast<CBService>(self); |
} |
+- (NSArray*)characteristics { |
+ return _characteristics.get(); |
+} |
+ |
@end |