| 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 110e9f992832b5c145b29f2809c64e64f3f5b622..f089adbb23d90f59416f7dc4bd28f88a0793d76b 100644
|
| --- a/device/bluetooth/test/bluetooth_test_mac.mm
|
| +++ b/device/bluetooth/test/bluetooth_test_mac.mm
|
| @@ -9,6 +9,7 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "build/build_config.h"
|
| #include "device/bluetooth/bluetooth_adapter_mac.h"
|
| +#include "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h"
|
| #include "device/bluetooth/test/mock_bluetooth_central_manager_mac.h"
|
| #include "device/bluetooth/test/test_bluetooth_adapter_observer.h"
|
| #include "third_party/ocmock/OCMock/OCMock.h"
|
| @@ -151,8 +152,11 @@ BluetoothDevice* BluetoothTestMac::DiscoverLowEnergyDevice(int device_ordinal) {
|
| break;
|
| }
|
| case 3: {
|
| - CBPeripheral* peripheral = CreateMockPeripheral(
|
| - [NSString stringWithUTF8String:kTestPeripheralUUID1.c_str()]);
|
| + NSString* uuid_string =
|
| + [NSString stringWithUTF8String:kTestPeripheralUUID1.c_str()];
|
| + NSUUID* identifier = [[NSUUID alloc] initWithUUIDString:uuid_string];
|
| + CBPeripheral* peripheral = (CBPeripheral*)[[MockCBPeripheral alloc]
|
| + initWithIdentifier:identifier];
|
| NSString* name =
|
| [NSString stringWithUTF8String:kTestDeviceNameEmpty.c_str()];
|
| NSArray* uuids = nil;
|
| @@ -161,6 +165,7 @@ BluetoothDevice* BluetoothTestMac::DiscoverLowEnergyDevice(int device_ordinal) {
|
| didDiscoverPeripheral:peripheral
|
| advertisementData:advertisement_data
|
| RSSI:[NSNumber numberWithInt:0]];
|
| + [peripheral release];
|
| break;
|
| }
|
| case 4: {
|
| @@ -180,6 +185,18 @@ BluetoothDevice* BluetoothTestMac::DiscoverLowEnergyDevice(int device_ordinal) {
|
| return observer.last_device();
|
| }
|
|
|
| +void BluetoothTestMac::SimulateGattConnection(BluetoothDevice* device) {
|
| + BluetoothLowEnergyDeviceMac* lowEnergyDeviceMac =
|
| + (BluetoothLowEnergyDeviceMac*)device;
|
| + BluetoothAdapterMac* adapter = lowEnergyDeviceMac->GetBluetoothAdapterMac();
|
| + CBPeripheral* peripheral = lowEnergyDeviceMac->GetPeripheral();
|
| + MockCBPeripheral* mockPeripheral = (MockCBPeripheral*)peripheral;
|
| + [mockPeripheral setStateForTesting:CBPeripheralStateConnected];
|
| + CBCentralManager* centralManager = adapter->GetCentralManagerForTesting();
|
| + [centralManager.delegate centralManager:centralManager
|
| + didConnectPeripheral:peripheral];
|
| +}
|
| +
|
| // Utility function for generating new (CBUUID, address) pairs where CBUUID
|
| // hashes to address. For use when adding a new device address to the testing
|
| // suite because CoreBluetooth peripherals have CBUUIDs in place of addresses,
|
|
|