Chromium Code Reviews| Index: chromeos/dbus/fake_bluetooth_device_client.cc |
| diff --git a/chromeos/dbus/fake_bluetooth_device_client.cc b/chromeos/dbus/fake_bluetooth_device_client.cc |
| index 325d95e69e94eeb90ae84de5e2fba40cf4c70691..46cf5afe78969556a2f62bf07b130a0b28b0bff0 100644 |
| --- a/chromeos/dbus/fake_bluetooth_device_client.cc |
| +++ b/chromeos/dbus/fake_bluetooth_device_client.cc |
| @@ -185,6 +185,15 @@ const char FakeBluetoothDeviceClient::kLowEnergyName[] = |
| const uint32 FakeBluetoothDeviceClient::kLowEnergyClass = |
| 0x000918; // Major class "Health", Minor class "Heart/Pulse Rate Monitor." |
| +const char FakeBluetoothDeviceClient::kPairedUnconnectableDevicePath[] = |
| + "/fake/hci0/devD"; |
| +const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress[] = |
| + "20:7D:74:00:00:04"; |
| +const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceName[] = |
| + "Paired Unconnectable Device"; |
| +const uint32 FakeBluetoothDeviceClient::kPairedUnconnectableDeviceClass = |
| + 0x000104; |
| + |
| FakeBluetoothDeviceClient::Properties::Properties( |
| const PropertyChangedCallback& callback) |
| : BluetoothDeviceClient::Properties( |
| @@ -249,6 +258,26 @@ FakeBluetoothDeviceClient::FakeBluetoothDeviceClient() |
| properties_map_[dbus::ObjectPath(kPairedDevicePath)] = properties; |
| device_list_.push_back(dbus::ObjectPath(kPairedDevicePath)); |
| + |
| + properties = new Properties(base::Bind( |
| + &FakeBluetoothDeviceClient::OnPropertyChanged, base::Unretained(this), |
|
armansito
2015/02/07 00:29:55
nit: Formatting. Put second argument in its own li
Marie Janssen
2015/02/09 18:58:41
git cl format chromeos disagrees, and chromeos/ re
armansito
2015/02/09 20:35:22
I disagree with git cl format here, it doesn't alw
|
| + dbus::ObjectPath(kPairedUnconnectableDevicePath))); |
| + properties->address.ReplaceValue(kPairedUnconnectableDeviceAddress); |
| + properties->bluetooth_class.ReplaceValue(kPairedUnconnectableDeviceClass); |
| + properties->name.ReplaceValue("Fake Device 2 (Unconnectable)"); |
| + properties->alias.ReplaceValue(kPairedUnconnectableDeviceName); |
| + properties->paired.ReplaceValue(true); |
| + properties->trusted.ReplaceValue(true); |
| + properties->adapter.ReplaceValue( |
| + dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); |
| + |
| + properties->uuids.ReplaceValue(uuids); |
| + |
| + properties->modalias.ReplaceValue("usb:v05ACp030Dd0306"); |
| + |
| + properties_map_[dbus::ObjectPath(kPairedUnconnectableDevicePath)] = |
| + properties; |
| + device_list_.push_back(dbus::ObjectPath(kPairedUnconnectableDevicePath)); |
| } |
| FakeBluetoothDeviceClient::~FakeBluetoothDeviceClient() { |
| @@ -304,7 +333,9 @@ void FakeBluetoothDeviceClient::Connect( |
| error_callback.Run(bluetooth_device::kErrorFailed, "Not paired"); |
| return; |
| } else if (properties->paired.value() == true && |
| - object_path == dbus::ObjectPath(kUnconnectableDevicePath)) { |
| + (object_path == dbus::ObjectPath(kUnconnectableDevicePath) || |
| + object_path == |
| + dbus::ObjectPath(kPairedUnconnectableDevicePath))) { |
| // Must not be paired |
| error_callback.Run(bluetooth_device::kErrorFailed, |
| "Connection fails while paired"); |
| @@ -368,6 +399,11 @@ void FakeBluetoothDeviceClient::ConnectProfile( |
| return; |
| } |
| + if (object_path == dbus::ObjectPath(kPairedUnconnectableDevicePath)) { |
| + error_callback.Run(kNoResponseError, "unconnectable"); |
|
armansito
2015/02/07 00:29:55
I think we use kNoResponseError for cases that are
Marie Janssen
2015/02/09 18:58:41
Done. Using kErrorFailed instead.
|
| + return; |
| + } |
| + |
| // Make a socket pair of a compatible type with the type used by Bluetooth; |
| // spin up a thread to simulate the server side and wrap the client side in |
| // a D-Bus file descriptor object. |