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

Unified Diff: device/bluetooth/bluetooth_experimental_chromeos_unittest.cc

Issue 15016004: Bluetooth: Parse the bluez.Error.Failed on pairing error. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 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_experimental_chromeos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_experimental_chromeos_unittest.cc
diff --git a/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc b/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc
index afd8325a1ed62c274b9720892f3b49825885136e..0dc3ad5e81ca0839cf7729e008bdb3459747bed2 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);
« no previous file with comments | « device/bluetooth/bluetooth_device_experimental_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698