Chromium Code Reviews| Index: device/bluetooth/test/bluetooth_test_bluez.cc |
| diff --git a/device/bluetooth/test/bluetooth_test_bluez.cc b/device/bluetooth/test/bluetooth_test_bluez.cc |
| index 3bb14fed244140a2876d8fd12aff1e0ab2adc1eb..9fe6ad4278f77a75ea8adadd845aa7847a2dbe3d 100644 |
| --- a/device/bluetooth/test/bluetooth_test_bluez.cc |
| +++ b/device/bluetooth/test/bluetooth_test_bluez.cc |
| @@ -122,15 +122,19 @@ BluetoothDevice* BluetoothTestBlueZ::SimulateLowEnergyDevice( |
| std::string device_address = kTestDeviceAddress1; |
| std::vector<std::string> service_uuids; |
| BluetoothTransport device_type = BLUETOOTH_TRANSPORT_LE; |
| + std::unordered_map<std::string, std::vector<uint8_t>> service_data; |
| switch (device_ordinal) { |
| case 1: |
| service_uuids.push_back(kTestUUIDGenericAccess); |
| service_uuids.push_back(kTestUUIDGenericAttribute); |
| + service_data[kTestUUIDHeartRate] = {1}; |
|
Miao
2017/03/28 22:56:40
nit: It is better to use the original format (0x01
xiaoyinh(OOO Sep 11-29)
2017/03/29 21:58:07
Thanks for the comments. I modified device_ordinal
|
| break; |
| case 2: |
| service_uuids.push_back(kTestUUIDImmediateAlert); |
| service_uuids.push_back(kTestUUIDLinkLoss); |
| + service_data[kTestUUIDHeartRate] = {2}; |
| + service_data[kTestUUIDImmediateAlert] = {0}; |
| break; |
| case 3: |
| device_name = kTestDeviceNameEmpty; |
| @@ -147,14 +151,18 @@ BluetoothDevice* BluetoothTestBlueZ::SimulateLowEnergyDevice( |
| break; |
| } |
| - if (!adapter_->GetDevice(device_address)) { |
| - fake_bluetooth_device_client_->CreateTestDevice( |
| - dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), |
| - /* name */ device_name, |
| - /* alias */ device_name.value_or("") + "(alias)", device_address, |
| - service_uuids, device_type); |
| - } |
| BluetoothDevice* device = adapter_->GetDevice(device_address); |
| + if (device) { |
|
Miao
2017/03/28 22:56:40
nit: The brackets can be removed here.
ortuno
2017/03/28 23:56:36
SimulateLowEnergyDevice is actually a misnomer. It
Miao
2017/03/29 17:58:58
It makes more sense with your explanation now.
xiaoyinh(OOO Sep 11-29)
2017/03/29 21:58:06
Thanks for the clarification! I've changed the cod
xiaoyinh(OOO Sep 11-29)
2017/03/29 21:58:07
Thanks! Changed to another approach.
|
| + DeleteDevice(device); |
| + } |
| + |
| + fake_bluetooth_device_client_->CreateTestDevice( |
| + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), |
| + /* name */ device_name, |
| + /* alias */ device_name.value_or("") + "(alias)", device_address, |
| + service_uuids, device_type, service_data); |
| + |
| + device = adapter_->GetDevice(device_address); |
| return device; |
| } |
| @@ -163,12 +171,13 @@ BluetoothDevice* BluetoothTestBlueZ::SimulateClassicDevice() { |
| std::string device_name = kTestDeviceName; |
| std::string device_address = kTestDeviceAddress3; |
| std::vector<std::string> service_uuids; |
| + std::unordered_map<std::string, std::vector<uint8_t>> service_data; |
| if (!adapter_->GetDevice(device_address)) { |
| fake_bluetooth_device_client_->CreateTestDevice( |
| dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), |
| device_name /* name */, device_name /* alias */, device_address, |
| - service_uuids, BLUETOOTH_TRANSPORT_CLASSIC); |
| + service_uuids, BLUETOOTH_TRANSPORT_CLASSIC, service_data); |
| } |
| return adapter_->GetDevice(device_address); |
| } |