| 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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 base::Bind(&BluetoothChromeOSTest::ErrorCallback, | 767 base::Bind(&BluetoothChromeOSTest::ErrorCallback, |
| 768 base::Unretained(this))); | 768 base::Unretained(this))); |
| 769 message_loop_.Run(); | 769 message_loop_.Run(); |
| 770 EXPECT_EQ(2, callback_count_); | 770 EXPECT_EQ(2, callback_count_); |
| 771 EXPECT_EQ(0, error_callback_count_); | 771 EXPECT_EQ(0, error_callback_count_); |
| 772 callback_count_ = 0; | 772 callback_count_ = 0; |
| 773 | 773 |
| 774 ASSERT_TRUE(adapter_->IsPowered()); | 774 ASSERT_TRUE(adapter_->IsPowered()); |
| 775 ASSERT_TRUE(adapter_->IsDiscovering()); | 775 ASSERT_TRUE(adapter_->IsDiscovering()); |
| 776 | 776 |
| 777 // First device to appear should be an Apple Mouse. | 777 // First device to appear. |
| 778 message_loop_.Run(); | 778 message_loop_.Run(); |
| 779 | 779 |
| 780 EXPECT_EQ(1, observer.device_added_count_); | 780 EXPECT_EQ(1, observer.device_added_count_); |
| 781 EXPECT_EQ(FakeBluetoothDeviceClient::kAppleMouseAddress, | 781 EXPECT_EQ(FakeBluetoothDeviceClient::kLegacyAutopairAddress, |
| 782 observer.last_device_address_); | 782 observer.last_device_address_); |
| 783 | 783 |
| 784 // Next we should get another two devices... | 784 // Next we should get another two devices... |
| 785 message_loop_.Run(); | 785 message_loop_.Run(); |
| 786 EXPECT_EQ(3, observer.device_added_count_); | 786 EXPECT_EQ(3, observer.device_added_count_); |
| 787 | 787 |
| 788 // Okay, let's run forward until a device is actually removed... | 788 // Okay, let's run forward until a device is actually removed... |
| 789 while (!observer.device_removed_count_) | 789 while (!observer.device_removed_count_) |
| 790 message_loop_.Run(); | 790 message_loop_.Run(); |
| 791 | 791 |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 // GetDevices shouldn't return the device either. | 1549 // GetDevices shouldn't return the device either. |
| 1550 devices = adapter_->GetDevices(); | 1550 devices = adapter_->GetDevices(); |
| 1551 ASSERT_EQ(0U, devices.size()); | 1551 ASSERT_EQ(0U, devices.size()); |
| 1552 } | 1552 } |
| 1553 | 1553 |
| 1554 TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { | 1554 TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { |
| 1555 GetAdapter(); | 1555 GetAdapter(); |
| 1556 DiscoverDevices(); | 1556 DiscoverDevices(); |
| 1557 | 1557 |
| 1558 BluetoothDevice* device = adapter_->GetDevice( | 1558 BluetoothDevice* device = adapter_->GetDevice( |
| 1559 FakeBluetoothDeviceClient::kMicrosoftMouseAddress); | 1559 FakeBluetoothDeviceClient::kConnectUnpairableAddress); |
| 1560 ASSERT_TRUE(device != NULL); | 1560 ASSERT_TRUE(device != NULL); |
| 1561 ASSERT_FALSE(device->IsPaired()); | 1561 ASSERT_FALSE(device->IsPaired()); |
| 1562 | 1562 |
| 1563 // Connect the device so it becomes trusted and remembered. | 1563 // Connect the device so it becomes trusted and remembered. |
| 1564 device->Connect( | 1564 device->Connect( |
| 1565 NULL, | 1565 NULL, |
| 1566 base::Bind(&BluetoothChromeOSTest::Callback, | 1566 base::Bind(&BluetoothChromeOSTest::Callback, |
| 1567 base::Unretained(this)), | 1567 base::Unretained(this)), |
| 1568 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 1568 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 1569 base::Unretained(this))); | 1569 base::Unretained(this))); |
| 1570 | 1570 |
| 1571 ASSERT_EQ(1, callback_count_); | 1571 ASSERT_EQ(1, callback_count_); |
| 1572 ASSERT_EQ(0, error_callback_count_); | 1572 ASSERT_EQ(0, error_callback_count_); |
| 1573 callback_count_ = 0; | 1573 callback_count_ = 0; |
| 1574 | 1574 |
| 1575 ASSERT_TRUE(device->IsConnected()); | 1575 ASSERT_TRUE(device->IsConnected()); |
| 1576 ASSERT_FALSE(device->IsConnecting()); | 1576 ASSERT_FALSE(device->IsConnecting()); |
| 1577 | 1577 |
| 1578 // Make sure the trusted property has been set to true. | 1578 // Make sure the trusted property has been set to true. |
| 1579 FakeBluetoothDeviceClient::Properties* properties = | 1579 FakeBluetoothDeviceClient::Properties* properties = |
| 1580 fake_bluetooth_device_client_->GetProperties( | 1580 fake_bluetooth_device_client_->GetProperties( |
| 1581 dbus::ObjectPath(FakeBluetoothDeviceClient::kMicrosoftMousePath)); | 1581 dbus::ObjectPath(FakeBluetoothDeviceClient::kConnectUnpairablePath)); |
| 1582 ASSERT_TRUE(properties->trusted.value()); | 1582 ASSERT_TRUE(properties->trusted.value()); |
| 1583 | 1583 |
| 1584 // Install an observer; expect the DeviceRemoved method to be called | 1584 // Install an observer; expect the DeviceRemoved method to be called |
| 1585 // with the device we remove. | 1585 // with the device we remove. |
| 1586 TestObserver observer(adapter_); | 1586 TestObserver observer(adapter_); |
| 1587 adapter_->AddObserver(&observer); | 1587 adapter_->AddObserver(&observer); |
| 1588 | 1588 |
| 1589 device->Forget( | 1589 device->Forget( |
| 1590 base::Bind(&BluetoothChromeOSTest::ErrorCallback, | 1590 base::Bind(&BluetoothChromeOSTest::ErrorCallback, |
| 1591 base::Unretained(this))); | 1591 base::Unretained(this))); |
| 1592 EXPECT_EQ(0, error_callback_count_); | 1592 EXPECT_EQ(0, error_callback_count_); |
| 1593 | 1593 |
| 1594 EXPECT_EQ(1, observer.device_removed_count_); | 1594 EXPECT_EQ(1, observer.device_removed_count_); |
| 1595 EXPECT_EQ(FakeBluetoothDeviceClient::kMicrosoftMouseAddress, | 1595 EXPECT_EQ(FakeBluetoothDeviceClient::kConnectUnpairableAddress, |
| 1596 observer.last_device_address_); | 1596 observer.last_device_address_); |
| 1597 | 1597 |
| 1598 // GetDevices shouldn't return the device either. | 1598 // GetDevices shouldn't return the device either. |
| 1599 device = adapter_->GetDevice( | 1599 device = adapter_->GetDevice( |
| 1600 FakeBluetoothDeviceClient::kMicrosoftMouseAddress); | 1600 FakeBluetoothDeviceClient::kConnectUnpairableAddress); |
| 1601 EXPECT_FALSE(device != NULL); | 1601 EXPECT_FALSE(device != NULL); |
| 1602 } | 1602 } |
| 1603 | 1603 |
| 1604 TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { | 1604 TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { |
| 1605 GetAdapter(); | 1605 GetAdapter(); |
| 1606 | 1606 |
| 1607 BluetoothDevice* device = adapter_->GetDevice( | 1607 BluetoothDevice* device = adapter_->GetDevice( |
| 1608 FakeBluetoothDeviceClient::kPairedDeviceAddress); | 1608 FakeBluetoothDeviceClient::kPairedDeviceAddress); |
| 1609 ASSERT_TRUE(device != NULL); | 1609 ASSERT_TRUE(device != NULL); |
| 1610 ASSERT_TRUE(device->IsPaired()); | 1610 ASSERT_TRUE(device->IsPaired()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1631 | 1631 |
| 1632 EXPECT_TRUE(device->IsConnected()); | 1632 EXPECT_TRUE(device->IsConnected()); |
| 1633 EXPECT_FALSE(device->IsConnecting()); | 1633 EXPECT_FALSE(device->IsConnecting()); |
| 1634 } | 1634 } |
| 1635 | 1635 |
| 1636 TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { | 1636 TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { |
| 1637 GetAdapter(); | 1637 GetAdapter(); |
| 1638 DiscoverDevices(); | 1638 DiscoverDevices(); |
| 1639 | 1639 |
| 1640 BluetoothDevice* device = adapter_->GetDevice( | 1640 BluetoothDevice* device = adapter_->GetDevice( |
| 1641 FakeBluetoothDeviceClient::kMicrosoftMouseAddress); | 1641 FakeBluetoothDeviceClient::kConnectUnpairableAddress); |
| 1642 ASSERT_TRUE(device != NULL); | 1642 ASSERT_TRUE(device != NULL); |
| 1643 ASSERT_FALSE(device->IsPaired()); | 1643 ASSERT_FALSE(device->IsPaired()); |
| 1644 | 1644 |
| 1645 TestObserver observer(adapter_); | 1645 TestObserver observer(adapter_); |
| 1646 adapter_->AddObserver(&observer); | 1646 adapter_->AddObserver(&observer); |
| 1647 | 1647 |
| 1648 // Connect without a pairing delegate; since the device does not require | 1648 // Connect without a pairing delegate; since the device does not require |
| 1649 // pairing, this should succeed and the device should become connected. | 1649 // pairing, this should succeed and the device should become connected. |
| 1650 device->Connect( | 1650 device->Connect( |
| 1651 NULL, | 1651 NULL, |
| 1652 base::Bind(&BluetoothChromeOSTest::Callback, | 1652 base::Bind(&BluetoothChromeOSTest::Callback, |
| 1653 base::Unretained(this)), | 1653 base::Unretained(this)), |
| 1654 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | 1654 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, |
| 1655 base::Unretained(this))); | 1655 base::Unretained(this))); |
| 1656 | 1656 |
| 1657 EXPECT_EQ(1, callback_count_); | 1657 EXPECT_EQ(1, callback_count_); |
| 1658 EXPECT_EQ(0, error_callback_count_); | 1658 EXPECT_EQ(0, error_callback_count_); |
| 1659 | 1659 |
| 1660 // Two changes for connecting, one for connected, one for for trusted after | 1660 // Two changes for connecting, one for connected, one for for trusted after |
| 1661 // connection, and one for the reconnect mode (IsConnectable). | 1661 // connection, and one for the reconnect mode (IsConnectable). |
| 1662 EXPECT_EQ(5, observer.device_changed_count_); | 1662 EXPECT_EQ(5, observer.device_changed_count_); |
| 1663 EXPECT_EQ(device, observer.last_device_); | 1663 EXPECT_EQ(device, observer.last_device_); |
| 1664 | 1664 |
| 1665 EXPECT_TRUE(device->IsConnected()); | 1665 EXPECT_TRUE(device->IsConnected()); |
| 1666 EXPECT_FALSE(device->IsConnecting()); | 1666 EXPECT_FALSE(device->IsConnecting()); |
| 1667 | 1667 |
| 1668 // Make sure the trusted property has been set to true. | 1668 // Make sure the trusted property has been set to true. |
| 1669 FakeBluetoothDeviceClient::Properties* properties = | 1669 FakeBluetoothDeviceClient::Properties* properties = |
| 1670 fake_bluetooth_device_client_->GetProperties( | 1670 fake_bluetooth_device_client_->GetProperties( |
| 1671 dbus::ObjectPath(FakeBluetoothDeviceClient::kMicrosoftMousePath)); | 1671 dbus::ObjectPath(FakeBluetoothDeviceClient::kConnectUnpairablePath)); |
| 1672 EXPECT_TRUE(properties->trusted.value()); | 1672 EXPECT_TRUE(properties->trusted.value()); |
| 1673 | 1673 |
| 1674 // Verify is a HID device and is not connectable. | 1674 // Verify is a HID device and is not connectable. |
| 1675 BluetoothDevice::ServiceList uuids = device->GetServices(); | 1675 BluetoothDevice::ServiceList uuids = device->GetServices(); |
| 1676 ASSERT_EQ(1U, uuids.size()); | 1676 ASSERT_EQ(1U, uuids.size()); |
| 1677 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb"); | 1677 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb"); |
| 1678 EXPECT_FALSE(device->IsConnectable()); | 1678 EXPECT_FALSE(device->IsConnectable()); |
| 1679 } | 1679 } |
| 1680 | 1680 |
| 1681 TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { | 1681 TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1720 | 1720 |
| 1721 EXPECT_TRUE(device->IsConnected()); | 1721 EXPECT_TRUE(device->IsConnected()); |
| 1722 EXPECT_FALSE(device->IsConnecting()); | 1722 EXPECT_FALSE(device->IsConnecting()); |
| 1723 } | 1723 } |
| 1724 | 1724 |
| 1725 TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { | 1725 TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { |
| 1726 GetAdapter(); | 1726 GetAdapter(); |
| 1727 DiscoverDevices(); | 1727 DiscoverDevices(); |
| 1728 | 1728 |
| 1729 BluetoothDevice* device = adapter_->GetDevice( | 1729 BluetoothDevice* device = adapter_->GetDevice( |
| 1730 FakeBluetoothDeviceClient::kAppleMouseAddress); | 1730 FakeBluetoothDeviceClient::kLegacyAutopairAddress); |
| 1731 ASSERT_TRUE(device != NULL); | 1731 ASSERT_TRUE(device != NULL); |
| 1732 ASSERT_FALSE(device->IsPaired()); | 1732 ASSERT_FALSE(device->IsPaired()); |
| 1733 | 1733 |
| 1734 TestObserver observer(adapter_); | 1734 TestObserver observer(adapter_); |
| 1735 adapter_->AddObserver(&observer); | 1735 adapter_->AddObserver(&observer); |
| 1736 | 1736 |
| 1737 // Connect without a pairing delegate; since the device requires pairing, | 1737 // Connect without a pairing delegate; since the device requires pairing, |
| 1738 // this should fail with an error. | 1738 // this should fail with an error. |
| 1739 device->Connect( | 1739 device->Connect( |
| 1740 NULL, | 1740 NULL, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 base::Unretained(this))); | 1816 base::Unretained(this))); |
| 1817 | 1817 |
| 1818 EXPECT_EQ(0, callback_count_); | 1818 EXPECT_EQ(0, callback_count_); |
| 1819 EXPECT_EQ(1, error_callback_count_); | 1819 EXPECT_EQ(1, error_callback_count_); |
| 1820 | 1820 |
| 1821 EXPECT_EQ(0, observer.device_changed_count_); | 1821 EXPECT_EQ(0, observer.device_changed_count_); |
| 1822 | 1822 |
| 1823 EXPECT_FALSE(device->IsConnected()); | 1823 EXPECT_FALSE(device->IsConnected()); |
| 1824 } | 1824 } |
| 1825 | 1825 |
| 1826 TEST_F(BluetoothChromeOSTest, PairAppleMouse) { | 1826 TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) { |
| 1827 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1827 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1828 | 1828 |
| 1829 GetAdapter(); | 1829 GetAdapter(); |
| 1830 DiscoverDevices(); | 1830 DiscoverDevices(); |
| 1831 | 1831 |
| 1832 // The Apple Mouse requires no PIN or Passkey to pair; this is equivalent | 1832 // The Legacy Autopair device requires no PIN or Passkey to pair because |
| 1833 // to Simple Secure Pairing or a device with a fixed 0000 PIN. | 1833 // the daemon provides 0000 to the device for us. |
| 1834 BluetoothDevice* device = adapter_->GetDevice( | 1834 BluetoothDevice* device = adapter_->GetDevice( |
| 1835 FakeBluetoothDeviceClient::kAppleMouseAddress); | 1835 FakeBluetoothDeviceClient::kLegacyAutopairAddress); |
| 1836 ASSERT_TRUE(device != NULL); | 1836 ASSERT_TRUE(device != NULL); |
| 1837 ASSERT_FALSE(device->IsPaired()); | 1837 ASSERT_FALSE(device->IsPaired()); |
| 1838 | 1838 |
| 1839 TestObserver observer(adapter_); | 1839 TestObserver observer(adapter_); |
| 1840 adapter_->AddObserver(&observer); | 1840 adapter_->AddObserver(&observer); |
| 1841 | 1841 |
| 1842 TestPairingDelegate pairing_delegate; | 1842 TestPairingDelegate pairing_delegate; |
| 1843 device->Connect( | 1843 device->Connect( |
| 1844 &pairing_delegate, | 1844 &pairing_delegate, |
| 1845 base::Bind(&BluetoothChromeOSTest::Callback, | 1845 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1868 | 1868 |
| 1869 // Verify is a HID device and is connectable. | 1869 // Verify is a HID device and is connectable. |
| 1870 BluetoothDevice::ServiceList uuids = device->GetServices(); | 1870 BluetoothDevice::ServiceList uuids = device->GetServices(); |
| 1871 ASSERT_EQ(1U, uuids.size()); | 1871 ASSERT_EQ(1U, uuids.size()); |
| 1872 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb"); | 1872 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb"); |
| 1873 EXPECT_TRUE(device->IsConnectable()); | 1873 EXPECT_TRUE(device->IsConnectable()); |
| 1874 | 1874 |
| 1875 // Make sure the trusted property has been set to true. | 1875 // Make sure the trusted property has been set to true. |
| 1876 FakeBluetoothDeviceClient::Properties* properties = | 1876 FakeBluetoothDeviceClient::Properties* properties = |
| 1877 fake_bluetooth_device_client_->GetProperties( | 1877 fake_bluetooth_device_client_->GetProperties( |
| 1878 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleMousePath)); | 1878 dbus::ObjectPath(FakeBluetoothDeviceClient::kLegacyAutopairPath)); |
| 1879 EXPECT_TRUE(properties->trusted.value()); | 1879 EXPECT_TRUE(properties->trusted.value()); |
| 1880 } | 1880 } |
| 1881 | 1881 |
| 1882 TEST_F(BluetoothChromeOSTest, PairAppleKeyboard) { | 1882 TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) { |
| 1883 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1883 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1884 | 1884 |
| 1885 GetAdapter(); | 1885 GetAdapter(); |
| 1886 DiscoverDevices(); | 1886 DiscoverDevices(); |
| 1887 | 1887 |
| 1888 // The Apple Keyboard requires that we display a randomly generated | 1888 // Requires that we display a randomly generated PIN on the screen. |
| 1889 // PIN on the screen. | |
| 1890 BluetoothDevice* device = adapter_->GetDevice( | 1889 BluetoothDevice* device = adapter_->GetDevice( |
| 1891 FakeBluetoothDeviceClient::kAppleKeyboardAddress); | 1890 FakeBluetoothDeviceClient::kDisplayPinCodeAddress); |
| 1892 ASSERT_TRUE(device != NULL); | 1891 ASSERT_TRUE(device != NULL); |
| 1893 ASSERT_FALSE(device->IsPaired()); | 1892 ASSERT_FALSE(device->IsPaired()); |
| 1894 | 1893 |
| 1895 TestObserver observer(adapter_); | 1894 TestObserver observer(adapter_); |
| 1896 adapter_->AddObserver(&observer); | 1895 adapter_->AddObserver(&observer); |
| 1897 | 1896 |
| 1898 TestPairingDelegate pairing_delegate; | 1897 TestPairingDelegate pairing_delegate; |
| 1899 device->Connect( | 1898 device->Connect( |
| 1900 &pairing_delegate, | 1899 &pairing_delegate, |
| 1901 base::Bind(&BluetoothChromeOSTest::Callback, | 1900 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1926 | 1925 |
| 1927 // Verify is a HID device and is connectable. | 1926 // Verify is a HID device and is connectable. |
| 1928 BluetoothDevice::ServiceList uuids = device->GetServices(); | 1927 BluetoothDevice::ServiceList uuids = device->GetServices(); |
| 1929 ASSERT_EQ(1U, uuids.size()); | 1928 ASSERT_EQ(1U, uuids.size()); |
| 1930 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb"); | 1929 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb"); |
| 1931 EXPECT_TRUE(device->IsConnectable()); | 1930 EXPECT_TRUE(device->IsConnectable()); |
| 1932 | 1931 |
| 1933 // Make sure the trusted property has been set to true. | 1932 // Make sure the trusted property has been set to true. |
| 1934 FakeBluetoothDeviceClient::Properties* properties = | 1933 FakeBluetoothDeviceClient::Properties* properties = |
| 1935 fake_bluetooth_device_client_->GetProperties( | 1934 fake_bluetooth_device_client_->GetProperties( |
| 1936 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleKeyboardPath)); | 1935 dbus::ObjectPath(FakeBluetoothDeviceClient::kDisplayPinCodePath)); |
| 1937 EXPECT_TRUE(properties->trusted.value()); | 1936 EXPECT_TRUE(properties->trusted.value()); |
| 1938 } | 1937 } |
| 1939 | 1938 |
| 1940 TEST_F(BluetoothChromeOSTest, PairMotorolaKeyboard) { | 1939 TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { |
| 1941 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 1940 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 1942 | 1941 |
| 1943 GetAdapter(); | 1942 GetAdapter(); |
| 1944 DiscoverDevices(); | 1943 DiscoverDevices(); |
| 1945 | 1944 |
| 1946 // The Motorola Keyboard requires that we display a randomly generated | 1945 // Requires that we display a randomly generated Passkey on the screen, |
| 1947 // Passkey on the screen, and notifies us as it's typed in. | 1946 // and notifies us as it's typed in. |
| 1948 BluetoothDevice* device = adapter_->GetDevice( | 1947 BluetoothDevice* device = adapter_->GetDevice( |
| 1949 FakeBluetoothDeviceClient::kMotorolaKeyboardAddress); | 1948 FakeBluetoothDeviceClient::kDisplayPasskeyAddress); |
| 1950 ASSERT_TRUE(device != NULL); | 1949 ASSERT_TRUE(device != NULL); |
| 1951 ASSERT_FALSE(device->IsPaired()); | 1950 ASSERT_FALSE(device->IsPaired()); |
| 1952 | 1951 |
| 1953 TestObserver observer(adapter_); | 1952 TestObserver observer(adapter_); |
| 1954 adapter_->AddObserver(&observer); | 1953 adapter_->AddObserver(&observer); |
| 1955 | 1954 |
| 1956 TestPairingDelegate pairing_delegate; | 1955 TestPairingDelegate pairing_delegate; |
| 1957 device->Connect( | 1956 device->Connect( |
| 1958 &pairing_delegate, | 1957 &pairing_delegate, |
| 1959 base::Bind(&BluetoothChromeOSTest::Callback, | 1958 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1999 EXPECT_TRUE(device->IsConnected()); | 1998 EXPECT_TRUE(device->IsConnected()); |
| 2000 EXPECT_FALSE(device->IsConnecting()); | 1999 EXPECT_FALSE(device->IsConnecting()); |
| 2001 | 2000 |
| 2002 EXPECT_TRUE(device->IsPaired()); | 2001 EXPECT_TRUE(device->IsPaired()); |
| 2003 | 2002 |
| 2004 // Verify is a HID device. | 2003 // Verify is a HID device. |
| 2005 BluetoothDevice::ServiceList uuids = device->GetServices(); | 2004 BluetoothDevice::ServiceList uuids = device->GetServices(); |
| 2006 ASSERT_EQ(1U, uuids.size()); | 2005 ASSERT_EQ(1U, uuids.size()); |
| 2007 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb"); | 2006 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb"); |
| 2008 | 2007 |
| 2009 // Fake MotorolaKeyboard is not connectable. | 2008 // And usually not connectable. |
| 2010 EXPECT_FALSE(device->IsConnectable()); | 2009 EXPECT_FALSE(device->IsConnectable()); |
| 2011 | 2010 |
| 2012 // Make sure the trusted property has been set to true. | 2011 // Make sure the trusted property has been set to true. |
| 2013 FakeBluetoothDeviceClient::Properties* properties = | 2012 FakeBluetoothDeviceClient::Properties* properties = |
| 2014 fake_bluetooth_device_client_->GetProperties( | 2013 fake_bluetooth_device_client_->GetProperties( |
| 2015 dbus::ObjectPath(FakeBluetoothDeviceClient::kMotorolaKeyboardPath)); | 2014 dbus::ObjectPath(FakeBluetoothDeviceClient::kDisplayPasskeyPath)); |
| 2016 EXPECT_TRUE(properties->trusted.value()); | 2015 EXPECT_TRUE(properties->trusted.value()); |
| 2017 } | 2016 } |
| 2018 | 2017 |
| 2019 TEST_F(BluetoothChromeOSTest, PairSonyHeadphones) { | 2018 TEST_F(BluetoothChromeOSTest, PairRequestPinCode) { |
| 2020 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2019 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2021 | 2020 |
| 2022 GetAdapter(); | 2021 GetAdapter(); |
| 2023 DiscoverDevices(); | 2022 DiscoverDevices(); |
| 2024 | 2023 |
| 2025 // The Sony Headphones fake requires that the user enters a PIN for them. | 2024 // Requires that the user enters a PIN for them. |
| 2026 BluetoothDevice* device = adapter_->GetDevice( | 2025 BluetoothDevice* device = adapter_->GetDevice( |
| 2027 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); | 2026 FakeBluetoothDeviceClient::kRequestPinCodeAddress); |
| 2028 ASSERT_TRUE(device != NULL); | 2027 ASSERT_TRUE(device != NULL); |
| 2029 ASSERT_FALSE(device->IsPaired()); | 2028 ASSERT_FALSE(device->IsPaired()); |
| 2030 | 2029 |
| 2031 TestObserver observer(adapter_); | 2030 TestObserver observer(adapter_); |
| 2032 adapter_->AddObserver(&observer); | 2031 adapter_->AddObserver(&observer); |
| 2033 | 2032 |
| 2034 TestPairingDelegate pairing_delegate; | 2033 TestPairingDelegate pairing_delegate; |
| 2035 device->Connect( | 2034 device->Connect( |
| 2036 &pairing_delegate, | 2035 &pairing_delegate, |
| 2037 base::Bind(&BluetoothChromeOSTest::Callback, | 2036 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2063 // Verify is not a HID device. | 2062 // Verify is not a HID device. |
| 2064 BluetoothDevice::ServiceList uuids = device->GetServices(); | 2063 BluetoothDevice::ServiceList uuids = device->GetServices(); |
| 2065 ASSERT_EQ(0U, uuids.size()); | 2064 ASSERT_EQ(0U, uuids.size()); |
| 2066 | 2065 |
| 2067 // Non HID devices are always connectable. | 2066 // Non HID devices are always connectable. |
| 2068 EXPECT_TRUE(device->IsConnectable()); | 2067 EXPECT_TRUE(device->IsConnectable()); |
| 2069 | 2068 |
| 2070 // Make sure the trusted property has been set to true. | 2069 // Make sure the trusted property has been set to true. |
| 2071 FakeBluetoothDeviceClient::Properties* properties = | 2070 FakeBluetoothDeviceClient::Properties* properties = |
| 2072 fake_bluetooth_device_client_->GetProperties( | 2071 fake_bluetooth_device_client_->GetProperties( |
| 2073 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath)); | 2072 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); |
| 2074 EXPECT_TRUE(properties->trusted.value()); | 2073 EXPECT_TRUE(properties->trusted.value()); |
| 2075 } | 2074 } |
| 2076 | 2075 |
| 2077 TEST_F(BluetoothChromeOSTest, PairPhone) { | 2076 TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) { |
| 2078 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2077 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2079 | 2078 |
| 2080 GetAdapter(); | 2079 GetAdapter(); |
| 2081 DiscoverDevices(); | 2080 DiscoverDevices(); |
| 2082 | 2081 |
| 2083 // The fake phone requests that we confirm a displayed passkey. | 2082 // Requests that we confirm a displayed passkey. |
| 2084 BluetoothDevice* device = adapter_->GetDevice( | 2083 BluetoothDevice* device = adapter_->GetDevice( |
| 2085 FakeBluetoothDeviceClient::kPhoneAddress); | 2084 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); |
| 2086 ASSERT_TRUE(device != NULL); | 2085 ASSERT_TRUE(device != NULL); |
| 2087 ASSERT_FALSE(device->IsPaired()); | 2086 ASSERT_FALSE(device->IsPaired()); |
| 2088 | 2087 |
| 2089 TestObserver observer(adapter_); | 2088 TestObserver observer(adapter_); |
| 2090 adapter_->AddObserver(&observer); | 2089 adapter_->AddObserver(&observer); |
| 2091 | 2090 |
| 2092 TestPairingDelegate pairing_delegate; | 2091 TestPairingDelegate pairing_delegate; |
| 2093 device->Connect( | 2092 device->Connect( |
| 2094 &pairing_delegate, | 2093 &pairing_delegate, |
| 2095 base::Bind(&BluetoothChromeOSTest::Callback, | 2094 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2118 EXPECT_FALSE(device->IsConnecting()); | 2117 EXPECT_FALSE(device->IsConnecting()); |
| 2119 | 2118 |
| 2120 EXPECT_TRUE(device->IsPaired()); | 2119 EXPECT_TRUE(device->IsPaired()); |
| 2121 | 2120 |
| 2122 // Non HID devices are always connectable. | 2121 // Non HID devices are always connectable. |
| 2123 EXPECT_TRUE(device->IsConnectable()); | 2122 EXPECT_TRUE(device->IsConnectable()); |
| 2124 | 2123 |
| 2125 // Make sure the trusted property has been set to true. | 2124 // Make sure the trusted property has been set to true. |
| 2126 FakeBluetoothDeviceClient::Properties* properties = | 2125 FakeBluetoothDeviceClient::Properties* properties = |
| 2127 fake_bluetooth_device_client_->GetProperties( | 2126 fake_bluetooth_device_client_->GetProperties( |
| 2128 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath)); | 2127 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| 2129 EXPECT_TRUE(properties->trusted.value()); | 2128 EXPECT_TRUE(properties->trusted.value()); |
| 2130 } | 2129 } |
| 2131 | 2130 |
| 2132 TEST_F(BluetoothChromeOSTest, PairWeirdDevice) { | 2131 TEST_F(BluetoothChromeOSTest, PairRequestPasskey) { |
| 2133 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2132 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2134 | 2133 |
| 2135 GetAdapter(); | 2134 GetAdapter(); |
| 2136 DiscoverDevices(); | 2135 DiscoverDevices(); |
| 2137 | 2136 |
| 2138 // Use the "weird device" fake that requires that the user enters a Passkey, | 2137 // Requires that the user enters a Passkey, this would be some kind of |
| 2139 // this would be some kind of device that has a display, but doesn't use | 2138 // device that has a display, but doesn't use "just works" - maybe a car? |
| 2140 // "just works" - maybe a car? | |
| 2141 BluetoothDevice* device = adapter_->GetDevice( | 2139 BluetoothDevice* device = adapter_->GetDevice( |
| 2142 FakeBluetoothDeviceClient::kWeirdDeviceAddress); | 2140 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 2143 ASSERT_TRUE(device != NULL); | 2141 ASSERT_TRUE(device != NULL); |
| 2144 ASSERT_FALSE(device->IsPaired()); | 2142 ASSERT_FALSE(device->IsPaired()); |
| 2145 | 2143 |
| 2146 TestObserver observer(adapter_); | 2144 TestObserver observer(adapter_); |
| 2147 adapter_->AddObserver(&observer); | 2145 adapter_->AddObserver(&observer); |
| 2148 | 2146 |
| 2149 TestPairingDelegate pairing_delegate; | 2147 TestPairingDelegate pairing_delegate; |
| 2150 device->Connect( | 2148 device->Connect( |
| 2151 &pairing_delegate, | 2149 &pairing_delegate, |
| 2152 base::Bind(&BluetoothChromeOSTest::Callback, | 2150 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2174 EXPECT_FALSE(device->IsConnecting()); | 2172 EXPECT_FALSE(device->IsConnecting()); |
| 2175 | 2173 |
| 2176 EXPECT_TRUE(device->IsPaired()); | 2174 EXPECT_TRUE(device->IsPaired()); |
| 2177 | 2175 |
| 2178 // Non HID devices are always connectable. | 2176 // Non HID devices are always connectable. |
| 2179 EXPECT_TRUE(device->IsConnectable()); | 2177 EXPECT_TRUE(device->IsConnectable()); |
| 2180 | 2178 |
| 2181 // Make sure the trusted property has been set to true. | 2179 // Make sure the trusted property has been set to true. |
| 2182 FakeBluetoothDeviceClient::Properties* properties = | 2180 FakeBluetoothDeviceClient::Properties* properties = |
| 2183 fake_bluetooth_device_client_->GetProperties( | 2181 fake_bluetooth_device_client_->GetProperties( |
| 2184 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath)); | 2182 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); |
| 2185 EXPECT_TRUE(properties->trusted.value()); | 2183 EXPECT_TRUE(properties->trusted.value()); |
| 2186 } | 2184 } |
| 2187 | 2185 |
| 2188 TEST_F(BluetoothChromeOSTest, PairBoseSpeakers) { | 2186 TEST_F(BluetoothChromeOSTest, PairJustWorks) { |
| 2189 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2187 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2190 | 2188 |
| 2191 GetAdapter(); | 2189 GetAdapter(); |
| 2192 DiscoverDevices(); | 2190 DiscoverDevices(); |
| 2193 | 2191 |
| 2194 // Use the "bose speakers" fake that uses just-works pairing, since this is | 2192 // Uses just-works pairing, since this is an outgoing pairing, no delegate |
| 2195 // an outgoing pairing, no delegate interaction is required. | 2193 // interaction is required. |
| 2196 BluetoothDevice* device = adapter_->GetDevice( | 2194 BluetoothDevice* device = adapter_->GetDevice( |
| 2197 FakeBluetoothDeviceClient::kBoseSpeakersAddress); | 2195 FakeBluetoothDeviceClient::kJustWorksAddress); |
| 2198 ASSERT_TRUE(device != NULL); | 2196 ASSERT_TRUE(device != NULL); |
| 2199 ASSERT_FALSE(device->IsPaired()); | 2197 ASSERT_FALSE(device->IsPaired()); |
| 2200 | 2198 |
| 2201 TestObserver observer(adapter_); | 2199 TestObserver observer(adapter_); |
| 2202 adapter_->AddObserver(&observer); | 2200 adapter_->AddObserver(&observer); |
| 2203 | 2201 |
| 2204 TestPairingDelegate pairing_delegate; | 2202 TestPairingDelegate pairing_delegate; |
| 2205 device->Connect( | 2203 device->Connect( |
| 2206 &pairing_delegate, | 2204 &pairing_delegate, |
| 2207 base::Bind(&BluetoothChromeOSTest::Callback, | 2205 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2225 EXPECT_FALSE(device->IsConnecting()); | 2223 EXPECT_FALSE(device->IsConnecting()); |
| 2226 | 2224 |
| 2227 EXPECT_TRUE(device->IsPaired()); | 2225 EXPECT_TRUE(device->IsPaired()); |
| 2228 | 2226 |
| 2229 // Non HID devices are always connectable. | 2227 // Non HID devices are always connectable. |
| 2230 EXPECT_TRUE(device->IsConnectable()); | 2228 EXPECT_TRUE(device->IsConnectable()); |
| 2231 | 2229 |
| 2232 // Make sure the trusted property has been set to true. | 2230 // Make sure the trusted property has been set to true. |
| 2233 FakeBluetoothDeviceClient::Properties* properties = | 2231 FakeBluetoothDeviceClient::Properties* properties = |
| 2234 fake_bluetooth_device_client_->GetProperties( | 2232 fake_bluetooth_device_client_->GetProperties( |
| 2235 dbus::ObjectPath(FakeBluetoothDeviceClient::kBoseSpeakersPath)); | 2233 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); |
| 2236 EXPECT_TRUE(properties->trusted.value()); | 2234 EXPECT_TRUE(properties->trusted.value()); |
| 2237 } | 2235 } |
| 2238 | 2236 |
| 2239 TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { | 2237 TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { |
| 2240 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2238 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2241 | 2239 |
| 2242 GetAdapter(); | 2240 GetAdapter(); |
| 2243 DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); | 2241 DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); |
| 2244 | 2242 |
| 2245 BluetoothDevice* device = adapter_->GetDevice( | 2243 BluetoothDevice* device = adapter_->GetDevice( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2366 } | 2364 } |
| 2367 | 2365 |
| 2368 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { | 2366 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { |
| 2369 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2367 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2370 | 2368 |
| 2371 GetAdapter(); | 2369 GetAdapter(); |
| 2372 DiscoverDevices(); | 2370 DiscoverDevices(); |
| 2373 | 2371 |
| 2374 // Reject the pairing after we receive a request for the PIN code. | 2372 // Reject the pairing after we receive a request for the PIN code. |
| 2375 BluetoothDevice* device = adapter_->GetDevice( | 2373 BluetoothDevice* device = adapter_->GetDevice( |
| 2376 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); | 2374 FakeBluetoothDeviceClient::kRequestPinCodeAddress); |
| 2377 ASSERT_TRUE(device != NULL); | 2375 ASSERT_TRUE(device != NULL); |
| 2378 ASSERT_FALSE(device->IsPaired()); | 2376 ASSERT_FALSE(device->IsPaired()); |
| 2379 | 2377 |
| 2380 TestObserver observer(adapter_); | 2378 TestObserver observer(adapter_); |
| 2381 adapter_->AddObserver(&observer); | 2379 adapter_->AddObserver(&observer); |
| 2382 | 2380 |
| 2383 TestPairingDelegate pairing_delegate; | 2381 TestPairingDelegate pairing_delegate; |
| 2384 device->Connect( | 2382 device->Connect( |
| 2385 &pairing_delegate, | 2383 &pairing_delegate, |
| 2386 base::Bind(&BluetoothChromeOSTest::Callback, | 2384 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2408 } | 2406 } |
| 2409 | 2407 |
| 2410 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { | 2408 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { |
| 2411 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2409 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2412 | 2410 |
| 2413 GetAdapter(); | 2411 GetAdapter(); |
| 2414 DiscoverDevices(); | 2412 DiscoverDevices(); |
| 2415 | 2413 |
| 2416 // Cancel the pairing after we receive a request for the PIN code. | 2414 // Cancel the pairing after we receive a request for the PIN code. |
| 2417 BluetoothDevice* device = adapter_->GetDevice( | 2415 BluetoothDevice* device = adapter_->GetDevice( |
| 2418 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); | 2416 FakeBluetoothDeviceClient::kRequestPinCodeAddress); |
| 2419 ASSERT_TRUE(device != NULL); | 2417 ASSERT_TRUE(device != NULL); |
| 2420 ASSERT_FALSE(device->IsPaired()); | 2418 ASSERT_FALSE(device->IsPaired()); |
| 2421 | 2419 |
| 2422 TestObserver observer(adapter_); | 2420 TestObserver observer(adapter_); |
| 2423 adapter_->AddObserver(&observer); | 2421 adapter_->AddObserver(&observer); |
| 2424 | 2422 |
| 2425 TestPairingDelegate pairing_delegate; | 2423 TestPairingDelegate pairing_delegate; |
| 2426 device->Connect( | 2424 device->Connect( |
| 2427 &pairing_delegate, | 2425 &pairing_delegate, |
| 2428 base::Bind(&BluetoothChromeOSTest::Callback, | 2426 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2450 } | 2448 } |
| 2451 | 2449 |
| 2452 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { | 2450 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { |
| 2453 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2451 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2454 | 2452 |
| 2455 GetAdapter(); | 2453 GetAdapter(); |
| 2456 DiscoverDevices(); | 2454 DiscoverDevices(); |
| 2457 | 2455 |
| 2458 // Reject the pairing after we receive a request for the passkey. | 2456 // Reject the pairing after we receive a request for the passkey. |
| 2459 BluetoothDevice* device = adapter_->GetDevice( | 2457 BluetoothDevice* device = adapter_->GetDevice( |
| 2460 FakeBluetoothDeviceClient::kWeirdDeviceAddress); | 2458 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 2461 ASSERT_TRUE(device != NULL); | 2459 ASSERT_TRUE(device != NULL); |
| 2462 ASSERT_FALSE(device->IsPaired()); | 2460 ASSERT_FALSE(device->IsPaired()); |
| 2463 | 2461 |
| 2464 TestObserver observer(adapter_); | 2462 TestObserver observer(adapter_); |
| 2465 adapter_->AddObserver(&observer); | 2463 adapter_->AddObserver(&observer); |
| 2466 | 2464 |
| 2467 TestPairingDelegate pairing_delegate; | 2465 TestPairingDelegate pairing_delegate; |
| 2468 device->Connect( | 2466 device->Connect( |
| 2469 &pairing_delegate, | 2467 &pairing_delegate, |
| 2470 base::Bind(&BluetoothChromeOSTest::Callback, | 2468 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2492 } | 2490 } |
| 2493 | 2491 |
| 2494 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { | 2492 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { |
| 2495 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2493 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2496 | 2494 |
| 2497 GetAdapter(); | 2495 GetAdapter(); |
| 2498 DiscoverDevices(); | 2496 DiscoverDevices(); |
| 2499 | 2497 |
| 2500 // Cancel the pairing after we receive a request for the passkey. | 2498 // Cancel the pairing after we receive a request for the passkey. |
| 2501 BluetoothDevice* device = adapter_->GetDevice( | 2499 BluetoothDevice* device = adapter_->GetDevice( |
| 2502 FakeBluetoothDeviceClient::kWeirdDeviceAddress); | 2500 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 2503 ASSERT_TRUE(device != NULL); | 2501 ASSERT_TRUE(device != NULL); |
| 2504 ASSERT_FALSE(device->IsPaired()); | 2502 ASSERT_FALSE(device->IsPaired()); |
| 2505 | 2503 |
| 2506 TestObserver observer(adapter_); | 2504 TestObserver observer(adapter_); |
| 2507 adapter_->AddObserver(&observer); | 2505 adapter_->AddObserver(&observer); |
| 2508 | 2506 |
| 2509 TestPairingDelegate pairing_delegate; | 2507 TestPairingDelegate pairing_delegate; |
| 2510 device->Connect( | 2508 device->Connect( |
| 2511 &pairing_delegate, | 2509 &pairing_delegate, |
| 2512 base::Bind(&BluetoothChromeOSTest::Callback, | 2510 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2534 } | 2532 } |
| 2535 | 2533 |
| 2536 TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { | 2534 TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { |
| 2537 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2535 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2538 | 2536 |
| 2539 GetAdapter(); | 2537 GetAdapter(); |
| 2540 DiscoverDevices(); | 2538 DiscoverDevices(); |
| 2541 | 2539 |
| 2542 // Reject the pairing after we receive a request for passkey confirmation. | 2540 // Reject the pairing after we receive a request for passkey confirmation. |
| 2543 BluetoothDevice* device = adapter_->GetDevice( | 2541 BluetoothDevice* device = adapter_->GetDevice( |
| 2544 FakeBluetoothDeviceClient::kPhoneAddress); | 2542 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); |
| 2545 ASSERT_TRUE(device != NULL); | 2543 ASSERT_TRUE(device != NULL); |
| 2546 ASSERT_FALSE(device->IsPaired()); | 2544 ASSERT_FALSE(device->IsPaired()); |
| 2547 | 2545 |
| 2548 TestObserver observer(adapter_); | 2546 TestObserver observer(adapter_); |
| 2549 adapter_->AddObserver(&observer); | 2547 adapter_->AddObserver(&observer); |
| 2550 | 2548 |
| 2551 TestPairingDelegate pairing_delegate; | 2549 TestPairingDelegate pairing_delegate; |
| 2552 device->Connect( | 2550 device->Connect( |
| 2553 &pairing_delegate, | 2551 &pairing_delegate, |
| 2554 base::Bind(&BluetoothChromeOSTest::Callback, | 2552 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2576 } | 2574 } |
| 2577 | 2575 |
| 2578 TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { | 2576 TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { |
| 2579 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2577 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2580 | 2578 |
| 2581 GetAdapter(); | 2579 GetAdapter(); |
| 2582 DiscoverDevices(); | 2580 DiscoverDevices(); |
| 2583 | 2581 |
| 2584 // Cancel the pairing after we receive a request for the passkey. | 2582 // Cancel the pairing after we receive a request for the passkey. |
| 2585 BluetoothDevice* device = adapter_->GetDevice( | 2583 BluetoothDevice* device = adapter_->GetDevice( |
| 2586 FakeBluetoothDeviceClient::kPhoneAddress); | 2584 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); |
| 2587 ASSERT_TRUE(device != NULL); | 2585 ASSERT_TRUE(device != NULL); |
| 2588 ASSERT_FALSE(device->IsPaired()); | 2586 ASSERT_FALSE(device->IsPaired()); |
| 2589 | 2587 |
| 2590 TestObserver observer(adapter_); | 2588 TestObserver observer(adapter_); |
| 2591 adapter_->AddObserver(&observer); | 2589 adapter_->AddObserver(&observer); |
| 2592 | 2590 |
| 2593 TestPairingDelegate pairing_delegate; | 2591 TestPairingDelegate pairing_delegate; |
| 2594 device->Connect( | 2592 device->Connect( |
| 2595 &pairing_delegate, | 2593 &pairing_delegate, |
| 2596 base::Bind(&BluetoothChromeOSTest::Callback, | 2594 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2618 } | 2616 } |
| 2619 | 2617 |
| 2620 TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { | 2618 TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { |
| 2621 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2619 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2622 | 2620 |
| 2623 GetAdapter(); | 2621 GetAdapter(); |
| 2624 DiscoverDevices(); | 2622 DiscoverDevices(); |
| 2625 | 2623 |
| 2626 // Cancel the pairing while we're waiting for the remote host. | 2624 // Cancel the pairing while we're waiting for the remote host. |
| 2627 BluetoothDevice* device = adapter_->GetDevice( | 2625 BluetoothDevice* device = adapter_->GetDevice( |
| 2628 FakeBluetoothDeviceClient::kAppleMouseAddress); | 2626 FakeBluetoothDeviceClient::kLegacyAutopairAddress); |
| 2629 ASSERT_TRUE(device != NULL); | 2627 ASSERT_TRUE(device != NULL); |
| 2630 ASSERT_FALSE(device->IsPaired()); | 2628 ASSERT_FALSE(device->IsPaired()); |
| 2631 | 2629 |
| 2632 TestObserver observer(adapter_); | 2630 TestObserver observer(adapter_); |
| 2633 adapter_->AddObserver(&observer); | 2631 adapter_->AddObserver(&observer); |
| 2634 | 2632 |
| 2635 TestPairingDelegate pairing_delegate; | 2633 TestPairingDelegate pairing_delegate; |
| 2636 device->Connect( | 2634 device->Connect( |
| 2637 &pairing_delegate, | 2635 &pairing_delegate, |
| 2638 base::Bind(&BluetoothChromeOSTest::Callback, | 2636 base::Bind(&BluetoothChromeOSTest::Callback, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2651 EXPECT_EQ(1, error_callback_count_); | 2649 EXPECT_EQ(1, error_callback_count_); |
| 2652 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_CANCELED, last_connect_error_); | 2650 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_CANCELED, last_connect_error_); |
| 2653 | 2651 |
| 2654 // Should be no changes except connecting going true and false. | 2652 // Should be no changes except connecting going true and false. |
| 2655 EXPECT_EQ(2, observer.device_changed_count_); | 2653 EXPECT_EQ(2, observer.device_changed_count_); |
| 2656 EXPECT_FALSE(device->IsConnected()); | 2654 EXPECT_FALSE(device->IsConnected()); |
| 2657 EXPECT_FALSE(device->IsConnecting()); | 2655 EXPECT_FALSE(device->IsConnecting()); |
| 2658 EXPECT_FALSE(device->IsPaired()); | 2656 EXPECT_FALSE(device->IsPaired()); |
| 2659 } | 2657 } |
| 2660 | 2658 |
| 2661 TEST_F(BluetoothChromeOSTest, IncomingPairSonyHeadphones) { | 2659 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCode) { |
| 2662 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2660 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2663 | 2661 |
| 2664 GetAdapter(); | 2662 GetAdapter(); |
| 2665 | 2663 |
| 2666 TestPairingDelegate pairing_delegate; | 2664 TestPairingDelegate pairing_delegate; |
| 2667 adapter_->AddPairingDelegate( | 2665 adapter_->AddPairingDelegate( |
| 2668 &pairing_delegate, | 2666 &pairing_delegate, |
| 2669 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); | 2667 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| 2670 | 2668 |
| 2671 // The sony headphones requests that we provide a PIN code. | 2669 // Requires that we provide a PIN code. |
| 2672 fake_bluetooth_device_client_->CreateDevice( | 2670 fake_bluetooth_device_client_->CreateDevice( |
| 2673 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 2671 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 2674 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath)); | 2672 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); |
| 2675 BluetoothDevice* device = adapter_->GetDevice( | 2673 BluetoothDevice* device = adapter_->GetDevice( |
| 2676 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); | 2674 FakeBluetoothDeviceClient::kRequestPinCodeAddress); |
| 2677 ASSERT_TRUE(device != NULL); | 2675 ASSERT_TRUE(device != NULL); |
| 2678 ASSERT_FALSE(device->IsPaired()); | 2676 ASSERT_FALSE(device->IsPaired()); |
| 2679 | 2677 |
| 2680 TestObserver observer(adapter_); | 2678 TestObserver observer(adapter_); |
| 2681 adapter_->AddObserver(&observer); | 2679 adapter_->AddObserver(&observer); |
| 2682 | 2680 |
| 2683 fake_bluetooth_device_client_->SimulatePairing( | 2681 fake_bluetooth_device_client_->SimulatePairing( |
| 2684 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath), | 2682 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), |
| 2685 true, | 2683 true, |
| 2686 base::Bind(&BluetoothChromeOSTest::Callback, | 2684 base::Bind(&BluetoothChromeOSTest::Callback, |
| 2687 base::Unretained(this)), | 2685 base::Unretained(this)), |
| 2688 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 2686 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 2689 base::Unretained(this))); | 2687 base::Unretained(this))); |
| 2690 | 2688 |
| 2691 EXPECT_EQ(1, pairing_delegate.call_count_); | 2689 EXPECT_EQ(1, pairing_delegate.call_count_); |
| 2692 EXPECT_EQ(1, pairing_delegate.request_pincode_count_); | 2690 EXPECT_EQ(1, pairing_delegate.request_pincode_count_); |
| 2693 | 2691 |
| 2694 // Set the PIN. | 2692 // Set the PIN. |
| 2695 device->SetPinCode("1234"); | 2693 device->SetPinCode("1234"); |
| 2696 message_loop_.Run(); | 2694 message_loop_.Run(); |
| 2697 | 2695 |
| 2698 EXPECT_EQ(1, callback_count_); | 2696 EXPECT_EQ(1, callback_count_); |
| 2699 EXPECT_EQ(0, error_callback_count_); | 2697 EXPECT_EQ(0, error_callback_count_); |
| 2700 | 2698 |
| 2701 // One for paired. | 2699 // One for paired. |
| 2702 EXPECT_EQ(1, observer.device_changed_count_); | 2700 EXPECT_EQ(1, observer.device_changed_count_); |
| 2703 EXPECT_EQ(device, observer.last_device_); | 2701 EXPECT_EQ(device, observer.last_device_); |
| 2704 | 2702 |
| 2705 EXPECT_TRUE(device->IsPaired()); | 2703 EXPECT_TRUE(device->IsPaired()); |
| 2706 | 2704 |
| 2707 // No pairing context should remain on the device. | 2705 // No pairing context should remain on the device. |
| 2708 BluetoothDeviceChromeOS* device_chromeos = | 2706 BluetoothDeviceChromeOS* device_chromeos = |
| 2709 static_cast<BluetoothDeviceChromeOS*>(device); | 2707 static_cast<BluetoothDeviceChromeOS*>(device); |
| 2710 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 2708 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); |
| 2711 } | 2709 } |
| 2712 | 2710 |
| 2713 TEST_F(BluetoothChromeOSTest, IncomingPairPhone) { | 2711 TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { |
| 2714 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2712 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2715 | 2713 |
| 2716 GetAdapter(); | 2714 GetAdapter(); |
| 2717 | 2715 |
| 2718 TestPairingDelegate pairing_delegate; | 2716 TestPairingDelegate pairing_delegate; |
| 2719 adapter_->AddPairingDelegate( | 2717 adapter_->AddPairingDelegate( |
| 2720 &pairing_delegate, | 2718 &pairing_delegate, |
| 2721 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); | 2719 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| 2722 | 2720 |
| 2723 // The fake phone requests that we confirm a displayed passkey. | 2721 // Requests that we confirm a displayed passkey. |
| 2724 fake_bluetooth_device_client_->CreateDevice( | 2722 fake_bluetooth_device_client_->CreateDevice( |
| 2725 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 2723 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 2726 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath)); | 2724 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| 2727 BluetoothDevice* device = adapter_->GetDevice( | 2725 BluetoothDevice* device = adapter_->GetDevice( |
| 2728 FakeBluetoothDeviceClient::kPhoneAddress); | 2726 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); |
| 2729 ASSERT_TRUE(device != NULL); | 2727 ASSERT_TRUE(device != NULL); |
| 2730 ASSERT_FALSE(device->IsPaired()); | 2728 ASSERT_FALSE(device->IsPaired()); |
| 2731 | 2729 |
| 2732 TestObserver observer(adapter_); | 2730 TestObserver observer(adapter_); |
| 2733 adapter_->AddObserver(&observer); | 2731 adapter_->AddObserver(&observer); |
| 2734 | 2732 |
| 2735 fake_bluetooth_device_client_->SimulatePairing( | 2733 fake_bluetooth_device_client_->SimulatePairing( |
| 2736 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath), | 2734 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), |
| 2737 true, | 2735 true, |
| 2738 base::Bind(&BluetoothChromeOSTest::Callback, | 2736 base::Bind(&BluetoothChromeOSTest::Callback, |
| 2739 base::Unretained(this)), | 2737 base::Unretained(this)), |
| 2740 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 2738 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 2741 base::Unretained(this))); | 2739 base::Unretained(this))); |
| 2742 | 2740 |
| 2743 EXPECT_EQ(1, pairing_delegate.call_count_); | 2741 EXPECT_EQ(1, pairing_delegate.call_count_); |
| 2744 EXPECT_EQ(1, pairing_delegate.confirm_passkey_count_); | 2742 EXPECT_EQ(1, pairing_delegate.confirm_passkey_count_); |
| 2745 EXPECT_EQ(123456U, pairing_delegate.last_passkey_); | 2743 EXPECT_EQ(123456U, pairing_delegate.last_passkey_); |
| 2746 | 2744 |
| 2747 // Confirm the passkey. | 2745 // Confirm the passkey. |
| 2748 device->ConfirmPairing(); | 2746 device->ConfirmPairing(); |
| 2749 message_loop_.Run(); | 2747 message_loop_.Run(); |
| 2750 | 2748 |
| 2751 EXPECT_EQ(1, callback_count_); | 2749 EXPECT_EQ(1, callback_count_); |
| 2752 EXPECT_EQ(0, error_callback_count_); | 2750 EXPECT_EQ(0, error_callback_count_); |
| 2753 | 2751 |
| 2754 // One for paired. | 2752 // One for paired. |
| 2755 EXPECT_EQ(1, observer.device_changed_count_); | 2753 EXPECT_EQ(1, observer.device_changed_count_); |
| 2756 EXPECT_EQ(device, observer.last_device_); | 2754 EXPECT_EQ(device, observer.last_device_); |
| 2757 | 2755 |
| 2758 EXPECT_TRUE(device->IsPaired()); | 2756 EXPECT_TRUE(device->IsPaired()); |
| 2759 | 2757 |
| 2760 // No pairing context should remain on the device. | 2758 // No pairing context should remain on the device. |
| 2761 BluetoothDeviceChromeOS* device_chromeos = | 2759 BluetoothDeviceChromeOS* device_chromeos = |
| 2762 static_cast<BluetoothDeviceChromeOS*>(device); | 2760 static_cast<BluetoothDeviceChromeOS*>(device); |
| 2763 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 2761 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); |
| 2764 } | 2762 } |
| 2765 | 2763 |
| 2766 TEST_F(BluetoothChromeOSTest, IncomingPairWeirdDevice) { | 2764 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { |
| 2767 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2765 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2768 | 2766 |
| 2769 GetAdapter(); | 2767 GetAdapter(); |
| 2770 | 2768 |
| 2771 TestPairingDelegate pairing_delegate; | 2769 TestPairingDelegate pairing_delegate; |
| 2772 adapter_->AddPairingDelegate( | 2770 adapter_->AddPairingDelegate( |
| 2773 &pairing_delegate, | 2771 &pairing_delegate, |
| 2774 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); | 2772 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| 2775 | 2773 |
| 2776 // The weird device requests that we provide a Passkey. | 2774 // Requests that we provide a Passkey. |
| 2777 fake_bluetooth_device_client_->CreateDevice( | 2775 fake_bluetooth_device_client_->CreateDevice( |
| 2778 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 2776 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 2779 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath)); | 2777 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); |
| 2780 BluetoothDevice* device = adapter_->GetDevice( | 2778 BluetoothDevice* device = adapter_->GetDevice( |
| 2781 FakeBluetoothDeviceClient::kWeirdDeviceAddress); | 2779 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 2782 ASSERT_TRUE(device != NULL); | 2780 ASSERT_TRUE(device != NULL); |
| 2783 ASSERT_FALSE(device->IsPaired()); | 2781 ASSERT_FALSE(device->IsPaired()); |
| 2784 | 2782 |
| 2785 TestObserver observer(adapter_); | 2783 TestObserver observer(adapter_); |
| 2786 adapter_->AddObserver(&observer); | 2784 adapter_->AddObserver(&observer); |
| 2787 | 2785 |
| 2788 fake_bluetooth_device_client_->SimulatePairing( | 2786 fake_bluetooth_device_client_->SimulatePairing( |
| 2789 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath), | 2787 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), |
| 2790 true, | 2788 true, |
| 2791 base::Bind(&BluetoothChromeOSTest::Callback, | 2789 base::Bind(&BluetoothChromeOSTest::Callback, |
| 2792 base::Unretained(this)), | 2790 base::Unretained(this)), |
| 2793 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 2791 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 2794 base::Unretained(this))); | 2792 base::Unretained(this))); |
| 2795 | 2793 |
| 2796 EXPECT_EQ(1, pairing_delegate.call_count_); | 2794 EXPECT_EQ(1, pairing_delegate.call_count_); |
| 2797 EXPECT_EQ(1, pairing_delegate.request_passkey_count_); | 2795 EXPECT_EQ(1, pairing_delegate.request_passkey_count_); |
| 2798 | 2796 |
| 2799 // Set the Passkey. | 2797 // Set the Passkey. |
| 2800 device->SetPasskey(1234); | 2798 device->SetPasskey(1234); |
| 2801 message_loop_.Run(); | 2799 message_loop_.Run(); |
| 2802 | 2800 |
| 2803 EXPECT_EQ(1, callback_count_); | 2801 EXPECT_EQ(1, callback_count_); |
| 2804 EXPECT_EQ(0, error_callback_count_); | 2802 EXPECT_EQ(0, error_callback_count_); |
| 2805 | 2803 |
| 2806 // One for paired. | 2804 // One for paired. |
| 2807 EXPECT_EQ(1, observer.device_changed_count_); | 2805 EXPECT_EQ(1, observer.device_changed_count_); |
| 2808 EXPECT_EQ(device, observer.last_device_); | 2806 EXPECT_EQ(device, observer.last_device_); |
| 2809 | 2807 |
| 2810 EXPECT_TRUE(device->IsPaired()); | 2808 EXPECT_TRUE(device->IsPaired()); |
| 2811 | 2809 |
| 2812 // No pairing context should remain on the device. | 2810 // No pairing context should remain on the device. |
| 2813 BluetoothDeviceChromeOS* device_chromeos = | 2811 BluetoothDeviceChromeOS* device_chromeos = |
| 2814 static_cast<BluetoothDeviceChromeOS*>(device); | 2812 static_cast<BluetoothDeviceChromeOS*>(device); |
| 2815 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 2813 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); |
| 2816 } | 2814 } |
| 2817 | 2815 |
| 2818 TEST_F(BluetoothChromeOSTest, IncomingPairBoseSpeakers) { | 2816 TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { |
| 2819 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2817 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2820 | 2818 |
| 2821 GetAdapter(); | 2819 GetAdapter(); |
| 2822 | 2820 |
| 2823 TestPairingDelegate pairing_delegate; | 2821 TestPairingDelegate pairing_delegate; |
| 2824 adapter_->AddPairingDelegate( | 2822 adapter_->AddPairingDelegate( |
| 2825 &pairing_delegate, | 2823 &pairing_delegate, |
| 2826 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); | 2824 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| 2827 | 2825 |
| 2828 // The Bose Speakers use just-works pairing so require authorization when | 2826 // Uses just-works pairing so, sinec this an incoming pairing, require |
| 2829 // the request is incoming. | 2827 // authorization from the user. |
| 2830 fake_bluetooth_device_client_->CreateDevice( | 2828 fake_bluetooth_device_client_->CreateDevice( |
| 2831 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 2829 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 2832 dbus::ObjectPath(FakeBluetoothDeviceClient::kBoseSpeakersPath)); | 2830 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); |
| 2833 BluetoothDevice* device = adapter_->GetDevice( | 2831 BluetoothDevice* device = adapter_->GetDevice( |
| 2834 FakeBluetoothDeviceClient::kBoseSpeakersAddress); | 2832 FakeBluetoothDeviceClient::kJustWorksAddress); |
| 2835 ASSERT_TRUE(device != NULL); | 2833 ASSERT_TRUE(device != NULL); |
| 2836 ASSERT_FALSE(device->IsPaired()); | 2834 ASSERT_FALSE(device->IsPaired()); |
| 2837 | 2835 |
| 2838 TestObserver observer(adapter_); | 2836 TestObserver observer(adapter_); |
| 2839 adapter_->AddObserver(&observer); | 2837 adapter_->AddObserver(&observer); |
| 2840 | 2838 |
| 2841 fake_bluetooth_device_client_->SimulatePairing( | 2839 fake_bluetooth_device_client_->SimulatePairing( |
| 2842 dbus::ObjectPath(FakeBluetoothDeviceClient::kBoseSpeakersPath), | 2840 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), |
| 2843 true, | 2841 true, |
| 2844 base::Bind(&BluetoothChromeOSTest::Callback, | 2842 base::Bind(&BluetoothChromeOSTest::Callback, |
| 2845 base::Unretained(this)), | 2843 base::Unretained(this)), |
| 2846 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 2844 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 2847 base::Unretained(this))); | 2845 base::Unretained(this))); |
| 2848 | 2846 |
| 2849 EXPECT_EQ(1, pairing_delegate.call_count_); | 2847 EXPECT_EQ(1, pairing_delegate.call_count_); |
| 2850 EXPECT_EQ(1, pairing_delegate.authorize_pairing_count_); | 2848 EXPECT_EQ(1, pairing_delegate.authorize_pairing_count_); |
| 2851 | 2849 |
| 2852 // Confirm the pairing. | 2850 // Confirm the pairing. |
| 2853 device->ConfirmPairing(); | 2851 device->ConfirmPairing(); |
| 2854 message_loop_.Run(); | 2852 message_loop_.Run(); |
| 2855 | 2853 |
| 2856 EXPECT_EQ(1, callback_count_); | 2854 EXPECT_EQ(1, callback_count_); |
| 2857 EXPECT_EQ(0, error_callback_count_); | 2855 EXPECT_EQ(0, error_callback_count_); |
| 2858 | 2856 |
| 2859 // One for paired. | 2857 // One for paired. |
| 2860 EXPECT_EQ(1, observer.device_changed_count_); | 2858 EXPECT_EQ(1, observer.device_changed_count_); |
| 2861 EXPECT_EQ(device, observer.last_device_); | 2859 EXPECT_EQ(device, observer.last_device_); |
| 2862 | 2860 |
| 2863 EXPECT_TRUE(device->IsPaired()); | 2861 EXPECT_TRUE(device->IsPaired()); |
| 2864 | 2862 |
| 2865 // No pairing context should remain on the device. | 2863 // No pairing context should remain on the device. |
| 2866 BluetoothDeviceChromeOS* device_chromeos = | 2864 BluetoothDeviceChromeOS* device_chromeos = |
| 2867 static_cast<BluetoothDeviceChromeOS*>(device); | 2865 static_cast<BluetoothDeviceChromeOS*>(device); |
| 2868 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 2866 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); |
| 2869 } | 2867 } |
| 2870 | 2868 |
| 2871 TEST_F(BluetoothChromeOSTest, IncomingPairSonyHeadphonesWithoutDelegate) { | 2869 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { |
| 2872 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2870 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2873 | 2871 |
| 2874 GetAdapter(); | 2872 GetAdapter(); |
| 2875 | 2873 |
| 2876 // The Sony Headphones requests that we provide a PIN Code, without a | 2874 // Requires that we provide a PIN Code, without a pairing delegate, |
| 2877 // pairing delegate, that will be rejected. | 2875 // that will be rejected. |
| 2878 fake_bluetooth_device_client_->CreateDevice( | 2876 fake_bluetooth_device_client_->CreateDevice( |
| 2879 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 2877 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 2880 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath)); | 2878 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); |
| 2881 BluetoothDevice* device = adapter_->GetDevice( | 2879 BluetoothDevice* device = adapter_->GetDevice( |
| 2882 FakeBluetoothDeviceClient::kSonyHeadphonesAddress); | 2880 FakeBluetoothDeviceClient::kRequestPinCodeAddress); |
| 2883 ASSERT_TRUE(device != NULL); | 2881 ASSERT_TRUE(device != NULL); |
| 2884 ASSERT_FALSE(device->IsPaired()); | 2882 ASSERT_FALSE(device->IsPaired()); |
| 2885 | 2883 |
| 2886 TestObserver observer(adapter_); | 2884 TestObserver observer(adapter_); |
| 2887 adapter_->AddObserver(&observer); | 2885 adapter_->AddObserver(&observer); |
| 2888 | 2886 |
| 2889 fake_bluetooth_device_client_->SimulatePairing( | 2887 fake_bluetooth_device_client_->SimulatePairing( |
| 2890 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath), | 2888 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), |
| 2891 true, | 2889 true, |
| 2892 base::Bind(&BluetoothChromeOSTest::Callback, | 2890 base::Bind(&BluetoothChromeOSTest::Callback, |
| 2893 base::Unretained(this)), | 2891 base::Unretained(this)), |
| 2894 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 2892 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 2895 base::Unretained(this))); | 2893 base::Unretained(this))); |
| 2896 | 2894 |
| 2897 message_loop_.Run(); | 2895 message_loop_.Run(); |
| 2898 | 2896 |
| 2899 EXPECT_EQ(0, callback_count_); | 2897 EXPECT_EQ(0, callback_count_); |
| 2900 EXPECT_EQ(1, error_callback_count_); | 2898 EXPECT_EQ(1, error_callback_count_); |
| 2901 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); | 2899 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); |
| 2902 | 2900 |
| 2903 // No changes should be observer. | 2901 // No changes should be observer. |
| 2904 EXPECT_EQ(0, observer.device_changed_count_); | 2902 EXPECT_EQ(0, observer.device_changed_count_); |
| 2905 | 2903 |
| 2906 EXPECT_FALSE(device->IsPaired()); | 2904 EXPECT_FALSE(device->IsPaired()); |
| 2907 | 2905 |
| 2908 // No pairing context should remain on the device. | 2906 // No pairing context should remain on the device. |
| 2909 BluetoothDeviceChromeOS* device_chromeos = | 2907 BluetoothDeviceChromeOS* device_chromeos = |
| 2910 static_cast<BluetoothDeviceChromeOS*>(device); | 2908 static_cast<BluetoothDeviceChromeOS*>(device); |
| 2911 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 2909 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); |
| 2912 } | 2910 } |
| 2913 | 2911 |
| 2914 TEST_F(BluetoothChromeOSTest, IncomingPairPhoneWithoutDelegate) { | 2912 TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { |
| 2915 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2913 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2916 | 2914 |
| 2917 GetAdapter(); | 2915 GetAdapter(); |
| 2918 | 2916 |
| 2919 // The fake phone requests that we confirm a displayed passkey, without a | 2917 // Requests that we confirm a displayed passkey, without a pairing delegate, |
| 2920 // pairing delegate, that will be rejected. | 2918 // that will be rejected. |
| 2921 fake_bluetooth_device_client_->CreateDevice( | 2919 fake_bluetooth_device_client_->CreateDevice( |
| 2922 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 2920 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 2923 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath)); | 2921 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| 2924 BluetoothDevice* device = adapter_->GetDevice( | 2922 BluetoothDevice* device = adapter_->GetDevice( |
| 2925 FakeBluetoothDeviceClient::kPhoneAddress); | 2923 FakeBluetoothDeviceClient::kConfirmPasskeyAddress); |
| 2926 ASSERT_TRUE(device != NULL); | 2924 ASSERT_TRUE(device != NULL); |
| 2927 ASSERT_FALSE(device->IsPaired()); | 2925 ASSERT_FALSE(device->IsPaired()); |
| 2928 | 2926 |
| 2929 TestObserver observer(adapter_); | 2927 TestObserver observer(adapter_); |
| 2930 adapter_->AddObserver(&observer); | 2928 adapter_->AddObserver(&observer); |
| 2931 | 2929 |
| 2932 fake_bluetooth_device_client_->SimulatePairing( | 2930 fake_bluetooth_device_client_->SimulatePairing( |
| 2933 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath), | 2931 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), |
| 2934 true, | 2932 true, |
| 2935 base::Bind(&BluetoothChromeOSTest::Callback, | 2933 base::Bind(&BluetoothChromeOSTest::Callback, |
| 2936 base::Unretained(this)), | 2934 base::Unretained(this)), |
| 2937 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 2935 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 2938 base::Unretained(this))); | 2936 base::Unretained(this))); |
| 2939 | 2937 |
| 2940 message_loop_.Run(); | 2938 message_loop_.Run(); |
| 2941 | 2939 |
| 2942 EXPECT_EQ(0, callback_count_); | 2940 EXPECT_EQ(0, callback_count_); |
| 2943 EXPECT_EQ(1, error_callback_count_); | 2941 EXPECT_EQ(1, error_callback_count_); |
| 2944 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); | 2942 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); |
| 2945 | 2943 |
| 2946 // No changes should be observer. | 2944 // No changes should be observer. |
| 2947 EXPECT_EQ(0, observer.device_changed_count_); | 2945 EXPECT_EQ(0, observer.device_changed_count_); |
| 2948 | 2946 |
| 2949 EXPECT_FALSE(device->IsPaired()); | 2947 EXPECT_FALSE(device->IsPaired()); |
| 2950 | 2948 |
| 2951 // No pairing context should remain on the device. | 2949 // No pairing context should remain on the device. |
| 2952 BluetoothDeviceChromeOS* device_chromeos = | 2950 BluetoothDeviceChromeOS* device_chromeos = |
| 2953 static_cast<BluetoothDeviceChromeOS*>(device); | 2951 static_cast<BluetoothDeviceChromeOS*>(device); |
| 2954 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 2952 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); |
| 2955 } | 2953 } |
| 2956 | 2954 |
| 2957 TEST_F(BluetoothChromeOSTest, IncomingPairWeirdDeviceWithoutDelegate) { | 2955 TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { |
| 2958 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2956 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 2959 | 2957 |
| 2960 GetAdapter(); | 2958 GetAdapter(); |
| 2961 | 2959 |
| 2962 // The weird device requests that we provide a displayed passkey, without a | 2960 // Requests that we provide a displayed passkey, without a pairing delegate, |
| 2963 // pairing delegate, that will be rejected. | 2961 // that will be rejected. |
| 2964 fake_bluetooth_device_client_->CreateDevice( | 2962 fake_bluetooth_device_client_->CreateDevice( |
| 2965 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 2963 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 2966 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath)); | 2964 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); |
| 2967 BluetoothDevice* device = adapter_->GetDevice( | 2965 BluetoothDevice* device = adapter_->GetDevice( |
| 2968 FakeBluetoothDeviceClient::kWeirdDeviceAddress); | 2966 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 2969 ASSERT_TRUE(device != NULL); | 2967 ASSERT_TRUE(device != NULL); |
| 2970 ASSERT_FALSE(device->IsPaired()); | 2968 ASSERT_FALSE(device->IsPaired()); |
| 2971 | 2969 |
| 2972 TestObserver observer(adapter_); | 2970 TestObserver observer(adapter_); |
| 2973 adapter_->AddObserver(&observer); | 2971 adapter_->AddObserver(&observer); |
| 2974 | 2972 |
| 2975 fake_bluetooth_device_client_->SimulatePairing( | 2973 fake_bluetooth_device_client_->SimulatePairing( |
| 2976 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath), | 2974 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), |
| 2977 true, | 2975 true, |
| 2978 base::Bind(&BluetoothChromeOSTest::Callback, | 2976 base::Bind(&BluetoothChromeOSTest::Callback, |
| 2979 base::Unretained(this)), | 2977 base::Unretained(this)), |
| 2980 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 2978 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 2981 base::Unretained(this))); | 2979 base::Unretained(this))); |
| 2982 | 2980 |
| 2983 message_loop_.Run(); | 2981 message_loop_.Run(); |
| 2984 | 2982 |
| 2985 EXPECT_EQ(0, callback_count_); | 2983 EXPECT_EQ(0, callback_count_); |
| 2986 EXPECT_EQ(1, error_callback_count_); | 2984 EXPECT_EQ(1, error_callback_count_); |
| 2987 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); | 2985 EXPECT_EQ(bluetooth_device::kErrorAuthenticationRejected, last_client_error_); |
| 2988 | 2986 |
| 2989 // No changes should be observer. | 2987 // No changes should be observer. |
| 2990 EXPECT_EQ(0, observer.device_changed_count_); | 2988 EXPECT_EQ(0, observer.device_changed_count_); |
| 2991 | 2989 |
| 2992 EXPECT_FALSE(device->IsPaired()); | 2990 EXPECT_FALSE(device->IsPaired()); |
| 2993 | 2991 |
| 2994 // No pairing context should remain on the device. | 2992 // No pairing context should remain on the device. |
| 2995 BluetoothDeviceChromeOS* device_chromeos = | 2993 BluetoothDeviceChromeOS* device_chromeos = |
| 2996 static_cast<BluetoothDeviceChromeOS*>(device); | 2994 static_cast<BluetoothDeviceChromeOS*>(device); |
| 2997 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); | 2995 EXPECT_TRUE(device_chromeos->GetPairing() == NULL); |
| 2998 } | 2996 } |
| 2999 | 2997 |
| 3000 TEST_F(BluetoothChromeOSTest, IncomingPairBoseSpeakersWithoutDelegate) { | 2998 TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { |
| 3001 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 2999 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3002 | 3000 |
| 3003 GetAdapter(); | 3001 GetAdapter(); |
| 3004 | 3002 |
| 3005 // The Bose Speakers uses just-works pairing and thus requires authorization, | 3003 // Uses just-works pairing and thus requires authorization for incoming |
| 3006 // without a pairing delegate, that will be rejected. | 3004 // pairings, without a pairing delegate, that will be rejected. |
| 3007 fake_bluetooth_device_client_->CreateDevice( | 3005 fake_bluetooth_device_client_->CreateDevice( |
| 3008 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3006 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3009 dbus::ObjectPath(FakeBluetoothDeviceClient::kBoseSpeakersPath)); | 3007 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); |
| 3010 BluetoothDevice* device = adapter_->GetDevice( | 3008 BluetoothDevice* device = adapter_->GetDevice( |
| 3011 FakeBluetoothDeviceClient::kBoseSpeakersAddress); | 3009 FakeBluetoothDeviceClient::kJustWorksAddress); |
| 3012 ASSERT_TRUE(device != NULL); | 3010 ASSERT_TRUE(device != NULL); |
| 3013 ASSERT_FALSE(device->IsPaired()); | 3011 ASSERT_FALSE(device->IsPaired()); |
| 3014 | 3012 |
| 3015 TestObserver observer(adapter_); | 3013 TestObserver observer(adapter_); |
| 3016 adapter_->AddObserver(&observer); | 3014 adapter_->AddObserver(&observer); |
| 3017 | 3015 |
| 3018 fake_bluetooth_device_client_->SimulatePairing( | 3016 fake_bluetooth_device_client_->SimulatePairing( |
| 3019 dbus::ObjectPath(FakeBluetoothDeviceClient::kBoseSpeakersPath), | 3017 dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), |
| 3020 true, | 3018 true, |
| 3021 base::Bind(&BluetoothChromeOSTest::Callback, | 3019 base::Bind(&BluetoothChromeOSTest::Callback, |
| 3022 base::Unretained(this)), | 3020 base::Unretained(this)), |
| 3023 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3021 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3024 base::Unretained(this))); | 3022 base::Unretained(this))); |
| 3025 | 3023 |
| 3026 message_loop_.Run(); | 3024 message_loop_.Run(); |
| 3027 | 3025 |
| 3028 EXPECT_EQ(0, callback_count_); | 3026 EXPECT_EQ(0, callback_count_); |
| 3029 EXPECT_EQ(1, error_callback_count_); | 3027 EXPECT_EQ(1, error_callback_count_); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3043 TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { | 3041 TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { |
| 3044 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); | 3042 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); |
| 3045 | 3043 |
| 3046 GetAdapter(); | 3044 GetAdapter(); |
| 3047 | 3045 |
| 3048 TestPairingDelegate pairing_delegate; | 3046 TestPairingDelegate pairing_delegate; |
| 3049 adapter_->AddPairingDelegate( | 3047 adapter_->AddPairingDelegate( |
| 3050 &pairing_delegate, | 3048 &pairing_delegate, |
| 3051 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); | 3049 BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| 3052 | 3050 |
| 3053 // The weird device requests that we provide a Passkey. | 3051 // Requests that we provide a Passkey. |
| 3054 fake_bluetooth_device_client_->CreateDevice( | 3052 fake_bluetooth_device_client_->CreateDevice( |
| 3055 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 3053 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 3056 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath)); | 3054 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); |
| 3057 BluetoothDevice* device = adapter_->GetDevice( | 3055 BluetoothDevice* device = adapter_->GetDevice( |
| 3058 FakeBluetoothDeviceClient::kWeirdDeviceAddress); | 3056 FakeBluetoothDeviceClient::kRequestPasskeyAddress); |
| 3059 ASSERT_TRUE(device != NULL); | 3057 ASSERT_TRUE(device != NULL); |
| 3060 ASSERT_FALSE(device->IsPaired()); | 3058 ASSERT_FALSE(device->IsPaired()); |
| 3061 | 3059 |
| 3062 TestObserver observer(adapter_); | 3060 TestObserver observer(adapter_); |
| 3063 adapter_->AddObserver(&observer); | 3061 adapter_->AddObserver(&observer); |
| 3064 | 3062 |
| 3065 fake_bluetooth_device_client_->SimulatePairing( | 3063 fake_bluetooth_device_client_->SimulatePairing( |
| 3066 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath), | 3064 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), |
| 3067 true, | 3065 true, |
| 3068 base::Bind(&BluetoothChromeOSTest::Callback, | 3066 base::Bind(&BluetoothChromeOSTest::Callback, |
| 3069 base::Unretained(this)), | 3067 base::Unretained(this)), |
| 3070 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, | 3068 base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, |
| 3071 base::Unretained(this))); | 3069 base::Unretained(this))); |
| 3072 | 3070 |
| 3073 EXPECT_EQ(1, pairing_delegate.call_count_); | 3071 EXPECT_EQ(1, pairing_delegate.call_count_); |
| 3074 EXPECT_EQ(1, pairing_delegate.request_passkey_count_); | 3072 EXPECT_EQ(1, pairing_delegate.request_passkey_count_); |
| 3075 | 3073 |
| 3076 // A pairing context should now be set on the device. | 3074 // A pairing context should now be set on the device. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3138 | 3136 |
| 3139 // Unknown vendor specification identifier. | 3137 // Unknown vendor specification identifier. |
| 3140 properties->modalias.ReplaceValue("chrome:v00E0p2400d0400"); | 3138 properties->modalias.ReplaceValue("chrome:v00E0p2400d0400"); |
| 3141 | 3139 |
| 3142 EXPECT_EQ(0, device->GetVendorID()); | 3140 EXPECT_EQ(0, device->GetVendorID()); |
| 3143 EXPECT_EQ(0, device->GetProductID()); | 3141 EXPECT_EQ(0, device->GetProductID()); |
| 3144 EXPECT_EQ(0, device->GetDeviceID()); | 3142 EXPECT_EQ(0, device->GetDeviceID()); |
| 3145 } | 3143 } |
| 3146 | 3144 |
| 3147 } // namespace chromeos | 3145 } // namespace chromeos |
| OLD | NEW |