| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
| 10 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 int request_passkey_count_; | 132 int request_passkey_count_; |
| 133 int display_pincode_count_; | 133 int display_pincode_count_; |
| 134 int display_passkey_count_; | 134 int display_passkey_count_; |
| 135 int keys_entered_count_; | 135 int keys_entered_count_; |
| 136 int confirm_passkey_count_; | 136 int confirm_passkey_count_; |
| 137 int authorize_pairing_count_; | 137 int authorize_pairing_count_; |
| 138 uint32 last_passkey_; | 138 uint32 last_passkey_; |
| 139 uint32 last_entered_; | 139 uint32 last_entered_; |
| 140 std::string last_pincode_; | 140 std::string last_pincode_; |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 // Some tests use a message loop since background processing is simulated; | 143 // Some tests use a message loop since background processing is simulated; |
| 144 // break out of those loops. | 144 // break out of those loops. |
| 145 void QuitMessageLoop() { | 145 void QuitMessageLoop() { |
| 146 if (base::MessageLoop::current() && | 146 if (base::MessageLoop::current() && |
| 147 base::MessageLoop::current()->is_running()) | 147 base::MessageLoop::current()->is_running()) { |
| 148 base::MessageLoop::current()->Quit(); | 148 base::MessageLoop::current()->Quit(); |
| 149 } | 149 } |
| 150 } |
| 150 }; | 151 }; |
| 151 | 152 |
| 152 class BluetoothChromeOSTest : public testing::Test { | 153 class BluetoothChromeOSTest : public testing::Test { |
| 153 public: | 154 public: |
| 154 void SetUp() override { | 155 void SetUp() override { |
| 155 scoped_ptr<DBusThreadManagerSetter> dbus_setter = | 156 scoped_ptr<DBusThreadManagerSetter> dbus_setter = |
| 156 chromeos::DBusThreadManager::GetSetterForTesting(); | 157 chromeos::DBusThreadManager::GetSetterForTesting(); |
| 157 // We need to initialize DBusThreadManager early to prevent | 158 // We need to initialize DBusThreadManager early to prevent |
| 158 // Bluetooth*::Create() methods from picking the real instead of fake | 159 // Bluetooth*::Create() methods from picking the real instead of fake |
| 159 // implementations. | 160 // implementations. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 187 ++iter) { | 188 ++iter) { |
| 188 BluetoothDiscoverySession* session = *iter; | 189 BluetoothDiscoverySession* session = *iter; |
| 189 if (!session->IsActive()) | 190 if (!session->IsActive()) |
| 190 continue; | 191 continue; |
| 191 callback_count_ = 0; | 192 callback_count_ = 0; |
| 192 session->Stop(GetCallback(), GetErrorCallback()); | 193 session->Stop(GetCallback(), GetErrorCallback()); |
| 193 message_loop_.Run(); | 194 message_loop_.Run(); |
| 194 ASSERT_EQ(1, callback_count_); | 195 ASSERT_EQ(1, callback_count_); |
| 195 } | 196 } |
| 196 discovery_sessions_.clear(); | 197 discovery_sessions_.clear(); |
| 197 adapter_ = NULL; | 198 adapter_ = nullptr; |
| 198 DBusThreadManager::Shutdown(); | 199 DBusThreadManager::Shutdown(); |
| 199 } | 200 } |
| 200 | 201 |
| 201 // Generic callbacks | 202 // Generic callbacks |
| 202 void Callback() { | 203 void Callback() { |
| 203 ++callback_count_; | 204 ++callback_count_; |
| 204 QuitMessageLoop(); | 205 QuitMessageLoop(); |
| 205 } | 206 } |
| 206 | 207 |
| 207 base::Closure GetCallback() { | 208 base::Closure GetCallback() { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 255 } |
| 255 | 256 |
| 256 void ErrorCompletionCallback(const std::string& error_message) { | 257 void ErrorCompletionCallback(const std::string& error_message) { |
| 257 ++error_callback_count_; | 258 ++error_callback_count_; |
| 258 QuitMessageLoop(); | 259 QuitMessageLoop(); |
| 259 } | 260 } |
| 260 | 261 |
| 261 // Call to fill the adapter_ member with a BluetoothAdapter instance. | 262 // Call to fill the adapter_ member with a BluetoothAdapter instance. |
| 262 void GetAdapter() { | 263 void GetAdapter() { |
| 263 adapter_ = new BluetoothAdapterChromeOS(); | 264 adapter_ = new BluetoothAdapterChromeOS(); |
| 264 ASSERT_TRUE(adapter_.get() != NULL); | 265 ASSERT_TRUE(adapter_.get() != nullptr); |
| 265 ASSERT_TRUE(adapter_->IsInitialized()); | 266 ASSERT_TRUE(adapter_->IsInitialized()); |
| 266 } | 267 } |
| 267 | 268 |
| 268 // Run a discovery phase until the named device is detected, or if the named | 269 // Run a discovery phase until the named device is detected, or if the named |
| 269 // device is not created, the discovery process ends without finding it. | 270 // device is not created, the discovery process ends without finding it. |
| 270 // | 271 // |
| 271 // The correct behavior of discovery is tested by the "Discovery" test case | 272 // The correct behavior of discovery is tested by the "Discovery" test case |
| 272 // without using this function. | 273 // without using this function. |
| 273 void DiscoverDevice(const std::string& address) { | 274 void DiscoverDevice(const std::string& address) { |
| 274 ASSERT_TRUE(adapter_.get() != NULL); | 275 ASSERT_TRUE(adapter_.get() != nullptr); |
| 275 ASSERT_TRUE(base::MessageLoop::current() != NULL); | 276 ASSERT_TRUE(base::MessageLoop::current() != nullptr); |
| 276 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 277 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 277 | 278 |
| 278 TestBluetoothAdapterObserver observer(adapter_); | 279 TestBluetoothAdapterObserver observer(adapter_); |
| 279 | 280 |
| 280 adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); | 281 adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); |
| 281 adapter_->StartDiscoverySession( | 282 adapter_->StartDiscoverySession( |
| 282 base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, | 283 base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, |
| 283 base::Unretained(this)), | 284 base::Unretained(this)), |
| 284 GetErrorCallback()); | 285 GetErrorCallback()); |
| 285 base::MessageLoop::current()->Run(); | 286 base::MessageLoop::current()->Run(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 enum BluetoothDevice::ConnectErrorCode last_connect_error_; | 324 enum BluetoothDevice::ConnectErrorCode last_connect_error_; |
| 324 std::string last_client_error_; | 325 std::string last_client_error_; |
| 325 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; | 326 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; |
| 326 BluetoothAdapterProfileChromeOS* adapter_profile_; | 327 BluetoothAdapterProfileChromeOS* adapter_profile_; |
| 327 | 328 |
| 328 private: | 329 private: |
| 329 // Some tests use a message loop since background processing is simulated; | 330 // Some tests use a message loop since background processing is simulated; |
| 330 // break out of those loops. | 331 // break out of those loops. |
| 331 void QuitMessageLoop() { | 332 void QuitMessageLoop() { |
| 332 if (base::MessageLoop::current() && | 333 if (base::MessageLoop::current() && |
| 333 base::MessageLoop::current()->is_running()) | 334 base::MessageLoop::current()->is_running()) { |
| 334 base::MessageLoop::current()->Quit(); | 335 base::MessageLoop::current()->Quit(); |
| 336 } |
| 335 } | 337 } |
| 336 }; | 338 }; |
| 337 | 339 |
| 338 TEST_F(BluetoothChromeOSTest, AlreadyPresent) { | 340 TEST_F(BluetoothChromeOSTest, AlreadyPresent) { |
| 339 GetAdapter(); | 341 GetAdapter(); |
| 340 | 342 |
| 341 // This verifies that the class gets the list of adapters when created; | 343 // This verifies that the class gets the list of adapters when created; |
| 342 // and initializes with an existing adapter if there is one. | 344 // and initializes with an existing adapter if there is one. |
| 343 EXPECT_TRUE(adapter_->IsPresent()); | 345 EXPECT_TRUE(adapter_->IsPresent()); |
| 344 EXPECT_FALSE(adapter_->IsPowered()); | 346 EXPECT_FALSE(adapter_->IsPowered()); |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 message_loop_.Run(); | 1393 message_loop_.Run(); |
| 1392 | 1394 |
| 1393 EXPECT_EQ(1, callback_count_); | 1395 EXPECT_EQ(1, callback_count_); |
| 1394 EXPECT_EQ(0, error_callback_count_); | 1396 EXPECT_EQ(0, error_callback_count_); |
| 1395 | 1397 |
| 1396 ASSERT_TRUE(adapter_->IsPowered()); | 1398 ASSERT_TRUE(adapter_->IsPowered()); |
| 1397 ASSERT_FALSE(adapter_->IsDiscovering()); | 1399 ASSERT_FALSE(adapter_->IsDiscovering()); |
| 1398 ASSERT_EQ((size_t)1, discovery_sessions_.size()); | 1400 ASSERT_EQ((size_t)1, discovery_sessions_.size()); |
| 1399 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); | 1401 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); |
| 1400 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), | 1402 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), |
| 1401 (BluetoothDiscoveryFilter*)NULL); | 1403 (BluetoothDiscoveryFilter*)nullptr); |
| 1402 | 1404 |
| 1403 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); | 1405 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); |
| 1404 EXPECT_EQ(nullptr, filter); | 1406 EXPECT_EQ(nullptr, filter); |
| 1405 } | 1407 } |
| 1406 | 1408 |
| 1407 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryFail) { | 1409 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryFail) { |
| 1408 // Test a simulated discovery session. | 1410 // Test a simulated discovery session. |
| 1409 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1411 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1410 GetAdapter(); | 1412 GetAdapter(); |
| 1411 | 1413 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 | 1532 |
| 1531 message_loop_.Run(); | 1533 message_loop_.Run(); |
| 1532 | 1534 |
| 1533 EXPECT_EQ(2, callback_count_); | 1535 EXPECT_EQ(2, callback_count_); |
| 1534 EXPECT_EQ(0, error_callback_count_); | 1536 EXPECT_EQ(0, error_callback_count_); |
| 1535 | 1537 |
| 1536 ASSERT_TRUE(adapter_->IsPowered()); | 1538 ASSERT_TRUE(adapter_->IsPowered()); |
| 1537 ASSERT_FALSE(adapter_->IsDiscovering()); | 1539 ASSERT_FALSE(adapter_->IsDiscovering()); |
| 1538 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); | 1540 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); |
| 1539 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), | 1541 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), |
| 1540 (BluetoothDiscoveryFilter*)NULL); | 1542 (BluetoothDiscoveryFilter*)nullptr); |
| 1541 ASSERT_FALSE(discovery_sessions_[1]->IsActive()); | 1543 ASSERT_FALSE(discovery_sessions_[1]->IsActive()); |
| 1542 ASSERT_EQ(discovery_sessions_[1]->GetDiscoveryFilter(), | 1544 ASSERT_EQ(discovery_sessions_[1]->GetDiscoveryFilter(), |
| 1543 (BluetoothDiscoveryFilter*)NULL); | 1545 (BluetoothDiscoveryFilter*)nullptr); |
| 1544 | 1546 |
| 1545 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); | 1547 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); |
| 1546 EXPECT_EQ(nullptr, filter); | 1548 EXPECT_EQ(nullptr, filter); |
| 1547 } | 1549 } |
| 1548 | 1550 |
| 1549 // Call StartFilteredDiscovery twice (2nd time while 1st call is still pending). | 1551 // Call StartFilteredDiscovery twice (2nd time while 1st call is still pending). |
| 1550 // Make the first SetDiscoveryFilter fail and the second one succeed. It should | 1552 // Make the first SetDiscoveryFilter fail and the second one succeed. It should |
| 1551 // end up with one active discovery session. | 1553 // end up with one active discovery session. |
| 1552 TEST_F(BluetoothChromeOSTest, | 1554 TEST_F(BluetoothChromeOSTest, |
| 1553 QueuedSetDiscoveryFilterBeforeStartDiscoveryFail) { | 1555 QueuedSetDiscoveryFilterBeforeStartDiscoveryFail) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 | 1636 |
| 1635 message_loop_.Run(); | 1637 message_loop_.Run(); |
| 1636 | 1638 |
| 1637 EXPECT_EQ(1, callback_count_); | 1639 EXPECT_EQ(1, callback_count_); |
| 1638 EXPECT_EQ(0, error_callback_count_); | 1640 EXPECT_EQ(0, error_callback_count_); |
| 1639 | 1641 |
| 1640 ASSERT_TRUE(adapter_->IsPowered()); | 1642 ASSERT_TRUE(adapter_->IsPowered()); |
| 1641 ASSERT_FALSE(adapter_->IsDiscovering()); | 1643 ASSERT_FALSE(adapter_->IsDiscovering()); |
| 1642 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); | 1644 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); |
| 1643 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), | 1645 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), |
| 1644 (BluetoothDiscoveryFilter*)NULL); | 1646 (BluetoothDiscoveryFilter*)nullptr); |
| 1645 | 1647 |
| 1646 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); | 1648 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); |
| 1647 EXPECT_EQ(nullptr, filter); | 1649 EXPECT_EQ(nullptr, filter); |
| 1648 } | 1650 } |
| 1649 | 1651 |
| 1650 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterAfterStartDiscovery) { | 1652 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterAfterStartDiscovery) { |
| 1651 // Test a simulated discovery session. | 1653 // Test a simulated discovery session. |
| 1652 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1654 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1653 GetAdapter(); | 1655 GetAdapter(); |
| 1654 | 1656 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1668 EXPECT_EQ(0, error_callback_count_); | 1670 EXPECT_EQ(0, error_callback_count_); |
| 1669 callback_count_ = 0; | 1671 callback_count_ = 0; |
| 1670 | 1672 |
| 1671 ASSERT_TRUE(adapter_->IsPowered()); | 1673 ASSERT_TRUE(adapter_->IsPowered()); |
| 1672 ASSERT_TRUE(adapter_->IsDiscovering()); | 1674 ASSERT_TRUE(adapter_->IsDiscovering()); |
| 1673 ASSERT_EQ((size_t)1, discovery_sessions_.size()); | 1675 ASSERT_EQ((size_t)1, discovery_sessions_.size()); |
| 1674 ASSERT_TRUE(discovery_sessions_[0]->IsActive()); | 1676 ASSERT_TRUE(discovery_sessions_[0]->IsActive()); |
| 1675 EXPECT_EQ(1, observer.discovering_changed_count()); | 1677 EXPECT_EQ(1, observer.discovering_changed_count()); |
| 1676 observer.Reset(); | 1678 observer.Reset(); |
| 1677 | 1679 |
| 1678 auto nullInstance = scoped_ptr<BluetoothDiscoveryFilter>(); | 1680 auto null_instance = scoped_ptr<BluetoothDiscoveryFilter>(); |
| 1679 nullInstance.reset(); | 1681 null_instance.reset(); |
| 1680 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), nullInstance.get()); | 1682 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), null_instance.get()); |
| 1681 | 1683 |
| 1682 auto filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); | 1684 auto filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); |
| 1683 EXPECT_EQ(nullptr, filter); | 1685 EXPECT_EQ(nullptr, filter); |
| 1684 | 1686 |
| 1685 BluetoothDiscoveryFilter* df = new BluetoothDiscoveryFilter( | 1687 BluetoothDiscoveryFilter* df = new BluetoothDiscoveryFilter( |
| 1686 BluetoothDiscoveryFilter::Transport::TRANSPORT_LE); | 1688 BluetoothDiscoveryFilter::Transport::TRANSPORT_LE); |
| 1687 df->SetRSSI(-60); | 1689 df->SetRSSI(-60); |
| 1688 df->AddUUID(BluetoothUUID("1000")); | 1690 df->AddUUID(BluetoothUUID("1000")); |
| 1689 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter(df); | 1691 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter(df); |
| 1690 | 1692 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1717 message_loop_.Run(); | 1719 message_loop_.Run(); |
| 1718 | 1720 |
| 1719 EXPECT_EQ(1, callback_count_); | 1721 EXPECT_EQ(1, callback_count_); |
| 1720 EXPECT_EQ(0, error_callback_count_); | 1722 EXPECT_EQ(0, error_callback_count_); |
| 1721 | 1723 |
| 1722 ASSERT_TRUE(adapter_->IsPowered()); | 1724 ASSERT_TRUE(adapter_->IsPowered()); |
| 1723 ASSERT_FALSE(adapter_->IsDiscovering()); | 1725 ASSERT_FALSE(adapter_->IsDiscovering()); |
| 1724 ASSERT_EQ((size_t)1, discovery_sessions_.size()); | 1726 ASSERT_EQ((size_t)1, discovery_sessions_.size()); |
| 1725 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); | 1727 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); |
| 1726 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), | 1728 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), |
| 1727 (BluetoothDiscoveryFilter*)NULL); | 1729 (BluetoothDiscoveryFilter*)nullptr); |
| 1728 | 1730 |
| 1729 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); | 1731 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); |
| 1730 EXPECT_EQ(nullptr, filter); | 1732 EXPECT_EQ(nullptr, filter); |
| 1731 } | 1733 } |
| 1732 | 1734 |
| 1733 // This unit test asserts that the basic reference counting, and filter merging | 1735 // This unit test asserts that the basic reference counting, and filter merging |
| 1734 // works correctly for discovery requests done via the BluetoothAdapter. | 1736 // works correctly for discovery requests done via the BluetoothAdapter. |
| 1735 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) { | 1737 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) { |
| 1736 GetAdapter(); | 1738 GetAdapter(); |
| 1737 adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, | 1739 adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2298 devices = adapter_->GetDevices(); | 2300 devices = adapter_->GetDevices(); |
| 2299 ASSERT_EQ(1U, devices.size()); | 2301 ASSERT_EQ(1U, devices.size()); |
| 2300 } | 2302 } |
| 2301 | 2303 |
| 2302 TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { | 2304 TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { |
| 2303 GetAdapter(); | 2305 GetAdapter(); |
| 2304 DiscoverDevices(); | 2306 DiscoverDevices(); |
| 2305 | 2307 |
| 2306 BluetoothDevice* device = adapter_->GetDevice( | 2308 BluetoothDevice* device = adapter_->GetDevice( |
| 2307 FakeBluetoothDeviceClient::kConnectUnpairableAddress); | 2309 FakeBluetoothDeviceClient::kConnectUnpairableAddress); |
| 2308 ASSERT_TRUE(device != NULL); | 2310 ASSERT_TRUE(device != nullptr); |
| 2309 ASSERT_FALSE(device->IsPaired()); | 2311 ASSERT_FALSE(device->IsPaired()); |
| 2310 | 2312 |
| 2311 // Connect the device so it becomes trusted and remembered. | 2313 // Connect the device so it becomes trusted and remembered. |
| 2312 device->Connect(NULL, GetCallback(), | 2314 device->Connect(nullptr, GetCallback(), |
| 2313 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2315 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2314 base::Unretained(this))); | 2316 base::Unretained(this))); |
| 2315 | 2317 |
| 2316 ASSERT_EQ(1, callback_count_); | 2318 ASSERT_EQ(1, callback_count_); |
| 2317 ASSERT_EQ(0, error_callback_count_); | 2319 ASSERT_EQ(0, error_callback_count_); |
| 2318 callback_count_ = 0; | 2320 callback_count_ = 0; |
| 2319 | 2321 |
| 2320 ASSERT_TRUE(device->IsConnected()); | 2322 ASSERT_TRUE(device->IsConnected()); |
| 2321 ASSERT_FALSE(device->IsConnecting()); | 2323 ASSERT_FALSE(device->IsConnecting()); |
| 2322 | 2324 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2333 device->Forget(GetErrorCallback()); | 2335 device->Forget(GetErrorCallback()); |
| 2334 EXPECT_EQ(0, error_callback_count_); | 2336 EXPECT_EQ(0, error_callback_count_); |
| 2335 | 2337 |
| 2336 EXPECT_EQ(1, observer.device_removed_count()); | 2338 EXPECT_EQ(1, observer.device_removed_count()); |
| 2337 EXPECT_EQ(FakeBluetoothDeviceClient::kConnectUnpairableAddress, | 2339 EXPECT_EQ(FakeBluetoothDeviceClient::kConnectUnpairableAddress, |
| 2338 observer.last_device_address()); | 2340 observer.last_device_address()); |
| 2339 | 2341 |
| 2340 // GetDevices shouldn't return the device either. | 2342 // GetDevices shouldn't return the device either. |
| 2341 device = adapter_->GetDevice( | 2343 device = adapter_->GetDevice( |
| 2342 FakeBluetoothDeviceClient::kConnectUnpairableAddress); | 2344 FakeBluetoothDeviceClient::kConnectUnpairableAddress); |
| 2343 EXPECT_FALSE(device != NULL); | 2345 EXPECT_FALSE(device != nullptr); |
| 2344 } | 2346 } |
| 2345 | 2347 |
| 2346 TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { | 2348 TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { |
| 2347 GetAdapter(); | 2349 GetAdapter(); |
| 2348 | 2350 |
| 2349 BluetoothDevice* device = adapter_->GetDevice( | 2351 BluetoothDevice* device = adapter_->GetDevice( |
| 2350 FakeBluetoothDeviceClient::kPairedDeviceAddress); | 2352 FakeBluetoothDeviceClient::kPairedDeviceAddress); |
| 2351 ASSERT_TRUE(device != NULL); | 2353 ASSERT_TRUE(device != nullptr); |
| 2352 ASSERT_TRUE(device->IsPaired()); | 2354 ASSERT_TRUE(device->IsPaired()); |
| 2353 | 2355 |
| 2354 TestBluetoothAdapterObserver observer(adapter_); | 2356 TestBluetoothAdapterObserver observer(adapter_); |
| 2355 | 2357 |
| 2356 // Connect without a pairing delegate; since the device is already Paired | 2358 // Connect without a pairing delegate; since the device is already Paired |
| 2357 // this should succeed and the device should become connected. | 2359 // this should succeed and the device should become connected. |
| 2358 device->Connect(NULL, GetCallback(), | 2360 device->Connect(nullptr, GetCallback(), |
| 2359 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2361 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2360 base::Unretained(this))); | 2362 base::Unretained(this))); |
| 2361 | 2363 |
| 2362 EXPECT_EQ(1, callback_count_); | 2364 EXPECT_EQ(1, callback_count_); |
| 2363 EXPECT_EQ(0, error_callback_count_); | 2365 EXPECT_EQ(0, error_callback_count_); |
| 2364 | 2366 |
| 2365 // Two changes for connecting, one for connected and one for for trusted | 2367 // Two changes for connecting, one for connected and one for for trusted |
| 2366 // after connecting. | 2368 // after connecting. |
| 2367 EXPECT_EQ(4, observer.device_changed_count()); | 2369 EXPECT_EQ(4, observer.device_changed_count()); |
| 2368 EXPECT_EQ(device, observer.last_device()); | 2370 EXPECT_EQ(device, observer.last_device()); |
| 2369 | 2371 |
| 2370 EXPECT_TRUE(device->IsConnected()); | 2372 EXPECT_TRUE(device->IsConnected()); |
| 2371 EXPECT_FALSE(device->IsConnecting()); | 2373 EXPECT_FALSE(device->IsConnecting()); |
| 2372 } | 2374 } |
| 2373 | 2375 |
| 2374 TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { | 2376 TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { |
| 2375 GetAdapter(); | 2377 GetAdapter(); |
| 2376 DiscoverDevices(); | 2378 DiscoverDevices(); |
| 2377 | 2379 |
| 2378 BluetoothDevice* device = adapter_->GetDevice( | 2380 BluetoothDevice* device = adapter_->GetDevice( |
| 2379 FakeBluetoothDeviceClient::kConnectUnpairableAddress); | 2381 FakeBluetoothDeviceClient::kConnectUnpairableAddress); |
| 2380 ASSERT_TRUE(device != NULL); | 2382 ASSERT_TRUE(device != nullptr); |
| 2381 ASSERT_FALSE(device->IsPaired()); | 2383 ASSERT_FALSE(device->IsPaired()); |
| 2382 | 2384 |
| 2383 TestBluetoothAdapterObserver observer(adapter_); | 2385 TestBluetoothAdapterObserver observer(adapter_); |
| 2384 | 2386 |
| 2385 // Connect without a pairing delegate; since the device does not require | 2387 // Connect without a pairing delegate; since the device does not require |
| 2386 // pairing, this should succeed and the device should become connected. | 2388 // pairing, this should succeed and the device should become connected. |
| 2387 device->Connect(NULL, GetCallback(), | 2389 device->Connect(nullptr, GetCallback(), |
| 2388 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2390 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2389 base::Unretained(this))); | 2391 base::Unretained(this))); |
| 2390 | 2392 |
| 2391 EXPECT_EQ(1, callback_count_); | 2393 EXPECT_EQ(1, callback_count_); |
| 2392 EXPECT_EQ(0, error_callback_count_); | 2394 EXPECT_EQ(0, error_callback_count_); |
| 2393 | 2395 |
| 2394 // Two changes for connecting, one for connected, one for for trusted after | 2396 // Two changes for connecting, one for connected, one for for trusted after |
| 2395 // connection, and one for the reconnect mode (IsConnectable). | 2397 // connection, and one for the reconnect mode (IsConnectable). |
| 2396 EXPECT_EQ(5, observer.device_changed_count()); | 2398 EXPECT_EQ(5, observer.device_changed_count()); |
| 2397 EXPECT_EQ(device, observer.last_device()); | 2399 EXPECT_EQ(device, observer.last_device()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2410 ASSERT_EQ(1U, uuids.size()); | 2412 ASSERT_EQ(1U, uuids.size()); |
| 2411 EXPECT_EQ(uuids[0], BluetoothUUID("1124")); | 2413 EXPECT_EQ(uuids[0], BluetoothUUID("1124")); |
| 2412 EXPECT_FALSE(device->IsConnectable()); | 2414 EXPECT_FALSE(device->IsConnectable()); |
| 2413 } | 2415 } |
| 2414 | 2416 |
| 2415 TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { | 2417 TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { |
| 2416 GetAdapter(); | 2418 GetAdapter(); |
| 2417 | 2419 |
| 2418 BluetoothDevice* device = adapter_->GetDevice( | 2420 BluetoothDevice* device = adapter_->GetDevice( |
| 2419 FakeBluetoothDeviceClient::kPairedDeviceAddress); | 2421 FakeBluetoothDeviceClient::kPairedDeviceAddress); |
| 2420 ASSERT_TRUE(device != NULL); | 2422 ASSERT_TRUE(device != nullptr); |
| 2421 ASSERT_TRUE(device->IsPaired()); | 2423 ASSERT_TRUE(device->IsPaired()); |
| 2422 | 2424 |
| 2423 device->Connect(NULL, GetCallback(), | 2425 device->Connect(nullptr, GetCallback(), |
| 2424 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2426 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2425 base::Unretained(this))); | 2427 base::Unretained(this))); |
| 2426 | 2428 |
| 2427 ASSERT_EQ(1, callback_count_); | 2429 ASSERT_EQ(1, callback_count_); |
| 2428 ASSERT_EQ(0, error_callback_count_); | 2430 ASSERT_EQ(0, error_callback_count_); |
| 2429 callback_count_ = 0; | 2431 callback_count_ = 0; |
| 2430 | 2432 |
| 2431 ASSERT_TRUE(device->IsConnected()); | 2433 ASSERT_TRUE(device->IsConnected()); |
| 2432 | 2434 |
| 2433 // Connect again; since the device is already Connected, this shouldn't do | 2435 // Connect again; since the device is already Connected, this shouldn't do |
| 2434 // anything to initiate the connection. | 2436 // anything to initiate the connection. |
| 2435 TestBluetoothAdapterObserver observer(adapter_); | 2437 TestBluetoothAdapterObserver observer(adapter_); |
| 2436 | 2438 |
| 2437 device->Connect(NULL, GetCallback(), | 2439 device->Connect(nullptr, GetCallback(), |
| 2438 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2440 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2439 base::Unretained(this))); | 2441 base::Unretained(this))); |
| 2440 | 2442 |
| 2441 EXPECT_EQ(1, callback_count_); | 2443 EXPECT_EQ(1, callback_count_); |
| 2442 EXPECT_EQ(0, error_callback_count_); | 2444 EXPECT_EQ(0, error_callback_count_); |
| 2443 | 2445 |
| 2444 // The observer will be called because Connecting will toggle true and false, | 2446 // The observer will be called because Connecting will toggle true and false, |
| 2445 // and the trusted property will be updated to true. | 2447 // and the trusted property will be updated to true. |
| 2446 EXPECT_EQ(3, observer.device_changed_count()); | 2448 EXPECT_EQ(3, observer.device_changed_count()); |
| 2447 | 2449 |
| 2448 EXPECT_TRUE(device->IsConnected()); | 2450 EXPECT_TRUE(device->IsConnected()); |
| 2449 EXPECT_FALSE(device->IsConnecting()); | 2451 EXPECT_FALSE(device->IsConnecting()); |
| 2450 } | 2452 } |
| 2451 | 2453 |
| 2452 TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { | 2454 TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { |
| 2453 GetAdapter(); | 2455 GetAdapter(); |
| 2454 DiscoverDevices(); | 2456 DiscoverDevices(); |
| 2455 | 2457 |
| 2456 BluetoothDevice* device = adapter_->GetDevice( | 2458 BluetoothDevice* device = adapter_->GetDevice( |
| 2457 FakeBluetoothDeviceClient::kLegacyAutopairAddress); | 2459 FakeBluetoothDeviceClient::kLegacyAutopairAddress); |
| 2458 ASSERT_TRUE(device != NULL); | 2460 ASSERT_TRUE(device != nullptr); |
| 2459 ASSERT_FALSE(device->IsPaired()); | 2461 ASSERT_FALSE(device->IsPaired()); |
| 2460 | 2462 |
| 2461 TestBluetoothAdapterObserver observer(adapter_); | 2463 TestBluetoothAdapterObserver observer(adapter_); |
| 2462 | 2464 |
| 2463 // Connect without a pairing delegate; since the device requires pairing, | 2465 // Connect without a pairing delegate; since the device requires pairing, |
| 2464 // this should fail with an error. | 2466 // this should fail with an error. |
| 2465 device->Connect(NULL, GetCallback(), | 2467 device->Connect(nullptr, GetCallback(), |
| 2466 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2468 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2467 base::Unretained(this))); | 2469 base::Unretained(this))); |
| 2468 | 2470 |
| 2469 EXPECT_EQ(0, callback_count_); | 2471 EXPECT_EQ(0, callback_count_); |
| 2470 EXPECT_EQ(1, error_callback_count_); | 2472 EXPECT_EQ(1, error_callback_count_); |
| 2471 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_); | 2473 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_); |
| 2472 | 2474 |
| 2473 EXPECT_EQ(2, observer.device_changed_count()); | 2475 EXPECT_EQ(2, observer.device_changed_count()); |
| 2474 | 2476 |
| 2475 EXPECT_FALSE(device->IsConnected()); | 2477 EXPECT_FALSE(device->IsConnected()); |
| 2476 EXPECT_FALSE(device->IsConnecting()); | 2478 EXPECT_FALSE(device->IsConnecting()); |
| 2477 } | 2479 } |
| 2478 | 2480 |
| 2479 TEST_F(BluetoothChromeOSTest, DisconnectDevice) { | 2481 TEST_F(BluetoothChromeOSTest, DisconnectDevice) { |
| 2480 GetAdapter(); | 2482 GetAdapter(); |
| 2481 | 2483 |
| 2482 BluetoothDevice* device = adapter_->GetDevice( | 2484 BluetoothDevice* device = adapter_->GetDevice( |
| 2483 FakeBluetoothDeviceClient::kPairedDeviceAddress); | 2485 FakeBluetoothDeviceClient::kPairedDeviceAddress); |
| 2484 ASSERT_TRUE(device != NULL); | 2486 ASSERT_TRUE(device != nullptr); |
| 2485 ASSERT_TRUE(device->IsPaired()); | 2487 ASSERT_TRUE(device->IsPaired()); |
| 2486 | 2488 |
| 2487 device->Connect(NULL, GetCallback(), | 2489 device->Connect(nullptr, GetCallback(), |
| 2488 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2490 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2489 base::Unretained(this))); | 2491 base::Unretained(this))); |
| 2490 | 2492 |
| 2491 ASSERT_EQ(1, callback_count_); | 2493 ASSERT_EQ(1, callback_count_); |
| 2492 ASSERT_EQ(0, error_callback_count_); | 2494 ASSERT_EQ(0, error_callback_count_); |
| 2493 callback_count_ = 0; | 2495 callback_count_ = 0; |
| 2494 | 2496 |
| 2495 ASSERT_TRUE(device->IsConnected()); | 2497 ASSERT_TRUE(device->IsConnected()); |
| 2496 ASSERT_FALSE(device->IsConnecting()); | 2498 ASSERT_FALSE(device->IsConnecting()); |
| 2497 | 2499 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2508 EXPECT_EQ(device, observer.last_device()); | 2510 EXPECT_EQ(device, observer.last_device()); |
| 2509 | 2511 |
| 2510 EXPECT_FALSE(device->IsConnected()); | 2512 EXPECT_FALSE(device->IsConnected()); |
| 2511 } | 2513 } |
| 2512 | 2514 |
| 2513 TEST_F(BluetoothChromeOSTest, DisconnectUnconnectedDevice) { | 2515 TEST_F(BluetoothChromeOSTest, DisconnectUnconnectedDevice) { |
| 2514 GetAdapter(); | 2516 GetAdapter(); |
| 2515 | 2517 |
| 2516 BluetoothDevice* device = adapter_->GetDevice( | 2518 BluetoothDevice* device = adapter_->GetDevice( |
| 2517 FakeBluetoothDeviceClient::kPairedDeviceAddress); | 2519 FakeBluetoothDeviceClient::kPairedDeviceAddress); |
| 2518 ASSERT_TRUE(device != NULL); | 2520 ASSERT_TRUE(device != nullptr); |
| 2519 ASSERT_TRUE(device->IsPaired()); | 2521 ASSERT_TRUE(device->IsPaired()); |
| 2520 ASSERT_FALSE(device->IsConnected()); | 2522 ASSERT_FALSE(device->IsConnected()); |
| 2521 | 2523 |
| 2522 // Disconnect the device, we should see the observer method fire and the | 2524 // Disconnect the device, we should see the observer method fire and the |
| 2523 // device get dropped. | 2525 // device get dropped. |
| 2524 TestBluetoothAdapterObserver observer(adapter_); | 2526 TestBluetoothAdapterObserver observer(adapter_); |
| 2525 | 2527 |
| 2526 device->Disconnect(GetCallback(), GetErrorCallback()); | 2528 device->Disconnect(GetCallback(), GetErrorCallback()); |
| 2527 | 2529 |
| 2528 EXPECT_EQ(0, callback_count_); | 2530 EXPECT_EQ(0, callback_count_); |
| 2529 EXPECT_EQ(1, error_callback_count_); | 2531 EXPECT_EQ(1, error_callback_count_); |
| 2530 | 2532 |
| 2531 EXPECT_EQ(0, observer.device_changed_count()); | 2533 EXPECT_EQ(0, observer.device_changed_count()); |
| 2532 | 2534 |
| 2533 EXPECT_FALSE(device->IsConnected()); | 2535 EXPECT_FALSE(device->IsConnected()); |
| 2534 } | 2536 } |
| 2535 | 2537 |
| 2536 TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) { | 2538 TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) { |
| 2537 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2539 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2538 | 2540 |
| 2539 GetAdapter(); | 2541 GetAdapter(); |
| 2540 DiscoverDevices(); | 2542 DiscoverDevices(); |
| 2541 | 2543 |
| 2542 // The Legacy Autopair device requires no PIN or Passkey to pair because | 2544 // The Legacy Autopair device requires no PIN or Passkey to pair because |
| 2543 // the daemon provides 0000 to the device for us. | 2545 // the daemon provides 0000 to the device for us. |
| 2544 BluetoothDevice* device = adapter_->GetDevice( | 2546 BluetoothDevice* device = adapter_->GetDevice( |
| 2545 FakeBluetoothDeviceClient::kLegacyAutopairAddress); | 2547 FakeBluetoothDeviceClient::kLegacyAutopairAddress); |
| 2546 ASSERT_TRUE(device != NULL); | 2548 ASSERT_TRUE(device != nullptr); |
| 2547 ASSERT_FALSE(device->IsPaired()); | 2549 ASSERT_FALSE(device->IsPaired()); |
| 2548 | 2550 |
| 2549 TestBluetoothAdapterObserver observer(adapter_); | 2551 TestBluetoothAdapterObserver observer(adapter_); |
| 2550 | 2552 |
| 2551 TestPairingDelegate pairing_delegate; | 2553 TestPairingDelegate pairing_delegate; |
| 2552 device->Connect(&pairing_delegate, GetCallback(), | 2554 device->Connect(&pairing_delegate, GetCallback(), |
| 2553 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2555 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2554 base::Unretained(this))); | 2556 base::Unretained(this))); |
| 2555 | 2557 |
| 2556 EXPECT_EQ(0, pairing_delegate.call_count_); | 2558 EXPECT_EQ(0, pairing_delegate.call_count_); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2587 | 2589 |
| 2588 TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) { | 2590 TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) { |
| 2589 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2591 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2590 | 2592 |
| 2591 GetAdapter(); | 2593 GetAdapter(); |
| 2592 DiscoverDevices(); | 2594 DiscoverDevices(); |
| 2593 | 2595 |
| 2594 // Requires that we display a randomly generated PIN on the screen. | 2596 // Requires that we display a randomly generated PIN on the screen. |
| 2595 BluetoothDevice* device = adapter_->GetDevice( | 2597 BluetoothDevice* device = adapter_->GetDevice( |
| 2596 FakeBluetoothDeviceClient::kDisplayPinCodeAddress); | 2598 FakeBluetoothDeviceClient::kDisplayPinCodeAddress); |
| 2597 ASSERT_TRUE(device != NULL); | 2599 ASSERT_TRUE(device != nullptr); |
| 2598 ASSERT_FALSE(device->IsPaired()); | 2600 ASSERT_FALSE(device->IsPaired()); |
| 2599 | 2601 |
| 2600 TestBluetoothAdapterObserver observer(adapter_); | 2602 TestBluetoothAdapterObserver observer(adapter_); |
| 2601 | 2603 |
| 2602 TestPairingDelegate pairing_delegate; | 2604 TestPairingDelegate pairing_delegate; |
| 2603 device->Connect(&pairing_delegate, GetCallback(), | 2605 device->Connect(&pairing_delegate, GetCallback(), |
| 2604 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2606 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2605 base::Unretained(this))); | 2607 base::Unretained(this))); |
| 2606 | 2608 |
| 2607 EXPECT_EQ(1, pairing_delegate.call_count_); | 2609 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { | 2643 TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { |
| 2642 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2644 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2643 | 2645 |
| 2644 GetAdapter(); | 2646 GetAdapter(); |
| 2645 DiscoverDevices(); | 2647 DiscoverDevices(); |
| 2646 | 2648 |
| 2647 // Requires that we display a randomly generated Passkey on the screen, | 2649 // Requires that we display a randomly generated Passkey on the screen, |
| 2648 // and notifies us as it's typed in. | 2650 // and notifies us as it's typed in. |
| 2649 BluetoothDevice* device = adapter_->GetDevice( | 2651 BluetoothDevice* device = adapter_->GetDevice( |
| 2650 FakeBluetoothDeviceClient::kDisplayPasskeyAddress); | 2652 FakeBluetoothDeviceClient::kDisplayPasskeyAddress); |
| 2651 ASSERT_TRUE(device != NULL); | 2653 ASSERT_TRUE(device != nullptr); |
| 2652 ASSERT_FALSE(device->IsPaired()); | 2654 ASSERT_FALSE(device->IsPaired()); |
| 2653 | 2655 |
| 2654 TestBluetoothAdapterObserver observer(adapter_); | 2656 TestBluetoothAdapterObserver observer(adapter_); |
| 2655 | 2657 |
| 2656 TestPairingDelegate pairing_delegate; | 2658 TestPairingDelegate pairing_delegate; |
| 2657 device->Connect(&pairing_delegate, GetCallback(), | 2659 device->Connect(&pairing_delegate, GetCallback(), |
| 2658 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2660 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2659 base::Unretained(this))); | 2661 base::Unretained(this))); |
| 2660 | 2662 |
| 2661 // One call for DisplayPasskey() and one for KeysEntered(). | 2663 // One call for DisplayPasskey() and one for KeysEntered(). |
| 2662 EXPECT_EQ(2, pairing_delegate.call_count_); | 2664 EXPECT_EQ(2, pairing_delegate.call_count_); |
| 2663 EXPECT_EQ(1, pairing_delegate.display_passkey_count_); | 2665 EXPECT_EQ(1, pairing_delegate.display_passkey_count_); |
| 2664 EXPECT_EQ(123456U, pairing_delegate.last_passkey_); | 2666 EXPECT_EQ(123456U, pairing_delegate.last_passkey_); |
| 2665 EXPECT_EQ(1, pairing_delegate.keys_entered_count_); | 2667 EXPECT_EQ(1, pairing_delegate.keys_entered_count_); |
| 2666 EXPECT_EQ(0U, pairing_delegate.last_entered_); | 2668 EXPECT_EQ(0U, pairing_delegate.last_entered_); |
| 2667 | 2669 |
| 2668 EXPECT_TRUE(device->IsConnecting()); | 2670 EXPECT_TRUE(device->IsConnecting()); |
| 2669 | 2671 |
| 2670 // One call to KeysEntered() for each key, including [enter]. | 2672 // One call to KeysEntered() for each key, including [enter]. |
| 2671 for(int i = 1; i <= 7; ++i) { | 2673 for (int i = 1; i <= 7; ++i) { |
| 2672 message_loop_.Run(); | 2674 message_loop_.Run(); |
| 2673 | 2675 |
| 2674 EXPECT_EQ(2 + i, pairing_delegate.call_count_); | 2676 EXPECT_EQ(2 + i, pairing_delegate.call_count_); |
| 2675 EXPECT_EQ(1 + i, pairing_delegate.keys_entered_count_); | 2677 EXPECT_EQ(1 + i, pairing_delegate.keys_entered_count_); |
| 2676 EXPECT_EQ(static_cast<uint32_t>(i), pairing_delegate.last_entered_); | 2678 EXPECT_EQ(static_cast<uint32_t>(i), pairing_delegate.last_entered_); |
| 2677 } | 2679 } |
| 2678 | 2680 |
| 2679 message_loop_.Run(); | 2681 message_loop_.Run(); |
| 2680 | 2682 |
| 2681 // 8 KeysEntered notifications (0 to 7, inclusive) and one aditional call for | 2683 // 8 KeysEntered notifications (0 to 7, inclusive) and one aditional call for |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2715 | 2717 |
| 2716 TEST_F(BluetoothChromeOSTest, PairRequestPinCode) { | 2718 TEST_F(BluetoothChromeOSTest, PairRequestPinCode) { |
| 2717 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2719 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2718 | 2720 |
| 2719 GetAdapter(); | 2721 GetAdapter(); |
| 2720 DiscoverDevices(); | 2722 DiscoverDevices(); |
| 2721 | 2723 |
| 2722 // Requires that the user enters a PIN for them. | 2724 // Requires that the user enters a PIN for them. |
| 2723 BluetoothDevice* device = adapter_->GetDevice( | 2725 BluetoothDevice* device = adapter_->GetDevice( |
| 2724 FakeBluetoothDeviceClient::kRequestPinCodeAddress); | 2726 FakeBluetoothDeviceClient::kRequestPinCodeAddress); |
| 2725 ASSERT_TRUE(device != NULL); | 2727 ASSERT_TRUE(device != nullptr); |
| 2726 ASSERT_FALSE(device->IsPaired()); | 2728 ASSERT_FALSE(device->IsPaired()); |
| 2727 | 2729 |
| 2728 TestBluetoothAdapterObserver observer(adapter_); | 2730 TestBluetoothAdapterObserver observer(adapter_); |
| 2729 | 2731 |
| 2730 TestPairingDelegate pairing_delegate; | 2732 TestPairingDelegate pairing_delegate; |
| 2731 device->Connect(&pairing_delegate, GetCallback(), | 2733 device->Connect(&pairing_delegate, GetCallback(), |
| 2732 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2734 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2733 base::Unretained(this))); | 2735 base::Unretained(this))); |
| 2734 | 2736 |
| 2735 EXPECT_EQ(1, pairing_delegate.call_count_); | 2737 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2769 | 2771 |
| 2770 TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) { | 2772 TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) { |
| 2771 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2773 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2772 | 2774 |
| 2773 GetAdapter(); | 2775 GetAdapter(); |
| 2774 DiscoverDevices(); | 2776 DiscoverDevices(); |
| 2775 | 2777 |
| 2776 // Requests that we confirm a displayed passkey. | 2778 // Requests that we confirm a displayed passkey. |
| 2777 BluetoothDevice* device = adapter_->GetDevice( | 2779 BluetoothDevice* device = adapter_->GetDevice( |
| 2778 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); | 2780 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); |
| 2779 ASSERT_TRUE(device != NULL); | 2781 ASSERT_TRUE(device != nullptr); |
| 2780 ASSERT_FALSE(device->IsPaired()); | 2782 ASSERT_FALSE(device->IsPaired()); |
| 2781 | 2783 |
| 2782 TestBluetoothAdapterObserver observer(adapter_); | 2784 TestBluetoothAdapterObserver observer(adapter_); |
| 2783 | 2785 |
| 2784 TestPairingDelegate pairing_delegate; | 2786 TestPairingDelegate pairing_delegate; |
| 2785 device->Connect(&pairing_delegate, GetCallback(), | 2787 device->Connect(&pairing_delegate, GetCallback(), |
| 2786 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2788 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2787 base::Unretained(this))); | 2789 base::Unretained(this))); |
| 2788 | 2790 |
| 2789 EXPECT_EQ(1, pairing_delegate.call_count_); | 2791 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2821 TEST_F(BluetoothChromeOSTest, PairRequestPasskey) { | 2823 TEST_F(BluetoothChromeOSTest, PairRequestPasskey) { |
| 2822 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2824 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2823 | 2825 |
| 2824 GetAdapter(); | 2826 GetAdapter(); |
| 2825 DiscoverDevices(); | 2827 DiscoverDevices(); |
| 2826 | 2828 |
| 2827 // Requires that the user enters a Passkey, this would be some kind of | 2829 // Requires that the user enters a Passkey, this would be some kind of |
| 2828 // device that has a display, but doesn't use "just works" - maybe a car? | 2830 // device that has a display, but doesn't use "just works" - maybe a car? |
| 2829 BluetoothDevice* device = adapter_->GetDevice( | 2831 BluetoothDevice* device = adapter_->GetDevice( |
| 2830 FakeBluetoothDeviceClient::kRequestPasskeyAddress); | 2832 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 2831 ASSERT_TRUE(device != NULL); | 2833 ASSERT_TRUE(device != nullptr); |
| 2832 ASSERT_FALSE(device->IsPaired()); | 2834 ASSERT_FALSE(device->IsPaired()); |
| 2833 | 2835 |
| 2834 TestBluetoothAdapterObserver observer(adapter_); | 2836 TestBluetoothAdapterObserver observer(adapter_); |
| 2835 | 2837 |
| 2836 TestPairingDelegate pairing_delegate; | 2838 TestPairingDelegate pairing_delegate; |
| 2837 device->Connect(&pairing_delegate, GetCallback(), | 2839 device->Connect(&pairing_delegate, GetCallback(), |
| 2838 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2840 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2839 base::Unretained(this))); | 2841 base::Unretained(this))); |
| 2840 | 2842 |
| 2841 EXPECT_EQ(1, pairing_delegate.call_count_); | 2843 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2872 TEST_F(BluetoothChromeOSTest, PairJustWorks) { | 2874 TEST_F(BluetoothChromeOSTest, PairJustWorks) { |
| 2873 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2875 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2874 | 2876 |
| 2875 GetAdapter(); | 2877 GetAdapter(); |
| 2876 DiscoverDevices(); | 2878 DiscoverDevices(); |
| 2877 | 2879 |
| 2878 // Uses just-works pairing, since this is an outgoing pairing, no delegate | 2880 // Uses just-works pairing, since this is an outgoing pairing, no delegate |
| 2879 // interaction is required. | 2881 // interaction is required. |
| 2880 BluetoothDevice* device = adapter_->GetDevice( | 2882 BluetoothDevice* device = adapter_->GetDevice( |
| 2881 FakeBluetoothDeviceClient::kJustWorksAddress); | 2883 FakeBluetoothDeviceClient::kJustWorksAddress); |
| 2882 ASSERT_TRUE(device != NULL); | 2884 ASSERT_TRUE(device != nullptr); |
| 2883 ASSERT_FALSE(device->IsPaired()); | 2885 ASSERT_FALSE(device->IsPaired()); |
| 2884 | 2886 |
| 2885 TestBluetoothAdapterObserver observer(adapter_); | 2887 TestBluetoothAdapterObserver observer(adapter_); |
| 2886 | 2888 |
| 2887 TestPairingDelegate pairing_delegate; | 2889 TestPairingDelegate pairing_delegate; |
| 2888 device->Connect(&pairing_delegate, GetCallback(), | 2890 device->Connect(&pairing_delegate, GetCallback(), |
| 2889 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2891 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2890 base::Unretained(this))); | 2892 base::Unretained(this))); |
| 2891 | 2893 |
| 2892 EXPECT_EQ(0, pairing_delegate.call_count_); | 2894 EXPECT_EQ(0, pairing_delegate.call_count_); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2917 } | 2919 } |
| 2918 | 2920 |
| 2919 TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { | 2921 TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { |
| 2920 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2922 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2921 | 2923 |
| 2922 GetAdapter(); | 2924 GetAdapter(); |
| 2923 DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); | 2925 DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); |
| 2924 | 2926 |
| 2925 BluetoothDevice* device = adapter_->GetDevice( | 2927 BluetoothDevice* device = adapter_->GetDevice( |
| 2926 FakeBluetoothDeviceClient::kUnpairableDeviceAddress); | 2928 FakeBluetoothDeviceClient::kUnpairableDeviceAddress); |
| 2927 ASSERT_TRUE(device != NULL); | 2929 ASSERT_TRUE(device != nullptr); |
| 2928 ASSERT_FALSE(device->IsPaired()); | 2930 ASSERT_FALSE(device->IsPaired()); |
| 2929 | 2931 |
| 2930 TestBluetoothAdapterObserver observer(adapter_); | 2932 TestBluetoothAdapterObserver observer(adapter_); |
| 2931 | 2933 |
| 2932 TestPairingDelegate pairing_delegate; | 2934 TestPairingDelegate pairing_delegate; |
| 2933 device->Connect(&pairing_delegate, GetCallback(), | 2935 device->Connect(&pairing_delegate, GetCallback(), |
| 2934 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2936 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2935 base::Unretained(this))); | 2937 base::Unretained(this))); |
| 2936 | 2938 |
| 2937 EXPECT_EQ(0, pairing_delegate.call_count_); | 2939 EXPECT_EQ(0, pairing_delegate.call_count_); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2952 | 2954 |
| 2953 TEST_F(BluetoothChromeOSTest, PairingFails) { | 2955 TEST_F(BluetoothChromeOSTest, PairingFails) { |
| 2954 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2956 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2955 | 2957 |
| 2956 GetAdapter(); | 2958 GetAdapter(); |
| 2957 DiscoverDevice(FakeBluetoothDeviceClient::kVanishingDeviceAddress); | 2959 DiscoverDevice(FakeBluetoothDeviceClient::kVanishingDeviceAddress); |
| 2958 | 2960 |
| 2959 // The vanishing device times out during pairing | 2961 // The vanishing device times out during pairing |
| 2960 BluetoothDevice* device = adapter_->GetDevice( | 2962 BluetoothDevice* device = adapter_->GetDevice( |
| 2961 FakeBluetoothDeviceClient::kVanishingDeviceAddress); | 2963 FakeBluetoothDeviceClient::kVanishingDeviceAddress); |
| 2962 ASSERT_TRUE(device != NULL); | 2964 ASSERT_TRUE(device != nullptr); |
| 2963 ASSERT_FALSE(device->IsPaired()); | 2965 ASSERT_FALSE(device->IsPaired()); |
| 2964 | 2966 |
| 2965 TestBluetoothAdapterObserver observer(adapter_); | 2967 TestBluetoothAdapterObserver observer(adapter_); |
| 2966 | 2968 |
| 2967 TestPairingDelegate pairing_delegate; | 2969 TestPairingDelegate pairing_delegate; |
| 2968 device->Connect(&pairing_delegate, GetCallback(), | 2970 device->Connect(&pairing_delegate, GetCallback(), |
| 2969 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 2971 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 2970 base::Unretained(this))); | 2972 base::Unretained(this))); |
| 2971 | 2973 |
| 2972 EXPECT_EQ(0, pairing_delegate.call_count_); | 2974 EXPECT_EQ(0, pairing_delegate.call_count_); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2988 TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { | 2990 TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { |
| 2989 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2991 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2990 | 2992 |
| 2991 GetAdapter(); | 2993 GetAdapter(); |
| 2992 DiscoverDevices(); | 2994 DiscoverDevices(); |
| 2993 | 2995 |
| 2994 // Everything seems to go according to plan with the unconnectable device; | 2996 // Everything seems to go according to plan with the unconnectable device; |
| 2995 // it pairs, but then you can't make connections to it after. | 2997 // it pairs, but then you can't make connections to it after. |
| 2996 BluetoothDevice* device = adapter_->GetDevice( | 2998 BluetoothDevice* device = adapter_->GetDevice( |
| 2997 FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); | 2999 FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); |
| 2998 ASSERT_TRUE(device != NULL); | 3000 ASSERT_TRUE(device != nullptr); |
| 2999 ASSERT_FALSE(device->IsPaired()); | 3001 ASSERT_FALSE(device->IsPaired()); |
| 3000 | 3002 |
| 3001 TestBluetoothAdapterObserver observer(adapter_); | 3003 TestBluetoothAdapterObserver observer(adapter_); |
| 3002 | 3004 |
| 3003 TestPairingDelegate pairing_delegate; | 3005 TestPairingDelegate pairing_delegate; |
| 3004 device->Connect(&pairing_delegate, GetCallback(), | 3006 device->Connect(&pairing_delegate, GetCallback(), |
| 3005 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 3007 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 3006 base::Unretained(this))); | 3008 base::Unretained(this))); |
| 3007 | 3009 |
| 3008 EXPECT_EQ(0, pairing_delegate.call_count_); | 3010 EXPECT_EQ(0, pairing_delegate.call_count_); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3035 | 3037 |
| 3036 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { | 3038 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { |
| 3037 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3039 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3038 | 3040 |
| 3039 GetAdapter(); | 3041 GetAdapter(); |
| 3040 DiscoverDevices(); | 3042 DiscoverDevices(); |
| 3041 | 3043 |
| 3042 // Reject the pairing after we receive a request for the PIN code. | 3044 // Reject the pairing after we receive a request for the PIN code. |
| 3043 BluetoothDevice* device = adapter_->GetDevice( | 3045 BluetoothDevice* device = adapter_->GetDevice( |
| 3044 FakeBluetoothDeviceClient::kRequestPinCodeAddress); | 3046 FakeBluetoothDeviceClient::kRequestPinCodeAddress); |
| 3045 ASSERT_TRUE(device != NULL); | 3047 ASSERT_TRUE(device != nullptr); |
| 3046 ASSERT_FALSE(device->IsPaired()); | 3048 ASSERT_FALSE(device->IsPaired()); |
| 3047 | 3049 |
| 3048 TestBluetoothAdapterObserver observer(adapter_); | 3050 TestBluetoothAdapterObserver observer(adapter_); |
| 3049 | 3051 |
| 3050 TestPairingDelegate pairing_delegate; | 3052 TestPairingDelegate pairing_delegate; |
| 3051 device->Connect(&pairing_delegate, GetCallback(), | 3053 device->Connect(&pairing_delegate, GetCallback(), |
| 3052 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 3054 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 3053 base::Unretained(this))); | 3055 base::Unretained(this))); |
| 3054 | 3056 |
| 3055 EXPECT_EQ(1, pairing_delegate.call_count_); | 3057 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3073 | 3075 |
| 3074 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { | 3076 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { |
| 3075 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3077 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3076 | 3078 |
| 3077 GetAdapter(); | 3079 GetAdapter(); |
| 3078 DiscoverDevices(); | 3080 DiscoverDevices(); |
| 3079 | 3081 |
| 3080 // Cancel the pairing after we receive a request for the PIN code. | 3082 // Cancel the pairing after we receive a request for the PIN code. |
| 3081 BluetoothDevice* device = adapter_->GetDevice( | 3083 BluetoothDevice* device = adapter_->GetDevice( |
| 3082 FakeBluetoothDeviceClient::kRequestPinCodeAddress); | 3084 FakeBluetoothDeviceClient::kRequestPinCodeAddress); |
| 3083 ASSERT_TRUE(device != NULL); | 3085 ASSERT_TRUE(device != nullptr); |
| 3084 ASSERT_FALSE(device->IsPaired()); | 3086 ASSERT_FALSE(device->IsPaired()); |
| 3085 | 3087 |
| 3086 TestBluetoothAdapterObserver observer(adapter_); | 3088 TestBluetoothAdapterObserver observer(adapter_); |
| 3087 | 3089 |
| 3088 TestPairingDelegate pairing_delegate; | 3090 TestPairingDelegate pairing_delegate; |
| 3089 device->Connect(&pairing_delegate, GetCallback(), | 3091 device->Connect(&pairing_delegate, GetCallback(), |
| 3090 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 3092 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 3091 base::Unretained(this))); | 3093 base::Unretained(this))); |
| 3092 | 3094 |
| 3093 EXPECT_EQ(1, pairing_delegate.call_count_); | 3095 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3111 | 3113 |
| 3112 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { | 3114 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { |
| 3113 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3115 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3114 | 3116 |
| 3115 GetAdapter(); | 3117 GetAdapter(); |
| 3116 DiscoverDevices(); | 3118 DiscoverDevices(); |
| 3117 | 3119 |
| 3118 // Reject the pairing after we receive a request for the passkey. | 3120 // Reject the pairing after we receive a request for the passkey. |
| 3119 BluetoothDevice* device = adapter_->GetDevice( | 3121 BluetoothDevice* device = adapter_->GetDevice( |
| 3120 FakeBluetoothDeviceClient::kRequestPasskeyAddress); | 3122 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 3121 ASSERT_TRUE(device != NULL); | 3123 ASSERT_TRUE(device != nullptr); |
| 3122 ASSERT_FALSE(device->IsPaired()); | 3124 ASSERT_FALSE(device->IsPaired()); |
| 3123 | 3125 |
| 3124 TestBluetoothAdapterObserver observer(adapter_); | 3126 TestBluetoothAdapterObserver observer(adapter_); |
| 3125 | 3127 |
| 3126 TestPairingDelegate pairing_delegate; | 3128 TestPairingDelegate pairing_delegate; |
| 3127 device->Connect(&pairing_delegate, GetCallback(), | 3129 device->Connect(&pairing_delegate, GetCallback(), |
| 3128 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 3130 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 3129 base::Unretained(this))); | 3131 base::Unretained(this))); |
| 3130 | 3132 |
| 3131 EXPECT_EQ(1, pairing_delegate.call_count_); | 3133 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3149 | 3151 |
| 3150 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { | 3152 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { |
| 3151 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3153 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3152 | 3154 |
| 3153 GetAdapter(); | 3155 GetAdapter(); |
| 3154 DiscoverDevices(); | 3156 DiscoverDevices(); |
| 3155 | 3157 |
| 3156 // Cancel the pairing after we receive a request for the passkey. | 3158 // Cancel the pairing after we receive a request for the passkey. |
| 3157 BluetoothDevice* device = adapter_->GetDevice( | 3159 BluetoothDevice* device = adapter_->GetDevice( |
| 3158 FakeBluetoothDeviceClient::kRequestPasskeyAddress); | 3160 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 3159 ASSERT_TRUE(device != NULL); | 3161 ASSERT_TRUE(device != nullptr); |
| 3160 ASSERT_FALSE(device->IsPaired()); | 3162 ASSERT_FALSE(device->IsPaired()); |
| 3161 | 3163 |
| 3162 TestBluetoothAdapterObserver observer(adapter_); | 3164 TestBluetoothAdapterObserver observer(adapter_); |
| 3163 | 3165 |
| 3164 TestPairingDelegate pairing_delegate; | 3166 TestPairingDelegate pairing_delegate; |
| 3165 device->Connect(&pairing_delegate, GetCallback(), | 3167 device->Connect(&pairing_delegate, GetCallback(), |
| 3166 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 3168 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 3167 base::Unretained(this))); | 3169 base::Unretained(this))); |
| 3168 | 3170 |
| 3169 EXPECT_EQ(1, pairing_delegate.call_count_); | 3171 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3187 | 3189 |
| 3188 TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { | 3190 TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { |
| 3189 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3191 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3190 | 3192 |
| 3191 GetAdapter(); | 3193 GetAdapter(); |
| 3192 DiscoverDevices(); | 3194 DiscoverDevices(); |
| 3193 | 3195 |
| 3194 // Reject the pairing after we receive a request for passkey confirmation. | 3196 // Reject the pairing after we receive a request for passkey confirmation. |
| 3195 BluetoothDevice* device = adapter_->GetDevice( | 3197 BluetoothDevice* device = adapter_->GetDevice( |
| 3196 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); | 3198 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); |
| 3197 ASSERT_TRUE(device != NULL); | 3199 ASSERT_TRUE(device != nullptr); |
| 3198 ASSERT_FALSE(device->IsPaired()); | 3200 ASSERT_FALSE(device->IsPaired()); |
| 3199 | 3201 |
| 3200 TestBluetoothAdapterObserver observer(adapter_); | 3202 TestBluetoothAdapterObserver observer(adapter_); |
| 3201 | 3203 |
| 3202 TestPairingDelegate pairing_delegate; | 3204 TestPairingDelegate pairing_delegate; |
| 3203 device->Connect(&pairing_delegate, GetCallback(), | 3205 device->Connect(&pairing_delegate, GetCallback(), |
| 3204 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 3206 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 3205 base::Unretained(this))); | 3207 base::Unretained(this))); |
| 3206 | 3208 |
| 3207 EXPECT_EQ(1, pairing_delegate.call_count_); | 3209 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3225 | 3227 |
| 3226 TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { | 3228 TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { |
| 3227 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3229 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3228 | 3230 |
| 3229 GetAdapter(); | 3231 GetAdapter(); |
| 3230 DiscoverDevices(); | 3232 DiscoverDevices(); |
| 3231 | 3233 |
| 3232 // Cancel the pairing after we receive a request for the passkey. | 3234 // Cancel the pairing after we receive a request for the passkey. |
| 3233 BluetoothDevice* device = adapter_->GetDevice( | 3235 BluetoothDevice* device = adapter_->GetDevice( |
| 3234 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); | 3236 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); |
| 3235 ASSERT_TRUE(device != NULL); | 3237 ASSERT_TRUE(device != nullptr); |
| 3236 ASSERT_FALSE(device->IsPaired()); | 3238 ASSERT_FALSE(device->IsPaired()); |
| 3237 | 3239 |
| 3238 TestBluetoothAdapterObserver observer(adapter_); | 3240 TestBluetoothAdapterObserver observer(adapter_); |
| 3239 | 3241 |
| 3240 TestPairingDelegate pairing_delegate; | 3242 TestPairingDelegate pairing_delegate; |
| 3241 device->Connect(&pairing_delegate, GetCallback(), | 3243 device->Connect(&pairing_delegate, GetCallback(), |
| 3242 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 3244 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 3243 base::Unretained(this))); | 3245 base::Unretained(this))); |
| 3244 | 3246 |
| 3245 EXPECT_EQ(1, pairing_delegate.call_count_); | 3247 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3263 | 3265 |
| 3264 TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { | 3266 TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { |
| 3265 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3267 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3266 | 3268 |
| 3267 GetAdapter(); | 3269 GetAdapter(); |
| 3268 DiscoverDevices(); | 3270 DiscoverDevices(); |
| 3269 | 3271 |
| 3270 // Cancel the pairing while we're waiting for the remote host. | 3272 // Cancel the pairing while we're waiting for the remote host. |
| 3271 BluetoothDevice* device = adapter_->GetDevice( | 3273 BluetoothDevice* device = adapter_->GetDevice( |
| 3272 FakeBluetoothDeviceClient::kLegacyAutopairAddress); | 3274 FakeBluetoothDeviceClient::kLegacyAutopairAddress); |
| 3273 ASSERT_TRUE(device != NULL); | 3275 ASSERT_TRUE(device != nullptr); |
| 3274 ASSERT_FALSE(device->IsPaired()); | 3276 ASSERT_FALSE(device->IsPaired()); |
| 3275 | 3277 |
| 3276 TestBluetoothAdapterObserver observer(adapter_); | 3278 TestBluetoothAdapterObserver observer(adapter_); |
| 3277 | 3279 |
| 3278 TestPairingDelegate pairing_delegate; | 3280 TestPairingDelegate pairing_delegate; |
| 3279 device->Connect(&pairing_delegate, GetCallback(), | 3281 device->Connect(&pairing_delegate, GetCallback(), |
| 3280 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 3282 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 3281 base::Unretained(this))); | 3283 base::Unretained(this))); |
| 3282 | 3284 |
| 3283 EXPECT_EQ(0, pairing_delegate.call_count_); | 3285 EXPECT_EQ(0, pairing_delegate.call_count_); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3307 adapter_->AddPairingDelegate( | 3309 adapter_->AddPairingDelegate( |
| 3308 &pairing_delegate, | 3310 &pairing_delegate, |
| 3309 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); | 3311 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| 3310 | 3312 |
| 3311 // Requires that we provide a PIN code. | 3313 // Requires that we provide a PIN code. |
| 3312 fake_bluetooth_device_client_->CreateDevice( | 3314 fake_bluetooth_device_client_->CreateDevice( |
| 3313 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3315 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3314 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); | 3316 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); |
| 3315 BluetoothDevice* device = adapter_->GetDevice( | 3317 BluetoothDevice* device = adapter_->GetDevice( |
| 3316 FakeBluetoothDeviceClient::kRequestPinCodeAddress); | 3318 FakeBluetoothDeviceClient::kRequestPinCodeAddress); |
| 3317 ASSERT_TRUE(device != NULL); | 3319 ASSERT_TRUE(device != nullptr); |
| 3318 ASSERT_FALSE(device->IsPaired()); | 3320 ASSERT_FALSE(device->IsPaired()); |
| 3319 | 3321 |
| 3320 TestBluetoothAdapterObserver observer(adapter_); | 3322 TestBluetoothAdapterObserver observer(adapter_); |
| 3321 | 3323 |
| 3322 fake_bluetooth_device_client_->SimulatePairing( | 3324 fake_bluetooth_device_client_->SimulatePairing( |
| 3323 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), true, | 3325 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), true, |
| 3324 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3326 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3325 base::Unretained(this))); | 3327 base::Unretained(this))); |
| 3326 | 3328 |
| 3327 EXPECT_EQ(1, pairing_delegate.call_count_); | 3329 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3342 | 3344 |
| 3343 // Make sure the trusted property has been set to true. | 3345 // Make sure the trusted property has been set to true. |
| 3344 FakeBluetoothDeviceClient::Properties* properties = | 3346 FakeBluetoothDeviceClient::Properties* properties = |
| 3345 fake_bluetooth_device_client_->GetProperties( | 3347 fake_bluetooth_device_client_->GetProperties( |
| 3346 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); | 3348 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); |
| 3347 ASSERT_TRUE(properties->trusted.value()); | 3349 ASSERT_TRUE(properties->trusted.value()); |
| 3348 | 3350 |
| 3349 // No pairing context should remain on the device. | 3351 // No pairing context should remain on the device. |
| 3350 BluetoothDeviceChromeOS* device_chromeos = | 3352 BluetoothDeviceChromeOS* device_chromeos = |
| 3351 static_cast<BluetoothDeviceChromeOS*>(device); | 3353 static_cast<BluetoothDeviceChromeOS*>(device); |
| 3352 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 3354 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); |
| 3353 } | 3355 } |
| 3354 | 3356 |
| 3355 TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { | 3357 TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { |
| 3356 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3358 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3357 | 3359 |
| 3358 GetAdapter(); | 3360 GetAdapter(); |
| 3359 | 3361 |
| 3360 TestPairingDelegate pairing_delegate; | 3362 TestPairingDelegate pairing_delegate; |
| 3361 adapter_->AddPairingDelegate( | 3363 adapter_->AddPairingDelegate( |
| 3362 &pairing_delegate, | 3364 &pairing_delegate, |
| 3363 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); | 3365 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| 3364 | 3366 |
| 3365 // Requests that we confirm a displayed passkey. | 3367 // Requests that we confirm a displayed passkey. |
| 3366 fake_bluetooth_device_client_->CreateDevice( | 3368 fake_bluetooth_device_client_->CreateDevice( |
| 3367 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3369 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3368 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 3370 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| 3369 BluetoothDevice* device = adapter_->GetDevice( | 3371 BluetoothDevice* device = adapter_->GetDevice( |
| 3370 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); | 3372 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); |
| 3371 ASSERT_TRUE(device != NULL); | 3373 ASSERT_TRUE(device != nullptr); |
| 3372 ASSERT_FALSE(device->IsPaired()); | 3374 ASSERT_FALSE(device->IsPaired()); |
| 3373 | 3375 |
| 3374 TestBluetoothAdapterObserver observer(adapter_); | 3376 TestBluetoothAdapterObserver observer(adapter_); |
| 3375 | 3377 |
| 3376 fake_bluetooth_device_client_->SimulatePairing( | 3378 fake_bluetooth_device_client_->SimulatePairing( |
| 3377 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), true, | 3379 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), true, |
| 3378 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3380 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3379 base::Unretained(this))); | 3381 base::Unretained(this))); |
| 3380 | 3382 |
| 3381 EXPECT_EQ(1, pairing_delegate.call_count_); | 3383 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3397 | 3399 |
| 3398 // Make sure the trusted property has been set to true. | 3400 // Make sure the trusted property has been set to true. |
| 3399 FakeBluetoothDeviceClient::Properties* properties = | 3401 FakeBluetoothDeviceClient::Properties* properties = |
| 3400 fake_bluetooth_device_client_->GetProperties( | 3402 fake_bluetooth_device_client_->GetProperties( |
| 3401 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 3403 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| 3402 ASSERT_TRUE(properties->trusted.value()); | 3404 ASSERT_TRUE(properties->trusted.value()); |
| 3403 | 3405 |
| 3404 // No pairing context should remain on the device. | 3406 // No pairing context should remain on the device. |
| 3405 BluetoothDeviceChromeOS* device_chromeos = | 3407 BluetoothDeviceChromeOS* device_chromeos = |
| 3406 static_cast<BluetoothDeviceChromeOS*>(device); | 3408 static_cast<BluetoothDeviceChromeOS*>(device); |
| 3407 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 3409 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); |
| 3408 } | 3410 } |
| 3409 | 3411 |
| 3410 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { | 3412 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { |
| 3411 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3413 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3412 | 3414 |
| 3413 GetAdapter(); | 3415 GetAdapter(); |
| 3414 | 3416 |
| 3415 TestPairingDelegate pairing_delegate; | 3417 TestPairingDelegate pairing_delegate; |
| 3416 adapter_->AddPairingDelegate( | 3418 adapter_->AddPairingDelegate( |
| 3417 &pairing_delegate, | 3419 &pairing_delegate, |
| 3418 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); | 3420 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| 3419 | 3421 |
| 3420 // Requests that we provide a Passkey. | 3422 // Requests that we provide a Passkey. |
| 3421 fake_bluetooth_device_client_->CreateDevice( | 3423 fake_bluetooth_device_client_->CreateDevice( |
| 3422 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3424 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3423 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); | 3425 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); |
| 3424 BluetoothDevice* device = adapter_->GetDevice( | 3426 BluetoothDevice* device = adapter_->GetDevice( |
| 3425 FakeBluetoothDeviceClient::kRequestPasskeyAddress); | 3427 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 3426 ASSERT_TRUE(device != NULL); | 3428 ASSERT_TRUE(device != nullptr); |
| 3427 ASSERT_FALSE(device->IsPaired()); | 3429 ASSERT_FALSE(device->IsPaired()); |
| 3428 | 3430 |
| 3429 TestBluetoothAdapterObserver observer(adapter_); | 3431 TestBluetoothAdapterObserver observer(adapter_); |
| 3430 | 3432 |
| 3431 fake_bluetooth_device_client_->SimulatePairing( | 3433 fake_bluetooth_device_client_->SimulatePairing( |
| 3432 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, | 3434 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, |
| 3433 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3435 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3434 base::Unretained(this))); | 3436 base::Unretained(this))); |
| 3435 | 3437 |
| 3436 EXPECT_EQ(1, pairing_delegate.call_count_); | 3438 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3451 | 3453 |
| 3452 // Make sure the trusted property has been set to true. | 3454 // Make sure the trusted property has been set to true. |
| 3453 FakeBluetoothDeviceClient::Properties* properties = | 3455 FakeBluetoothDeviceClient::Properties* properties = |
| 3454 fake_bluetooth_device_client_->GetProperties( | 3456 fake_bluetooth_device_client_->GetProperties( |
| 3455 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); | 3457 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); |
| 3456 ASSERT_TRUE(properties->trusted.value()); | 3458 ASSERT_TRUE(properties->trusted.value()); |
| 3457 | 3459 |
| 3458 // No pairing context should remain on the device. | 3460 // No pairing context should remain on the device. |
| 3459 BluetoothDeviceChromeOS* device_chromeos = | 3461 BluetoothDeviceChromeOS* device_chromeos = |
| 3460 static_cast<BluetoothDeviceChromeOS*>(device); | 3462 static_cast<BluetoothDeviceChromeOS*>(device); |
| 3461 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 3463 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); |
| 3462 } | 3464 } |
| 3463 | 3465 |
| 3464 TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { | 3466 TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { |
| 3465 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3467 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3466 | 3468 |
| 3467 GetAdapter(); | 3469 GetAdapter(); |
| 3468 | 3470 |
| 3469 TestPairingDelegate pairing_delegate; | 3471 TestPairingDelegate pairing_delegate; |
| 3470 adapter_->AddPairingDelegate( | 3472 adapter_->AddPairingDelegate( |
| 3471 &pairing_delegate, | 3473 &pairing_delegate, |
| 3472 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); | 3474 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| 3473 | 3475 |
| 3474 // Uses just-works pairing so, sinec this an incoming pairing, require | 3476 // Uses just-works pairing so, sinec this an incoming pairing, require |
| 3475 // authorization from the user. | 3477 // authorization from the user. |
| 3476 fake_bluetooth_device_client_->CreateDevice( | 3478 fake_bluetooth_device_client_->CreateDevice( |
| 3477 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3479 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3478 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); | 3480 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); |
| 3479 BluetoothDevice* device = adapter_->GetDevice( | 3481 BluetoothDevice* device = adapter_->GetDevice( |
| 3480 FakeBluetoothDeviceClient::kJustWorksAddress); | 3482 FakeBluetoothDeviceClient::kJustWorksAddress); |
| 3481 ASSERT_TRUE(device != NULL); | 3483 ASSERT_TRUE(device != nullptr); |
| 3482 ASSERT_FALSE(device->IsPaired()); | 3484 ASSERT_FALSE(device->IsPaired()); |
| 3483 | 3485 |
| 3484 TestBluetoothAdapterObserver observer(adapter_); | 3486 TestBluetoothAdapterObserver observer(adapter_); |
| 3485 | 3487 |
| 3486 fake_bluetooth_device_client_->SimulatePairing( | 3488 fake_bluetooth_device_client_->SimulatePairing( |
| 3487 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), true, | 3489 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), true, |
| 3488 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3490 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3489 base::Unretained(this))); | 3491 base::Unretained(this))); |
| 3490 | 3492 |
| 3491 EXPECT_EQ(1, pairing_delegate.call_count_); | 3493 EXPECT_EQ(1, pairing_delegate.call_count_); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3506 | 3508 |
| 3507 // Make sure the trusted property has been set to true. | 3509 // Make sure the trusted property has been set to true. |
| 3508 FakeBluetoothDeviceClient::Properties* properties = | 3510 FakeBluetoothDeviceClient::Properties* properties = |
| 3509 fake_bluetooth_device_client_->GetProperties( | 3511 fake_bluetooth_device_client_->GetProperties( |
| 3510 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); | 3512 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); |
| 3511 ASSERT_TRUE(properties->trusted.value()); | 3513 ASSERT_TRUE(properties->trusted.value()); |
| 3512 | 3514 |
| 3513 // No pairing context should remain on the device. | 3515 // No pairing context should remain on the device. |
| 3514 BluetoothDeviceChromeOS* device_chromeos = | 3516 BluetoothDeviceChromeOS* device_chromeos = |
| 3515 static_cast<BluetoothDeviceChromeOS*>(device); | 3517 static_cast<BluetoothDeviceChromeOS*>(device); |
| 3516 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 3518 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); |
| 3517 } | 3519 } |
| 3518 | 3520 |
| 3519 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { | 3521 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { |
| 3520 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3522 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3521 | 3523 |
| 3522 GetAdapter(); | 3524 GetAdapter(); |
| 3523 | 3525 |
| 3524 // Requires that we provide a PIN Code, without a pairing delegate, | 3526 // Requires that we provide a PIN Code, without a pairing delegate, |
| 3525 // that will be rejected. | 3527 // that will be rejected. |
| 3526 fake_bluetooth_device_client_->CreateDevice( | 3528 fake_bluetooth_device_client_->CreateDevice( |
| 3527 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3529 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3528 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); | 3530 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); |
| 3529 BluetoothDevice* device = adapter_->GetDevice( | 3531 BluetoothDevice* device = adapter_->GetDevice( |
| 3530 FakeBluetoothDeviceClient::kRequestPinCodeAddress); | 3532 FakeBluetoothDeviceClient::kRequestPinCodeAddress); |
| 3531 ASSERT_TRUE(device != NULL); | 3533 ASSERT_TRUE(device != nullptr); |
| 3532 ASSERT_FALSE(device->IsPaired()); | 3534 ASSERT_FALSE(device->IsPaired()); |
| 3533 | 3535 |
| 3534 TestBluetoothAdapterObserver observer(adapter_); | 3536 TestBluetoothAdapterObserver observer(adapter_); |
| 3535 | 3537 |
| 3536 fake_bluetooth_device_client_->SimulatePairing( | 3538 fake_bluetooth_device_client_->SimulatePairing( |
| 3537 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), true, | 3539 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), true, |
| 3538 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3540 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3539 base::Unretained(this))); | 3541 base::Unretained(this))); |
| 3540 | 3542 |
| 3541 message_loop_.Run(); | 3543 message_loop_.Run(); |
| 3542 | 3544 |
| 3543 EXPECT_EQ(0, callback_count_); | 3545 EXPECT_EQ(0, callback_count_); |
| 3544 EXPECT_EQ(1, error_callback_count_); | 3546 EXPECT_EQ(1, error_callback_count_); |
| 3545 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); | 3547 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); |
| 3546 | 3548 |
| 3547 // No changes should be observer. | 3549 // No changes should be observer. |
| 3548 EXPECT_EQ(0, observer.device_changed_count()); | 3550 EXPECT_EQ(0, observer.device_changed_count()); |
| 3549 | 3551 |
| 3550 EXPECT_FALSE(device->IsPaired()); | 3552 EXPECT_FALSE(device->IsPaired()); |
| 3551 | 3553 |
| 3552 // No pairing context should remain on the device. | 3554 // No pairing context should remain on the device. |
| 3553 BluetoothDeviceChromeOS* device_chromeos = | 3555 BluetoothDeviceChromeOS* device_chromeos = |
| 3554 static_cast<BluetoothDeviceChromeOS*>(device); | 3556 static_cast<BluetoothDeviceChromeOS*>(device); |
| 3555 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 3557 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); |
| 3556 } | 3558 } |
| 3557 | 3559 |
| 3558 TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { | 3560 TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { |
| 3559 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3561 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3560 | 3562 |
| 3561 GetAdapter(); | 3563 GetAdapter(); |
| 3562 | 3564 |
| 3563 // Requests that we confirm a displayed passkey, without a pairing delegate, | 3565 // Requests that we confirm a displayed passkey, without a pairing delegate, |
| 3564 // that will be rejected. | 3566 // that will be rejected. |
| 3565 fake_bluetooth_device_client_->CreateDevice( | 3567 fake_bluetooth_device_client_->CreateDevice( |
| 3566 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3568 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3567 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 3569 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| 3568 BluetoothDevice* device = adapter_->GetDevice( | 3570 BluetoothDevice* device = adapter_->GetDevice( |
| 3569 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); | 3571 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); |
| 3570 ASSERT_TRUE(device != NULL); | 3572 ASSERT_TRUE(device != nullptr); |
| 3571 ASSERT_FALSE(device->IsPaired()); | 3573 ASSERT_FALSE(device->IsPaired()); |
| 3572 | 3574 |
| 3573 TestBluetoothAdapterObserver observer(adapter_); | 3575 TestBluetoothAdapterObserver observer(adapter_); |
| 3574 | 3576 |
| 3575 fake_bluetooth_device_client_->SimulatePairing( | 3577 fake_bluetooth_device_client_->SimulatePairing( |
| 3576 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), true, | 3578 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), true, |
| 3577 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3579 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3578 base::Unretained(this))); | 3580 base::Unretained(this))); |
| 3579 | 3581 |
| 3580 message_loop_.Run(); | 3582 message_loop_.Run(); |
| 3581 | 3583 |
| 3582 EXPECT_EQ(0, callback_count_); | 3584 EXPECT_EQ(0, callback_count_); |
| 3583 EXPECT_EQ(1, error_callback_count_); | 3585 EXPECT_EQ(1, error_callback_count_); |
| 3584 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); | 3586 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); |
| 3585 | 3587 |
| 3586 // No changes should be observer. | 3588 // No changes should be observer. |
| 3587 EXPECT_EQ(0, observer.device_changed_count()); | 3589 EXPECT_EQ(0, observer.device_changed_count()); |
| 3588 | 3590 |
| 3589 EXPECT_FALSE(device->IsPaired()); | 3591 EXPECT_FALSE(device->IsPaired()); |
| 3590 | 3592 |
| 3591 // No pairing context should remain on the device. | 3593 // No pairing context should remain on the device. |
| 3592 BluetoothDeviceChromeOS* device_chromeos = | 3594 BluetoothDeviceChromeOS* device_chromeos = |
| 3593 static_cast<BluetoothDeviceChromeOS*>(device); | 3595 static_cast<BluetoothDeviceChromeOS*>(device); |
| 3594 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 3596 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); |
| 3595 } | 3597 } |
| 3596 | 3598 |
| 3597 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { | 3599 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { |
| 3598 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3600 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3599 | 3601 |
| 3600 GetAdapter(); | 3602 GetAdapter(); |
| 3601 | 3603 |
| 3602 // Requests that we provide a displayed passkey, without a pairing delegate, | 3604 // Requests that we provide a displayed passkey, without a pairing delegate, |
| 3603 // that will be rejected. | 3605 // that will be rejected. |
| 3604 fake_bluetooth_device_client_->CreateDevice( | 3606 fake_bluetooth_device_client_->CreateDevice( |
| 3605 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3607 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3606 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); | 3608 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); |
| 3607 BluetoothDevice* device = adapter_->GetDevice( | 3609 BluetoothDevice* device = adapter_->GetDevice( |
| 3608 FakeBluetoothDeviceClient::kRequestPasskeyAddress); | 3610 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 3609 ASSERT_TRUE(device != NULL); | 3611 ASSERT_TRUE(device != nullptr); |
| 3610 ASSERT_FALSE(device->IsPaired()); | 3612 ASSERT_FALSE(device->IsPaired()); |
| 3611 | 3613 |
| 3612 TestBluetoothAdapterObserver observer(adapter_); | 3614 TestBluetoothAdapterObserver observer(adapter_); |
| 3613 | 3615 |
| 3614 fake_bluetooth_device_client_->SimulatePairing( | 3616 fake_bluetooth_device_client_->SimulatePairing( |
| 3615 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, | 3617 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, |
| 3616 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3618 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3617 base::Unretained(this))); | 3619 base::Unretained(this))); |
| 3618 | 3620 |
| 3619 message_loop_.Run(); | 3621 message_loop_.Run(); |
| 3620 | 3622 |
| 3621 EXPECT_EQ(0, callback_count_); | 3623 EXPECT_EQ(0, callback_count_); |
| 3622 EXPECT_EQ(1, error_callback_count_); | 3624 EXPECT_EQ(1, error_callback_count_); |
| 3623 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); | 3625 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); |
| 3624 | 3626 |
| 3625 // No changes should be observer. | 3627 // No changes should be observer. |
| 3626 EXPECT_EQ(0, observer.device_changed_count()); | 3628 EXPECT_EQ(0, observer.device_changed_count()); |
| 3627 | 3629 |
| 3628 EXPECT_FALSE(device->IsPaired()); | 3630 EXPECT_FALSE(device->IsPaired()); |
| 3629 | 3631 |
| 3630 // No pairing context should remain on the device. | 3632 // No pairing context should remain on the device. |
| 3631 BluetoothDeviceChromeOS* device_chromeos = | 3633 BluetoothDeviceChromeOS* device_chromeos = |
| 3632 static_cast<BluetoothDeviceChromeOS*>(device); | 3634 static_cast<BluetoothDeviceChromeOS*>(device); |
| 3633 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 3635 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); |
| 3634 } | 3636 } |
| 3635 | 3637 |
| 3636 TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { | 3638 TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { |
| 3637 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3639 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3638 | 3640 |
| 3639 GetAdapter(); | 3641 GetAdapter(); |
| 3640 | 3642 |
| 3641 // Uses just-works pairing and thus requires authorization for incoming | 3643 // Uses just-works pairing and thus requires authorization for incoming |
| 3642 // pairings, without a pairing delegate, that will be rejected. | 3644 // pairings, without a pairing delegate, that will be rejected. |
| 3643 fake_bluetooth_device_client_->CreateDevice( | 3645 fake_bluetooth_device_client_->CreateDevice( |
| 3644 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3646 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3645 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); | 3647 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); |
| 3646 BluetoothDevice* device = adapter_->GetDevice( | 3648 BluetoothDevice* device = adapter_->GetDevice( |
| 3647 FakeBluetoothDeviceClient::kJustWorksAddress); | 3649 FakeBluetoothDeviceClient::kJustWorksAddress); |
| 3648 ASSERT_TRUE(device != NULL); | 3650 ASSERT_TRUE(device != nullptr); |
| 3649 ASSERT_FALSE(device->IsPaired()); | 3651 ASSERT_FALSE(device->IsPaired()); |
| 3650 | 3652 |
| 3651 TestBluetoothAdapterObserver observer(adapter_); | 3653 TestBluetoothAdapterObserver observer(adapter_); |
| 3652 | 3654 |
| 3653 fake_bluetooth_device_client_->SimulatePairing( | 3655 fake_bluetooth_device_client_->SimulatePairing( |
| 3654 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), true, | 3656 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), true, |
| 3655 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3657 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3656 base::Unretained(this))); | 3658 base::Unretained(this))); |
| 3657 | 3659 |
| 3658 message_loop_.Run(); | 3660 message_loop_.Run(); |
| 3659 | 3661 |
| 3660 EXPECT_EQ(0, callback_count_); | 3662 EXPECT_EQ(0, callback_count_); |
| 3661 EXPECT_EQ(1, error_callback_count_); | 3663 EXPECT_EQ(1, error_callback_count_); |
| 3662 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); | 3664 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); |
| 3663 | 3665 |
| 3664 // No changes should be observer. | 3666 // No changes should be observer. |
| 3665 EXPECT_EQ(0, observer.device_changed_count()); | 3667 EXPECT_EQ(0, observer.device_changed_count()); |
| 3666 | 3668 |
| 3667 EXPECT_FALSE(device->IsPaired()); | 3669 EXPECT_FALSE(device->IsPaired()); |
| 3668 | 3670 |
| 3669 // No pairing context should remain on the device. | 3671 // No pairing context should remain on the device. |
| 3670 BluetoothDeviceChromeOS* device_chromeos = | 3672 BluetoothDeviceChromeOS* device_chromeos = |
| 3671 static_cast<BluetoothDeviceChromeOS*>(device); | 3673 static_cast<BluetoothDeviceChromeOS*>(device); |
| 3672 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 3674 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); |
| 3673 } | 3675 } |
| 3674 | 3676 |
| 3675 TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { | 3677 TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { |
| 3676 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3678 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3677 | 3679 |
| 3678 GetAdapter(); | 3680 GetAdapter(); |
| 3679 | 3681 |
| 3680 TestPairingDelegate pairing_delegate; | 3682 TestPairingDelegate pairing_delegate; |
| 3681 adapter_->AddPairingDelegate( | 3683 adapter_->AddPairingDelegate( |
| 3682 &pairing_delegate, | 3684 &pairing_delegate, |
| 3683 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); | 3685 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| 3684 | 3686 |
| 3685 // Requests that we provide a Passkey. | 3687 // Requests that we provide a Passkey. |
| 3686 fake_bluetooth_device_client_->CreateDevice( | 3688 fake_bluetooth_device_client_->CreateDevice( |
| 3687 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3689 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3688 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); | 3690 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); |
| 3689 BluetoothDevice* device = adapter_->GetDevice( | 3691 BluetoothDevice* device = adapter_->GetDevice( |
| 3690 FakeBluetoothDeviceClient::kRequestPasskeyAddress); | 3692 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 3691 ASSERT_TRUE(device != NULL); | 3693 ASSERT_TRUE(device != nullptr); |
| 3692 ASSERT_FALSE(device->IsPaired()); | 3694 ASSERT_FALSE(device->IsPaired()); |
| 3693 | 3695 |
| 3694 TestBluetoothAdapterObserver observer(adapter_); | 3696 TestBluetoothAdapterObserver observer(adapter_); |
| 3695 | 3697 |
| 3696 fake_bluetooth_device_client_->SimulatePairing( | 3698 fake_bluetooth_device_client_->SimulatePairing( |
| 3697 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, | 3699 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, |
| 3698 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3700 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3699 base::Unretained(this))); | 3701 base::Unretained(this))); |
| 3700 | 3702 |
| 3701 EXPECT_EQ(1, pairing_delegate.call_count_); | 3703 EXPECT_EQ(1, pairing_delegate.call_count_); |
| 3702 EXPECT_EQ(1, pairing_delegate.request_passkey_count_); | 3704 EXPECT_EQ(1, pairing_delegate.request_passkey_count_); |
| 3703 | 3705 |
| 3704 // A pairing context should now be set on the device. | 3706 // A pairing context should now be set on the device. |
| 3705 BluetoothDeviceChromeOS* device_chromeos = | 3707 BluetoothDeviceChromeOS* device_chromeos = |
| 3706 static_cast<BluetoothDeviceChromeOS*>(device); | 3708 static_cast<BluetoothDeviceChromeOS*>(device); |
| 3707 ASSERT_TRUE(device_chromeos->GetPairing() != NULL); | 3709 ASSERT_TRUE(device_chromeos->GetPairing() != nullptr); |
| 3708 | 3710 |
| 3709 // Removing the pairing delegate should remove that pairing context. | 3711 // Removing the pairing delegate should remove that pairing context. |
| 3710 adapter_->RemovePairingDelegate(&pairing_delegate); | 3712 adapter_->RemovePairingDelegate(&pairing_delegate); |
| 3711 | 3713 |
| 3712 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 3714 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); |
| 3713 | 3715 |
| 3714 // Set the Passkey, this should now have no effect since the pairing has | 3716 // Set the Passkey, this should now have no effect since the pairing has |
| 3715 // been, in-effect, cancelled | 3717 // been, in-effect, cancelled |
| 3716 device->SetPasskey(1234); | 3718 device->SetPasskey(1234); |
| 3717 | 3719 |
| 3718 EXPECT_EQ(0, callback_count_); | 3720 EXPECT_EQ(0, callback_count_); |
| 3719 EXPECT_EQ(0, error_callback_count_); | 3721 EXPECT_EQ(0, error_callback_count_); |
| 3720 EXPECT_EQ(0, observer.device_changed_count()); | 3722 EXPECT_EQ(0, observer.device_changed_count()); |
| 3721 | 3723 |
| 3722 EXPECT_FALSE(device->IsPaired()); | 3724 EXPECT_FALSE(device->IsPaired()); |
| 3723 } | 3725 } |
| 3724 | 3726 |
| 3725 TEST_F(BluetoothChromeOSTest, DeviceId) { | 3727 TEST_F(BluetoothChromeOSTest, DeviceId) { |
| 3726 GetAdapter(); | 3728 GetAdapter(); |
| 3727 | 3729 |
| 3728 // Use the built-in paired device for this test, grab its Properties | 3730 // Use the built-in paired device for this test, grab its Properties |
| 3729 // structure so we can adjust the underlying modalias property. | 3731 // structure so we can adjust the underlying modalias property. |
| 3730 BluetoothDevice* device = adapter_->GetDevice( | 3732 BluetoothDevice* device = adapter_->GetDevice( |
| 3731 FakeBluetoothDeviceClient::kPairedDeviceAddress); | 3733 FakeBluetoothDeviceClient::kPairedDeviceAddress); |
| 3732 FakeBluetoothDeviceClient::Properties* properties = | 3734 FakeBluetoothDeviceClient::Properties* properties = |
| 3733 fake_bluetooth_device_client_->GetProperties( | 3735 fake_bluetooth_device_client_->GetProperties( |
| 3734 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); | 3736 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); |
| 3735 | 3737 |
| 3736 ASSERT_TRUE(device != NULL); | 3738 ASSERT_TRUE(device != nullptr); |
| 3737 ASSERT_TRUE(properties != NULL); | 3739 ASSERT_TRUE(properties != nullptr); |
| 3738 | 3740 |
| 3739 // Valid USB IF-assigned identifier. | 3741 // Valid USB IF-assigned identifier. |
| 3740 ASSERT_EQ("usb:v05ACp030Dd0306", properties->modalias.value()); | 3742 ASSERT_EQ("usb:v05ACp030Dd0306", properties->modalias.value()); |
| 3741 | 3743 |
| 3742 EXPECT_EQ(BluetoothDevice::VENDOR_ID_USB, device->GetVendorIDSource()); | 3744 EXPECT_EQ(BluetoothDevice::VENDOR_ID_USB, device->GetVendorIDSource()); |
| 3743 EXPECT_EQ(0x05ac, device->GetVendorID()); | 3745 EXPECT_EQ(0x05ac, device->GetVendorID()); |
| 3744 EXPECT_EQ(0x030d, device->GetProductID()); | 3746 EXPECT_EQ(0x030d, device->GetProductID()); |
| 3745 EXPECT_EQ(0x0306, device->GetDeviceID()); | 3747 EXPECT_EQ(0x0306, device->GetDeviceID()); |
| 3746 | 3748 |
| 3747 // Valid Bluetooth SIG-assigned identifier. | 3749 // Valid Bluetooth SIG-assigned identifier. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3791 EXPECT_EQ(unknown_power, conn_info.rssi); | 3793 EXPECT_EQ(unknown_power, conn_info.rssi); |
| 3792 EXPECT_EQ(unknown_power, conn_info.transmit_power); | 3794 EXPECT_EQ(unknown_power, conn_info.transmit_power); |
| 3793 EXPECT_EQ(unknown_power, conn_info.max_transmit_power); | 3795 EXPECT_EQ(unknown_power, conn_info.max_transmit_power); |
| 3794 } | 3796 } |
| 3795 | 3797 |
| 3796 TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) { | 3798 TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) { |
| 3797 GetAdapter(); | 3799 GetAdapter(); |
| 3798 BluetoothDevice* device = | 3800 BluetoothDevice* device = |
| 3799 adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); | 3801 adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); |
| 3800 | 3802 |
| 3801 device->Connect(NULL, GetCallback(), | 3803 device->Connect(nullptr, GetCallback(), |
| 3802 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 3804 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 3803 base::Unretained(this))); | 3805 base::Unretained(this))); |
| 3804 EXPECT_TRUE(device->IsConnected()); | 3806 EXPECT_TRUE(device->IsConnected()); |
| 3805 | 3807 |
| 3806 // Calling GetConnectionInfo for a connected device should return valid | 3808 // Calling GetConnectionInfo for a connected device should return valid |
| 3807 // results. | 3809 // results. |
| 3808 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); | 3810 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); |
| 3809 BluetoothDevice::ConnectionInfo conn_info; | 3811 BluetoothDevice::ConnectionInfo conn_info; |
| 3810 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); | 3812 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); |
| 3811 EXPECT_EQ(-10, conn_info.rssi); | 3813 EXPECT_EQ(-10, conn_info.rssi); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3887 audio_sink_options, | 3889 audio_sink_options, |
| 3888 base::Bind(&BluetoothChromeOSTest::AudioSinkAcquiredCallback, | 3890 base::Bind(&BluetoothChromeOSTest::AudioSinkAcquiredCallback, |
| 3889 base::Unretained(this)), | 3891 base::Unretained(this)), |
| 3890 base::Bind(&BluetoothChromeOSTest::AudioSinkErrorCallback, | 3892 base::Bind(&BluetoothChromeOSTest::AudioSinkErrorCallback, |
| 3891 base::Unretained(this))); | 3893 base::Unretained(this))); |
| 3892 EXPECT_EQ(0, callback_count_); | 3894 EXPECT_EQ(0, callback_count_); |
| 3893 EXPECT_EQ(1, error_callback_count_--) << "RegisterAudioSink error"; | 3895 EXPECT_EQ(1, error_callback_count_--) << "RegisterAudioSink error"; |
| 3894 | 3896 |
| 3895 BluetoothAdapterChromeOS* adapter_chrome_os = | 3897 BluetoothAdapterChromeOS* adapter_chrome_os = |
| 3896 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); | 3898 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); |
| 3897 EXPECT_EQ(NULL, adapter_chrome_os->GetDeviceWithPath(dbus::ObjectPath(""))); | 3899 EXPECT_EQ(nullptr, |
| 3900 adapter_chrome_os->GetDeviceWithPath(dbus::ObjectPath(""))); |
| 3898 | 3901 |
| 3899 // Notify methods presume objects exist that are owned by the adapter and | 3902 // Notify methods presume objects exist that are owned by the adapter and |
| 3900 // destroyed in Shutdown(). Mocks are not attempted here that won't exist, | 3903 // destroyed in Shutdown(). Mocks are not attempted here that won't exist, |
| 3901 // as verified below by EXPECT_EQ(0U, adapter_->GetDevices().size()); | 3904 // as verified below by EXPECT_EQ(0U, adapter_->GetDevices().size()); |
| 3902 // NotifyDeviceChanged | 3905 // NotifyDeviceChanged |
| 3903 // NotifyGattServiceAdded | 3906 // NotifyGattServiceAdded |
| 3904 // NotifyGattServiceRemoved | 3907 // NotifyGattServiceRemoved |
| 3905 // NotifyGattServiceChanged | 3908 // NotifyGattServiceChanged |
| 3906 // NotifyGattDiscoveryComplete | 3909 // NotifyGattDiscoveryComplete |
| 3907 // NotifyGattCharacteristicAdded | 3910 // NotifyGattCharacteristicAdded |
| 3908 // NotifyGattCharacteristicRemoved | 3911 // NotifyGattCharacteristicRemoved |
| 3909 // NotifyGattDescriptorAdded | 3912 // NotifyGattDescriptorAdded |
| 3910 // NotifyGattDescriptorRemoved | 3913 // NotifyGattDescriptorRemoved |
| 3911 // NotifyGattCharacteristicValueChanged | 3914 // NotifyGattCharacteristicValueChanged |
| 3912 // NotifyGattDescriptorValueChanged | 3915 // NotifyGattDescriptorValueChanged |
| 3913 | 3916 |
| 3914 EXPECT_EQ(dbus::ObjectPath(""), adapter_chrome_os->object_path()); | 3917 EXPECT_EQ(dbus::ObjectPath(""), adapter_chrome_os->object_path()); |
| 3915 | 3918 |
| 3916 adapter_profile_ = NULL; | 3919 adapter_profile_ = nullptr; |
| 3917 | 3920 |
| 3918 FakeBluetoothProfileServiceProviderDelegate profile_delegate; | 3921 FakeBluetoothProfileServiceProviderDelegate profile_delegate; |
| 3919 adapter_chrome_os->UseProfile( | 3922 adapter_chrome_os->UseProfile( |
| 3920 BluetoothUUID(), dbus::ObjectPath(""), | 3923 BluetoothUUID(), dbus::ObjectPath(""), |
| 3921 BluetoothProfileManagerClient::Options(), &profile_delegate, | 3924 BluetoothProfileManagerClient::Options(), &profile_delegate, |
| 3922 base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, | 3925 base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, |
| 3923 base::Unretained(this)), | 3926 base::Unretained(this)), |
| 3924 base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, | 3927 base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, |
| 3925 base::Unretained(this))); | 3928 base::Unretained(this))); |
| 3926 | 3929 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3982 adapter_chrome_os->RemoveDiscoverySession(nullptr, GetCallback(), | 3985 adapter_chrome_os->RemoveDiscoverySession(nullptr, GetCallback(), |
| 3983 GetErrorCallback()); | 3986 GetErrorCallback()); |
| 3984 EXPECT_EQ(0, callback_count_) << "RemoveDiscoverySession error"; | 3987 EXPECT_EQ(0, callback_count_) << "RemoveDiscoverySession error"; |
| 3985 EXPECT_EQ(1, error_callback_count_--) << "RemoveDiscoverySession error"; | 3988 EXPECT_EQ(1, error_callback_count_--) << "RemoveDiscoverySession error"; |
| 3986 | 3989 |
| 3987 // OnStartDiscovery tested in Shutdown_OnStartDiscovery | 3990 // OnStartDiscovery tested in Shutdown_OnStartDiscovery |
| 3988 // OnStartDiscoveryError tested in Shutdown_OnStartDiscoveryError | 3991 // OnStartDiscoveryError tested in Shutdown_OnStartDiscoveryError |
| 3989 // OnStopDiscovery tested in Shutdown_OnStopDiscovery | 3992 // OnStopDiscovery tested in Shutdown_OnStopDiscovery |
| 3990 // OnStopDiscoveryError tested in Shutdown_OnStopDiscoveryError | 3993 // OnStopDiscoveryError tested in Shutdown_OnStopDiscoveryError |
| 3991 | 3994 |
| 3992 adapter_profile_ = NULL; | 3995 adapter_profile_ = nullptr; |
| 3993 | 3996 |
| 3994 // OnRegisterProfile SetProfileDelegate, OnRegisterProfileError, require | 3997 // OnRegisterProfile SetProfileDelegate, OnRegisterProfileError, require |
| 3995 // UseProfile to be set first, do so again here just before calling them. | 3998 // UseProfile to be set first, do so again here just before calling them. |
| 3996 adapter_chrome_os->UseProfile( | 3999 adapter_chrome_os->UseProfile( |
| 3997 BluetoothUUID(), dbus::ObjectPath(""), | 4000 BluetoothUUID(), dbus::ObjectPath(""), |
| 3998 BluetoothProfileManagerClient::Options(), &profile_delegate, | 4001 BluetoothProfileManagerClient::Options(), &profile_delegate, |
| 3999 base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, | 4002 base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, |
| 4000 base::Unretained(this)), | 4003 base::Unretained(this)), |
| 4001 base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, | 4004 base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, |
| 4002 base::Unretained(this))); | 4005 base::Unretained(this))); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4129 adapter_->Shutdown(); | 4132 adapter_->Shutdown(); |
| 4130 adapter_chrome_os->OnStopDiscoveryError(GetErrorCallback(), "", ""); | 4133 adapter_chrome_os->OnStopDiscoveryError(GetErrorCallback(), "", ""); |
| 4131 | 4134 |
| 4132 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, | 4135 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, |
| 4133 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. | 4136 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. |
| 4134 EXPECT_EQ(0, callback_count_); | 4137 EXPECT_EQ(0, callback_count_); |
| 4135 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); | 4138 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); |
| 4136 } | 4139 } |
| 4137 | 4140 |
| 4138 } // namespace chromeos | 4141 } // namespace chromeos |
| OLD | NEW |