| OLD | NEW |
| 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_cbservice_mac.h" | 10 #include "device/bluetooth/test/mock_bluetooth_cbservice_mac.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 - (void)discoverCharacteristics:(NSArray*)characteristics | 90 - (void)discoverCharacteristics:(NSArray*)characteristics |
| 91 forService:(CBService*)service { | 91 forService:(CBService*)service { |
| 92 } | 92 } |
| 93 | 93 |
| 94 - (void)readValueForCharacteristic:(CBCharacteristic*)characteristic { | 94 - (void)readValueForCharacteristic:(CBCharacteristic*)characteristic { |
| 95 DCHECK(_bluetoothTestMac); | 95 DCHECK(_bluetoothTestMac); |
| 96 _bluetoothTestMac->OnFakeBluetoothCharacteristicReadValue(); | 96 _bluetoothTestMac->OnFakeBluetoothCharacteristicReadValue(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 - (void)writeValue:(NSData*)data |
| 100 forCharacteristic:(CBCharacteristic*)characteristic |
| 101 type:(CBCharacteristicWriteType)type { |
| 102 DCHECK(_bluetoothTestMac); |
| 103 const uint8_t* buffer = static_cast<const uint8_t*>(data.bytes); |
| 104 std::vector<uint8_t> value(buffer, buffer + data.length); |
| 105 _bluetoothTestMac->OnFakeBluetoothCharacteristicWriteValue(value); |
| 106 } |
| 107 |
| 99 - (void)removeAllServices { | 108 - (void)removeAllServices { |
| 100 [_services.get() removeAllObjects]; | 109 [_services.get() removeAllObjects]; |
| 101 } | 110 } |
| 102 | 111 |
| 103 - (void)addServices:(NSArray*)services { | 112 - (void)addServices:(NSArray*)services { |
| 104 if (!_services.get()) { | 113 if (!_services.get()) { |
| 105 _services.reset([[NSMutableArray alloc] init]); | 114 _services.reset([[NSMutableArray alloc] init]); |
| 106 } | 115 } |
| 107 for (CBUUID* uuid in services) { | 116 for (CBUUID* uuid in services) { |
| 108 base::scoped_nsobject<MockCBService> service([[MockCBService alloc] | 117 base::scoped_nsobject<MockCBService> service([[MockCBService alloc] |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 164 |
| 156 - (NSArray*)services { | 165 - (NSArray*)services { |
| 157 return _services.get(); | 166 return _services.get(); |
| 158 } | 167 } |
| 159 | 168 |
| 160 - (CBPeripheral*)peripheral { | 169 - (CBPeripheral*)peripheral { |
| 161 return ObjCCast<CBPeripheral>(self); | 170 return ObjCCast<CBPeripheral>(self); |
| 162 } | 171 } |
| 163 | 172 |
| 164 @end | 173 @end |
| OLD | NEW |