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

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

Issue 2640883002: Enable more unittests for BlueZ and ChromeOS. (Closed)
Patch Set: Added comment in TearDown. Created 3 years, 11 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/bluetooth_device_unittest.cc ('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 cd588b546c8bd537fde514146fcf91b92ab7e11d..a43c228cf8f98883f8af8eb5865f7ff310b0dc44 100644
--- a/device/bluetooth/dbus/fake_bluetooth_device_client.cc
+++ b/device/bluetooth/dbus/fake_bluetooth_device_client.cc
@@ -15,6 +15,7 @@
#include <string>
#include <utility>
+#include "base/base64.h"
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/logging.h"
@@ -23,6 +24,7 @@
#include "base/rand_util.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
+#include "base/strings/string_util.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
@@ -1775,9 +1777,12 @@ void FakeBluetoothDeviceClient::CreateTestDevice(
device::BluetoothTransport type) {
// Create a random device path.
dbus::ObjectPath device_path;
+ std::string id;
do {
- device_path = dbus::ObjectPath(adapter_path.value() + "/dev" +
- base::RandBytesAsString(10));
+ // Construct an id that is valid according to the DBUS specification.
+ base::Base64Encode(base::RandBytesAsString(10), &id);
+ base::RemoveChars(id, "+/=", &id);
+ device_path = dbus::ObjectPath(adapter_path.value() + "/dev" + id);
} while (std::find(device_list_.begin(), device_list_.end(), device_path) !=
device_list_.end());
@@ -1794,6 +1799,8 @@ void FakeBluetoothDeviceClient::CreateTestDevice(
properties->alias.ReplaceValue(alias);
properties->uuids.ReplaceValue(service_uuids);
+ properties->bluetooth_class.ReplaceValue(
+ 0x1F00u); // Unspecified Device Class
switch (type) {
case device::BLUETOOTH_TRANSPORT_CLASSIC:
« no previous file with comments | « device/bluetooth/bluetooth_device_unittest.cc ('k') | device/bluetooth/test/bluetooth_test_bluez.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698