Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3311)

Unified Diff: device/bluetooth/test/bluetooth_test_bluez.cc

Issue 2783733002: Bluetooth: Add service data unit tests for chromeos (Closed)
Patch Set: comments and rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..829dd0ba2795c7570d445386b6c141ec9e46839b 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] = {0x01};
break;
case 2:
service_uuids.push_back(kTestUUIDImmediateAlert);
service_uuids.push_back(kTestUUIDLinkLoss);
+ service_data[kTestUUIDHeartRate] = {};
+ service_data[kTestUUIDImmediateAlert] = {0x00, 0x02};
break;
case 3:
device_name = kTestDeviceNameEmpty;
@@ -147,28 +151,33 @@ 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) {
+ fake_bluetooth_device_client_->UpdateServiceData(GetDevicePath(device),
+ service_data);
+ return 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);
- return device;
+ return adapter_->GetDevice(device_address);
}
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);
}

Powered by Google App Engine
This is Rietveld 408576698