| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chromeos/dbus/dbus_thread_manager.h" | 8 #include "chromeos/dbus/dbus_thread_manager.h" |
| 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
| 10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 // This verifies that the class gets the list of adapters when created; | 407 // This verifies that the class gets the list of adapters when created; |
| 408 // and initializes with an existing adapter if there is one. | 408 // and initializes with an existing adapter if there is one. |
| 409 EXPECT_TRUE(adapter_->IsPresent()); | 409 EXPECT_TRUE(adapter_->IsPresent()); |
| 410 EXPECT_FALSE(adapter_->IsPowered()); | 410 EXPECT_FALSE(adapter_->IsPowered()); |
| 411 EXPECT_EQ(FakeBluetoothAdapterClient::kAdapterAddress, | 411 EXPECT_EQ(FakeBluetoothAdapterClient::kAdapterAddress, |
| 412 adapter_->GetAddress()); | 412 adapter_->GetAddress()); |
| 413 EXPECT_FALSE(adapter_->IsDiscovering()); | 413 EXPECT_FALSE(adapter_->IsDiscovering()); |
| 414 | 414 |
| 415 // There should be a device | 415 // There should be a device |
| 416 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 416 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
| 417 EXPECT_EQ(1U, devices.size()); | 417 EXPECT_EQ(2U, devices.size()); |
| 418 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 418 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, |
| 419 devices[0]->GetAddress()); | 419 devices[0]->GetAddress()); |
| 420 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress, |
| 421 devices[1]->GetAddress()); |
| 420 } | 422 } |
| 421 | 423 |
| 422 TEST_F(BluetoothChromeOSTest, BecomePresent) { | 424 TEST_F(BluetoothChromeOSTest, BecomePresent) { |
| 423 fake_bluetooth_adapter_client_->SetVisible(false); | 425 fake_bluetooth_adapter_client_->SetVisible(false); |
| 424 GetAdapter(); | 426 GetAdapter(); |
| 425 ASSERT_FALSE(adapter_->IsPresent()); | 427 ASSERT_FALSE(adapter_->IsPresent()); |
| 426 | 428 |
| 427 // Install an observer; expect the AdapterPresentChanged to be called | 429 // Install an observer; expect the AdapterPresentChanged to be called |
| 428 // with true, and IsPresent() to return true. | 430 // with true, and IsPresent() to return true. |
| 429 TestObserver observer(adapter_); | 431 TestObserver observer(adapter_); |
| 430 | 432 |
| 431 fake_bluetooth_adapter_client_->SetVisible(true); | 433 fake_bluetooth_adapter_client_->SetVisible(true); |
| 432 | 434 |
| 433 EXPECT_EQ(1, observer.present_changed_count_); | 435 EXPECT_EQ(1, observer.present_changed_count_); |
| 434 EXPECT_TRUE(observer.last_present_); | 436 EXPECT_TRUE(observer.last_present_); |
| 435 | 437 |
| 436 EXPECT_TRUE(adapter_->IsPresent()); | 438 EXPECT_TRUE(adapter_->IsPresent()); |
| 437 | 439 |
| 438 // We should have had a device announced. | 440 // We should have had a device announced. |
| 439 EXPECT_EQ(1, observer.device_added_count_); | 441 EXPECT_EQ(2, observer.device_added_count_); |
| 440 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 442 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress, |
| 441 observer.last_device_address_); | 443 observer.last_device_address_); |
| 442 | 444 |
| 443 // Other callbacks shouldn't be called if the values are false. | 445 // Other callbacks shouldn't be called if the values are false. |
| 444 EXPECT_EQ(0, observer.powered_changed_count_); | 446 EXPECT_EQ(0, observer.powered_changed_count_); |
| 445 EXPECT_EQ(0, observer.discovering_changed_count_); | 447 EXPECT_EQ(0, observer.discovering_changed_count_); |
| 446 EXPECT_FALSE(adapter_->IsPowered()); | 448 EXPECT_FALSE(adapter_->IsPowered()); |
| 447 EXPECT_FALSE(adapter_->IsDiscovering()); | 449 EXPECT_FALSE(adapter_->IsDiscovering()); |
| 448 } | 450 } |
| 449 | 451 |
| 450 TEST_F(BluetoothChromeOSTest, BecomeNotPresent) { | 452 TEST_F(BluetoothChromeOSTest, BecomeNotPresent) { |
| 451 GetAdapter(); | 453 GetAdapter(); |
| 452 ASSERT_TRUE(adapter_->IsPresent()); | 454 ASSERT_TRUE(adapter_->IsPresent()); |
| 453 | 455 |
| 454 // Install an observer; expect the AdapterPresentChanged to be called | 456 // Install an observer; expect the AdapterPresentChanged to be called |
| 455 // with false, and IsPresent() to return false. | 457 // with false, and IsPresent() to return false. |
| 456 TestObserver observer(adapter_); | 458 TestObserver observer(adapter_); |
| 457 | 459 |
| 458 fake_bluetooth_adapter_client_->SetVisible(false); | 460 fake_bluetooth_adapter_client_->SetVisible(false); |
| 459 | 461 |
| 460 EXPECT_EQ(1, observer.present_changed_count_); | 462 EXPECT_EQ(1, observer.present_changed_count_); |
| 461 EXPECT_FALSE(observer.last_present_); | 463 EXPECT_FALSE(observer.last_present_); |
| 462 | 464 |
| 463 EXPECT_FALSE(adapter_->IsPresent()); | 465 EXPECT_FALSE(adapter_->IsPresent()); |
| 464 | 466 |
| 465 // We should have had a device removed. | 467 // We should have had a device removed. |
| 466 EXPECT_EQ(1, observer.device_removed_count_); | 468 EXPECT_EQ(2, observer.device_removed_count_); |
| 467 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 469 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress, |
| 468 observer.last_device_address_); | 470 observer.last_device_address_); |
| 469 | 471 |
| 470 // Other callbacks shouldn't be called since the values are false. | 472 // Other callbacks shouldn't be called since the values are false. |
| 471 EXPECT_EQ(0, observer.powered_changed_count_); | 473 EXPECT_EQ(0, observer.powered_changed_count_); |
| 472 EXPECT_EQ(0, observer.discovering_changed_count_); | 474 EXPECT_EQ(0, observer.discovering_changed_count_); |
| 473 EXPECT_FALSE(adapter_->IsPowered()); | 475 EXPECT_FALSE(adapter_->IsPowered()); |
| 474 EXPECT_FALSE(adapter_->IsDiscovering()); | 476 EXPECT_FALSE(adapter_->IsDiscovering()); |
| 475 } | 477 } |
| 476 | 478 |
| 477 TEST_F(BluetoothChromeOSTest, SecondAdapter) { | 479 TEST_F(BluetoothChromeOSTest, SecondAdapter) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 493 // Try removing the first adapter, we should now act as if the adapter | 495 // Try removing the first adapter, we should now act as if the adapter |
| 494 // is no longer present rather than fall back to the second. | 496 // is no longer present rather than fall back to the second. |
| 495 fake_bluetooth_adapter_client_->SetVisible(false); | 497 fake_bluetooth_adapter_client_->SetVisible(false); |
| 496 | 498 |
| 497 EXPECT_EQ(1, observer.present_changed_count_); | 499 EXPECT_EQ(1, observer.present_changed_count_); |
| 498 EXPECT_FALSE(observer.last_present_); | 500 EXPECT_FALSE(observer.last_present_); |
| 499 | 501 |
| 500 EXPECT_FALSE(adapter_->IsPresent()); | 502 EXPECT_FALSE(adapter_->IsPresent()); |
| 501 | 503 |
| 502 // We should have had a device removed. | 504 // We should have had a device removed. |
| 503 EXPECT_EQ(1, observer.device_removed_count_); | 505 EXPECT_EQ(2, observer.device_removed_count_); |
| 504 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 506 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress, |
| 505 observer.last_device_address_); | 507 observer.last_device_address_); |
| 506 | 508 |
| 507 // Other callbacks shouldn't be called since the values are false. | 509 // Other callbacks shouldn't be called since the values are false. |
| 508 EXPECT_EQ(0, observer.powered_changed_count_); | 510 EXPECT_EQ(0, observer.powered_changed_count_); |
| 509 EXPECT_EQ(0, observer.discovering_changed_count_); | 511 EXPECT_EQ(0, observer.discovering_changed_count_); |
| 510 EXPECT_FALSE(adapter_->IsPowered()); | 512 EXPECT_FALSE(adapter_->IsPowered()); |
| 511 EXPECT_FALSE(adapter_->IsDiscovering()); | 513 EXPECT_FALSE(adapter_->IsDiscovering()); |
| 512 | 514 |
| 513 observer.device_removed_count_ = 0; | 515 observer.device_removed_count_ = 0; |
| 514 | 516 |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 EXPECT_EQ(4, callback_count_); | 1529 EXPECT_EQ(4, callback_count_); |
| 1528 EXPECT_EQ(0, error_callback_count_); | 1530 EXPECT_EQ(0, error_callback_count_); |
| 1529 EXPECT_FALSE(observer.last_discovering_); | 1531 EXPECT_FALSE(observer.last_discovering_); |
| 1530 EXPECT_FALSE(adapter_->IsDiscovering()); | 1532 EXPECT_FALSE(adapter_->IsDiscovering()); |
| 1531 } | 1533 } |
| 1532 | 1534 |
| 1533 TEST_F(BluetoothChromeOSTest, DeviceProperties) { | 1535 TEST_F(BluetoothChromeOSTest, DeviceProperties) { |
| 1534 GetAdapter(); | 1536 GetAdapter(); |
| 1535 | 1537 |
| 1536 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 1538 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
| 1537 ASSERT_EQ(1U, devices.size()); | 1539 ASSERT_EQ(2U, devices.size()); |
| 1538 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 1540 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, |
| 1539 devices[0]->GetAddress()); | 1541 devices[0]->GetAddress()); |
| 1540 | 1542 |
| 1541 // Verify the other device properties. | 1543 // Verify the other device properties. |
| 1542 EXPECT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), | 1544 EXPECT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), |
| 1543 devices[0]->GetName()); | 1545 devices[0]->GetName()); |
| 1544 EXPECT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[0]->GetDeviceType()); | 1546 EXPECT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[0]->GetDeviceType()); |
| 1545 EXPECT_TRUE(devices[0]->IsPaired()); | 1547 EXPECT_TRUE(devices[0]->IsPaired()); |
| 1546 EXPECT_FALSE(devices[0]->IsConnected()); | 1548 EXPECT_FALSE(devices[0]->IsConnected()); |
| 1547 EXPECT_FALSE(devices[0]->IsConnecting()); | 1549 EXPECT_FALSE(devices[0]->IsConnecting()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1559 EXPECT_EQ(0x030d, devices[0]->GetProductID()); | 1561 EXPECT_EQ(0x030d, devices[0]->GetProductID()); |
| 1560 EXPECT_EQ(0x0306, devices[0]->GetDeviceID()); | 1562 EXPECT_EQ(0x0306, devices[0]->GetDeviceID()); |
| 1561 } | 1563 } |
| 1562 | 1564 |
| 1563 TEST_F(BluetoothChromeOSTest, DeviceClassChanged) { | 1565 TEST_F(BluetoothChromeOSTest, DeviceClassChanged) { |
| 1564 // Simulate a change of class of a device, as sometimes occurs | 1566 // Simulate a change of class of a device, as sometimes occurs |
| 1565 // during discovery. | 1567 // during discovery. |
| 1566 GetAdapter(); | 1568 GetAdapter(); |
| 1567 | 1569 |
| 1568 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 1570 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
| 1569 ASSERT_EQ(1U, devices.size()); | 1571 ASSERT_EQ(2U, devices.size()); |
| 1570 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 1572 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, |
| 1571 devices[0]->GetAddress()); | 1573 devices[0]->GetAddress()); |
| 1572 ASSERT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[0]->GetDeviceType()); | 1574 ASSERT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[0]->GetDeviceType()); |
| 1573 | 1575 |
| 1574 // Install an observer; expect the DeviceChanged method to be called when | 1576 // Install an observer; expect the DeviceChanged method to be called when |
| 1575 // we change the class of the device. | 1577 // we change the class of the device. |
| 1576 TestObserver observer(adapter_); | 1578 TestObserver observer(adapter_); |
| 1577 | 1579 |
| 1578 FakeBluetoothDeviceClient::Properties* properties = | 1580 FakeBluetoothDeviceClient::Properties* properties = |
| 1579 fake_bluetooth_device_client_->GetProperties( | 1581 fake_bluetooth_device_client_->GetProperties( |
| 1580 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); | 1582 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); |
| 1581 | 1583 |
| 1582 properties->bluetooth_class.ReplaceValue(0x002580); | 1584 properties->bluetooth_class.ReplaceValue(0x002580); |
| 1583 | 1585 |
| 1584 EXPECT_EQ(1, observer.device_changed_count_); | 1586 EXPECT_EQ(1, observer.device_changed_count_); |
| 1585 EXPECT_EQ(devices[0], observer.last_device_); | 1587 EXPECT_EQ(devices[0], observer.last_device_); |
| 1586 | 1588 |
| 1587 EXPECT_EQ(BluetoothDevice::DEVICE_MOUSE, devices[0]->GetDeviceType()); | 1589 EXPECT_EQ(BluetoothDevice::DEVICE_MOUSE, devices[0]->GetDeviceType()); |
| 1588 } | 1590 } |
| 1589 | 1591 |
| 1590 TEST_F(BluetoothChromeOSTest, DeviceNameChanged) { | 1592 TEST_F(BluetoothChromeOSTest, DeviceNameChanged) { |
| 1591 // Simulate a change of name of a device. | 1593 // Simulate a change of name of a device. |
| 1592 GetAdapter(); | 1594 GetAdapter(); |
| 1593 | 1595 |
| 1594 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 1596 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
| 1595 ASSERT_EQ(1U, devices.size()); | 1597 ASSERT_EQ(2U, devices.size()); |
| 1596 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 1598 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, |
| 1597 devices[0]->GetAddress()); | 1599 devices[0]->GetAddress()); |
| 1598 ASSERT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), | 1600 ASSERT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), |
| 1599 devices[0]->GetName()); | 1601 devices[0]->GetName()); |
| 1600 | 1602 |
| 1601 // Install an observer; expect the DeviceChanged method to be called when | 1603 // Install an observer; expect the DeviceChanged method to be called when |
| 1602 // we change the alias of the device. | 1604 // we change the alias of the device. |
| 1603 TestObserver observer(adapter_); | 1605 TestObserver observer(adapter_); |
| 1604 | 1606 |
| 1605 FakeBluetoothDeviceClient::Properties* properties = | 1607 FakeBluetoothDeviceClient::Properties* properties = |
| 1606 fake_bluetooth_device_client_->GetProperties( | 1608 fake_bluetooth_device_client_->GetProperties( |
| 1607 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); | 1609 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); |
| 1608 | 1610 |
| 1609 static const std::string new_name("New Device Name"); | 1611 static const std::string new_name("New Device Name"); |
| 1610 properties->alias.ReplaceValue(new_name); | 1612 properties->alias.ReplaceValue(new_name); |
| 1611 | 1613 |
| 1612 EXPECT_EQ(1, observer.device_changed_count_); | 1614 EXPECT_EQ(1, observer.device_changed_count_); |
| 1613 EXPECT_EQ(devices[0], observer.last_device_); | 1615 EXPECT_EQ(devices[0], observer.last_device_); |
| 1614 | 1616 |
| 1615 EXPECT_EQ(base::UTF8ToUTF16(new_name), devices[0]->GetName()); | 1617 EXPECT_EQ(base::UTF8ToUTF16(new_name), devices[0]->GetName()); |
| 1616 } | 1618 } |
| 1617 | 1619 |
| 1618 TEST_F(BluetoothChromeOSTest, DeviceUuidsChanged) { | 1620 TEST_F(BluetoothChromeOSTest, DeviceUuidsChanged) { |
| 1619 // Simulate a change of advertised services of a device. | 1621 // Simulate a change of advertised services of a device. |
| 1620 GetAdapter(); | 1622 GetAdapter(); |
| 1621 | 1623 |
| 1622 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 1624 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
| 1623 ASSERT_EQ(1U, devices.size()); | 1625 ASSERT_EQ(2U, devices.size()); |
| 1624 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 1626 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, |
| 1625 devices[0]->GetAddress()); | 1627 devices[0]->GetAddress()); |
| 1626 | 1628 |
| 1627 BluetoothDevice::UUIDList uuids = devices[0]->GetUUIDs(); | 1629 BluetoothDevice::UUIDList uuids = devices[0]->GetUUIDs(); |
| 1628 ASSERT_EQ(2U, uuids.size()); | 1630 ASSERT_EQ(2U, uuids.size()); |
| 1629 ASSERT_EQ(uuids[0], BluetoothUUID("1800")); | 1631 ASSERT_EQ(uuids[0], BluetoothUUID("1800")); |
| 1630 ASSERT_EQ(uuids[1], BluetoothUUID("1801")); | 1632 ASSERT_EQ(uuids[1], BluetoothUUID("1801")); |
| 1631 | 1633 |
| 1632 // Install an observer; expect the DeviceChanged method to be called when | 1634 // Install an observer; expect the DeviceChanged method to be called when |
| 1633 // we change the class of the device. | 1635 // we change the class of the device. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1656 EXPECT_EQ(uuids[1], BluetoothUUID("1801")); | 1658 EXPECT_EQ(uuids[1], BluetoothUUID("1801")); |
| 1657 EXPECT_EQ(uuids[2], BluetoothUUID("110c")); | 1659 EXPECT_EQ(uuids[2], BluetoothUUID("110c")); |
| 1658 EXPECT_EQ(uuids[3], BluetoothUUID("110e")); | 1660 EXPECT_EQ(uuids[3], BluetoothUUID("110e")); |
| 1659 EXPECT_EQ(uuids[4], BluetoothUUID("110a")); | 1661 EXPECT_EQ(uuids[4], BluetoothUUID("110a")); |
| 1660 } | 1662 } |
| 1661 | 1663 |
| 1662 TEST_F(BluetoothChromeOSTest, ForgetDevice) { | 1664 TEST_F(BluetoothChromeOSTest, ForgetDevice) { |
| 1663 GetAdapter(); | 1665 GetAdapter(); |
| 1664 | 1666 |
| 1665 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 1667 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
| 1666 ASSERT_EQ(1U, devices.size()); | 1668 ASSERT_EQ(2U, devices.size()); |
| 1667 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 1669 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, |
| 1668 devices[0]->GetAddress()); | 1670 devices[0]->GetAddress()); |
| 1669 | 1671 |
| 1670 std::string address = devices[0]->GetAddress(); | 1672 std::string address = devices[0]->GetAddress(); |
| 1671 | 1673 |
| 1672 // Install an observer; expect the DeviceRemoved method to be called | 1674 // Install an observer; expect the DeviceRemoved method to be called |
| 1673 // with the device we remove. | 1675 // with the device we remove. |
| 1674 TestObserver observer(adapter_); | 1676 TestObserver observer(adapter_); |
| 1675 | 1677 |
| 1676 devices[0]->Forget( | 1678 devices[0]->Forget( |
| 1677 base::Bind(&BluetoothChromeOSTest::ErrorCallback, | 1679 base::Bind(&BluetoothChromeOSTest::ErrorCallback, |
| 1678 base::Unretained(this))); | 1680 base::Unretained(this))); |
| 1679 EXPECT_EQ(0, error_callback_count_); | 1681 EXPECT_EQ(0, error_callback_count_); |
| 1680 | 1682 |
| 1681 EXPECT_EQ(1, observer.device_removed_count_); | 1683 EXPECT_EQ(1, observer.device_removed_count_); |
| 1682 EXPECT_EQ(address, observer.last_device_address_); | 1684 EXPECT_EQ(address, observer.last_device_address_); |
| 1683 | 1685 |
| 1684 // GetDevices shouldn't return the device either. | 1686 // GetDevices shouldn't return the device either. |
| 1685 devices = adapter_->GetDevices(); | 1687 devices = adapter_->GetDevices(); |
| 1686 ASSERT_EQ(0U, devices.size()); | 1688 ASSERT_EQ(1U, devices.size()); |
| 1687 } | 1689 } |
| 1688 | 1690 |
| 1689 TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { | 1691 TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { |
| 1690 GetAdapter(); | 1692 GetAdapter(); |
| 1691 DiscoverDevices(); | 1693 DiscoverDevices(); |
| 1692 | 1694 |
| 1693 BluetoothDevice* device = adapter_->GetDevice( | 1695 BluetoothDevice* device = adapter_->GetDevice( |
| 1694 FakeBluetoothDeviceClient::kConnectUnpairableAddress); | 1696 FakeBluetoothDeviceClient::kConnectUnpairableAddress); |
| 1695 ASSERT_TRUE(device != NULL); | 1697 ASSERT_TRUE(device != NULL); |
| 1696 ASSERT_FALSE(device->IsPaired()); | 1698 ASSERT_FALSE(device->IsPaired()); |
| (...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3335 callback_count_ = 0; | 3337 callback_count_ = 0; |
| 3336 | 3338 |
| 3337 // Validate running adapter state. | 3339 // Validate running adapter state. |
| 3338 EXPECT_NE("", adapter_->GetAddress()); | 3340 EXPECT_NE("", adapter_->GetAddress()); |
| 3339 EXPECT_NE("", adapter_->GetName()); | 3341 EXPECT_NE("", adapter_->GetName()); |
| 3340 EXPECT_TRUE(adapter_->IsInitialized()); | 3342 EXPECT_TRUE(adapter_->IsInitialized()); |
| 3341 EXPECT_TRUE(adapter_->IsPresent()); | 3343 EXPECT_TRUE(adapter_->IsPresent()); |
| 3342 EXPECT_TRUE(adapter_->IsPowered()); | 3344 EXPECT_TRUE(adapter_->IsPowered()); |
| 3343 EXPECT_TRUE(adapter_->IsDiscoverable()); | 3345 EXPECT_TRUE(adapter_->IsDiscoverable()); |
| 3344 EXPECT_TRUE(adapter_->IsDiscovering()); | 3346 EXPECT_TRUE(adapter_->IsDiscovering()); |
| 3345 EXPECT_EQ(1U, adapter_->GetDevices().size()); | 3347 EXPECT_EQ(2U, adapter_->GetDevices().size()); |
| 3346 EXPECT_NE(nullptr, adapter_->GetDevice( | 3348 EXPECT_NE(nullptr, adapter_->GetDevice( |
| 3347 FakeBluetoothDeviceClient::kPairedDeviceAddress)); | 3349 FakeBluetoothDeviceClient::kPairedDeviceAddress)); |
| 3348 EXPECT_NE(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>( | 3350 EXPECT_NE(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>( |
| 3349 adapter_.get())->object_path()); | 3351 adapter_.get())->object_path()); |
| 3350 | 3352 |
| 3351 // Shutdown | 3353 // Shutdown |
| 3352 static_cast<BluetoothAdapterChromeOS*>(adapter_.get())->Shutdown(); | 3354 static_cast<BluetoothAdapterChromeOS*>(adapter_.get())->Shutdown(); |
| 3353 | 3355 |
| 3354 // Validate post shutdown state. | 3356 // Validate post shutdown state. |
| 3355 EXPECT_EQ("", adapter_->GetAddress()); | 3357 EXPECT_EQ("", adapter_->GetAddress()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3376 adapter_->StartDiscoverySession( | 3378 adapter_->StartDiscoverySession( |
| 3377 base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, | 3379 base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, |
| 3378 base::Unretained(this)), | 3380 base::Unretained(this)), |
| 3379 base::Bind(&BluetoothChromeOSTest::ErrorCallback, | 3381 base::Bind(&BluetoothChromeOSTest::ErrorCallback, |
| 3380 base::Unretained(this))); | 3382 base::Unretained(this))); |
| 3381 ASSERT_EQ(0, callback_count_); | 3383 ASSERT_EQ(0, callback_count_); |
| 3382 ASSERT_EQ(3, error_callback_count_); | 3384 ASSERT_EQ(3, error_callback_count_); |
| 3383 } | 3385 } |
| 3384 | 3386 |
| 3385 } // namespace chromeos | 3387 } // namespace chromeos |
| OLD | NEW |