| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 7 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
| 8 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 8 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
| 9 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
| 10 #include "chromeos/dbus/fake_bluetooth_input_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_input_client.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 // Run a discovery phase until the named device is detected, or if the named | 258 // Run a discovery phase until the named device is detected, or if the named |
| 259 // device is not created, the discovery process ends without finding it. | 259 // device is not created, the discovery process ends without finding it. |
| 260 // | 260 // |
| 261 // The correct behavior of discovery is tested by the "Discovery" test case | 261 // The correct behavior of discovery is tested by the "Discovery" test case |
| 262 // without using this function. | 262 // without using this function. |
| 263 void DiscoverDevice(const std::string& address) { | 263 void DiscoverDevice(const std::string& address) { |
| 264 ASSERT_TRUE(adapter_.get() != NULL); | 264 ASSERT_TRUE(adapter_.get() != NULL); |
| 265 | 265 |
| 266 if (base::MessageLoop::current() == NULL) { | 266 if (base::MessageLoop::current() == NULL) { |
| 267 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 267 base::MessageLoop message_loop; |
| 268 DiscoverDevices(); | 268 DiscoverDevices(); |
| 269 return; | 269 return; |
| 270 } | 270 } |
| 271 | 271 |
| 272 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 272 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 273 | 273 |
| 274 TestObserver observer(adapter_); | 274 TestObserver observer(adapter_); |
| 275 adapter_->AddObserver(&observer); | 275 adapter_->AddObserver(&observer); |
| 276 | 276 |
| 277 adapter_->SetPowered( | 277 adapter_->SetPowered( |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 EXPECT_EQ(1, callback_count_); | 501 EXPECT_EQ(1, callback_count_); |
| 502 EXPECT_EQ(0, error_callback_count_); | 502 EXPECT_EQ(0, error_callback_count_); |
| 503 | 503 |
| 504 EXPECT_EQ(1, observer.powered_changed_count_); | 504 EXPECT_EQ(1, observer.powered_changed_count_); |
| 505 EXPECT_FALSE(observer.last_powered_); | 505 EXPECT_FALSE(observer.last_powered_); |
| 506 | 506 |
| 507 EXPECT_FALSE(adapter_->IsPowered()); | 507 EXPECT_FALSE(adapter_->IsPowered()); |
| 508 } | 508 } |
| 509 | 509 |
| 510 TEST_F(BluetoothChromeOSTest, StopDiscovery) { | 510 TEST_F(BluetoothChromeOSTest, StopDiscovery) { |
| 511 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 511 base::MessageLoop message_loop; |
| 512 | 512 |
| 513 GetAdapter(); | 513 GetAdapter(); |
| 514 | 514 |
| 515 adapter_->SetPowered( | 515 adapter_->SetPowered( |
| 516 true, | 516 true, |
| 517 base::Bind(&BluetoothChromeOSTest::Callback, | 517 base::Bind(&BluetoothChromeOSTest::Callback, |
| 518 base::Unretained(this)), | 518 base::Unretained(this)), |
| 519 base::Bind(&BluetoothChromeOSTest::ErrorCallback, | 519 base::Bind(&BluetoothChromeOSTest::ErrorCallback, |
| 520 base::Unretained(this))); | 520 base::Unretained(this))); |
| 521 adapter_->StartDiscovering( | 521 adapter_->StartDiscovering( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 544 EXPECT_EQ(1, callback_count_); | 544 EXPECT_EQ(1, callback_count_); |
| 545 EXPECT_EQ(0, error_callback_count_); | 545 EXPECT_EQ(0, error_callback_count_); |
| 546 | 546 |
| 547 EXPECT_EQ(1, observer.discovering_changed_count_); | 547 EXPECT_EQ(1, observer.discovering_changed_count_); |
| 548 EXPECT_FALSE(observer.last_discovering_); | 548 EXPECT_FALSE(observer.last_discovering_); |
| 549 | 549 |
| 550 EXPECT_FALSE(adapter_->IsDiscovering()); | 550 EXPECT_FALSE(adapter_->IsDiscovering()); |
| 551 } | 551 } |
| 552 | 552 |
| 553 TEST_F(BluetoothChromeOSTest, StopDiscoveryAfterTwoStarts) { | 553 TEST_F(BluetoothChromeOSTest, StopDiscoveryAfterTwoStarts) { |
| 554 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 554 base::MessageLoop message_loop; |
| 555 | 555 |
| 556 GetAdapter(); | 556 GetAdapter(); |
| 557 | 557 |
| 558 adapter_->SetPowered( | 558 adapter_->SetPowered( |
| 559 true, | 559 true, |
| 560 base::Bind(&BluetoothChromeOSTest::Callback, | 560 base::Bind(&BluetoothChromeOSTest::Callback, |
| 561 base::Unretained(this)), | 561 base::Unretained(this)), |
| 562 base::Bind(&BluetoothChromeOSTest::ErrorCallback, | 562 base::Bind(&BluetoothChromeOSTest::ErrorCallback, |
| 563 base::Unretained(this))); | 563 base::Unretained(this))); |
| 564 adapter_->StartDiscovering( | 564 adapter_->StartDiscovering( |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 EXPECT_EQ(0, error_callback_count_); | 616 EXPECT_EQ(0, error_callback_count_); |
| 617 | 617 |
| 618 EXPECT_EQ(1, observer.discovering_changed_count_); | 618 EXPECT_EQ(1, observer.discovering_changed_count_); |
| 619 EXPECT_FALSE(observer.last_discovering_); | 619 EXPECT_FALSE(observer.last_discovering_); |
| 620 | 620 |
| 621 EXPECT_FALSE(adapter_->IsDiscovering()); | 621 EXPECT_FALSE(adapter_->IsDiscovering()); |
| 622 } | 622 } |
| 623 | 623 |
| 624 TEST_F(BluetoothChromeOSTest, Discovery) { | 624 TEST_F(BluetoothChromeOSTest, Discovery) { |
| 625 // Test a simulated discovery session. | 625 // Test a simulated discovery session. |
| 626 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 626 base::MessageLoop message_loop; |
| 627 | 627 |
| 628 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 628 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 629 GetAdapter(); | 629 GetAdapter(); |
| 630 | 630 |
| 631 TestObserver observer(adapter_); | 631 TestObserver observer(adapter_); |
| 632 adapter_->AddObserver(&observer); | 632 adapter_->AddObserver(&observer); |
| 633 | 633 |
| 634 adapter_->SetPowered( | 634 adapter_->SetPowered( |
| 635 true, | 635 true, |
| 636 base::Bind(&BluetoothChromeOSTest::Callback, | 636 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 663 // Okay, let's run forward until a device is actually removed... | 663 // Okay, let's run forward until a device is actually removed... |
| 664 while (!observer.device_removed_count_) | 664 while (!observer.device_removed_count_) |
| 665 message_loop.Run(); | 665 message_loop.Run(); |
| 666 | 666 |
| 667 EXPECT_EQ(1, observer.device_removed_count_); | 667 EXPECT_EQ(1, observer.device_removed_count_); |
| 668 EXPECT_EQ(FakeBluetoothDeviceClient::kVanishingDeviceAddress, | 668 EXPECT_EQ(FakeBluetoothDeviceClient::kVanishingDeviceAddress, |
| 669 observer.last_device_address_); | 669 observer.last_device_address_); |
| 670 } | 670 } |
| 671 | 671 |
| 672 TEST_F(BluetoothChromeOSTest, PoweredAndDiscovering) { | 672 TEST_F(BluetoothChromeOSTest, PoweredAndDiscovering) { |
| 673 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 673 base::MessageLoop message_loop; |
| 674 | 674 |
| 675 GetAdapter(); | 675 GetAdapter(); |
| 676 adapter_->SetPowered( | 676 adapter_->SetPowered( |
| 677 true, | 677 true, |
| 678 base::Bind(&BluetoothChromeOSTest::Callback, | 678 base::Bind(&BluetoothChromeOSTest::Callback, |
| 679 base::Unretained(this)), | 679 base::Unretained(this)), |
| 680 base::Bind(&BluetoothChromeOSTest::ErrorCallback, | 680 base::Bind(&BluetoothChromeOSTest::ErrorCallback, |
| 681 base::Unretained(this))); | 681 base::Unretained(this))); |
| 682 adapter_->StartDiscovering( | 682 adapter_->StartDiscovering( |
| 683 base::Bind(&BluetoothChromeOSTest::Callback, | 683 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 | 1162 |
| 1163 EXPECT_EQ(0, callback_count_); | 1163 EXPECT_EQ(0, callback_count_); |
| 1164 EXPECT_EQ(1, error_callback_count_); | 1164 EXPECT_EQ(1, error_callback_count_); |
| 1165 | 1165 |
| 1166 EXPECT_EQ(0, observer.device_changed_count_); | 1166 EXPECT_EQ(0, observer.device_changed_count_); |
| 1167 | 1167 |
| 1168 EXPECT_FALSE(device->IsConnected()); | 1168 EXPECT_FALSE(device->IsConnected()); |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 TEST_F(BluetoothChromeOSTest, PairAppleMouse) { | 1171 TEST_F(BluetoothChromeOSTest, PairAppleMouse) { |
| 1172 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1172 base::MessageLoop message_loop; |
| 1173 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1173 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1174 | 1174 |
| 1175 GetAdapter(); | 1175 GetAdapter(); |
| 1176 DiscoverDevices(); | 1176 DiscoverDevices(); |
| 1177 | 1177 |
| 1178 // The Apple Mouse requires no PIN or Passkey to pair; this is equivalent | 1178 // The Apple Mouse requires no PIN or Passkey to pair; this is equivalent |
| 1179 // to Simple Secure Pairing or a device with a fixed 0000 PIN. | 1179 // to Simple Secure Pairing or a device with a fixed 0000 PIN. |
| 1180 BluetoothDevice* device = adapter_->GetDevice( | 1180 BluetoothDevice* device = adapter_->GetDevice( |
| 1181 FakeBluetoothDeviceClient::kAppleMouseAddress); | 1181 FakeBluetoothDeviceClient::kAppleMouseAddress); |
| 1182 ASSERT_TRUE(device != NULL); | 1182 ASSERT_TRUE(device != NULL); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1223 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1224 | 1224 |
| 1225 // Make sure the trusted property has been set to true. | 1225 // Make sure the trusted property has been set to true. |
| 1226 FakeBluetoothDeviceClient::Properties* properties = | 1226 FakeBluetoothDeviceClient::Properties* properties = |
| 1227 fake_bluetooth_device_client_->GetProperties( | 1227 fake_bluetooth_device_client_->GetProperties( |
| 1228 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleMousePath)); | 1228 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleMousePath)); |
| 1229 EXPECT_TRUE(properties->trusted.value()); | 1229 EXPECT_TRUE(properties->trusted.value()); |
| 1230 } | 1230 } |
| 1231 | 1231 |
| 1232 TEST_F(BluetoothChromeOSTest, PairAppleKeyboard) { | 1232 TEST_F(BluetoothChromeOSTest, PairAppleKeyboard) { |
| 1233 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1233 base::MessageLoop message_loop; |
| 1234 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1234 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1235 | 1235 |
| 1236 GetAdapter(); | 1236 GetAdapter(); |
| 1237 DiscoverDevices(); | 1237 DiscoverDevices(); |
| 1238 | 1238 |
| 1239 // The Apple Keyboard requires that we display a randomly generated | 1239 // The Apple Keyboard requires that we display a randomly generated |
| 1240 // PIN on the screen. | 1240 // PIN on the screen. |
| 1241 BluetoothDevice* device = adapter_->GetDevice( | 1241 BluetoothDevice* device = adapter_->GetDevice( |
| 1242 FakeBluetoothDeviceClient::kAppleKeyboardAddress); | 1242 FakeBluetoothDeviceClient::kAppleKeyboardAddress); |
| 1243 ASSERT_TRUE(device != NULL); | 1243 ASSERT_TRUE(device != NULL); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1285 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1286 | 1286 |
| 1287 // Make sure the trusted property has been set to true. | 1287 // Make sure the trusted property has been set to true. |
| 1288 FakeBluetoothDeviceClient::Properties* properties = | 1288 FakeBluetoothDeviceClient::Properties* properties = |
| 1289 fake_bluetooth_device_client_->GetProperties( | 1289 fake_bluetooth_device_client_->GetProperties( |
| 1290 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleKeyboardPath)); | 1290 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleKeyboardPath)); |
| 1291 EXPECT_TRUE(properties->trusted.value()); | 1291 EXPECT_TRUE(properties->trusted.value()); |
| 1292 } | 1292 } |
| 1293 | 1293 |
| 1294 TEST_F(BluetoothChromeOSTest, PairMotorolaKeyboard) { | 1294 TEST_F(BluetoothChromeOSTest, PairMotorolaKeyboard) { |
| 1295 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1295 base::MessageLoop message_loop; |
| 1296 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1296 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1297 | 1297 |
| 1298 GetAdapter(); | 1298 GetAdapter(); |
| 1299 DiscoverDevices(); | 1299 DiscoverDevices(); |
| 1300 | 1300 |
| 1301 // The Motorola Keyboard requires that we display a randomly generated | 1301 // The Motorola Keyboard requires that we display a randomly generated |
| 1302 // Passkey on the screen, and notifies us as it's typed in. | 1302 // Passkey on the screen, and notifies us as it's typed in. |
| 1303 BluetoothDevice* device = adapter_->GetDevice( | 1303 BluetoothDevice* device = adapter_->GetDevice( |
| 1304 FakeBluetoothDeviceClient::kMotorolaKeyboardAddress); | 1304 FakeBluetoothDeviceClient::kMotorolaKeyboardAddress); |
| 1305 ASSERT_TRUE(device != NULL); | 1305 ASSERT_TRUE(device != NULL); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1368 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1369 | 1369 |
| 1370 // Make sure the trusted property has been set to true. | 1370 // Make sure the trusted property has been set to true. |
| 1371 FakeBluetoothDeviceClient::Properties* properties = | 1371 FakeBluetoothDeviceClient::Properties* properties = |
| 1372 fake_bluetooth_device_client_->GetProperties( | 1372 fake_bluetooth_device_client_->GetProperties( |
| 1373 dbus::ObjectPath(FakeBluetoothDeviceClient::kMotorolaKeyboardPath)); | 1373 dbus::ObjectPath(FakeBluetoothDeviceClient::kMotorolaKeyboardPath)); |
| 1374 EXPECT_TRUE(properties->trusted.value()); | 1374 EXPECT_TRUE(properties->trusted.value()); |
| 1375 } | 1375 } |
| 1376 | 1376 |
| 1377 TEST_F(BluetoothChromeOSTest, PairSonyHeadphones) { | 1377 TEST_F(BluetoothChromeOSTest, PairSonyHeadphones) { |
| 1378 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1378 base::MessageLoop message_loop; |
| 1379 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1379 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1380 | 1380 |
| 1381 GetAdapter(); | 1381 GetAdapter(); |
| 1382 DiscoverDevices(); | 1382 DiscoverDevices(); |
| 1383 | 1383 |
| 1384 // The Sony Headphones fake requires that the user enters a PIN for them. | 1384 // The Sony Headphones fake requires that the user enters a PIN for them. |
| 1385 BluetoothDevice* device = adapter_->GetDevice( | 1385 BluetoothDevice* device = adapter_->GetDevice( |
| 1386 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); | 1386 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); |
| 1387 ASSERT_TRUE(device != NULL); | 1387 ASSERT_TRUE(device != NULL); |
| 1388 ASSERT_FALSE(device->IsPaired()); | 1388 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1431 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1432 | 1432 |
| 1433 // Make sure the trusted property has been set to true. | 1433 // Make sure the trusted property has been set to true. |
| 1434 FakeBluetoothDeviceClient::Properties* properties = | 1434 FakeBluetoothDeviceClient::Properties* properties = |
| 1435 fake_bluetooth_device_client_->GetProperties( | 1435 fake_bluetooth_device_client_->GetProperties( |
| 1436 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath)); | 1436 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath)); |
| 1437 EXPECT_TRUE(properties->trusted.value()); | 1437 EXPECT_TRUE(properties->trusted.value()); |
| 1438 } | 1438 } |
| 1439 | 1439 |
| 1440 TEST_F(BluetoothChromeOSTest, PairPhone) { | 1440 TEST_F(BluetoothChromeOSTest, PairPhone) { |
| 1441 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1441 base::MessageLoop message_loop; |
| 1442 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1442 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1443 | 1443 |
| 1444 GetAdapter(); | 1444 GetAdapter(); |
| 1445 DiscoverDevices(); | 1445 DiscoverDevices(); |
| 1446 | 1446 |
| 1447 // The fake phone requests that we confirm a displayed passkey. | 1447 // The fake phone requests that we confirm a displayed passkey. |
| 1448 BluetoothDevice* device = adapter_->GetDevice( | 1448 BluetoothDevice* device = adapter_->GetDevice( |
| 1449 FakeBluetoothDeviceClient::kPhoneAddress); | 1449 FakeBluetoothDeviceClient::kPhoneAddress); |
| 1450 ASSERT_TRUE(device != NULL); | 1450 ASSERT_TRUE(device != NULL); |
| 1451 ASSERT_FALSE(device->IsPaired()); | 1451 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1491 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1492 | 1492 |
| 1493 // Make sure the trusted property has been set to true. | 1493 // Make sure the trusted property has been set to true. |
| 1494 FakeBluetoothDeviceClient::Properties* properties = | 1494 FakeBluetoothDeviceClient::Properties* properties = |
| 1495 fake_bluetooth_device_client_->GetProperties( | 1495 fake_bluetooth_device_client_->GetProperties( |
| 1496 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath)); | 1496 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath)); |
| 1497 EXPECT_TRUE(properties->trusted.value()); | 1497 EXPECT_TRUE(properties->trusted.value()); |
| 1498 } | 1498 } |
| 1499 | 1499 |
| 1500 TEST_F(BluetoothChromeOSTest, PairWeirdDevice) { | 1500 TEST_F(BluetoothChromeOSTest, PairWeirdDevice) { |
| 1501 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1501 base::MessageLoop message_loop; |
| 1502 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1502 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1503 | 1503 |
| 1504 GetAdapter(); | 1504 GetAdapter(); |
| 1505 DiscoverDevices(); | 1505 DiscoverDevices(); |
| 1506 | 1506 |
| 1507 // Use the "weird device" fake that requires that the user enters a Passkey, | 1507 // Use the "weird device" fake that requires that the user enters a Passkey, |
| 1508 // this would be some kind of device that has a display, but doesn't use | 1508 // this would be some kind of device that has a display, but doesn't use |
| 1509 // "just works" - maybe a car? | 1509 // "just works" - maybe a car? |
| 1510 BluetoothDevice* device = adapter_->GetDevice( | 1510 BluetoothDevice* device = adapter_->GetDevice( |
| 1511 FakeBluetoothDeviceClient::kWeirdDeviceAddress); | 1511 FakeBluetoothDeviceClient::kWeirdDeviceAddress); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1552 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1553 | 1553 |
| 1554 // Make sure the trusted property has been set to true. | 1554 // Make sure the trusted property has been set to true. |
| 1555 FakeBluetoothDeviceClient::Properties* properties = | 1555 FakeBluetoothDeviceClient::Properties* properties = |
| 1556 fake_bluetooth_device_client_->GetProperties( | 1556 fake_bluetooth_device_client_->GetProperties( |
| 1557 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath)); | 1557 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath)); |
| 1558 EXPECT_TRUE(properties->trusted.value()); | 1558 EXPECT_TRUE(properties->trusted.value()); |
| 1559 } | 1559 } |
| 1560 | 1560 |
| 1561 TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { | 1561 TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { |
| 1562 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1562 base::MessageLoop message_loop; |
| 1563 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1563 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1564 | 1564 |
| 1565 GetAdapter(); | 1565 GetAdapter(); |
| 1566 DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); | 1566 DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); |
| 1567 | 1567 |
| 1568 BluetoothDevice* device = adapter_->GetDevice( | 1568 BluetoothDevice* device = adapter_->GetDevice( |
| 1569 FakeBluetoothDeviceClient::kUnpairableDeviceAddress); | 1569 FakeBluetoothDeviceClient::kUnpairableDeviceAddress); |
| 1570 ASSERT_TRUE(device != NULL); | 1570 ASSERT_TRUE(device != NULL); |
| 1571 ASSERT_FALSE(device->IsPaired()); | 1571 ASSERT_FALSE(device->IsPaired()); |
| 1572 | 1572 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1595 EXPECT_FALSE(device->IsConnected()); | 1595 EXPECT_FALSE(device->IsConnected()); |
| 1596 EXPECT_FALSE(device->IsConnecting()); | 1596 EXPECT_FALSE(device->IsConnecting()); |
| 1597 EXPECT_FALSE(device->IsPaired()); | 1597 EXPECT_FALSE(device->IsPaired()); |
| 1598 | 1598 |
| 1599 // Pairing dialog should be dismissed | 1599 // Pairing dialog should be dismissed |
| 1600 EXPECT_EQ(1, pairing_delegate.call_count_); | 1600 EXPECT_EQ(1, pairing_delegate.call_count_); |
| 1601 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1601 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1602 } | 1602 } |
| 1603 | 1603 |
| 1604 TEST_F(BluetoothChromeOSTest, PairingFails) { | 1604 TEST_F(BluetoothChromeOSTest, PairingFails) { |
| 1605 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1605 base::MessageLoop message_loop; |
| 1606 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1606 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1607 | 1607 |
| 1608 GetAdapter(); | 1608 GetAdapter(); |
| 1609 DiscoverDevice(FakeBluetoothDeviceClient::kVanishingDeviceAddress); | 1609 DiscoverDevice(FakeBluetoothDeviceClient::kVanishingDeviceAddress); |
| 1610 | 1610 |
| 1611 // The vanishing device times out during pairing | 1611 // The vanishing device times out during pairing |
| 1612 BluetoothDevice* device = adapter_->GetDevice( | 1612 BluetoothDevice* device = adapter_->GetDevice( |
| 1613 FakeBluetoothDeviceClient::kVanishingDeviceAddress); | 1613 FakeBluetoothDeviceClient::kVanishingDeviceAddress); |
| 1614 ASSERT_TRUE(device != NULL); | 1614 ASSERT_TRUE(device != NULL); |
| 1615 ASSERT_FALSE(device->IsPaired()); | 1615 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1639 EXPECT_FALSE(device->IsConnected()); | 1639 EXPECT_FALSE(device->IsConnected()); |
| 1640 EXPECT_FALSE(device->IsConnecting()); | 1640 EXPECT_FALSE(device->IsConnecting()); |
| 1641 EXPECT_FALSE(device->IsPaired()); | 1641 EXPECT_FALSE(device->IsPaired()); |
| 1642 | 1642 |
| 1643 // Pairing dialog should be dismissed | 1643 // Pairing dialog should be dismissed |
| 1644 EXPECT_EQ(1, pairing_delegate.call_count_); | 1644 EXPECT_EQ(1, pairing_delegate.call_count_); |
| 1645 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1645 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1646 } | 1646 } |
| 1647 | 1647 |
| 1648 TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { | 1648 TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { |
| 1649 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1649 base::MessageLoop message_loop; |
| 1650 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1650 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1651 | 1651 |
| 1652 GetAdapter(); | 1652 GetAdapter(); |
| 1653 DiscoverDevices(); | 1653 DiscoverDevices(); |
| 1654 | 1654 |
| 1655 // Everything seems to go according to plan with the unconnectable device; | 1655 // Everything seems to go according to plan with the unconnectable device; |
| 1656 // it pairs, but then you can't make connections to it after. | 1656 // it pairs, but then you can't make connections to it after. |
| 1657 BluetoothDevice* device = adapter_->GetDevice( | 1657 BluetoothDevice* device = adapter_->GetDevice( |
| 1658 FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); | 1658 FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); |
| 1659 ASSERT_TRUE(device != NULL); | 1659 ASSERT_TRUE(device != NULL); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 // Make sure the trusted property has been set to true still (since pairing | 1696 // Make sure the trusted property has been set to true still (since pairing |
| 1697 // worked). | 1697 // worked). |
| 1698 FakeBluetoothDeviceClient::Properties* properties = | 1698 FakeBluetoothDeviceClient::Properties* properties = |
| 1699 fake_bluetooth_device_client_->GetProperties( | 1699 fake_bluetooth_device_client_->GetProperties( |
| 1700 dbus::ObjectPath( | 1700 dbus::ObjectPath( |
| 1701 FakeBluetoothDeviceClient::kUnconnectableDevicePath)); | 1701 FakeBluetoothDeviceClient::kUnconnectableDevicePath)); |
| 1702 EXPECT_TRUE(properties->trusted.value()); | 1702 EXPECT_TRUE(properties->trusted.value()); |
| 1703 } | 1703 } |
| 1704 | 1704 |
| 1705 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { | 1705 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { |
| 1706 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1706 base::MessageLoop message_loop; |
| 1707 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1707 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1708 | 1708 |
| 1709 GetAdapter(); | 1709 GetAdapter(); |
| 1710 DiscoverDevices(); | 1710 DiscoverDevices(); |
| 1711 | 1711 |
| 1712 // Reject the pairing after we receive a request for the PIN code. | 1712 // Reject the pairing after we receive a request for the PIN code. |
| 1713 BluetoothDevice* device = adapter_->GetDevice( | 1713 BluetoothDevice* device = adapter_->GetDevice( |
| 1714 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); | 1714 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); |
| 1715 ASSERT_TRUE(device != NULL); | 1715 ASSERT_TRUE(device != NULL); |
| 1716 ASSERT_FALSE(device->IsPaired()); | 1716 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1743 EXPECT_FALSE(device->IsConnected()); | 1743 EXPECT_FALSE(device->IsConnected()); |
| 1744 EXPECT_FALSE(device->IsConnecting()); | 1744 EXPECT_FALSE(device->IsConnecting()); |
| 1745 EXPECT_FALSE(device->IsPaired()); | 1745 EXPECT_FALSE(device->IsPaired()); |
| 1746 | 1746 |
| 1747 // Pairing dialog should be dismissed | 1747 // Pairing dialog should be dismissed |
| 1748 EXPECT_EQ(2, pairing_delegate.call_count_); | 1748 EXPECT_EQ(2, pairing_delegate.call_count_); |
| 1749 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1749 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1750 } | 1750 } |
| 1751 | 1751 |
| 1752 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { | 1752 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { |
| 1753 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1753 base::MessageLoop message_loop; |
| 1754 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1754 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1755 | 1755 |
| 1756 GetAdapter(); | 1756 GetAdapter(); |
| 1757 DiscoverDevices(); | 1757 DiscoverDevices(); |
| 1758 | 1758 |
| 1759 // Cancel the pairing after we receive a request for the PIN code. | 1759 // Cancel the pairing after we receive a request for the PIN code. |
| 1760 BluetoothDevice* device = adapter_->GetDevice( | 1760 BluetoothDevice* device = adapter_->GetDevice( |
| 1761 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); | 1761 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); |
| 1762 ASSERT_TRUE(device != NULL); | 1762 ASSERT_TRUE(device != NULL); |
| 1763 ASSERT_FALSE(device->IsPaired()); | 1763 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1790 EXPECT_FALSE(device->IsConnected()); | 1790 EXPECT_FALSE(device->IsConnected()); |
| 1791 EXPECT_FALSE(device->IsConnecting()); | 1791 EXPECT_FALSE(device->IsConnecting()); |
| 1792 EXPECT_FALSE(device->IsPaired()); | 1792 EXPECT_FALSE(device->IsPaired()); |
| 1793 | 1793 |
| 1794 // Pairing dialog should be dismissed | 1794 // Pairing dialog should be dismissed |
| 1795 EXPECT_EQ(2, pairing_delegate.call_count_); | 1795 EXPECT_EQ(2, pairing_delegate.call_count_); |
| 1796 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1796 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1797 } | 1797 } |
| 1798 | 1798 |
| 1799 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { | 1799 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { |
| 1800 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1800 base::MessageLoop message_loop; |
| 1801 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1801 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1802 | 1802 |
| 1803 GetAdapter(); | 1803 GetAdapter(); |
| 1804 DiscoverDevices(); | 1804 DiscoverDevices(); |
| 1805 | 1805 |
| 1806 // Reject the pairing after we receive a request for the passkey. | 1806 // Reject the pairing after we receive a request for the passkey. |
| 1807 BluetoothDevice* device = adapter_->GetDevice( | 1807 BluetoothDevice* device = adapter_->GetDevice( |
| 1808 FakeBluetoothDeviceClient::kWeirdDeviceAddress); | 1808 FakeBluetoothDeviceClient::kWeirdDeviceAddress); |
| 1809 ASSERT_TRUE(device != NULL); | 1809 ASSERT_TRUE(device != NULL); |
| 1810 ASSERT_FALSE(device->IsPaired()); | 1810 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1837 EXPECT_FALSE(device->IsConnected()); | 1837 EXPECT_FALSE(device->IsConnected()); |
| 1838 EXPECT_FALSE(device->IsConnecting()); | 1838 EXPECT_FALSE(device->IsConnecting()); |
| 1839 EXPECT_FALSE(device->IsPaired()); | 1839 EXPECT_FALSE(device->IsPaired()); |
| 1840 | 1840 |
| 1841 // Pairing dialog should be dismissed | 1841 // Pairing dialog should be dismissed |
| 1842 EXPECT_EQ(2, pairing_delegate.call_count_); | 1842 EXPECT_EQ(2, pairing_delegate.call_count_); |
| 1843 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1843 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1844 } | 1844 } |
| 1845 | 1845 |
| 1846 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { | 1846 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { |
| 1847 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1847 base::MessageLoop message_loop; |
| 1848 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1848 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1849 | 1849 |
| 1850 GetAdapter(); | 1850 GetAdapter(); |
| 1851 DiscoverDevices(); | 1851 DiscoverDevices(); |
| 1852 | 1852 |
| 1853 // Cancel the pairing after we receive a request for the passkey. | 1853 // Cancel the pairing after we receive a request for the passkey. |
| 1854 BluetoothDevice* device = adapter_->GetDevice( | 1854 BluetoothDevice* device = adapter_->GetDevice( |
| 1855 FakeBluetoothDeviceClient::kWeirdDeviceAddress); | 1855 FakeBluetoothDeviceClient::kWeirdDeviceAddress); |
| 1856 ASSERT_TRUE(device != NULL); | 1856 ASSERT_TRUE(device != NULL); |
| 1857 ASSERT_FALSE(device->IsPaired()); | 1857 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1884 EXPECT_FALSE(device->IsConnected()); | 1884 EXPECT_FALSE(device->IsConnected()); |
| 1885 EXPECT_FALSE(device->IsConnecting()); | 1885 EXPECT_FALSE(device->IsConnecting()); |
| 1886 EXPECT_FALSE(device->IsPaired()); | 1886 EXPECT_FALSE(device->IsPaired()); |
| 1887 | 1887 |
| 1888 // Pairing dialog should be dismissed | 1888 // Pairing dialog should be dismissed |
| 1889 EXPECT_EQ(2, pairing_delegate.call_count_); | 1889 EXPECT_EQ(2, pairing_delegate.call_count_); |
| 1890 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1890 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1891 } | 1891 } |
| 1892 | 1892 |
| 1893 TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { | 1893 TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { |
| 1894 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1894 base::MessageLoop message_loop; |
| 1895 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1895 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1896 | 1896 |
| 1897 GetAdapter(); | 1897 GetAdapter(); |
| 1898 DiscoverDevices(); | 1898 DiscoverDevices(); |
| 1899 | 1899 |
| 1900 // Reject the pairing after we receive a request for passkey confirmation. | 1900 // Reject the pairing after we receive a request for passkey confirmation. |
| 1901 BluetoothDevice* device = adapter_->GetDevice( | 1901 BluetoothDevice* device = adapter_->GetDevice( |
| 1902 FakeBluetoothDeviceClient::kPhoneAddress); | 1902 FakeBluetoothDeviceClient::kPhoneAddress); |
| 1903 ASSERT_TRUE(device != NULL); | 1903 ASSERT_TRUE(device != NULL); |
| 1904 ASSERT_FALSE(device->IsPaired()); | 1904 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1931 EXPECT_FALSE(device->IsConnected()); | 1931 EXPECT_FALSE(device->IsConnected()); |
| 1932 EXPECT_FALSE(device->IsConnecting()); | 1932 EXPECT_FALSE(device->IsConnecting()); |
| 1933 EXPECT_FALSE(device->IsPaired()); | 1933 EXPECT_FALSE(device->IsPaired()); |
| 1934 | 1934 |
| 1935 // Pairing dialog should be dismissed | 1935 // Pairing dialog should be dismissed |
| 1936 EXPECT_EQ(2, pairing_delegate.call_count_); | 1936 EXPECT_EQ(2, pairing_delegate.call_count_); |
| 1937 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1937 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1938 } | 1938 } |
| 1939 | 1939 |
| 1940 TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { | 1940 TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { |
| 1941 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1941 base::MessageLoop message_loop; |
| 1942 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1942 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1943 | 1943 |
| 1944 GetAdapter(); | 1944 GetAdapter(); |
| 1945 DiscoverDevices(); | 1945 DiscoverDevices(); |
| 1946 | 1946 |
| 1947 // Cancel the pairing after we receive a request for the passkey. | 1947 // Cancel the pairing after we receive a request for the passkey. |
| 1948 BluetoothDevice* device = adapter_->GetDevice( | 1948 BluetoothDevice* device = adapter_->GetDevice( |
| 1949 FakeBluetoothDeviceClient::kPhoneAddress); | 1949 FakeBluetoothDeviceClient::kPhoneAddress); |
| 1950 ASSERT_TRUE(device != NULL); | 1950 ASSERT_TRUE(device != NULL); |
| 1951 ASSERT_FALSE(device->IsPaired()); | 1951 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1978 EXPECT_FALSE(device->IsConnected()); | 1978 EXPECT_FALSE(device->IsConnected()); |
| 1979 EXPECT_FALSE(device->IsConnecting()); | 1979 EXPECT_FALSE(device->IsConnecting()); |
| 1980 EXPECT_FALSE(device->IsPaired()); | 1980 EXPECT_FALSE(device->IsPaired()); |
| 1981 | 1981 |
| 1982 // Pairing dialog should be dismissed | 1982 // Pairing dialog should be dismissed |
| 1983 EXPECT_EQ(2, pairing_delegate.call_count_); | 1983 EXPECT_EQ(2, pairing_delegate.call_count_); |
| 1984 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 1984 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 1985 } | 1985 } |
| 1986 | 1986 |
| 1987 TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { | 1987 TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { |
| 1988 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); | 1988 base::MessageLoop message_loop; |
| 1989 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1989 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1990 | 1990 |
| 1991 GetAdapter(); | 1991 GetAdapter(); |
| 1992 DiscoverDevices(); | 1992 DiscoverDevices(); |
| 1993 | 1993 |
| 1994 // Cancel the pairing while we're waiting for the remote host. | 1994 // Cancel the pairing while we're waiting for the remote host. |
| 1995 BluetoothDevice* device = adapter_->GetDevice( | 1995 BluetoothDevice* device = adapter_->GetDevice( |
| 1996 FakeBluetoothDeviceClient::kAppleMouseAddress); | 1996 FakeBluetoothDeviceClient::kAppleMouseAddress); |
| 1997 ASSERT_TRUE(device != NULL); | 1997 ASSERT_TRUE(device != NULL); |
| 1998 ASSERT_FALSE(device->IsPaired()); | 1998 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2024 EXPECT_FALSE(device->IsConnected()); | 2024 EXPECT_FALSE(device->IsConnected()); |
| 2025 EXPECT_FALSE(device->IsConnecting()); | 2025 EXPECT_FALSE(device->IsConnecting()); |
| 2026 EXPECT_FALSE(device->IsPaired()); | 2026 EXPECT_FALSE(device->IsPaired()); |
| 2027 | 2027 |
| 2028 // Pairing dialog should be dismissed | 2028 // Pairing dialog should be dismissed |
| 2029 EXPECT_EQ(1, pairing_delegate.call_count_); | 2029 EXPECT_EQ(1, pairing_delegate.call_count_); |
| 2030 EXPECT_EQ(1, pairing_delegate.dismiss_count_); | 2030 EXPECT_EQ(1, pairing_delegate.dismiss_count_); |
| 2031 } | 2031 } |
| 2032 | 2032 |
| 2033 } // namespace chromeos | 2033 } // namespace chromeos |
| OLD | NEW |