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

Unified Diff: device/bluetooth/dbus/fake_bluetooth_device_client.cc

Issue 1884033002: Implement BluetoothTestBlueZ and enable some LE tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_device_client.h ('k') | device/bluetooth/test/bluetooth_test_bluez.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/dbus/fake_bluetooth_device_client.cc
diff --git a/device/bluetooth/dbus/fake_bluetooth_device_client.cc b/device/bluetooth/dbus/fake_bluetooth_device_client.cc
index c3b3c2e24f99f8b15cdbc56a102d13843147092f..2be89cea78ed2e8873cc7d0e6d6c80dfb3334f48 100644
--- a/device/bluetooth/dbus/fake_bluetooth_device_client.cc
+++ b/device/bluetooth/dbus/fake_bluetooth_device_client.cc
@@ -1672,4 +1672,39 @@ void FakeBluetoothDeviceClient::DisconnectionCallback(
}
}
+void FakeBluetoothDeviceClient::RemoveAllDevices() {
+ device_list_.clear();
+}
+
+void FakeBluetoothDeviceClient::CreateTestDevice(
+ const dbus::ObjectPath& adapter_path,
+ const std::string name,
+ const std::string alias,
+ const std::string device_address,
+ const std::vector<std::string>& service_uuids) {
+ // Create a random device path.
+ dbus::ObjectPath device_path;
+ do {
+ device_path = dbus::ObjectPath(adapter_path.value() + "/dev" +
+ base::RandBytesAsString(10));
+ } while (std::find(device_list_.begin(), device_list_.end(), device_path) !=
+ device_list_.end());
+
+ std::unique_ptr<Properties> properties(
+ new Properties(base::Bind(&FakeBluetoothDeviceClient::OnPropertyChanged,
+ base::Unretained(this), device_path)));
+ properties->adapter.ReplaceValue(adapter_path);
+
+ properties->address.ReplaceValue(device_address);
+ properties->name.ReplaceValue(name);
+ properties->alias.ReplaceValue(alias);
+
+ properties->uuids.ReplaceValue(service_uuids);
+
+ properties_map_.insert(std::make_pair(device_path, std::move(properties)));
+ device_list_.push_back(device_path);
+ FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_,
+ DeviceAdded(device_path));
+}
+
} // namespace bluez
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_device_client.h ('k') | device/bluetooth/test/bluetooth_test_bluez.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698