summaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
authordeymo@chromium.org <deymo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 23:21:58 +0000
committerdeymo@chromium.org <deymo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 23:21:58 +0000
commitba03c8c05b52aa7e48a8235a9c26c765cbf5cf9e (patch)
tree7262ca92152f29163741dd19f1deded75ba095ca /device
parent3075512bc3609dc550233ce28ce48d142869c9d8 (diff)
downloadchromium_src-ba03c8c05b52aa7e48a8235a9c26c765cbf5cf9e.zip
chromium_src-ba03c8c05b52aa7e48a8235a9c26c765cbf5cf9e.tar.gz
chromium_src-ba03c8c05b52aa7e48a8235a9c26c765cbf5cf9e.tar.bz2
Bluetooth: Parse the bluez.Error.Failed on pairing error.
The method org.bluez.Device1.Pair can return with different errors. Among those, an org.bluez.Error.Failed: "Device or resource busy" is a possible option. This patch parses that D-Bus error as an ERROR_FAILED. BUG=238479 TEST=BluetoothExperimentalChromeOSTest.PairUnpairableDevice on device_unittests passed with the fix, and fails without it. Review URL: https://chromiumcodereview.appspot.com/15016004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199048 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device')
-rw-r--r--device/bluetooth/bluetooth_device_experimental_chromeos.cc2
-rw-r--r--device/bluetooth/bluetooth_experimental_chromeos_unittest.cc43
2 files changed, 45 insertions, 0 deletions
diff --git a/device/bluetooth/bluetooth_device_experimental_chromeos.cc b/device/bluetooth/bluetooth_device_experimental_chromeos.cc
index fb45ad0..35478d9 100644
--- a/device/bluetooth/bluetooth_device_experimental_chromeos.cc
+++ b/device/bluetooth/bluetooth_device_experimental_chromeos.cc
@@ -682,6 +682,8 @@ void BluetoothDeviceExperimentalChromeOS::OnPairError(
ConnectErrorCode error_code = ERROR_UNKNOWN;
if (error_name == bluetooth_adapter::kErrorConnectionAttemptFailed) {
error_code = ERROR_FAILED;
+ } else if (error_name == bluetooth_adapter::kErrorFailed) {
+ error_code = ERROR_FAILED;
} else if (error_name == bluetooth_adapter::kErrorAuthenticationFailed) {
error_code = ERROR_AUTH_FAILED;
} else if (error_name == bluetooth_adapter::kErrorAuthenticationCanceled) {
diff --git a/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc b/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc
index afd8325..0dc3ad5 100644
--- a/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc
@@ -1559,6 +1559,49 @@ TEST_F(BluetoothExperimentalChromeOSTest, PairWeirdDevice) {
EXPECT_TRUE(properties->trusted.value());
}
+TEST_F(BluetoothExperimentalChromeOSTest, PairUnpairableDeviceFails) {
+ base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+ fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
+
+ GetAdapter();
+ DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress);
+
+ BluetoothDevice* device = adapter_->GetDevice(
+ FakeBluetoothDeviceClient::kUnpairableDeviceAddress);
+ ASSERT_TRUE(device != NULL);
+ ASSERT_FALSE(device->IsPaired());
+
+ TestObserver observer(adapter_);
+ adapter_->AddObserver(&observer);
+
+ TestPairingDelegate pairing_delegate;
+ device->Connect(
+ &pairing_delegate,
+ base::Bind(&BluetoothExperimentalChromeOSTest::Callback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback,
+ base::Unretained(this)));
+
+ EXPECT_EQ(0, pairing_delegate.call_count_);
+ EXPECT_TRUE(device->IsConnecting());
+
+ // Run the loop to get the error..
+ message_loop.Run();
+
+ EXPECT_EQ(0, callback_count_);
+ EXPECT_EQ(1, error_callback_count_);
+
+ EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_);
+
+ EXPECT_FALSE(device->IsConnected());
+ EXPECT_FALSE(device->IsConnecting());
+ EXPECT_FALSE(device->IsPaired());
+
+ // Pairing dialog should be dismissed
+ EXPECT_EQ(1, pairing_delegate.call_count_);
+ EXPECT_EQ(1, pairing_delegate.dismiss_count_);
+}
+
TEST_F(BluetoothExperimentalChromeOSTest, PairingFails) {
base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
fake_bluetooth_device_client_->SetSimulationIntervalMs(10);