summaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
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);