| 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 777e91339cf66d8d512b200378f7e9f0ebc7f116..593179edf1f7d37ddbfdd4c87069ed6bb1b7c998 100644
|
| --- a/device/bluetooth/test/bluetooth_test_mac.mm
|
| +++ b/device/bluetooth/test/bluetooth_test_mac.mm
|
| @@ -377,7 +377,7 @@ void BluetoothTestMac::SimulateGattDescriptor(
|
| MockCBCharacteristic* characteristic_mock =
|
| GetCBMockCharacteristic(characteristic);
|
| CBUUID* cb_uuid = [CBUUID UUIDWithString:@(uuid.c_str())];
|
| - [characteristic_mock simulateDescriptorWithUUID:cb_uuid];
|
| + [characteristic_mock addDescriptorWithUUID:cb_uuid];
|
| MockCBPeripheral* peripheral_mock = GetMockCBPeripheral(characteristic);
|
| [peripheral_mock didModifyServices:@[]];
|
| // After -[MockCBPeripheral didModifyServices:], BluetoothLowEnergyDeviceMac
|
| @@ -463,13 +463,64 @@ void BluetoothTestMac::ExpectedNotifyValue(
|
| }
|
| }
|
|
|
| -void BluetoothTestMac::SimulateDidDiscoverServices(
|
| - BluetoothDevice* device,
|
| - const std::vector<std::string>& uuids) {
|
| - AddServicesToDevice(device, uuids);
|
| +void BluetoothTestMac::SimulateDidDiscoverServices(BluetoothDevice* device) {
|
| [GetMockCBPeripheral(device) mockDidDiscoverServices];
|
| }
|
|
|
| +void BluetoothTestMac::SimulateDidDiscoverCharacteristics(
|
| + BluetoothRemoteGattService* service) {
|
| + BluetoothRemoteGattServiceMac* mac_gatt_service =
|
| + static_cast<BluetoothRemoteGattServiceMac*>(service);
|
| + CBService* cb_service = mac_gatt_service->GetService();
|
| + [GetMockCBPeripheral(service)
|
| + mockDidDiscoverCharacteristicsForService:cb_service];
|
| +}
|
| +
|
| +void BluetoothTestMac::SimulateDidDiscoverDescriptors(
|
| + BluetoothRemoteGattCharacteristic* characteristic) {
|
| + BluetoothRemoteGattCharacteristicMac* mac_gatt_characteristic =
|
| + static_cast<BluetoothRemoteGattCharacteristicMac*>(characteristic);
|
| + CBCharacteristic* cb_characteristic =
|
| + mac_gatt_characteristic->GetCBCharacteristic();
|
| + [GetMockCBPeripheral(characteristic)
|
| + mockDidDiscoverDescriptorsForCharacteristic:cb_characteristic];
|
| +}
|
| +
|
| +void BluetoothTest::AddServicesToDevice(BluetoothDevice* device,
|
| + const std::vector<std::string>& uuids) {
|
| + scoped_nsobject<NSMutableArray> services([[NSMutableArray alloc] init]);
|
| + for (auto uuid : uuids) {
|
| + CBUUID* cb_service_uuid = [CBUUID UUIDWithString:@(uuid.c_str())];
|
| + [services addObject:cb_service_uuid];
|
| + }
|
| + [GetMockCBPeripheral(device) addServices:services];
|
| +}
|
| +
|
| +void BluetoothTestMac::AddCharacteristicToService(
|
| + BluetoothRemoteGattService* service,
|
| + const std::string& characteristic_uuid,
|
| + int properties) {
|
| + BluetoothRemoteGattServiceMac* mac_gatt_service =
|
| + static_cast<BluetoothRemoteGattServiceMac*>(service);
|
| + CBService* cb_service = mac_gatt_service->GetService();
|
| + MockCBService* service_mock = ObjCCast<MockCBService>(cb_service);
|
| + CBUUID* cb_uuid = [CBUUID UUIDWithString:@(characteristic_uuid.c_str())];
|
| + [service_mock addCharacteristicWithUUID:cb_uuid properties:properties];
|
| +}
|
| +
|
| +void BluetoothTestMac::AddDescriptorToCharacteristic(
|
| + BluetoothRemoteGattCharacteristic* characteristic,
|
| + const std::string& uuid) {
|
| + BluetoothRemoteGattCharacteristicMac* mac_gatt_characteristic =
|
| + static_cast<BluetoothRemoteGattCharacteristicMac*>(characteristic);
|
| + CBCharacteristic* cb_characteristic =
|
| + mac_gatt_characteristic->GetCBCharacteristic();
|
| + MockCBCharacteristic* characteristic_mock =
|
| + ObjCCast<MockCBCharacteristic>(cb_characteristic);
|
| + CBUUID* cb_uuid = [CBUUID UUIDWithString:@(uuid.c_str())];
|
| + [characteristic_mock addDescriptorWithUUID:cb_uuid];
|
| +}
|
| +
|
| void BluetoothTestMac::OnFakeBluetoothDeviceConnectGattCalled() {
|
| gatt_connection_attempts_++;
|
| }
|
| @@ -550,16 +601,6 @@ MockCBCharacteristic* BluetoothTest::GetCBMockCharacteristic(
|
| return ObjCCast<MockCBCharacteristic>(cb_characteristic);
|
| }
|
|
|
| -void BluetoothTest::AddServicesToDevice(BluetoothDevice* device,
|
| - const std::vector<std::string>& uuids) {
|
| - scoped_nsobject<NSMutableArray> services([[NSMutableArray alloc] init]);
|
| - for (auto uuid : uuids) {
|
| - CBUUID* cb_service_uuid = [CBUUID UUIDWithString:@(uuid.c_str())];
|
| - [services addObject:cb_service_uuid];
|
| - }
|
| - [GetMockCBPeripheral(device) addServices:services];
|
| -}
|
| -
|
| // 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,
|
|
|