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

Unified Diff: device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm

Issue 2052513002: Read characteristic implementation on macOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@characteristicscan_servicescan_cleanup
Patch Set: Addressing msarda's comment Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm
diff --git a/device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm b/device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm
index 97d260a41709dc7f8db72c1ed4127c0cb69ebd06..eb46b173be745f94e1de9ad4e1fab8583c7a1e79 100644
--- a/device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm
+++ b/device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm
@@ -89,16 +89,22 @@ CBCharacteristicProperties GattCharacteristicPropertyToCBCharacteristicProperty(
} // device
@interface MockCBCharacteristic () {
+ // Owner of this instance.
+ CBService* _service;
scoped_nsobject<CBUUID> _UUID;
CBCharacteristicProperties _cb_properties;
+ base::scoped_nsobject<NSData> _value;
}
@end
@implementation MockCBCharacteristic
-- (instancetype)initWithCBUUID:(CBUUID*)uuid properties:(int)properties {
+- (instancetype)initWithService:(CBService*)service
+ CBUUID:(CBUUID*)uuid
+ properties:(int)properties {
self = [super init];
if (self) {
+ _service = service;
_UUID.reset([uuid retain]);
_cb_properties =
device::GattCharacteristicPropertyToCBCharacteristicProperty(
@@ -123,6 +129,14 @@ CBCharacteristicProperties GattCharacteristicPropertyToCBCharacteristicProperty(
return [super isKindOfClass:aClass];
}
+- (void)simulateReadWithValue:(NSData*)value error:(NSError*)error {
+ _value.reset([value copy]);
+ CBPeripheral* peripheral = _service.peripheral;
+ [peripheral.delegate peripheral:peripheral
+ didUpdateValueForCharacteristic:self.characteristic
+ error:error];
+}
+
- (CBUUID*)UUID {
return _UUID.get();
}
@@ -131,8 +145,16 @@ CBCharacteristicProperties GattCharacteristicPropertyToCBCharacteristicProperty(
return ObjCCast<CBCharacteristic>(self);
}
+- (CBService*)service {
+ return _service;
+}
+
- (CBCharacteristicProperties)properties {
return _cb_properties;
}
+- (NSData*)value {
+ return _value.get();
+}
+
@end
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h ('k') | device/bluetooth/test/mock_bluetooth_cbperipheral_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698