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

Side by Side Diff: device/bluetooth/bluetooth_chromeos_unittest.cc

Issue 1124883004: Submission for C++ Readability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address first round of review comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 message_loop_.Run(); 1368 message_loop_.Run();
1367 1369
1368 EXPECT_EQ(1, callback_count_); 1370 EXPECT_EQ(1, callback_count_);
1369 EXPECT_EQ(0, error_callback_count_); 1371 EXPECT_EQ(0, error_callback_count_);
1370 1372
1371 ASSERT_TRUE(adapter_->IsPowered()); 1373 ASSERT_TRUE(adapter_->IsPowered());
1372 ASSERT_FALSE(adapter_->IsDiscovering()); 1374 ASSERT_FALSE(adapter_->IsDiscovering());
1373 ASSERT_EQ((size_t)1, discovery_sessions_.size()); 1375 ASSERT_EQ((size_t)1, discovery_sessions_.size());
1374 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); 1376 ASSERT_FALSE(discovery_sessions_[0]->IsActive());
1375 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), 1377 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(),
1376 (BluetoothDiscoveryFilter*)NULL); 1378 (BluetoothDiscoveryFilter*)nullptr);
1377 1379
1378 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); 1380 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
1379 EXPECT_EQ(nullptr, filter); 1381 EXPECT_EQ(nullptr, filter);
1380 } 1382 }
1381 1383
1382 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryFail) { 1384 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryFail) {
1383 // Test a simulated discovery session. 1385 // Test a simulated discovery session.
1384 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 1386 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
1385 GetAdapter(); 1387 GetAdapter();
1386 1388
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 1507
1506 message_loop_.Run(); 1508 message_loop_.Run();
1507 1509
1508 EXPECT_EQ(2, callback_count_); 1510 EXPECT_EQ(2, callback_count_);
1509 EXPECT_EQ(0, error_callback_count_); 1511 EXPECT_EQ(0, error_callback_count_);
1510 1512
1511 ASSERT_TRUE(adapter_->IsPowered()); 1513 ASSERT_TRUE(adapter_->IsPowered());
1512 ASSERT_FALSE(adapter_->IsDiscovering()); 1514 ASSERT_FALSE(adapter_->IsDiscovering());
1513 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); 1515 ASSERT_FALSE(discovery_sessions_[0]->IsActive());
1514 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), 1516 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(),
1515 (BluetoothDiscoveryFilter*)NULL); 1517 (BluetoothDiscoveryFilter*)nullptr);
1516 ASSERT_FALSE(discovery_sessions_[1]->IsActive()); 1518 ASSERT_FALSE(discovery_sessions_[1]->IsActive());
1517 ASSERT_EQ(discovery_sessions_[1]->GetDiscoveryFilter(), 1519 ASSERT_EQ(discovery_sessions_[1]->GetDiscoveryFilter(),
1518 (BluetoothDiscoveryFilter*)NULL); 1520 (BluetoothDiscoveryFilter*)nullptr);
1519 1521
1520 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); 1522 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
1521 EXPECT_EQ(nullptr, filter); 1523 EXPECT_EQ(nullptr, filter);
1522 } 1524 }
1523 1525
1524 // Call StartFilteredDiscovery twice (2nd time while 1st call is still pending). 1526 // Call StartFilteredDiscovery twice (2nd time while 1st call is still pending).
1525 // Make the first SetDiscoveryFilter fail and the second one succeed. It should 1527 // Make the first SetDiscoveryFilter fail and the second one succeed. It should
1526 // end up with one active discovery session. 1528 // end up with one active discovery session.
1527 TEST_F(BluetoothChromeOSTest, 1529 TEST_F(BluetoothChromeOSTest,
1528 QueuedSetDiscoveryFilterBeforeStartDiscoveryFail) { 1530 QueuedSetDiscoveryFilterBeforeStartDiscoveryFail) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 1611
1610 message_loop_.Run(); 1612 message_loop_.Run();
1611 1613
1612 EXPECT_EQ(1, callback_count_); 1614 EXPECT_EQ(1, callback_count_);
1613 EXPECT_EQ(0, error_callback_count_); 1615 EXPECT_EQ(0, error_callback_count_);
1614 1616
1615 ASSERT_TRUE(adapter_->IsPowered()); 1617 ASSERT_TRUE(adapter_->IsPowered());
1616 ASSERT_FALSE(adapter_->IsDiscovering()); 1618 ASSERT_FALSE(adapter_->IsDiscovering());
1617 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); 1619 ASSERT_FALSE(discovery_sessions_[0]->IsActive());
1618 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), 1620 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(),
1619 (BluetoothDiscoveryFilter*)NULL); 1621 (BluetoothDiscoveryFilter*)nullptr);
1620 1622
1621 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); 1623 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
1622 EXPECT_EQ(nullptr, filter); 1624 EXPECT_EQ(nullptr, filter);
1623 } 1625 }
1624 1626
1625 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterAfterStartDiscovery) { 1627 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterAfterStartDiscovery) {
1626 // Test a simulated discovery session. 1628 // Test a simulated discovery session.
1627 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 1629 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
1628 GetAdapter(); 1630 GetAdapter();
1629 1631
(...skipping 13 matching lines...) Expand all
1643 EXPECT_EQ(0, error_callback_count_); 1645 EXPECT_EQ(0, error_callback_count_);
1644 callback_count_ = 0; 1646 callback_count_ = 0;
1645 1647
1646 ASSERT_TRUE(adapter_->IsPowered()); 1648 ASSERT_TRUE(adapter_->IsPowered());
1647 ASSERT_TRUE(adapter_->IsDiscovering()); 1649 ASSERT_TRUE(adapter_->IsDiscovering());
1648 ASSERT_EQ((size_t)1, discovery_sessions_.size()); 1650 ASSERT_EQ((size_t)1, discovery_sessions_.size());
1649 ASSERT_TRUE(discovery_sessions_[0]->IsActive()); 1651 ASSERT_TRUE(discovery_sessions_[0]->IsActive());
1650 EXPECT_EQ(1, observer.discovering_changed_count()); 1652 EXPECT_EQ(1, observer.discovering_changed_count());
1651 observer.Reset(); 1653 observer.Reset();
1652 1654
1653 auto nullInstance = scoped_ptr<BluetoothDiscoveryFilter>(); 1655 auto null_instance = scoped_ptr<BluetoothDiscoveryFilter>();
1654 nullInstance.reset(); 1656 null_instance.reset();
1655 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), nullInstance.get()); 1657 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), null_instance.get());
1656 1658
1657 auto filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); 1659 auto filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
1658 EXPECT_EQ(nullptr, filter); 1660 EXPECT_EQ(nullptr, filter);
1659 1661
1660 BluetoothDiscoveryFilter* df = new BluetoothDiscoveryFilter( 1662 BluetoothDiscoveryFilter* df = new BluetoothDiscoveryFilter(
1661 BluetoothDiscoveryFilter::Transport::TRANSPORT_LE); 1663 BluetoothDiscoveryFilter::Transport::TRANSPORT_LE);
1662 df->SetRSSI(-60); 1664 df->SetRSSI(-60);
1663 df->AddUUID(BluetoothUUID("1000")); 1665 df->AddUUID(BluetoothUUID("1000"));
1664 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter(df); 1666 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter(df);
1665 1667
(...skipping 26 matching lines...) Expand all
1692 message_loop_.Run(); 1694 message_loop_.Run();
1693 1695
1694 EXPECT_EQ(1, callback_count_); 1696 EXPECT_EQ(1, callback_count_);
1695 EXPECT_EQ(0, error_callback_count_); 1697 EXPECT_EQ(0, error_callback_count_);
1696 1698
1697 ASSERT_TRUE(adapter_->IsPowered()); 1699 ASSERT_TRUE(adapter_->IsPowered());
1698 ASSERT_FALSE(adapter_->IsDiscovering()); 1700 ASSERT_FALSE(adapter_->IsDiscovering());
1699 ASSERT_EQ((size_t)1, discovery_sessions_.size()); 1701 ASSERT_EQ((size_t)1, discovery_sessions_.size());
1700 ASSERT_FALSE(discovery_sessions_[0]->IsActive()); 1702 ASSERT_FALSE(discovery_sessions_[0]->IsActive());
1701 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(), 1703 ASSERT_EQ(discovery_sessions_[0]->GetDiscoveryFilter(),
1702 (BluetoothDiscoveryFilter*)NULL); 1704 (BluetoothDiscoveryFilter*)nullptr);
1703 1705
1704 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter(); 1706 filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
1705 EXPECT_EQ(nullptr, filter); 1707 EXPECT_EQ(nullptr, filter);
1706 } 1708 }
1707 1709
1708 // This unit test asserts that the basic reference counting, and filter merging 1710 // This unit test asserts that the basic reference counting, and filter merging
1709 // works correctly for discovery requests done via the BluetoothAdapter. 1711 // works correctly for discovery requests done via the BluetoothAdapter.
1710 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) { 1712 TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) {
1711 GetAdapter(); 1713 GetAdapter();
1712 adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, 1714 adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback,
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 devices = adapter_->GetDevices(); 2205 devices = adapter_->GetDevices();
2204 ASSERT_EQ(1U, devices.size()); 2206 ASSERT_EQ(1U, devices.size());
2205 } 2207 }
2206 2208
2207 TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { 2209 TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) {
2208 GetAdapter(); 2210 GetAdapter();
2209 DiscoverDevices(); 2211 DiscoverDevices();
2210 2212
2211 BluetoothDevice* device = adapter_->GetDevice( 2213 BluetoothDevice* device = adapter_->GetDevice(
2212 FakeBluetoothDeviceClient::kConnectUnpairableAddress); 2214 FakeBluetoothDeviceClient::kConnectUnpairableAddress);
2213 ASSERT_TRUE(device != NULL); 2215 ASSERT_TRUE(device != nullptr);
2214 ASSERT_FALSE(device->IsPaired()); 2216 ASSERT_FALSE(device->IsPaired());
2215 2217
2216 // Connect the device so it becomes trusted and remembered. 2218 // Connect the device so it becomes trusted and remembered.
2217 device->Connect(NULL, GetCallback(), 2219 device->Connect(nullptr, GetCallback(),
2218 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2220 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2219 base::Unretained(this))); 2221 base::Unretained(this)));
2220 2222
2221 ASSERT_EQ(1, callback_count_); 2223 ASSERT_EQ(1, callback_count_);
2222 ASSERT_EQ(0, error_callback_count_); 2224 ASSERT_EQ(0, error_callback_count_);
2223 callback_count_ = 0; 2225 callback_count_ = 0;
2224 2226
2225 ASSERT_TRUE(device->IsConnected()); 2227 ASSERT_TRUE(device->IsConnected());
2226 ASSERT_FALSE(device->IsConnecting()); 2228 ASSERT_FALSE(device->IsConnecting());
2227 2229
(...skipping 10 matching lines...) Expand all
2238 device->Forget(GetErrorCallback()); 2240 device->Forget(GetErrorCallback());
2239 EXPECT_EQ(0, error_callback_count_); 2241 EXPECT_EQ(0, error_callback_count_);
2240 2242
2241 EXPECT_EQ(1, observer.device_removed_count()); 2243 EXPECT_EQ(1, observer.device_removed_count());
2242 EXPECT_EQ(FakeBluetoothDeviceClient::kConnectUnpairableAddress, 2244 EXPECT_EQ(FakeBluetoothDeviceClient::kConnectUnpairableAddress,
2243 observer.last_device_address()); 2245 observer.last_device_address());
2244 2246
2245 // GetDevices shouldn't return the device either. 2247 // GetDevices shouldn't return the device either.
2246 device = adapter_->GetDevice( 2248 device = adapter_->GetDevice(
2247 FakeBluetoothDeviceClient::kConnectUnpairableAddress); 2249 FakeBluetoothDeviceClient::kConnectUnpairableAddress);
2248 EXPECT_FALSE(device != NULL); 2250 EXPECT_FALSE(device != nullptr);
2249 } 2251 }
2250 2252
2251 TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { 2253 TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) {
2252 GetAdapter(); 2254 GetAdapter();
2253 2255
2254 BluetoothDevice* device = adapter_->GetDevice( 2256 BluetoothDevice* device = adapter_->GetDevice(
2255 FakeBluetoothDeviceClient::kPairedDeviceAddress); 2257 FakeBluetoothDeviceClient::kPairedDeviceAddress);
2256 ASSERT_TRUE(device != NULL); 2258 ASSERT_TRUE(device != nullptr);
2257 ASSERT_TRUE(device->IsPaired()); 2259 ASSERT_TRUE(device->IsPaired());
2258 2260
2259 TestBluetoothAdapterObserver observer(adapter_); 2261 TestBluetoothAdapterObserver observer(adapter_);
2260 2262
2261 // Connect without a pairing delegate; since the device is already Paired 2263 // Connect without a pairing delegate; since the device is already Paired
2262 // this should succeed and the device should become connected. 2264 // this should succeed and the device should become connected.
2263 device->Connect(NULL, GetCallback(), 2265 device->Connect(nullptr, GetCallback(),
2264 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2266 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2265 base::Unretained(this))); 2267 base::Unretained(this)));
2266 2268
2267 EXPECT_EQ(1, callback_count_); 2269 EXPECT_EQ(1, callback_count_);
2268 EXPECT_EQ(0, error_callback_count_); 2270 EXPECT_EQ(0, error_callback_count_);
2269 2271
2270 // Two changes for connecting, one for connected and one for for trusted 2272 // Two changes for connecting, one for connected and one for for trusted
2271 // after connecting. 2273 // after connecting.
2272 EXPECT_EQ(4, observer.device_changed_count()); 2274 EXPECT_EQ(4, observer.device_changed_count());
2273 EXPECT_EQ(device, observer.last_device()); 2275 EXPECT_EQ(device, observer.last_device());
2274 2276
2275 EXPECT_TRUE(device->IsConnected()); 2277 EXPECT_TRUE(device->IsConnected());
2276 EXPECT_FALSE(device->IsConnecting()); 2278 EXPECT_FALSE(device->IsConnecting());
2277 } 2279 }
2278 2280
2279 TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { 2281 TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) {
2280 GetAdapter(); 2282 GetAdapter();
2281 DiscoverDevices(); 2283 DiscoverDevices();
2282 2284
2283 BluetoothDevice* device = adapter_->GetDevice( 2285 BluetoothDevice* device = adapter_->GetDevice(
2284 FakeBluetoothDeviceClient::kConnectUnpairableAddress); 2286 FakeBluetoothDeviceClient::kConnectUnpairableAddress);
2285 ASSERT_TRUE(device != NULL); 2287 ASSERT_TRUE(device != nullptr);
2286 ASSERT_FALSE(device->IsPaired()); 2288 ASSERT_FALSE(device->IsPaired());
2287 2289
2288 TestBluetoothAdapterObserver observer(adapter_); 2290 TestBluetoothAdapterObserver observer(adapter_);
2289 2291
2290 // Connect without a pairing delegate; since the device does not require 2292 // Connect without a pairing delegate; since the device does not require
2291 // pairing, this should succeed and the device should become connected. 2293 // pairing, this should succeed and the device should become connected.
2292 device->Connect(NULL, GetCallback(), 2294 device->Connect(nullptr, GetCallback(),
2293 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2295 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2294 base::Unretained(this))); 2296 base::Unretained(this)));
2295 2297
2296 EXPECT_EQ(1, callback_count_); 2298 EXPECT_EQ(1, callback_count_);
2297 EXPECT_EQ(0, error_callback_count_); 2299 EXPECT_EQ(0, error_callback_count_);
2298 2300
2299 // Two changes for connecting, one for connected, one for for trusted after 2301 // Two changes for connecting, one for connected, one for for trusted after
2300 // connection, and one for the reconnect mode (IsConnectable). 2302 // connection, and one for the reconnect mode (IsConnectable).
2301 EXPECT_EQ(5, observer.device_changed_count()); 2303 EXPECT_EQ(5, observer.device_changed_count());
2302 EXPECT_EQ(device, observer.last_device()); 2304 EXPECT_EQ(device, observer.last_device());
(...skipping 12 matching lines...) Expand all
2315 ASSERT_EQ(1U, uuids.size()); 2317 ASSERT_EQ(1U, uuids.size());
2316 EXPECT_EQ(uuids[0], BluetoothUUID("1124")); 2318 EXPECT_EQ(uuids[0], BluetoothUUID("1124"));
2317 EXPECT_FALSE(device->IsConnectable()); 2319 EXPECT_FALSE(device->IsConnectable());
2318 } 2320 }
2319 2321
2320 TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { 2322 TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) {
2321 GetAdapter(); 2323 GetAdapter();
2322 2324
2323 BluetoothDevice* device = adapter_->GetDevice( 2325 BluetoothDevice* device = adapter_->GetDevice(
2324 FakeBluetoothDeviceClient::kPairedDeviceAddress); 2326 FakeBluetoothDeviceClient::kPairedDeviceAddress);
2325 ASSERT_TRUE(device != NULL); 2327 ASSERT_TRUE(device != nullptr);
2326 ASSERT_TRUE(device->IsPaired()); 2328 ASSERT_TRUE(device->IsPaired());
2327 2329
2328 device->Connect(NULL, GetCallback(), 2330 device->Connect(nullptr, GetCallback(),
2329 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2331 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2330 base::Unretained(this))); 2332 base::Unretained(this)));
2331 2333
2332 ASSERT_EQ(1, callback_count_); 2334 ASSERT_EQ(1, callback_count_);
2333 ASSERT_EQ(0, error_callback_count_); 2335 ASSERT_EQ(0, error_callback_count_);
2334 callback_count_ = 0; 2336 callback_count_ = 0;
2335 2337
2336 ASSERT_TRUE(device->IsConnected()); 2338 ASSERT_TRUE(device->IsConnected());
2337 2339
2338 // Connect again; since the device is already Connected, this shouldn't do 2340 // Connect again; since the device is already Connected, this shouldn't do
2339 // anything to initiate the connection. 2341 // anything to initiate the connection.
2340 TestBluetoothAdapterObserver observer(adapter_); 2342 TestBluetoothAdapterObserver observer(adapter_);
2341 2343
2342 device->Connect(NULL, GetCallback(), 2344 device->Connect(nullptr, GetCallback(),
2343 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2345 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2344 base::Unretained(this))); 2346 base::Unretained(this)));
2345 2347
2346 EXPECT_EQ(1, callback_count_); 2348 EXPECT_EQ(1, callback_count_);
2347 EXPECT_EQ(0, error_callback_count_); 2349 EXPECT_EQ(0, error_callback_count_);
2348 2350
2349 // The observer will be called because Connecting will toggle true and false, 2351 // The observer will be called because Connecting will toggle true and false,
2350 // and the trusted property will be updated to true. 2352 // and the trusted property will be updated to true.
2351 EXPECT_EQ(3, observer.device_changed_count()); 2353 EXPECT_EQ(3, observer.device_changed_count());
2352 2354
2353 EXPECT_TRUE(device->IsConnected()); 2355 EXPECT_TRUE(device->IsConnected());
2354 EXPECT_FALSE(device->IsConnecting()); 2356 EXPECT_FALSE(device->IsConnecting());
2355 } 2357 }
2356 2358
2357 TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { 2359 TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) {
2358 GetAdapter(); 2360 GetAdapter();
2359 DiscoverDevices(); 2361 DiscoverDevices();
2360 2362
2361 BluetoothDevice* device = adapter_->GetDevice( 2363 BluetoothDevice* device = adapter_->GetDevice(
2362 FakeBluetoothDeviceClient::kLegacyAutopairAddress); 2364 FakeBluetoothDeviceClient::kLegacyAutopairAddress);
2363 ASSERT_TRUE(device != NULL); 2365 ASSERT_TRUE(device != nullptr);
2364 ASSERT_FALSE(device->IsPaired()); 2366 ASSERT_FALSE(device->IsPaired());
2365 2367
2366 TestBluetoothAdapterObserver observer(adapter_); 2368 TestBluetoothAdapterObserver observer(adapter_);
2367 2369
2368 // Connect without a pairing delegate; since the device requires pairing, 2370 // Connect without a pairing delegate; since the device requires pairing,
2369 // this should fail with an error. 2371 // this should fail with an error.
2370 device->Connect(NULL, GetCallback(), 2372 device->Connect(nullptr, GetCallback(),
2371 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2373 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2372 base::Unretained(this))); 2374 base::Unretained(this)));
2373 2375
2374 EXPECT_EQ(0, callback_count_); 2376 EXPECT_EQ(0, callback_count_);
2375 EXPECT_EQ(1, error_callback_count_); 2377 EXPECT_EQ(1, error_callback_count_);
2376 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_); 2378 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_);
2377 2379
2378 EXPECT_EQ(2, observer.device_changed_count()); 2380 EXPECT_EQ(2, observer.device_changed_count());
2379 2381
2380 EXPECT_FALSE(device->IsConnected()); 2382 EXPECT_FALSE(device->IsConnected());
2381 EXPECT_FALSE(device->IsConnecting()); 2383 EXPECT_FALSE(device->IsConnecting());
2382 } 2384 }
2383 2385
2384 TEST_F(BluetoothChromeOSTest, DisconnectDevice) { 2386 TEST_F(BluetoothChromeOSTest, DisconnectDevice) {
2385 GetAdapter(); 2387 GetAdapter();
2386 2388
2387 BluetoothDevice* device = adapter_->GetDevice( 2389 BluetoothDevice* device = adapter_->GetDevice(
2388 FakeBluetoothDeviceClient::kPairedDeviceAddress); 2390 FakeBluetoothDeviceClient::kPairedDeviceAddress);
2389 ASSERT_TRUE(device != NULL); 2391 ASSERT_TRUE(device != nullptr);
2390 ASSERT_TRUE(device->IsPaired()); 2392 ASSERT_TRUE(device->IsPaired());
2391 2393
2392 device->Connect(NULL, GetCallback(), 2394 device->Connect(nullptr, GetCallback(),
2393 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2395 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2394 base::Unretained(this))); 2396 base::Unretained(this)));
2395 2397
2396 ASSERT_EQ(1, callback_count_); 2398 ASSERT_EQ(1, callback_count_);
2397 ASSERT_EQ(0, error_callback_count_); 2399 ASSERT_EQ(0, error_callback_count_);
2398 callback_count_ = 0; 2400 callback_count_ = 0;
2399 2401
2400 ASSERT_TRUE(device->IsConnected()); 2402 ASSERT_TRUE(device->IsConnected());
2401 ASSERT_FALSE(device->IsConnecting()); 2403 ASSERT_FALSE(device->IsConnecting());
2402 2404
(...skipping 10 matching lines...) Expand all
2413 EXPECT_EQ(device, observer.last_device()); 2415 EXPECT_EQ(device, observer.last_device());
2414 2416
2415 EXPECT_FALSE(device->IsConnected()); 2417 EXPECT_FALSE(device->IsConnected());
2416 } 2418 }
2417 2419
2418 TEST_F(BluetoothChromeOSTest, DisconnectUnconnectedDevice) { 2420 TEST_F(BluetoothChromeOSTest, DisconnectUnconnectedDevice) {
2419 GetAdapter(); 2421 GetAdapter();
2420 2422
2421 BluetoothDevice* device = adapter_->GetDevice( 2423 BluetoothDevice* device = adapter_->GetDevice(
2422 FakeBluetoothDeviceClient::kPairedDeviceAddress); 2424 FakeBluetoothDeviceClient::kPairedDeviceAddress);
2423 ASSERT_TRUE(device != NULL); 2425 ASSERT_TRUE(device != nullptr);
2424 ASSERT_TRUE(device->IsPaired()); 2426 ASSERT_TRUE(device->IsPaired());
2425 ASSERT_FALSE(device->IsConnected()); 2427 ASSERT_FALSE(device->IsConnected());
2426 2428
2427 // Disconnect the device, we should see the observer method fire and the 2429 // Disconnect the device, we should see the observer method fire and the
2428 // device get dropped. 2430 // device get dropped.
2429 TestBluetoothAdapterObserver observer(adapter_); 2431 TestBluetoothAdapterObserver observer(adapter_);
2430 2432
2431 device->Disconnect(GetCallback(), GetErrorCallback()); 2433 device->Disconnect(GetCallback(), GetErrorCallback());
2432 2434
2433 EXPECT_EQ(0, callback_count_); 2435 EXPECT_EQ(0, callback_count_);
2434 EXPECT_EQ(1, error_callback_count_); 2436 EXPECT_EQ(1, error_callback_count_);
2435 2437
2436 EXPECT_EQ(0, observer.device_changed_count()); 2438 EXPECT_EQ(0, observer.device_changed_count());
2437 2439
2438 EXPECT_FALSE(device->IsConnected()); 2440 EXPECT_FALSE(device->IsConnected());
2439 } 2441 }
2440 2442
2441 TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) { 2443 TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) {
2442 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2444 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2443 2445
2444 GetAdapter(); 2446 GetAdapter();
2445 DiscoverDevices(); 2447 DiscoverDevices();
2446 2448
2447 // The Legacy Autopair device requires no PIN or Passkey to pair because 2449 // The Legacy Autopair device requires no PIN or Passkey to pair because
2448 // the daemon provides 0000 to the device for us. 2450 // the daemon provides 0000 to the device for us.
2449 BluetoothDevice* device = adapter_->GetDevice( 2451 BluetoothDevice* device = adapter_->GetDevice(
2450 FakeBluetoothDeviceClient::kLegacyAutopairAddress); 2452 FakeBluetoothDeviceClient::kLegacyAutopairAddress);
2451 ASSERT_TRUE(device != NULL); 2453 ASSERT_TRUE(device != nullptr);
2452 ASSERT_FALSE(device->IsPaired()); 2454 ASSERT_FALSE(device->IsPaired());
2453 2455
2454 TestBluetoothAdapterObserver observer(adapter_); 2456 TestBluetoothAdapterObserver observer(adapter_);
2455 2457
2456 TestPairingDelegate pairing_delegate; 2458 TestPairingDelegate pairing_delegate;
2457 device->Connect(&pairing_delegate, GetCallback(), 2459 device->Connect(&pairing_delegate, GetCallback(),
2458 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2460 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2459 base::Unretained(this))); 2461 base::Unretained(this)));
2460 2462
2461 EXPECT_EQ(0, pairing_delegate.call_count_); 2463 EXPECT_EQ(0, pairing_delegate.call_count_);
(...skipping 30 matching lines...) Expand all
2492 2494
2493 TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) { 2495 TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) {
2494 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2496 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2495 2497
2496 GetAdapter(); 2498 GetAdapter();
2497 DiscoverDevices(); 2499 DiscoverDevices();
2498 2500
2499 // Requires that we display a randomly generated PIN on the screen. 2501 // Requires that we display a randomly generated PIN on the screen.
2500 BluetoothDevice* device = adapter_->GetDevice( 2502 BluetoothDevice* device = adapter_->GetDevice(
2501 FakeBluetoothDeviceClient::kDisplayPinCodeAddress); 2503 FakeBluetoothDeviceClient::kDisplayPinCodeAddress);
2502 ASSERT_TRUE(device != NULL); 2504 ASSERT_TRUE(device != nullptr);
2503 ASSERT_FALSE(device->IsPaired()); 2505 ASSERT_FALSE(device->IsPaired());
2504 2506
2505 TestBluetoothAdapterObserver observer(adapter_); 2507 TestBluetoothAdapterObserver observer(adapter_);
2506 2508
2507 TestPairingDelegate pairing_delegate; 2509 TestPairingDelegate pairing_delegate;
2508 device->Connect(&pairing_delegate, GetCallback(), 2510 device->Connect(&pairing_delegate, GetCallback(),
2509 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2511 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2510 base::Unretained(this))); 2512 base::Unretained(this)));
2511 2513
2512 EXPECT_EQ(1, pairing_delegate.call_count_); 2514 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { 2548 TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) {
2547 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2549 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2548 2550
2549 GetAdapter(); 2551 GetAdapter();
2550 DiscoverDevices(); 2552 DiscoverDevices();
2551 2553
2552 // Requires that we display a randomly generated Passkey on the screen, 2554 // Requires that we display a randomly generated Passkey on the screen,
2553 // and notifies us as it's typed in. 2555 // and notifies us as it's typed in.
2554 BluetoothDevice* device = adapter_->GetDevice( 2556 BluetoothDevice* device = adapter_->GetDevice(
2555 FakeBluetoothDeviceClient::kDisplayPasskeyAddress); 2557 FakeBluetoothDeviceClient::kDisplayPasskeyAddress);
2556 ASSERT_TRUE(device != NULL); 2558 ASSERT_TRUE(device != nullptr);
2557 ASSERT_FALSE(device->IsPaired()); 2559 ASSERT_FALSE(device->IsPaired());
2558 2560
2559 TestBluetoothAdapterObserver observer(adapter_); 2561 TestBluetoothAdapterObserver observer(adapter_);
2560 2562
2561 TestPairingDelegate pairing_delegate; 2563 TestPairingDelegate pairing_delegate;
2562 device->Connect(&pairing_delegate, GetCallback(), 2564 device->Connect(&pairing_delegate, GetCallback(),
2563 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2565 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2564 base::Unretained(this))); 2566 base::Unretained(this)));
2565 2567
2566 // One call for DisplayPasskey() and one for KeysEntered(). 2568 // One call for DisplayPasskey() and one for KeysEntered().
2567 EXPECT_EQ(2, pairing_delegate.call_count_); 2569 EXPECT_EQ(2, pairing_delegate.call_count_);
2568 EXPECT_EQ(1, pairing_delegate.display_passkey_count_); 2570 EXPECT_EQ(1, pairing_delegate.display_passkey_count_);
2569 EXPECT_EQ(123456U, pairing_delegate.last_passkey_); 2571 EXPECT_EQ(123456U, pairing_delegate.last_passkey_);
2570 EXPECT_EQ(1, pairing_delegate.keys_entered_count_); 2572 EXPECT_EQ(1, pairing_delegate.keys_entered_count_);
2571 EXPECT_EQ(0U, pairing_delegate.last_entered_); 2573 EXPECT_EQ(0U, pairing_delegate.last_entered_);
2572 2574
2573 EXPECT_TRUE(device->IsConnecting()); 2575 EXPECT_TRUE(device->IsConnecting());
2574 2576
2575 // One call to KeysEntered() for each key, including [enter]. 2577 // One call to KeysEntered() for each key, including [enter].
2576 for(int i = 1; i <= 7; ++i) { 2578 for (int i = 1; i <= 7; ++i) {
2577 message_loop_.Run(); 2579 message_loop_.Run();
2578 2580
2579 EXPECT_EQ(2 + i, pairing_delegate.call_count_); 2581 EXPECT_EQ(2 + i, pairing_delegate.call_count_);
2580 EXPECT_EQ(1 + i, pairing_delegate.keys_entered_count_); 2582 EXPECT_EQ(1 + i, pairing_delegate.keys_entered_count_);
2581 EXPECT_EQ(static_cast<uint32_t>(i), pairing_delegate.last_entered_); 2583 EXPECT_EQ(static_cast<uint32_t>(i), pairing_delegate.last_entered_);
2582 } 2584 }
2583 2585
2584 message_loop_.Run(); 2586 message_loop_.Run();
2585 2587
2586 // 8 KeysEntered notifications (0 to 7, inclusive) and one aditional call for 2588 // 8 KeysEntered notifications (0 to 7, inclusive) and one aditional call for
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 2622
2621 TEST_F(BluetoothChromeOSTest, PairRequestPinCode) { 2623 TEST_F(BluetoothChromeOSTest, PairRequestPinCode) {
2622 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2624 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2623 2625
2624 GetAdapter(); 2626 GetAdapter();
2625 DiscoverDevices(); 2627 DiscoverDevices();
2626 2628
2627 // Requires that the user enters a PIN for them. 2629 // Requires that the user enters a PIN for them.
2628 BluetoothDevice* device = adapter_->GetDevice( 2630 BluetoothDevice* device = adapter_->GetDevice(
2629 FakeBluetoothDeviceClient::kRequestPinCodeAddress); 2631 FakeBluetoothDeviceClient::kRequestPinCodeAddress);
2630 ASSERT_TRUE(device != NULL); 2632 ASSERT_TRUE(device != nullptr);
2631 ASSERT_FALSE(device->IsPaired()); 2633 ASSERT_FALSE(device->IsPaired());
2632 2634
2633 TestBluetoothAdapterObserver observer(adapter_); 2635 TestBluetoothAdapterObserver observer(adapter_);
2634 2636
2635 TestPairingDelegate pairing_delegate; 2637 TestPairingDelegate pairing_delegate;
2636 device->Connect(&pairing_delegate, GetCallback(), 2638 device->Connect(&pairing_delegate, GetCallback(),
2637 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2639 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2638 base::Unretained(this))); 2640 base::Unretained(this)));
2639 2641
2640 EXPECT_EQ(1, pairing_delegate.call_count_); 2642 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 2676
2675 TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) { 2677 TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) {
2676 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2678 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2677 2679
2678 GetAdapter(); 2680 GetAdapter();
2679 DiscoverDevices(); 2681 DiscoverDevices();
2680 2682
2681 // Requests that we confirm a displayed passkey. 2683 // Requests that we confirm a displayed passkey.
2682 BluetoothDevice* device = adapter_->GetDevice( 2684 BluetoothDevice* device = adapter_->GetDevice(
2683 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); 2685 FakeBluetoothDeviceClient::kConfirmPasskeyAddress);
2684 ASSERT_TRUE(device != NULL); 2686 ASSERT_TRUE(device != nullptr);
2685 ASSERT_FALSE(device->IsPaired()); 2687 ASSERT_FALSE(device->IsPaired());
2686 2688
2687 TestBluetoothAdapterObserver observer(adapter_); 2689 TestBluetoothAdapterObserver observer(adapter_);
2688 2690
2689 TestPairingDelegate pairing_delegate; 2691 TestPairingDelegate pairing_delegate;
2690 device->Connect(&pairing_delegate, GetCallback(), 2692 device->Connect(&pairing_delegate, GetCallback(),
2691 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2693 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2692 base::Unretained(this))); 2694 base::Unretained(this)));
2693 2695
2694 EXPECT_EQ(1, pairing_delegate.call_count_); 2696 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2726 TEST_F(BluetoothChromeOSTest, PairRequestPasskey) { 2728 TEST_F(BluetoothChromeOSTest, PairRequestPasskey) {
2727 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2729 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2728 2730
2729 GetAdapter(); 2731 GetAdapter();
2730 DiscoverDevices(); 2732 DiscoverDevices();
2731 2733
2732 // Requires that the user enters a Passkey, this would be some kind of 2734 // Requires that the user enters a Passkey, this would be some kind of
2733 // device that has a display, but doesn't use "just works" - maybe a car? 2735 // device that has a display, but doesn't use "just works" - maybe a car?
2734 BluetoothDevice* device = adapter_->GetDevice( 2736 BluetoothDevice* device = adapter_->GetDevice(
2735 FakeBluetoothDeviceClient::kRequestPasskeyAddress); 2737 FakeBluetoothDeviceClient::kRequestPasskeyAddress);
2736 ASSERT_TRUE(device != NULL); 2738 ASSERT_TRUE(device != nullptr);
2737 ASSERT_FALSE(device->IsPaired()); 2739 ASSERT_FALSE(device->IsPaired());
2738 2740
2739 TestBluetoothAdapterObserver observer(adapter_); 2741 TestBluetoothAdapterObserver observer(adapter_);
2740 2742
2741 TestPairingDelegate pairing_delegate; 2743 TestPairingDelegate pairing_delegate;
2742 device->Connect(&pairing_delegate, GetCallback(), 2744 device->Connect(&pairing_delegate, GetCallback(),
2743 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2745 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2744 base::Unretained(this))); 2746 base::Unretained(this)));
2745 2747
2746 EXPECT_EQ(1, pairing_delegate.call_count_); 2748 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 30 matching lines...) Expand all
2777 TEST_F(BluetoothChromeOSTest, PairJustWorks) { 2779 TEST_F(BluetoothChromeOSTest, PairJustWorks) {
2778 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2780 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2779 2781
2780 GetAdapter(); 2782 GetAdapter();
2781 DiscoverDevices(); 2783 DiscoverDevices();
2782 2784
2783 // Uses just-works pairing, since this is an outgoing pairing, no delegate 2785 // Uses just-works pairing, since this is an outgoing pairing, no delegate
2784 // interaction is required. 2786 // interaction is required.
2785 BluetoothDevice* device = adapter_->GetDevice( 2787 BluetoothDevice* device = adapter_->GetDevice(
2786 FakeBluetoothDeviceClient::kJustWorksAddress); 2788 FakeBluetoothDeviceClient::kJustWorksAddress);
2787 ASSERT_TRUE(device != NULL); 2789 ASSERT_TRUE(device != nullptr);
2788 ASSERT_FALSE(device->IsPaired()); 2790 ASSERT_FALSE(device->IsPaired());
2789 2791
2790 TestBluetoothAdapterObserver observer(adapter_); 2792 TestBluetoothAdapterObserver observer(adapter_);
2791 2793
2792 TestPairingDelegate pairing_delegate; 2794 TestPairingDelegate pairing_delegate;
2793 device->Connect(&pairing_delegate, GetCallback(), 2795 device->Connect(&pairing_delegate, GetCallback(),
2794 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2796 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2795 base::Unretained(this))); 2797 base::Unretained(this)));
2796 2798
2797 EXPECT_EQ(0, pairing_delegate.call_count_); 2799 EXPECT_EQ(0, pairing_delegate.call_count_);
(...skipping 24 matching lines...) Expand all
2822 } 2824 }
2823 2825
2824 TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { 2826 TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) {
2825 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2827 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2826 2828
2827 GetAdapter(); 2829 GetAdapter();
2828 DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); 2830 DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress);
2829 2831
2830 BluetoothDevice* device = adapter_->GetDevice( 2832 BluetoothDevice* device = adapter_->GetDevice(
2831 FakeBluetoothDeviceClient::kUnpairableDeviceAddress); 2833 FakeBluetoothDeviceClient::kUnpairableDeviceAddress);
2832 ASSERT_TRUE(device != NULL); 2834 ASSERT_TRUE(device != nullptr);
2833 ASSERT_FALSE(device->IsPaired()); 2835 ASSERT_FALSE(device->IsPaired());
2834 2836
2835 TestBluetoothAdapterObserver observer(adapter_); 2837 TestBluetoothAdapterObserver observer(adapter_);
2836 2838
2837 TestPairingDelegate pairing_delegate; 2839 TestPairingDelegate pairing_delegate;
2838 device->Connect(&pairing_delegate, GetCallback(), 2840 device->Connect(&pairing_delegate, GetCallback(),
2839 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2841 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2840 base::Unretained(this))); 2842 base::Unretained(this)));
2841 2843
2842 EXPECT_EQ(0, pairing_delegate.call_count_); 2844 EXPECT_EQ(0, pairing_delegate.call_count_);
(...skipping 14 matching lines...) Expand all
2857 2859
2858 TEST_F(BluetoothChromeOSTest, PairingFails) { 2860 TEST_F(BluetoothChromeOSTest, PairingFails) {
2859 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2861 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2860 2862
2861 GetAdapter(); 2863 GetAdapter();
2862 DiscoverDevice(FakeBluetoothDeviceClient::kVanishingDeviceAddress); 2864 DiscoverDevice(FakeBluetoothDeviceClient::kVanishingDeviceAddress);
2863 2865
2864 // The vanishing device times out during pairing 2866 // The vanishing device times out during pairing
2865 BluetoothDevice* device = adapter_->GetDevice( 2867 BluetoothDevice* device = adapter_->GetDevice(
2866 FakeBluetoothDeviceClient::kVanishingDeviceAddress); 2868 FakeBluetoothDeviceClient::kVanishingDeviceAddress);
2867 ASSERT_TRUE(device != NULL); 2869 ASSERT_TRUE(device != nullptr);
2868 ASSERT_FALSE(device->IsPaired()); 2870 ASSERT_FALSE(device->IsPaired());
2869 2871
2870 TestBluetoothAdapterObserver observer(adapter_); 2872 TestBluetoothAdapterObserver observer(adapter_);
2871 2873
2872 TestPairingDelegate pairing_delegate; 2874 TestPairingDelegate pairing_delegate;
2873 device->Connect(&pairing_delegate, GetCallback(), 2875 device->Connect(&pairing_delegate, GetCallback(),
2874 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2876 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2875 base::Unretained(this))); 2877 base::Unretained(this)));
2876 2878
2877 EXPECT_EQ(0, pairing_delegate.call_count_); 2879 EXPECT_EQ(0, pairing_delegate.call_count_);
(...skipping 15 matching lines...) Expand all
2893 TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { 2895 TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) {
2894 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2896 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2895 2897
2896 GetAdapter(); 2898 GetAdapter();
2897 DiscoverDevices(); 2899 DiscoverDevices();
2898 2900
2899 // Everything seems to go according to plan with the unconnectable device; 2901 // Everything seems to go according to plan with the unconnectable device;
2900 // it pairs, but then you can't make connections to it after. 2902 // it pairs, but then you can't make connections to it after.
2901 BluetoothDevice* device = adapter_->GetDevice( 2903 BluetoothDevice* device = adapter_->GetDevice(
2902 FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); 2904 FakeBluetoothDeviceClient::kUnconnectableDeviceAddress);
2903 ASSERT_TRUE(device != NULL); 2905 ASSERT_TRUE(device != nullptr);
2904 ASSERT_FALSE(device->IsPaired()); 2906 ASSERT_FALSE(device->IsPaired());
2905 2907
2906 TestBluetoothAdapterObserver observer(adapter_); 2908 TestBluetoothAdapterObserver observer(adapter_);
2907 2909
2908 TestPairingDelegate pairing_delegate; 2910 TestPairingDelegate pairing_delegate;
2909 device->Connect(&pairing_delegate, GetCallback(), 2911 device->Connect(&pairing_delegate, GetCallback(),
2910 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2912 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2911 base::Unretained(this))); 2913 base::Unretained(this)));
2912 2914
2913 EXPECT_EQ(0, pairing_delegate.call_count_); 2915 EXPECT_EQ(0, pairing_delegate.call_count_);
(...skipping 26 matching lines...) Expand all
2940 2942
2941 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { 2943 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) {
2942 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2944 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2943 2945
2944 GetAdapter(); 2946 GetAdapter();
2945 DiscoverDevices(); 2947 DiscoverDevices();
2946 2948
2947 // Reject the pairing after we receive a request for the PIN code. 2949 // Reject the pairing after we receive a request for the PIN code.
2948 BluetoothDevice* device = adapter_->GetDevice( 2950 BluetoothDevice* device = adapter_->GetDevice(
2949 FakeBluetoothDeviceClient::kRequestPinCodeAddress); 2951 FakeBluetoothDeviceClient::kRequestPinCodeAddress);
2950 ASSERT_TRUE(device != NULL); 2952 ASSERT_TRUE(device != nullptr);
2951 ASSERT_FALSE(device->IsPaired()); 2953 ASSERT_FALSE(device->IsPaired());
2952 2954
2953 TestBluetoothAdapterObserver observer(adapter_); 2955 TestBluetoothAdapterObserver observer(adapter_);
2954 2956
2955 TestPairingDelegate pairing_delegate; 2957 TestPairingDelegate pairing_delegate;
2956 device->Connect(&pairing_delegate, GetCallback(), 2958 device->Connect(&pairing_delegate, GetCallback(),
2957 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2959 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2958 base::Unretained(this))); 2960 base::Unretained(this)));
2959 2961
2960 EXPECT_EQ(1, pairing_delegate.call_count_); 2962 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 17 matching lines...) Expand all
2978 2980
2979 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { 2981 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) {
2980 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 2982 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
2981 2983
2982 GetAdapter(); 2984 GetAdapter();
2983 DiscoverDevices(); 2985 DiscoverDevices();
2984 2986
2985 // Cancel the pairing after we receive a request for the PIN code. 2987 // Cancel the pairing after we receive a request for the PIN code.
2986 BluetoothDevice* device = adapter_->GetDevice( 2988 BluetoothDevice* device = adapter_->GetDevice(
2987 FakeBluetoothDeviceClient::kRequestPinCodeAddress); 2989 FakeBluetoothDeviceClient::kRequestPinCodeAddress);
2988 ASSERT_TRUE(device != NULL); 2990 ASSERT_TRUE(device != nullptr);
2989 ASSERT_FALSE(device->IsPaired()); 2991 ASSERT_FALSE(device->IsPaired());
2990 2992
2991 TestBluetoothAdapterObserver observer(adapter_); 2993 TestBluetoothAdapterObserver observer(adapter_);
2992 2994
2993 TestPairingDelegate pairing_delegate; 2995 TestPairingDelegate pairing_delegate;
2994 device->Connect(&pairing_delegate, GetCallback(), 2996 device->Connect(&pairing_delegate, GetCallback(),
2995 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 2997 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
2996 base::Unretained(this))); 2998 base::Unretained(this)));
2997 2999
2998 EXPECT_EQ(1, pairing_delegate.call_count_); 3000 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 17 matching lines...) Expand all
3016 3018
3017 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { 3019 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) {
3018 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3020 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3019 3021
3020 GetAdapter(); 3022 GetAdapter();
3021 DiscoverDevices(); 3023 DiscoverDevices();
3022 3024
3023 // Reject the pairing after we receive a request for the passkey. 3025 // Reject the pairing after we receive a request for the passkey.
3024 BluetoothDevice* device = adapter_->GetDevice( 3026 BluetoothDevice* device = adapter_->GetDevice(
3025 FakeBluetoothDeviceClient::kRequestPasskeyAddress); 3027 FakeBluetoothDeviceClient::kRequestPasskeyAddress);
3026 ASSERT_TRUE(device != NULL); 3028 ASSERT_TRUE(device != nullptr);
3027 ASSERT_FALSE(device->IsPaired()); 3029 ASSERT_FALSE(device->IsPaired());
3028 3030
3029 TestBluetoothAdapterObserver observer(adapter_); 3031 TestBluetoothAdapterObserver observer(adapter_);
3030 3032
3031 TestPairingDelegate pairing_delegate; 3033 TestPairingDelegate pairing_delegate;
3032 device->Connect(&pairing_delegate, GetCallback(), 3034 device->Connect(&pairing_delegate, GetCallback(),
3033 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 3035 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
3034 base::Unretained(this))); 3036 base::Unretained(this)));
3035 3037
3036 EXPECT_EQ(1, pairing_delegate.call_count_); 3038 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 17 matching lines...) Expand all
3054 3056
3055 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { 3057 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) {
3056 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3058 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3057 3059
3058 GetAdapter(); 3060 GetAdapter();
3059 DiscoverDevices(); 3061 DiscoverDevices();
3060 3062
3061 // Cancel the pairing after we receive a request for the passkey. 3063 // Cancel the pairing after we receive a request for the passkey.
3062 BluetoothDevice* device = adapter_->GetDevice( 3064 BluetoothDevice* device = adapter_->GetDevice(
3063 FakeBluetoothDeviceClient::kRequestPasskeyAddress); 3065 FakeBluetoothDeviceClient::kRequestPasskeyAddress);
3064 ASSERT_TRUE(device != NULL); 3066 ASSERT_TRUE(device != nullptr);
3065 ASSERT_FALSE(device->IsPaired()); 3067 ASSERT_FALSE(device->IsPaired());
3066 3068
3067 TestBluetoothAdapterObserver observer(adapter_); 3069 TestBluetoothAdapterObserver observer(adapter_);
3068 3070
3069 TestPairingDelegate pairing_delegate; 3071 TestPairingDelegate pairing_delegate;
3070 device->Connect(&pairing_delegate, GetCallback(), 3072 device->Connect(&pairing_delegate, GetCallback(),
3071 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 3073 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
3072 base::Unretained(this))); 3074 base::Unretained(this)));
3073 3075
3074 EXPECT_EQ(1, pairing_delegate.call_count_); 3076 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 17 matching lines...) Expand all
3092 3094
3093 TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { 3095 TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) {
3094 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3096 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3095 3097
3096 GetAdapter(); 3098 GetAdapter();
3097 DiscoverDevices(); 3099 DiscoverDevices();
3098 3100
3099 // Reject the pairing after we receive a request for passkey confirmation. 3101 // Reject the pairing after we receive a request for passkey confirmation.
3100 BluetoothDevice* device = adapter_->GetDevice( 3102 BluetoothDevice* device = adapter_->GetDevice(
3101 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); 3103 FakeBluetoothDeviceClient::kConfirmPasskeyAddress);
3102 ASSERT_TRUE(device != NULL); 3104 ASSERT_TRUE(device != nullptr);
3103 ASSERT_FALSE(device->IsPaired()); 3105 ASSERT_FALSE(device->IsPaired());
3104 3106
3105 TestBluetoothAdapterObserver observer(adapter_); 3107 TestBluetoothAdapterObserver observer(adapter_);
3106 3108
3107 TestPairingDelegate pairing_delegate; 3109 TestPairingDelegate pairing_delegate;
3108 device->Connect(&pairing_delegate, GetCallback(), 3110 device->Connect(&pairing_delegate, GetCallback(),
3109 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 3111 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
3110 base::Unretained(this))); 3112 base::Unretained(this)));
3111 3113
3112 EXPECT_EQ(1, pairing_delegate.call_count_); 3114 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 17 matching lines...) Expand all
3130 3132
3131 TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { 3133 TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) {
3132 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3134 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3133 3135
3134 GetAdapter(); 3136 GetAdapter();
3135 DiscoverDevices(); 3137 DiscoverDevices();
3136 3138
3137 // Cancel the pairing after we receive a request for the passkey. 3139 // Cancel the pairing after we receive a request for the passkey.
3138 BluetoothDevice* device = adapter_->GetDevice( 3140 BluetoothDevice* device = adapter_->GetDevice(
3139 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); 3141 FakeBluetoothDeviceClient::kConfirmPasskeyAddress);
3140 ASSERT_TRUE(device != NULL); 3142 ASSERT_TRUE(device != nullptr);
3141 ASSERT_FALSE(device->IsPaired()); 3143 ASSERT_FALSE(device->IsPaired());
3142 3144
3143 TestBluetoothAdapterObserver observer(adapter_); 3145 TestBluetoothAdapterObserver observer(adapter_);
3144 3146
3145 TestPairingDelegate pairing_delegate; 3147 TestPairingDelegate pairing_delegate;
3146 device->Connect(&pairing_delegate, GetCallback(), 3148 device->Connect(&pairing_delegate, GetCallback(),
3147 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 3149 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
3148 base::Unretained(this))); 3150 base::Unretained(this)));
3149 3151
3150 EXPECT_EQ(1, pairing_delegate.call_count_); 3152 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 17 matching lines...) Expand all
3168 3170
3169 TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { 3171 TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) {
3170 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3172 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3171 3173
3172 GetAdapter(); 3174 GetAdapter();
3173 DiscoverDevices(); 3175 DiscoverDevices();
3174 3176
3175 // Cancel the pairing while we're waiting for the remote host. 3177 // Cancel the pairing while we're waiting for the remote host.
3176 BluetoothDevice* device = adapter_->GetDevice( 3178 BluetoothDevice* device = adapter_->GetDevice(
3177 FakeBluetoothDeviceClient::kLegacyAutopairAddress); 3179 FakeBluetoothDeviceClient::kLegacyAutopairAddress);
3178 ASSERT_TRUE(device != NULL); 3180 ASSERT_TRUE(device != nullptr);
3179 ASSERT_FALSE(device->IsPaired()); 3181 ASSERT_FALSE(device->IsPaired());
3180 3182
3181 TestBluetoothAdapterObserver observer(adapter_); 3183 TestBluetoothAdapterObserver observer(adapter_);
3182 3184
3183 TestPairingDelegate pairing_delegate; 3185 TestPairingDelegate pairing_delegate;
3184 device->Connect(&pairing_delegate, GetCallback(), 3186 device->Connect(&pairing_delegate, GetCallback(),
3185 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 3187 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
3186 base::Unretained(this))); 3188 base::Unretained(this)));
3187 3189
3188 EXPECT_EQ(0, pairing_delegate.call_count_); 3190 EXPECT_EQ(0, pairing_delegate.call_count_);
(...skipping 23 matching lines...) Expand all
3212 adapter_->AddPairingDelegate( 3214 adapter_->AddPairingDelegate(
3213 &pairing_delegate, 3215 &pairing_delegate,
3214 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); 3216 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH);
3215 3217
3216 // Requires that we provide a PIN code. 3218 // Requires that we provide a PIN code.
3217 fake_bluetooth_device_client_->CreateDevice( 3219 fake_bluetooth_device_client_->CreateDevice(
3218 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), 3220 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
3219 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); 3221 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath));
3220 BluetoothDevice* device = adapter_->GetDevice( 3222 BluetoothDevice* device = adapter_->GetDevice(
3221 FakeBluetoothDeviceClient::kRequestPinCodeAddress); 3223 FakeBluetoothDeviceClient::kRequestPinCodeAddress);
3222 ASSERT_TRUE(device != NULL); 3224 ASSERT_TRUE(device != nullptr);
3223 ASSERT_FALSE(device->IsPaired()); 3225 ASSERT_FALSE(device->IsPaired());
3224 3226
3225 TestBluetoothAdapterObserver observer(adapter_); 3227 TestBluetoothAdapterObserver observer(adapter_);
3226 3228
3227 fake_bluetooth_device_client_->SimulatePairing( 3229 fake_bluetooth_device_client_->SimulatePairing(
3228 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), true, 3230 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), true,
3229 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, 3231 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback,
3230 base::Unretained(this))); 3232 base::Unretained(this)));
3231 3233
3232 EXPECT_EQ(1, pairing_delegate.call_count_); 3234 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 14 matching lines...) Expand all
3247 3249
3248 // Make sure the trusted property has been set to true. 3250 // Make sure the trusted property has been set to true.
3249 FakeBluetoothDeviceClient::Properties* properties = 3251 FakeBluetoothDeviceClient::Properties* properties =
3250 fake_bluetooth_device_client_->GetProperties( 3252 fake_bluetooth_device_client_->GetProperties(
3251 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); 3253 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath));
3252 ASSERT_TRUE(properties->trusted.value()); 3254 ASSERT_TRUE(properties->trusted.value());
3253 3255
3254 // No pairing context should remain on the device. 3256 // No pairing context should remain on the device.
3255 BluetoothDeviceChromeOS* device_chromeos = 3257 BluetoothDeviceChromeOS* device_chromeos =
3256 static_cast<BluetoothDeviceChromeOS*>(device); 3258 static_cast<BluetoothDeviceChromeOS*>(device);
3257 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); 3259 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr);
3258 } 3260 }
3259 3261
3260 TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { 3262 TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) {
3261 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3263 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3262 3264
3263 GetAdapter(); 3265 GetAdapter();
3264 3266
3265 TestPairingDelegate pairing_delegate; 3267 TestPairingDelegate pairing_delegate;
3266 adapter_->AddPairingDelegate( 3268 adapter_->AddPairingDelegate(
3267 &pairing_delegate, 3269 &pairing_delegate,
3268 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); 3270 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH);
3269 3271
3270 // Requests that we confirm a displayed passkey. 3272 // Requests that we confirm a displayed passkey.
3271 fake_bluetooth_device_client_->CreateDevice( 3273 fake_bluetooth_device_client_->CreateDevice(
3272 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), 3274 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
3273 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); 3275 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath));
3274 BluetoothDevice* device = adapter_->GetDevice( 3276 BluetoothDevice* device = adapter_->GetDevice(
3275 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); 3277 FakeBluetoothDeviceClient::kConfirmPasskeyAddress);
3276 ASSERT_TRUE(device != NULL); 3278 ASSERT_TRUE(device != nullptr);
3277 ASSERT_FALSE(device->IsPaired()); 3279 ASSERT_FALSE(device->IsPaired());
3278 3280
3279 TestBluetoothAdapterObserver observer(adapter_); 3281 TestBluetoothAdapterObserver observer(adapter_);
3280 3282
3281 fake_bluetooth_device_client_->SimulatePairing( 3283 fake_bluetooth_device_client_->SimulatePairing(
3282 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), true, 3284 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), true,
3283 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, 3285 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback,
3284 base::Unretained(this))); 3286 base::Unretained(this)));
3285 3287
3286 EXPECT_EQ(1, pairing_delegate.call_count_); 3288 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 15 matching lines...) Expand all
3302 3304
3303 // Make sure the trusted property has been set to true. 3305 // Make sure the trusted property has been set to true.
3304 FakeBluetoothDeviceClient::Properties* properties = 3306 FakeBluetoothDeviceClient::Properties* properties =
3305 fake_bluetooth_device_client_->GetProperties( 3307 fake_bluetooth_device_client_->GetProperties(
3306 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); 3308 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath));
3307 ASSERT_TRUE(properties->trusted.value()); 3309 ASSERT_TRUE(properties->trusted.value());
3308 3310
3309 // No pairing context should remain on the device. 3311 // No pairing context should remain on the device.
3310 BluetoothDeviceChromeOS* device_chromeos = 3312 BluetoothDeviceChromeOS* device_chromeos =
3311 static_cast<BluetoothDeviceChromeOS*>(device); 3313 static_cast<BluetoothDeviceChromeOS*>(device);
3312 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); 3314 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr);
3313 } 3315 }
3314 3316
3315 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { 3317 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) {
3316 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3318 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3317 3319
3318 GetAdapter(); 3320 GetAdapter();
3319 3321
3320 TestPairingDelegate pairing_delegate; 3322 TestPairingDelegate pairing_delegate;
3321 adapter_->AddPairingDelegate( 3323 adapter_->AddPairingDelegate(
3322 &pairing_delegate, 3324 &pairing_delegate,
3323 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); 3325 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH);
3324 3326
3325 // Requests that we provide a Passkey. 3327 // Requests that we provide a Passkey.
3326 fake_bluetooth_device_client_->CreateDevice( 3328 fake_bluetooth_device_client_->CreateDevice(
3327 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), 3329 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
3328 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); 3330 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath));
3329 BluetoothDevice* device = adapter_->GetDevice( 3331 BluetoothDevice* device = adapter_->GetDevice(
3330 FakeBluetoothDeviceClient::kRequestPasskeyAddress); 3332 FakeBluetoothDeviceClient::kRequestPasskeyAddress);
3331 ASSERT_TRUE(device != NULL); 3333 ASSERT_TRUE(device != nullptr);
3332 ASSERT_FALSE(device->IsPaired()); 3334 ASSERT_FALSE(device->IsPaired());
3333 3335
3334 TestBluetoothAdapterObserver observer(adapter_); 3336 TestBluetoothAdapterObserver observer(adapter_);
3335 3337
3336 fake_bluetooth_device_client_->SimulatePairing( 3338 fake_bluetooth_device_client_->SimulatePairing(
3337 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, 3339 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true,
3338 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, 3340 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback,
3339 base::Unretained(this))); 3341 base::Unretained(this)));
3340 3342
3341 EXPECT_EQ(1, pairing_delegate.call_count_); 3343 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 14 matching lines...) Expand all
3356 3358
3357 // Make sure the trusted property has been set to true. 3359 // Make sure the trusted property has been set to true.
3358 FakeBluetoothDeviceClient::Properties* properties = 3360 FakeBluetoothDeviceClient::Properties* properties =
3359 fake_bluetooth_device_client_->GetProperties( 3361 fake_bluetooth_device_client_->GetProperties(
3360 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); 3362 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath));
3361 ASSERT_TRUE(properties->trusted.value()); 3363 ASSERT_TRUE(properties->trusted.value());
3362 3364
3363 // No pairing context should remain on the device. 3365 // No pairing context should remain on the device.
3364 BluetoothDeviceChromeOS* device_chromeos = 3366 BluetoothDeviceChromeOS* device_chromeos =
3365 static_cast<BluetoothDeviceChromeOS*>(device); 3367 static_cast<BluetoothDeviceChromeOS*>(device);
3366 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); 3368 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr);
3367 } 3369 }
3368 3370
3369 TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { 3371 TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) {
3370 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3372 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3371 3373
3372 GetAdapter(); 3374 GetAdapter();
3373 3375
3374 TestPairingDelegate pairing_delegate; 3376 TestPairingDelegate pairing_delegate;
3375 adapter_->AddPairingDelegate( 3377 adapter_->AddPairingDelegate(
3376 &pairing_delegate, 3378 &pairing_delegate,
3377 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); 3379 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH);
3378 3380
3379 // Uses just-works pairing so, sinec this an incoming pairing, require 3381 // Uses just-works pairing so, sinec this an incoming pairing, require
3380 // authorization from the user. 3382 // authorization from the user.
3381 fake_bluetooth_device_client_->CreateDevice( 3383 fake_bluetooth_device_client_->CreateDevice(
3382 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), 3384 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
3383 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); 3385 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath));
3384 BluetoothDevice* device = adapter_->GetDevice( 3386 BluetoothDevice* device = adapter_->GetDevice(
3385 FakeBluetoothDeviceClient::kJustWorksAddress); 3387 FakeBluetoothDeviceClient::kJustWorksAddress);
3386 ASSERT_TRUE(device != NULL); 3388 ASSERT_TRUE(device != nullptr);
3387 ASSERT_FALSE(device->IsPaired()); 3389 ASSERT_FALSE(device->IsPaired());
3388 3390
3389 TestBluetoothAdapterObserver observer(adapter_); 3391 TestBluetoothAdapterObserver observer(adapter_);
3390 3392
3391 fake_bluetooth_device_client_->SimulatePairing( 3393 fake_bluetooth_device_client_->SimulatePairing(
3392 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), true, 3394 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), true,
3393 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, 3395 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback,
3394 base::Unretained(this))); 3396 base::Unretained(this)));
3395 3397
3396 EXPECT_EQ(1, pairing_delegate.call_count_); 3398 EXPECT_EQ(1, pairing_delegate.call_count_);
(...skipping 14 matching lines...) Expand all
3411 3413
3412 // Make sure the trusted property has been set to true. 3414 // Make sure the trusted property has been set to true.
3413 FakeBluetoothDeviceClient::Properties* properties = 3415 FakeBluetoothDeviceClient::Properties* properties =
3414 fake_bluetooth_device_client_->GetProperties( 3416 fake_bluetooth_device_client_->GetProperties(
3415 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); 3417 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath));
3416 ASSERT_TRUE(properties->trusted.value()); 3418 ASSERT_TRUE(properties->trusted.value());
3417 3419
3418 // No pairing context should remain on the device. 3420 // No pairing context should remain on the device.
3419 BluetoothDeviceChromeOS* device_chromeos = 3421 BluetoothDeviceChromeOS* device_chromeos =
3420 static_cast<BluetoothDeviceChromeOS*>(device); 3422 static_cast<BluetoothDeviceChromeOS*>(device);
3421 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); 3423 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr);
3422 } 3424 }
3423 3425
3424 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { 3426 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) {
3425 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3427 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3426 3428
3427 GetAdapter(); 3429 GetAdapter();
3428 3430
3429 // Requires that we provide a PIN Code, without a pairing delegate, 3431 // Requires that we provide a PIN Code, without a pairing delegate,
3430 // that will be rejected. 3432 // that will be rejected.
3431 fake_bluetooth_device_client_->CreateDevice( 3433 fake_bluetooth_device_client_->CreateDevice(
3432 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), 3434 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
3433 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); 3435 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath));
3434 BluetoothDevice* device = adapter_->GetDevice( 3436 BluetoothDevice* device = adapter_->GetDevice(
3435 FakeBluetoothDeviceClient::kRequestPinCodeAddress); 3437 FakeBluetoothDeviceClient::kRequestPinCodeAddress);
3436 ASSERT_TRUE(device != NULL); 3438 ASSERT_TRUE(device != nullptr);
3437 ASSERT_FALSE(device->IsPaired()); 3439 ASSERT_FALSE(device->IsPaired());
3438 3440
3439 TestBluetoothAdapterObserver observer(adapter_); 3441 TestBluetoothAdapterObserver observer(adapter_);
3440 3442
3441 fake_bluetooth_device_client_->SimulatePairing( 3443 fake_bluetooth_device_client_->SimulatePairing(
3442 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), true, 3444 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), true,
3443 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, 3445 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback,
3444 base::Unretained(this))); 3446 base::Unretained(this)));
3445 3447
3446 message_loop_.Run(); 3448 message_loop_.Run();
3447 3449
3448 EXPECT_EQ(0, callback_count_); 3450 EXPECT_EQ(0, callback_count_);
3449 EXPECT_EQ(1, error_callback_count_); 3451 EXPECT_EQ(1, error_callback_count_);
3450 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); 3452 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_);
3451 3453
3452 // No changes should be observer. 3454 // No changes should be observer.
3453 EXPECT_EQ(0, observer.device_changed_count()); 3455 EXPECT_EQ(0, observer.device_changed_count());
3454 3456
3455 EXPECT_FALSE(device->IsPaired()); 3457 EXPECT_FALSE(device->IsPaired());
3456 3458
3457 // No pairing context should remain on the device. 3459 // No pairing context should remain on the device.
3458 BluetoothDeviceChromeOS* device_chromeos = 3460 BluetoothDeviceChromeOS* device_chromeos =
3459 static_cast<BluetoothDeviceChromeOS*>(device); 3461 static_cast<BluetoothDeviceChromeOS*>(device);
3460 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); 3462 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr);
3461 } 3463 }
3462 3464
3463 TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { 3465 TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) {
3464 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3466 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3465 3467
3466 GetAdapter(); 3468 GetAdapter();
3467 3469
3468 // Requests that we confirm a displayed passkey, without a pairing delegate, 3470 // Requests that we confirm a displayed passkey, without a pairing delegate,
3469 // that will be rejected. 3471 // that will be rejected.
3470 fake_bluetooth_device_client_->CreateDevice( 3472 fake_bluetooth_device_client_->CreateDevice(
3471 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), 3473 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
3472 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); 3474 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath));
3473 BluetoothDevice* device = adapter_->GetDevice( 3475 BluetoothDevice* device = adapter_->GetDevice(
3474 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); 3476 FakeBluetoothDeviceClient::kConfirmPasskeyAddress);
3475 ASSERT_TRUE(device != NULL); 3477 ASSERT_TRUE(device != nullptr);
3476 ASSERT_FALSE(device->IsPaired()); 3478 ASSERT_FALSE(device->IsPaired());
3477 3479
3478 TestBluetoothAdapterObserver observer(adapter_); 3480 TestBluetoothAdapterObserver observer(adapter_);
3479 3481
3480 fake_bluetooth_device_client_->SimulatePairing( 3482 fake_bluetooth_device_client_->SimulatePairing(
3481 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), true, 3483 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), true,
3482 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, 3484 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback,
3483 base::Unretained(this))); 3485 base::Unretained(this)));
3484 3486
3485 message_loop_.Run(); 3487 message_loop_.Run();
3486 3488
3487 EXPECT_EQ(0, callback_count_); 3489 EXPECT_EQ(0, callback_count_);
3488 EXPECT_EQ(1, error_callback_count_); 3490 EXPECT_EQ(1, error_callback_count_);
3489 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); 3491 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_);
3490 3492
3491 // No changes should be observer. 3493 // No changes should be observer.
3492 EXPECT_EQ(0, observer.device_changed_count()); 3494 EXPECT_EQ(0, observer.device_changed_count());
3493 3495
3494 EXPECT_FALSE(device->IsPaired()); 3496 EXPECT_FALSE(device->IsPaired());
3495 3497
3496 // No pairing context should remain on the device. 3498 // No pairing context should remain on the device.
3497 BluetoothDeviceChromeOS* device_chromeos = 3499 BluetoothDeviceChromeOS* device_chromeos =
3498 static_cast<BluetoothDeviceChromeOS*>(device); 3500 static_cast<BluetoothDeviceChromeOS*>(device);
3499 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); 3501 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr);
3500 } 3502 }
3501 3503
3502 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { 3504 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) {
3503 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3505 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3504 3506
3505 GetAdapter(); 3507 GetAdapter();
3506 3508
3507 // Requests that we provide a displayed passkey, without a pairing delegate, 3509 // Requests that we provide a displayed passkey, without a pairing delegate,
3508 // that will be rejected. 3510 // that will be rejected.
3509 fake_bluetooth_device_client_->CreateDevice( 3511 fake_bluetooth_device_client_->CreateDevice(
3510 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), 3512 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
3511 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); 3513 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath));
3512 BluetoothDevice* device = adapter_->GetDevice( 3514 BluetoothDevice* device = adapter_->GetDevice(
3513 FakeBluetoothDeviceClient::kRequestPasskeyAddress); 3515 FakeBluetoothDeviceClient::kRequestPasskeyAddress);
3514 ASSERT_TRUE(device != NULL); 3516 ASSERT_TRUE(device != nullptr);
3515 ASSERT_FALSE(device->IsPaired()); 3517 ASSERT_FALSE(device->IsPaired());
3516 3518
3517 TestBluetoothAdapterObserver observer(adapter_); 3519 TestBluetoothAdapterObserver observer(adapter_);
3518 3520
3519 fake_bluetooth_device_client_->SimulatePairing( 3521 fake_bluetooth_device_client_->SimulatePairing(
3520 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, 3522 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true,
3521 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, 3523 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback,
3522 base::Unretained(this))); 3524 base::Unretained(this)));
3523 3525
3524 message_loop_.Run(); 3526 message_loop_.Run();
3525 3527
3526 EXPECT_EQ(0, callback_count_); 3528 EXPECT_EQ(0, callback_count_);
3527 EXPECT_EQ(1, error_callback_count_); 3529 EXPECT_EQ(1, error_callback_count_);
3528 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); 3530 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_);
3529 3531
3530 // No changes should be observer. 3532 // No changes should be observer.
3531 EXPECT_EQ(0, observer.device_changed_count()); 3533 EXPECT_EQ(0, observer.device_changed_count());
3532 3534
3533 EXPECT_FALSE(device->IsPaired()); 3535 EXPECT_FALSE(device->IsPaired());
3534 3536
3535 // No pairing context should remain on the device. 3537 // No pairing context should remain on the device.
3536 BluetoothDeviceChromeOS* device_chromeos = 3538 BluetoothDeviceChromeOS* device_chromeos =
3537 static_cast<BluetoothDeviceChromeOS*>(device); 3539 static_cast<BluetoothDeviceChromeOS*>(device);
3538 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); 3540 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr);
3539 } 3541 }
3540 3542
3541 TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { 3543 TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) {
3542 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3544 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3543 3545
3544 GetAdapter(); 3546 GetAdapter();
3545 3547
3546 // Uses just-works pairing and thus requires authorization for incoming 3548 // Uses just-works pairing and thus requires authorization for incoming
3547 // pairings, without a pairing delegate, that will be rejected. 3549 // pairings, without a pairing delegate, that will be rejected.
3548 fake_bluetooth_device_client_->CreateDevice( 3550 fake_bluetooth_device_client_->CreateDevice(
3549 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), 3551 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
3550 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); 3552 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath));
3551 BluetoothDevice* device = adapter_->GetDevice( 3553 BluetoothDevice* device = adapter_->GetDevice(
3552 FakeBluetoothDeviceClient::kJustWorksAddress); 3554 FakeBluetoothDeviceClient::kJustWorksAddress);
3553 ASSERT_TRUE(device != NULL); 3555 ASSERT_TRUE(device != nullptr);
3554 ASSERT_FALSE(device->IsPaired()); 3556 ASSERT_FALSE(device->IsPaired());
3555 3557
3556 TestBluetoothAdapterObserver observer(adapter_); 3558 TestBluetoothAdapterObserver observer(adapter_);
3557 3559
3558 fake_bluetooth_device_client_->SimulatePairing( 3560 fake_bluetooth_device_client_->SimulatePairing(
3559 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), true, 3561 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), true,
3560 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, 3562 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback,
3561 base::Unretained(this))); 3563 base::Unretained(this)));
3562 3564
3563 message_loop_.Run(); 3565 message_loop_.Run();
3564 3566
3565 EXPECT_EQ(0, callback_count_); 3567 EXPECT_EQ(0, callback_count_);
3566 EXPECT_EQ(1, error_callback_count_); 3568 EXPECT_EQ(1, error_callback_count_);
3567 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); 3569 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_);
3568 3570
3569 // No changes should be observer. 3571 // No changes should be observer.
3570 EXPECT_EQ(0, observer.device_changed_count()); 3572 EXPECT_EQ(0, observer.device_changed_count());
3571 3573
3572 EXPECT_FALSE(device->IsPaired()); 3574 EXPECT_FALSE(device->IsPaired());
3573 3575
3574 // No pairing context should remain on the device. 3576 // No pairing context should remain on the device.
3575 BluetoothDeviceChromeOS* device_chromeos = 3577 BluetoothDeviceChromeOS* device_chromeos =
3576 static_cast<BluetoothDeviceChromeOS*>(device); 3578 static_cast<BluetoothDeviceChromeOS*>(device);
3577 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); 3579 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr);
3578 } 3580 }
3579 3581
3580 TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { 3582 TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) {
3581 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 3583 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
3582 3584
3583 GetAdapter(); 3585 GetAdapter();
3584 3586
3585 TestPairingDelegate pairing_delegate; 3587 TestPairingDelegate pairing_delegate;
3586 adapter_->AddPairingDelegate( 3588 adapter_->AddPairingDelegate(
3587 &pairing_delegate, 3589 &pairing_delegate,
3588 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); 3590 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH);
3589 3591
3590 // Requests that we provide a Passkey. 3592 // Requests that we provide a Passkey.
3591 fake_bluetooth_device_client_->CreateDevice( 3593 fake_bluetooth_device_client_->CreateDevice(
3592 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), 3594 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
3593 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); 3595 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath));
3594 BluetoothDevice* device = adapter_->GetDevice( 3596 BluetoothDevice* device = adapter_->GetDevice(
3595 FakeBluetoothDeviceClient::kRequestPasskeyAddress); 3597 FakeBluetoothDeviceClient::kRequestPasskeyAddress);
3596 ASSERT_TRUE(device != NULL); 3598 ASSERT_TRUE(device != nullptr);
3597 ASSERT_FALSE(device->IsPaired()); 3599 ASSERT_FALSE(device->IsPaired());
3598 3600
3599 TestBluetoothAdapterObserver observer(adapter_); 3601 TestBluetoothAdapterObserver observer(adapter_);
3600 3602
3601 fake_bluetooth_device_client_->SimulatePairing( 3603 fake_bluetooth_device_client_->SimulatePairing(
3602 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, 3604 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true,
3603 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, 3605 GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback,
3604 base::Unretained(this))); 3606 base::Unretained(this)));
3605 3607
3606 EXPECT_EQ(1, pairing_delegate.call_count_); 3608 EXPECT_EQ(1, pairing_delegate.call_count_);
3607 EXPECT_EQ(1, pairing_delegate.request_passkey_count_); 3609 EXPECT_EQ(1, pairing_delegate.request_passkey_count_);
3608 3610
3609 // A pairing context should now be set on the device. 3611 // A pairing context should now be set on the device.
3610 BluetoothDeviceChromeOS* device_chromeos = 3612 BluetoothDeviceChromeOS* device_chromeos =
3611 static_cast<BluetoothDeviceChromeOS*>(device); 3613 static_cast<BluetoothDeviceChromeOS*>(device);
3612 ASSERT_TRUE(device_chromeos->GetPairing() != NULL); 3614 ASSERT_TRUE(device_chromeos->GetPairing() != nullptr);
3613 3615
3614 // Removing the pairing delegate should remove that pairing context. 3616 // Removing the pairing delegate should remove that pairing context.
3615 adapter_->RemovePairingDelegate(&pairing_delegate); 3617 adapter_->RemovePairingDelegate(&pairing_delegate);
3616 3618
3617 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); 3619 EXPECT_TRUE(device_chromeos->GetPairing() == nullptr);
3618 3620
3619 // Set the Passkey, this should now have no effect since the pairing has 3621 // Set the Passkey, this should now have no effect since the pairing has
3620 // been, in-effect, cancelled 3622 // been, in-effect, cancelled
3621 device->SetPasskey(1234); 3623 device->SetPasskey(1234);
3622 3624
3623 EXPECT_EQ(0, callback_count_); 3625 EXPECT_EQ(0, callback_count_);
3624 EXPECT_EQ(0, error_callback_count_); 3626 EXPECT_EQ(0, error_callback_count_);
3625 EXPECT_EQ(0, observer.device_changed_count()); 3627 EXPECT_EQ(0, observer.device_changed_count());
3626 3628
3627 EXPECT_FALSE(device->IsPaired()); 3629 EXPECT_FALSE(device->IsPaired());
3628 } 3630 }
3629 3631
3630 TEST_F(BluetoothChromeOSTest, DeviceId) { 3632 TEST_F(BluetoothChromeOSTest, DeviceId) {
3631 GetAdapter(); 3633 GetAdapter();
3632 3634
3633 // Use the built-in paired device for this test, grab its Properties 3635 // Use the built-in paired device for this test, grab its Properties
3634 // structure so we can adjust the underlying modalias property. 3636 // structure so we can adjust the underlying modalias property.
3635 BluetoothDevice* device = adapter_->GetDevice( 3637 BluetoothDevice* device = adapter_->GetDevice(
3636 FakeBluetoothDeviceClient::kPairedDeviceAddress); 3638 FakeBluetoothDeviceClient::kPairedDeviceAddress);
3637 FakeBluetoothDeviceClient::Properties* properties = 3639 FakeBluetoothDeviceClient::Properties* properties =
3638 fake_bluetooth_device_client_->GetProperties( 3640 fake_bluetooth_device_client_->GetProperties(
3639 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); 3641 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath));
3640 3642
3641 ASSERT_TRUE(device != NULL); 3643 ASSERT_TRUE(device != nullptr);
3642 ASSERT_TRUE(properties != NULL); 3644 ASSERT_TRUE(properties != nullptr);
3643 3645
3644 // Valid USB IF-assigned identifier. 3646 // Valid USB IF-assigned identifier.
3645 ASSERT_EQ("usb:v05ACp030Dd0306", properties->modalias.value()); 3647 ASSERT_EQ("usb:v05ACp030Dd0306", properties->modalias.value());
3646 3648
3647 EXPECT_EQ(BluetoothDevice::VENDOR_ID_USB, device->GetVendorIDSource()); 3649 EXPECT_EQ(BluetoothDevice::VENDOR_ID_USB, device->GetVendorIDSource());
3648 EXPECT_EQ(0x05ac, device->GetVendorID()); 3650 EXPECT_EQ(0x05ac, device->GetVendorID());
3649 EXPECT_EQ(0x030d, device->GetProductID()); 3651 EXPECT_EQ(0x030d, device->GetProductID());
3650 EXPECT_EQ(0x0306, device->GetDeviceID()); 3652 EXPECT_EQ(0x0306, device->GetDeviceID());
3651 3653
3652 // Valid Bluetooth SIG-assigned identifier. 3654 // Valid Bluetooth SIG-assigned identifier.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3696 EXPECT_EQ(unknown_power, conn_info.rssi); 3698 EXPECT_EQ(unknown_power, conn_info.rssi);
3697 EXPECT_EQ(unknown_power, conn_info.transmit_power); 3699 EXPECT_EQ(unknown_power, conn_info.transmit_power);
3698 EXPECT_EQ(unknown_power, conn_info.max_transmit_power); 3700 EXPECT_EQ(unknown_power, conn_info.max_transmit_power);
3699 } 3701 }
3700 3702
3701 TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) { 3703 TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) {
3702 GetAdapter(); 3704 GetAdapter();
3703 BluetoothDevice* device = 3705 BluetoothDevice* device =
3704 adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); 3706 adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress);
3705 3707
3706 device->Connect(NULL, GetCallback(), 3708 device->Connect(nullptr, GetCallback(),
3707 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, 3709 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback,
3708 base::Unretained(this))); 3710 base::Unretained(this)));
3709 EXPECT_TRUE(device->IsConnected()); 3711 EXPECT_TRUE(device->IsConnected());
3710 3712
3711 // Calling GetConnectionInfo for a connected device should return valid 3713 // Calling GetConnectionInfo for a connected device should return valid
3712 // results. 3714 // results.
3713 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); 3715 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4);
3714 BluetoothDevice::ConnectionInfo conn_info; 3716 BluetoothDevice::ConnectionInfo conn_info;
3715 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); 3717 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info));
3716 EXPECT_EQ(-10, conn_info.rssi); 3718 EXPECT_EQ(-10, conn_info.rssi);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
3792 audio_sink_options, 3794 audio_sink_options,
3793 base::Bind(&BluetoothChromeOSTest::AudioSinkAcquiredCallback, 3795 base::Bind(&BluetoothChromeOSTest::AudioSinkAcquiredCallback,
3794 base::Unretained(this)), 3796 base::Unretained(this)),
3795 base::Bind(&BluetoothChromeOSTest::AudioSinkErrorCallback, 3797 base::Bind(&BluetoothChromeOSTest::AudioSinkErrorCallback,
3796 base::Unretained(this))); 3798 base::Unretained(this)));
3797 EXPECT_EQ(0, callback_count_); 3799 EXPECT_EQ(0, callback_count_);
3798 EXPECT_EQ(1, error_callback_count_--) << "RegisterAudioSink error"; 3800 EXPECT_EQ(1, error_callback_count_--) << "RegisterAudioSink error";
3799 3801
3800 BluetoothAdapterChromeOS* adapter_chrome_os = 3802 BluetoothAdapterChromeOS* adapter_chrome_os =
3801 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); 3803 static_cast<BluetoothAdapterChromeOS*>(adapter_.get());
3802 EXPECT_EQ(NULL, adapter_chrome_os->GetDeviceWithPath(dbus::ObjectPath(""))); 3804 EXPECT_EQ(nullptr,
3805 adapter_chrome_os->GetDeviceWithPath(dbus::ObjectPath("")));
3803 3806
3804 // Notify methods presume objects exist that are owned by the adapter and 3807 // Notify methods presume objects exist that are owned by the adapter and
3805 // destroyed in Shutdown(). Mocks are not attempted here that won't exist, 3808 // destroyed in Shutdown(). Mocks are not attempted here that won't exist,
3806 // as verified below by EXPECT_EQ(0U, adapter_->GetDevices().size()); 3809 // as verified below by EXPECT_EQ(0U, adapter_->GetDevices().size());
3807 // NotifyDeviceChanged 3810 // NotifyDeviceChanged
3808 // NotifyGattServiceAdded 3811 // NotifyGattServiceAdded
3809 // NotifyGattServiceRemoved 3812 // NotifyGattServiceRemoved
3810 // NotifyGattServiceChanged 3813 // NotifyGattServiceChanged
3811 // NotifyGattDiscoveryComplete 3814 // NotifyGattDiscoveryComplete
3812 // NotifyGattCharacteristicAdded 3815 // NotifyGattCharacteristicAdded
3813 // NotifyGattCharacteristicRemoved 3816 // NotifyGattCharacteristicRemoved
3814 // NotifyGattDescriptorAdded 3817 // NotifyGattDescriptorAdded
3815 // NotifyGattDescriptorRemoved 3818 // NotifyGattDescriptorRemoved
3816 // NotifyGattCharacteristicValueChanged 3819 // NotifyGattCharacteristicValueChanged
3817 // NotifyGattDescriptorValueChanged 3820 // NotifyGattDescriptorValueChanged
3818 3821
3819 EXPECT_EQ(dbus::ObjectPath(""), adapter_chrome_os->object_path()); 3822 EXPECT_EQ(dbus::ObjectPath(""), adapter_chrome_os->object_path());
3820 3823
3821 adapter_profile_ = NULL; 3824 adapter_profile_ = nullptr;
3822 3825
3823 FakeBluetoothProfileServiceProviderDelegate profile_delegate; 3826 FakeBluetoothProfileServiceProviderDelegate profile_delegate;
3824 adapter_chrome_os->UseProfile( 3827 adapter_chrome_os->UseProfile(
3825 BluetoothUUID(), dbus::ObjectPath(""), 3828 BluetoothUUID(), dbus::ObjectPath(""),
3826 BluetoothProfileManagerClient::Options(), &profile_delegate, 3829 BluetoothProfileManagerClient::Options(), &profile_delegate,
3827 base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, 3830 base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback,
3828 base::Unretained(this)), 3831 base::Unretained(this)),
3829 base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, 3832 base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback,
3830 base::Unretained(this))); 3833 base::Unretained(this)));
3831 3834
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3887 adapter_chrome_os->RemoveDiscoverySession(nullptr, GetCallback(), 3890 adapter_chrome_os->RemoveDiscoverySession(nullptr, GetCallback(),
3888 GetErrorCallback()); 3891 GetErrorCallback());
3889 EXPECT_EQ(0, callback_count_) << "RemoveDiscoverySession error"; 3892 EXPECT_EQ(0, callback_count_) << "RemoveDiscoverySession error";
3890 EXPECT_EQ(1, error_callback_count_--) << "RemoveDiscoverySession error"; 3893 EXPECT_EQ(1, error_callback_count_--) << "RemoveDiscoverySession error";
3891 3894
3892 // OnStartDiscovery tested in Shutdown_OnStartDiscovery 3895 // OnStartDiscovery tested in Shutdown_OnStartDiscovery
3893 // OnStartDiscoveryError tested in Shutdown_OnStartDiscoveryError 3896 // OnStartDiscoveryError tested in Shutdown_OnStartDiscoveryError
3894 // OnStopDiscovery tested in Shutdown_OnStopDiscovery 3897 // OnStopDiscovery tested in Shutdown_OnStopDiscovery
3895 // OnStopDiscoveryError tested in Shutdown_OnStopDiscoveryError 3898 // OnStopDiscoveryError tested in Shutdown_OnStopDiscoveryError
3896 3899
3897 adapter_profile_ = NULL; 3900 adapter_profile_ = nullptr;
3898 3901
3899 // OnRegisterProfile SetProfileDelegate, OnRegisterProfileError, require 3902 // OnRegisterProfile SetProfileDelegate, OnRegisterProfileError, require
3900 // UseProfile to be set first, do so again here just before calling them. 3903 // UseProfile to be set first, do so again here just before calling them.
3901 adapter_chrome_os->UseProfile( 3904 adapter_chrome_os->UseProfile(
3902 BluetoothUUID(), dbus::ObjectPath(""), 3905 BluetoothUUID(), dbus::ObjectPath(""),
3903 BluetoothProfileManagerClient::Options(), &profile_delegate, 3906 BluetoothProfileManagerClient::Options(), &profile_delegate,
3904 base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, 3907 base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback,
3905 base::Unretained(this)), 3908 base::Unretained(this)),
3906 base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, 3909 base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback,
3907 base::Unretained(this))); 3910 base::Unretained(this)));
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4034 adapter_->Shutdown(); 4037 adapter_->Shutdown();
4035 adapter_chrome_os->OnStopDiscoveryError(GetErrorCallback(), "", ""); 4038 adapter_chrome_os->OnStopDiscoveryError(GetErrorCallback(), "", "");
4036 4039
4037 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, 4040 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError,
4038 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. 4041 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession.
4039 EXPECT_EQ(0, callback_count_); 4042 EXPECT_EQ(0, callback_count_);
4040 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); 4043 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_);
4041 } 4044 }
4042 4045
4043 } // namespace chromeos 4046 } // namespace chromeos
4047
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698