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

Side by Side Diff: device/bluetooth/test/mock_bluetooth_cbperipheral_mac.mm

Issue 2767813002: Bluetooth: macOS: Implementing read/write for descriptors (Closed)
Patch Set: . Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_cbperipheral_mac.h" 5 #include "device/bluetooth/test/mock_bluetooth_cbperipheral_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_mac.h" 9 #include "device/bluetooth/test/bluetooth_test_mac.h"
10 #include "device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h" 10 #include "device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h"
11 #include "device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.h"
11 #include "device/bluetooth/test/mock_bluetooth_cbservice_mac.h" 12 #include "device/bluetooth/test/mock_bluetooth_cbservice_mac.h"
12 13
13 using base::mac::ObjCCast; 14 using base::mac::ObjCCast;
14 using base::scoped_nsobject; 15 using base::scoped_nsobject;
15 16
16 @interface MockCBPeripheral () { 17 @interface MockCBPeripheral () {
17 scoped_nsobject<NSUUID> _identifier; 18 scoped_nsobject<NSUUID> _identifier;
18 scoped_nsobject<NSString> _name; 19 scoped_nsobject<NSString> _name;
19 id<CBPeripheralDelegate> _delegate; 20 id<CBPeripheralDelegate> _delegate;
20 scoped_nsobject<NSMutableArray> _services; 21 scoped_nsobject<NSMutableArray> _services;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 106
106 - (void)writeValue:(NSData*)data 107 - (void)writeValue:(NSData*)data
107 forCharacteristic:(CBCharacteristic*)characteristic 108 forCharacteristic:(CBCharacteristic*)characteristic
108 type:(CBCharacteristicWriteType)type { 109 type:(CBCharacteristicWriteType)type {
109 DCHECK(_bluetoothTestMac); 110 DCHECK(_bluetoothTestMac);
110 const uint8_t* buffer = static_cast<const uint8_t*>(data.bytes); 111 const uint8_t* buffer = static_cast<const uint8_t*>(data.bytes);
111 std::vector<uint8_t> value(buffer, buffer + data.length); 112 std::vector<uint8_t> value(buffer, buffer + data.length);
112 _bluetoothTestMac->OnFakeBluetoothCharacteristicWriteValue(value); 113 _bluetoothTestMac->OnFakeBluetoothCharacteristicWriteValue(value);
113 } 114 }
114 115
116 - (void)readValueForDescriptor:(CBDescriptor*)descriptor {
117 DCHECK(_bluetoothTestMac);
118 _bluetoothTestMac->OnFakeBluetoothDescriptorReadValue();
119 }
120
121 - (void)writeValue:(NSData*)data forDescriptor:(CBDescriptor*)descriptor {
122 DCHECK(_bluetoothTestMac);
123 const uint8_t* buffer = static_cast<const uint8_t*>(data.bytes);
124 std::vector<uint8_t> value(buffer, buffer + data.length);
125 _bluetoothTestMac->OnFakeBluetoothDescriptorWriteValue(value);
126 }
127
115 - (void)removeAllServices { 128 - (void)removeAllServices {
116 [_services.get() removeAllObjects]; 129 [_services.get() removeAllObjects];
117 } 130 }
118 131
119 - (void)addServices:(NSArray*)services { 132 - (void)addServices:(NSArray*)services {
120 if (!_services.get()) { 133 if (!_services.get()) {
121 _services.reset([[NSMutableArray alloc] init]); 134 _services.reset([[NSMutableArray alloc] init]);
122 } 135 }
123 for (CBUUID* uuid in services) { 136 for (CBUUID* uuid in services) {
124 base::scoped_nsobject<MockCBService> service([[MockCBService alloc] 137 base::scoped_nsobject<MockCBService> service([[MockCBService alloc]
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return ObjCCast<CBPeripheral>(self); 207 return ObjCCast<CBPeripheral>(self);
195 } 208 }
196 209
197 - (void)setNotifyValue:(BOOL)notification 210 - (void)setNotifyValue:(BOOL)notification
198 forCharacteristic:(CBCharacteristic*)characteristic { 211 forCharacteristic:(CBCharacteristic*)characteristic {
199 _bluetoothTestMac->OnFakeBluetoothGattSetCharacteristicNotification( 212 _bluetoothTestMac->OnFakeBluetoothGattSetCharacteristicNotification(
200 notification == YES); 213 notification == YES);
201 } 214 }
202 215
203 @end 216 @end
OLDNEW
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698