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

Unified Diff: device/bluetooth/bluetooth_experimental_chromeos_unittest.cc

Issue 14225017: Bluetooth: treat unpairable devices as Trusted/Paired (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indentation and log message Created 7 years, 8 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 7bd7c25fd3582280afff2caef24636298934ad15..a58585adbda25e7b27c7743a1f0c2da17545d55a 100644
--- a/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc
@@ -881,6 +881,56 @@ TEST_F(BluetoothExperimentalChromeOSTest, ForgetDevice) {
ASSERT_EQ(0U, devices.size());
}
+TEST_F(BluetoothExperimentalChromeOSTest, ForgetUnpairedDevice) {
+ GetAdapter();
+ DiscoverDevices();
+
+ BluetoothDevice* device = adapter_->GetDevice(
+ FakeBluetoothDeviceClient::kMicrosoftMouseAddress);
+ ASSERT_TRUE(device != NULL);
+ ASSERT_FALSE(device->IsPaired());
+
+ // Connect the device so it becomes trusted and remembered.
+ device->Connect(
+ NULL,
+ base::Bind(&BluetoothExperimentalChromeOSTest::Callback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback,
+ base::Unretained(this)));
+
+ ASSERT_EQ(1, callback_count_);
+ ASSERT_EQ(0, error_callback_count_);
+ callback_count_ = 0;
+
+ ASSERT_TRUE(device->IsConnected());
+ ASSERT_FALSE(device->IsConnecting());
+
+ // Make sure the trusted property has been set to true.
+ FakeBluetoothDeviceClient::Properties* properties =
+ fake_bluetooth_device_client_->GetProperties(
+ dbus::ObjectPath(FakeBluetoothDeviceClient::kMicrosoftMousePath));
+ ASSERT_TRUE(properties->trusted.value());
+
+ // Install an observer; expect the DeviceRemoved method to be called
+ // with the device we remove.
+ TestObserver observer(adapter_);
+ adapter_->AddObserver(&observer);
+
+ device->Forget(
+ base::Bind(&BluetoothExperimentalChromeOSTest::ErrorCallback,
+ base::Unretained(this)));
+ EXPECT_EQ(0, error_callback_count_);
+
+ EXPECT_EQ(1, observer.device_removed_count_);
+ EXPECT_EQ(FakeBluetoothDeviceClient::kMicrosoftMouseAddress,
+ observer.last_device_address_);
+
+ // GetDevices shouldn't return the device either.
+ device = adapter_->GetDevice(
+ FakeBluetoothDeviceClient::kMicrosoftMouseAddress);
+ EXPECT_FALSE(device != NULL);
+}
+
TEST_F(BluetoothExperimentalChromeOSTest, ConnectPairedDevice) {
GetAdapter();
@@ -940,6 +990,12 @@ TEST_F(BluetoothExperimentalChromeOSTest, ConnectUnpairableDevice) {
EXPECT_TRUE(device->IsConnected());
EXPECT_FALSE(device->IsConnecting());
+
+ // Make sure the trusted property has been set to true.
+ FakeBluetoothDeviceClient::Properties* properties =
+ fake_bluetooth_device_client_->GetProperties(
+ dbus::ObjectPath(FakeBluetoothDeviceClient::kMicrosoftMousePath));
+ EXPECT_TRUE(properties->trusted.value());
}
TEST_F(BluetoothExperimentalChromeOSTest, ConnectConnectedDevice) {
« 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