| Index: device/bluetooth/test/bluetooth_test_mac.mm
|
| diff --git a/device/bluetooth/test/bluetooth_test_mac.mm b/device/bluetooth/test/bluetooth_test_mac.mm
|
| index d7e6f4b63ad6020d8ebfeed19d13e4afb3bd52ee..0edb5f28c6df9d8187fe7d9b9a1b406e7839c0ee 100644
|
| --- a/device/bluetooth/test/bluetooth_test_mac.mm
|
| +++ b/device/bluetooth/test/bluetooth_test_mac.mm
|
| @@ -8,6 +8,7 @@
|
|
|
| #include "base/mac/foundation_util.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "base/strings/sys_string_conversions.h"
|
| #include "build/build_config.h"
|
| #include "device/bluetooth/bluetooth_adapter_mac.h"
|
| #include "device/bluetooth/bluetooth_device_mac.h"
|
| @@ -144,6 +145,39 @@ void BluetoothTestMac::InitWithFakeAdapter() {
|
| }
|
| }
|
|
|
| +void BluetoothTestMac::SimulateConnectedLowEnergyDevice(
|
| + int device_ordinal,
|
| + const BluetoothDevice::UUIDSet& service_uuids) {
|
| + const char* identifier = NULL;
|
| + NSString* name;
|
| + switch (device_ordinal) {
|
| + case 1:
|
| + identifier = kTestPeripheralUUID1.c_str();
|
| + break;
|
| + case 2:
|
| + identifier = kTestPeripheralUUID2.c_str();
|
| + break;
|
| + default:
|
| + NOTREACHED() << "SimulateLowEnergyDevice not implemented for "
|
| + << device_ordinal;
|
| + }
|
| + name = @(kTestDeviceName.c_str());
|
| + scoped_nsobject<MockCBPeripheral> mock_peripheral([[MockCBPeripheral alloc]
|
| + initWithUTF8StringIdentifier:identifier
|
| + name:name]);
|
| + mock_peripheral.get().bluetoothTestMac = this;
|
| + scoped_nsobject<NSMutableSet> cbUUIDs([[NSMutableSet alloc] init]);
|
| + for (auto iterator = service_uuids.begin(); iterator != service_uuids.end();
|
| + ++iterator) {
|
| + NSString* uuidString =
|
| + base::SysUTF8ToNSString(iterator->canonical_value().c_str());
|
| + [cbUUIDs.get() addObject:[CBUUID UUIDWithString:uuidString]];
|
| + }
|
| + [mock_central_manager_->get()
|
| + setConnectedMockPeripheral:mock_peripheral.get().peripheral
|
| + withServiceUUIDs:cbUUIDs.get()];
|
| +}
|
| +
|
| BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
|
| TestBluetoothAdapterObserver observer(adapter_);
|
| CBCentralManager* central_manager = adapter_mac_->low_energy_central_manager_;
|
|
|