Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "device/bluetooth/bluetooth_device.h" | 5 #include "device/bluetooth/bluetooth_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 return static_cast<int8_t>(tx_power); | 39 return static_cast<int8_t>(tx_power); |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 using UUIDSet = BluetoothDevice::UUIDSet; | 46 using UUIDSet = BluetoothDevice::UUIDSet; |
| 47 using ServiceDataMap = BluetoothDevice::ServiceDataMap; | 47 using ServiceDataMap = BluetoothDevice::ServiceDataMap; |
| 48 | 48 |
| 49 class BluetoothGetServiceOrCharacteristicTest : public BluetoothTest { | 49 class BluetoothGetServiceOrCharacteristicOrDescriptorTest |
| 50 : public BluetoothTest { | |
| 50 public: | 51 public: |
| 51 // Creates |device_|, |services_|. | 52 // Creates |device_|, |service_uuids_|. |
| 52 void FakeServiceBoilerplate() { | 53 void FakeServiceBoilerplate() { |
| 53 InitWithFakeAdapter(); | 54 InitWithFakeAdapter(); |
| 54 StartLowEnergyDiscoverySession(); | 55 StartLowEnergyDiscoverySession(); |
| 55 device_ = SimulateLowEnergyDevice(3); | 56 device_ = SimulateLowEnergyDevice(3); |
| 56 EXPECT_FALSE(device_->IsConnected()); | 57 EXPECT_FALSE(device_->IsConnected()); |
| 57 | 58 |
| 58 // Connect to the device. | 59 // Connect to the device. |
| 59 ResetEventCounts(); | 60 ResetEventCounts(); |
| 60 device_->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), | 61 device_->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), |
| 61 GetConnectErrorCallback(Call::NOT_EXPECTED)); | 62 GetConnectErrorCallback(Call::NOT_EXPECTED)); |
| 62 TestBluetoothAdapterObserver observer(adapter_); | 63 TestBluetoothAdapterObserver observer(adapter_); |
| 63 SimulateGattConnection(device_); | 64 SimulateGattConnection(device_); |
| 64 base::RunLoop().RunUntilIdle(); | 65 base::RunLoop().RunUntilIdle(); |
| 65 EXPECT_TRUE(device_->IsConnected()); | 66 EXPECT_TRUE(device_->IsConnected()); |
| 66 | 67 |
| 67 // Discover services. | 68 // Discover services. |
| 68 services_.push_back("00000000-0000-1000-8000-00805f9b34fb"); | 69 service_uuids_.push_back("00000000-0000-1000-8000-00805f9b34fb"); |
|
ortuno
2017/04/03 03:36:37
Please use existing service uuids:
https://cs.chr
juncai
2017/04/04 03:03:42
Done.
| |
| 69 // 2 duplicate UUIDs creating 2 instances. | 70 // 2 duplicate UUIDs creating 2 instances. |
| 70 services_.push_back("00000001-0000-1000-8000-00805f9b34fb"); | 71 service_uuids_.push_back("00000001-0000-1000-8000-00805f9b34fb"); |
| 71 services_.push_back("00000001-0000-1000-8000-00805f9b34fb"); | 72 service_uuids_.push_back("00000001-0000-1000-8000-00805f9b34fb"); |
| 72 SimulateGattServicesDiscovered(device_, services_); | 73 SimulateGattServicesDiscovered(device_, service_uuids_); |
| 73 base::RunLoop().RunUntilIdle(); | 74 base::RunLoop().RunUntilIdle(); |
| 74 EXPECT_TRUE(device_->IsGattServicesDiscoveryComplete()); | 75 EXPECT_TRUE(device_->IsGattServicesDiscoveryComplete()); |
| 75 } | 76 } |
| 76 | 77 |
| 77 protected: | 78 protected: |
| 78 BluetoothDevice* device_ = nullptr; | 79 BluetoothDevice* device_ = nullptr; |
| 79 std::vector<std::string> services_; | 80 std::vector<std::string> service_uuids_; |
|
ortuno
2017/04/03 03:36:38
It might be better to name the UUIDs like you did
juncai
2017/04/04 03:03:42
It seems redundant to do this since there are alre
ortuno
2017/04/04 03:32:11
If you read the test its hard to understand why
d
juncai
2017/04/04 20:33:40
Done.
| |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 TEST(BluetoothDeviceTest, CanonicalizeAddressFormat_AcceptsAllValidFormats) { | 83 TEST(BluetoothDeviceTest, CanonicalizeAddressFormat_AcceptsAllValidFormats) { |
| 83 // There are three valid separators (':', '-', and none). | 84 // There are three valid separators (':', '-', and none). |
| 84 // Case shouldn't matter. | 85 // Case shouldn't matter. |
| 85 const char* const kValidFormats[] = { | 86 const char* const kValidFormats[] = { |
| 86 "1A:2B:3C:4D:5E:6F", | 87 "1A:2B:3C:4D:5E:6F", |
| 87 "1a:2B:3c:4D:5e:6F", | 88 "1a:2B:3c:4D:5e:6F", |
| 88 "1a:2b:3c:4d:5e:6f", | 89 "1a:2b:3c:4d:5e:6f", |
| 89 "1A-2B-3C-4D-5E-6F", | 90 "1A-2B-3C-4D-5E-6F", |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1510 | 1511 |
| 1511 BluetoothDevice* device2 = SimulateLowEnergyDevice(6); | 1512 BluetoothDevice* device2 = SimulateLowEnergyDevice(6); |
| 1512 EXPECT_EQ(BLUETOOTH_TRANSPORT_DUAL, device2->GetType()); | 1513 EXPECT_EQ(BLUETOOTH_TRANSPORT_DUAL, device2->GetType()); |
| 1513 | 1514 |
| 1514 BluetoothDevice* device3 = SimulateClassicDevice(); | 1515 BluetoothDevice* device3 = SimulateClassicDevice(); |
| 1515 EXPECT_EQ(BLUETOOTH_TRANSPORT_CLASSIC, device3->GetType()); | 1516 EXPECT_EQ(BLUETOOTH_TRANSPORT_CLASSIC, device3->GetType()); |
| 1516 } | 1517 } |
| 1517 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX) | 1518 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX) |
| 1518 | 1519 |
| 1519 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 1520 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1520 TEST_F(BluetoothGetServiceOrCharacteristicTest, GetPrimaryServices) { | 1521 // TODO(https://crbug.com/507419): Run test on Windows once Bluetooth |
|
ortuno
2017/04/03 03:36:38
It's strange to have this since we already have ma
juncai
2017/04/04 03:03:42
device_->IsConnected() returns false on Windows so
ortuno
2017/04/04 03:32:11
We already run many Service tests[1] on Windows so
juncai
2017/04/04 20:33:40
Done.
| |
| 1522 // connection is implemented. | |
| 1523 TEST_F(BluetoothGetServiceOrCharacteristicOrDescriptorTest, | |
| 1524 GetPrimaryServices) { | |
| 1521 if (!PlatformSupportsLowEnergy()) { | 1525 if (!PlatformSupportsLowEnergy()) { |
| 1522 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 1526 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| 1523 return; | 1527 return; |
| 1524 } | 1528 } |
| 1525 ASSERT_NO_FATAL_FAILURE(FakeServiceBoilerplate()); | 1529 ASSERT_NO_FATAL_FAILURE(FakeServiceBoilerplate()); |
| 1526 | 1530 |
| 1527 EXPECT_EQ(3u, device_->GetPrimaryServices().size()); | 1531 EXPECT_EQ(3u, device_->GetPrimaryServices().size()); |
| 1528 } | 1532 } |
| 1529 | 1533 |
| 1530 TEST_F(BluetoothGetServiceOrCharacteristicTest, GetPrimaryServicesByUUID) { | 1534 TEST_F(BluetoothGetServiceOrCharacteristicOrDescriptorTest, |
| 1535 GetPrimaryServicesByUUID) { | |
| 1531 if (!PlatformSupportsLowEnergy()) { | 1536 if (!PlatformSupportsLowEnergy()) { |
| 1532 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 1537 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| 1533 return; | 1538 return; |
| 1534 } | 1539 } |
| 1535 ASSERT_NO_FATAL_FAILURE(FakeServiceBoilerplate()); | 1540 ASSERT_NO_FATAL_FAILURE(FakeServiceBoilerplate()); |
| 1536 | 1541 |
| 1537 EXPECT_EQ( | 1542 std::vector<BluetoothRemoteGattService*> services0 = |
|
ortuno
2017/04/03 03:36:38
To avoid services0, services1, etc. you could add
juncai
2017/04/04 03:03:42
Done.
| |
| 1538 1u, | 1543 device_->GetPrimaryServicesByUUID(BluetoothUUID(service_uuids_[0])); |
| 1539 device_->GetPrimaryServicesByUUID(BluetoothUUID(services_[0])).size()); | 1544 EXPECT_EQ(1u, services0.size()); |
| 1540 EXPECT_EQ( | 1545 EXPECT_EQ(BluetoothUUID(service_uuids_[0]), services0[0]->GetUUID()); |
| 1541 2u, | 1546 |
| 1542 device_->GetPrimaryServicesByUUID(BluetoothUUID(services_[1])).size()); | 1547 std::vector<BluetoothRemoteGattService*> services1 = |
| 1543 std::string service_uuid_not_exist_in_setup = | 1548 device_->GetPrimaryServicesByUUID(BluetoothUUID(service_uuids_[1])); |
| 1544 "00000002-0000-1000-8000-00805f9b34fb"; | 1549 EXPECT_EQ(2u, services1.size()); |
| 1550 EXPECT_EQ(BluetoothUUID(service_uuids_[1]), services1[0]->GetUUID()); | |
| 1551 EXPECT_EQ(BluetoothUUID(service_uuids_[1]), services1[1]->GetUUID()); | |
|
ortuno
2017/04/03 03:36:38
Add:
EXPECT_NEQ(services1[0]->GetIdentifier(), se
juncai
2017/04/04 03:03:41
Done.
| |
| 1552 | |
| 1545 EXPECT_TRUE(device_ | 1553 EXPECT_TRUE(device_ |
| 1546 ->GetPrimaryServicesByUUID( | 1554 ->GetPrimaryServicesByUUID( |
| 1547 BluetoothUUID(service_uuid_not_exist_in_setup)) | 1555 BluetoothUUID(BluetoothTestBase::kTestUUIDGenericAccess)) |
| 1548 .empty()); | 1556 .empty()); |
| 1549 } | 1557 } |
| 1550 | 1558 |
| 1551 TEST_F(BluetoothGetServiceOrCharacteristicTest, GetCharacteristicsByUUID) { | 1559 TEST_F(BluetoothGetServiceOrCharacteristicOrDescriptorTest, |
| 1560 GetCharacteristicsByUUID) { | |
| 1552 if (!PlatformSupportsLowEnergy()) { | 1561 if (!PlatformSupportsLowEnergy()) { |
| 1553 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 1562 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| 1554 return; | 1563 return; |
| 1555 } | 1564 } |
| 1556 ASSERT_NO_FATAL_FAILURE(FakeServiceBoilerplate()); | 1565 ASSERT_NO_FATAL_FAILURE(FakeServiceBoilerplate()); |
| 1557 | 1566 |
| 1558 std::vector<BluetoothRemoteGattService*> primary_services = | 1567 std::vector<BluetoothRemoteGattService*> primary_services = |
|
ortuno
2017/04/03 03:36:38
Any reason why we need this code here? Could we mo
juncai
2017/04/04 03:03:41
GetPrimaryServices() is the function to be tested
| |
| 1559 device_->GetPrimaryServices(); | 1568 device_->GetPrimaryServices(); |
| 1560 std::string service_instance_id0 = primary_services[0]->GetIdentifier(); | 1569 std::string service_instance_id0 = primary_services[0]->GetIdentifier(); |
| 1561 std::string service_instance_id1 = primary_services[1]->GetIdentifier(); | 1570 std::string service_instance_id1 = primary_services[1]->GetIdentifier(); |
| 1562 std::string service_instance_id2 = primary_services[2]->GetIdentifier(); | 1571 std::string service_instance_id2 = primary_services[2]->GetIdentifier(); |
| 1563 | 1572 |
| 1564 std::string characteristic_uuid0 = "00000002-0000-1000-8000-00805f9b34fb"; | 1573 std::string characteristic_uuid0 = "00000002-0000-1000-8000-00805f9b34fb"; |
|
ortuno
2017/04/03 03:36:38
Add standard UUIDs to the list of test UUIDs and u
juncai
2017/04/04 03:03:41
Done.
| |
| 1565 std::string characteristic_uuid1 = "00000003-0000-1000-8000-00805f9b34fb"; | 1574 std::string characteristic_uuid1 = "00000003-0000-1000-8000-00805f9b34fb"; |
| 1566 SimulateGattCharacteristic(primary_services[0], characteristic_uuid0, | 1575 SimulateGattCharacteristic(primary_services[0], characteristic_uuid0, |
| 1567 0 /* properties */); | 1576 0 /* properties */); |
| 1568 SimulateGattCharacteristic(primary_services[1], characteristic_uuid1, | 1577 SimulateGattCharacteristic(primary_services[1], characteristic_uuid1, |
|
ortuno
2017/04/03 03:36:38
Add a characteristic with the same UUID to this se
juncai
2017/04/04 03:03:42
Done.
| |
| 1569 0 /* properties */); | 1578 0 /* properties */); |
| 1570 SimulateGattCharacteristic(primary_services[2], characteristic_uuid1, | 1579 SimulateGattCharacteristic(primary_services[2], characteristic_uuid1, |
| 1571 0 /* properties */); | 1580 0 /* properties */); |
| 1572 | 1581 |
| 1573 EXPECT_EQ(1u, | 1582 std::vector<BluetoothRemoteGattCharacteristic*> characteristics0 = |
|
ortuno
2017/04/03 03:36:38
Also consider using brackets to avoid characterist
juncai
2017/04/04 03:03:41
Done.
| |
| 1574 device_ | 1583 device_->GetCharacteristicsByUUID(service_instance_id0, |
| 1575 ->GetCharacteristicsByUUID(service_instance_id0, | 1584 BluetoothUUID(characteristic_uuid0)); |
| 1576 BluetoothUUID(characteristic_uuid0)) | 1585 EXPECT_EQ(1u, characteristics0.size()); |
| 1577 .size()); | 1586 EXPECT_EQ(BluetoothUUID(characteristic_uuid0), |
| 1578 EXPECT_EQ(1u, | 1587 characteristics0[0]->GetUUID()); |
| 1579 device_ | 1588 |
| 1580 ->GetCharacteristicsByUUID(service_instance_id1, | 1589 std::vector<BluetoothRemoteGattCharacteristic*> characteristics1 = |
| 1581 BluetoothUUID(characteristic_uuid1)) | 1590 device_->GetCharacteristicsByUUID(service_instance_id1, |
| 1582 .size()); | 1591 BluetoothUUID(characteristic_uuid1)); |
| 1583 EXPECT_EQ(1u, | 1592 EXPECT_EQ(1u, characteristics1.size()); |
| 1584 device_ | 1593 EXPECT_EQ(BluetoothUUID(characteristic_uuid1), |
| 1585 ->GetCharacteristicsByUUID(service_instance_id2, | 1594 characteristics1[0]->GetUUID()); |
| 1586 BluetoothUUID(characteristic_uuid1)) | 1595 |
| 1587 .size()); | 1596 std::vector<BluetoothRemoteGattCharacteristic*> characteristics2 = |
| 1597 device_->GetCharacteristicsByUUID(service_instance_id2, | |
| 1598 BluetoothUUID(characteristic_uuid1)); | |
| 1599 EXPECT_EQ(1u, characteristics2.size()); | |
| 1600 EXPECT_EQ(BluetoothUUID(characteristic_uuid1), | |
| 1601 characteristics2[0]->GetUUID()); | |
| 1588 | 1602 |
| 1589 std::string service_instance_id_not_exist_in_setup = | 1603 std::string service_instance_id_not_exist_in_setup = |
|
ortuno
2017/04/03 03:36:38
Can we refactor this method to be in the service t
juncai
2017/04/04 03:03:42
https://cs.chromium.org/chromium/src/device/blueto
ortuno
2017/04/04 03:32:11
Can you open an issue explaining what needs to be
juncai
2017/04/04 20:33:40
Moved it to BluetoothRemoteGattService.
Done.
| |
| 1590 "non-existent platform specific service instance id"; | 1604 "non-existent platform specific service instance id"; |
| 1591 EXPECT_TRUE( | 1605 EXPECT_TRUE( |
| 1592 device_ | 1606 device_ |
| 1593 ->GetCharacteristicsByUUID(service_instance_id_not_exist_in_setup, | 1607 ->GetCharacteristicsByUUID(service_instance_id_not_exist_in_setup, |
| 1594 BluetoothUUID(characteristic_uuid0)) | 1608 BluetoothUUID(characteristic_uuid0)) |
| 1595 .empty()); | 1609 .empty()); |
| 1596 EXPECT_TRUE( | 1610 EXPECT_TRUE( |
| 1597 device_ | 1611 device_ |
| 1598 ->GetCharacteristicsByUUID(service_instance_id_not_exist_in_setup, | 1612 ->GetCharacteristicsByUUID(service_instance_id_not_exist_in_setup, |
| 1599 BluetoothUUID(characteristic_uuid1)) | 1613 BluetoothUUID(characteristic_uuid1)) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1610 ->GetCharacteristicsByUUID( | 1624 ->GetCharacteristicsByUUID( |
| 1611 service_instance_id1, | 1625 service_instance_id1, |
| 1612 BluetoothUUID(characteristic_uuid_not_exist_in_setup)) | 1626 BluetoothUUID(characteristic_uuid_not_exist_in_setup)) |
| 1613 .empty()); | 1627 .empty()); |
| 1614 EXPECT_TRUE(device_ | 1628 EXPECT_TRUE(device_ |
| 1615 ->GetCharacteristicsByUUID( | 1629 ->GetCharacteristicsByUUID( |
| 1616 service_instance_id2, | 1630 service_instance_id2, |
| 1617 BluetoothUUID(characteristic_uuid_not_exist_in_setup)) | 1631 BluetoothUUID(characteristic_uuid_not_exist_in_setup)) |
| 1618 .empty()); | 1632 .empty()); |
| 1619 } | 1633 } |
| 1634 | |
| 1635 TEST_F(BluetoothGetServiceOrCharacteristicOrDescriptorTest, | |
| 1636 GetDescriptorsByUUID) { | |
| 1637 if (!PlatformSupportsLowEnergy()) { | |
| 1638 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | |
| 1639 return; | |
| 1640 } | |
| 1641 ASSERT_NO_FATAL_FAILURE(FakeServiceBoilerplate()); | |
| 1642 | |
| 1643 std::vector<BluetoothRemoteGattService*> primary_services = | |
| 1644 device_->GetPrimaryServices(); | |
| 1645 | |
| 1646 std::string characteristic_uuid0 = "00000002-0000-1000-8000-00805f9b34fb"; | |
| 1647 std::string characteristic_uuid1 = "00000003-0000-1000-8000-00805f9b34fb"; | |
| 1648 SimulateGattCharacteristic(primary_services[0], characteristic_uuid0, | |
| 1649 0 /* properties */); | |
| 1650 SimulateGattCharacteristic(primary_services[1], characteristic_uuid1, | |
| 1651 0 /* properties */); | |
| 1652 SimulateGattCharacteristic(primary_services[2], characteristic_uuid1, | |
| 1653 0 /* properties */); | |
| 1654 | |
| 1655 BluetoothRemoteGattCharacteristic* characteristic0 = | |
| 1656 primary_services[0]->GetCharacteristics()[0]; | |
| 1657 BluetoothRemoteGattCharacteristic* characteristic1 = | |
| 1658 primary_services[1]->GetCharacteristics()[0]; | |
| 1659 BluetoothRemoteGattCharacteristic* characteristic2 = | |
| 1660 primary_services[2]->GetCharacteristics()[0]; | |
| 1661 | |
| 1662 // Add several descriptors. No descriptors are added to |characteristic2|. | |
|
ortuno
2017/04/03 03:36:38
We should just put all these setup code in the con
juncai
2017/04/04 03:03:42
The same function already exists at BluetoothRemot
| |
| 1663 BluetoothUUID descriptor_uuid0("11111111-0000-1000-8000-00805f9b34fb"); | |
| 1664 BluetoothUUID descriptor_uuid1("22222222-0000-1000-8000-00805f9b34fb"); | |
| 1665 BluetoothUUID descriptor_uuid2("33333333-0000-1000-8000-00805f9b34fb"); | |
|
ortuno
2017/04/03 03:36:38
Also add these to the list of test UUIDs. I would
juncai
2017/04/04 03:03:42
ditto.
| |
| 1666 SimulateGattDescriptor(characteristic0, descriptor_uuid0.canonical_value()); | |
| 1667 SimulateGattDescriptor(characteristic0, descriptor_uuid1.canonical_value()); | |
| 1668 SimulateGattDescriptor(characteristic1, descriptor_uuid2.canonical_value()); | |
| 1669 SimulateGattDescriptor(characteristic1, descriptor_uuid2.canonical_value()); | |
| 1670 | |
| 1671 BluetoothUUID descriptor_uuid_not_exist_in_setup( | |
| 1672 "12345678-0000-1000-8000-00805f9b34fb"); | |
| 1673 | |
| 1674 std::vector<device::BluetoothRemoteGattDescriptor*> descriptors0 = | |
| 1675 device_->GetDescriptorsByUUID(characteristic0, descriptor_uuid0); | |
| 1676 EXPECT_EQ(1u, descriptors0.size()); | |
| 1677 EXPECT_EQ(descriptor_uuid0, descriptors0[0]->GetUUID()); | |
| 1678 std::vector<device::BluetoothRemoteGattDescriptor*> descriptors1 = | |
|
ortuno
2017/04/03 03:36:38
nit: add new line
juncai
2017/04/04 03:03:42
ditto.
| |
| 1679 device_->GetDescriptorsByUUID(characteristic0, descriptor_uuid1); | |
| 1680 EXPECT_EQ(1u, descriptors1.size()); | |
| 1681 EXPECT_EQ(descriptor_uuid1, descriptors1[0]->GetUUID()); | |
| 1682 EXPECT_TRUE( | |
| 1683 device_->GetDescriptorsByUUID(characteristic0, descriptor_uuid2).empty()); | |
| 1684 EXPECT_TRUE(device_ | |
| 1685 ->GetDescriptorsByUUID(characteristic0, | |
| 1686 descriptor_uuid_not_exist_in_setup) | |
| 1687 .empty()); | |
| 1688 | |
| 1689 std::vector<device::BluetoothRemoteGattDescriptor*> descriptors2 = | |
| 1690 device_->GetDescriptorsByUUID(characteristic1, descriptor_uuid2); | |
| 1691 EXPECT_EQ(2u, descriptors2.size()); | |
| 1692 EXPECT_EQ(descriptor_uuid2, descriptors2[0]->GetUUID()); | |
| 1693 EXPECT_EQ(descriptor_uuid2, descriptors2[1]->GetUUID()); | |
| 1694 EXPECT_TRUE( | |
| 1695 device_->GetDescriptorsByUUID(characteristic1, descriptor_uuid0).empty()); | |
| 1696 EXPECT_TRUE( | |
| 1697 device_->GetDescriptorsByUUID(characteristic1, descriptor_uuid1).empty()); | |
| 1698 EXPECT_TRUE(device_ | |
| 1699 ->GetDescriptorsByUUID(characteristic1, | |
| 1700 descriptor_uuid_not_exist_in_setup) | |
| 1701 .empty()); | |
| 1702 | |
| 1703 EXPECT_TRUE( | |
| 1704 device_->GetDescriptorsByUUID(characteristic2, descriptor_uuid0).empty()); | |
| 1705 EXPECT_TRUE( | |
| 1706 device_->GetDescriptorsByUUID(characteristic2, descriptor_uuid1).empty()); | |
| 1707 EXPECT_TRUE( | |
| 1708 device_->GetDescriptorsByUUID(characteristic2, descriptor_uuid2).empty()); | |
| 1709 EXPECT_TRUE(device_ | |
| 1710 ->GetDescriptorsByUUID(characteristic2, | |
| 1711 descriptor_uuid_not_exist_in_setup) | |
| 1712 .empty()); | |
| 1713 | |
| 1714 EXPECT_TRUE( | |
|
ortuno
2017/04/03 03:36:38
Can we refactor this method to be in the character
juncai
2017/04/04 03:03:42
ditto.
| |
| 1715 device_ | |
| 1716 ->GetDescriptorsByUUID(nullptr /* characteristic */, descriptor_uuid0) | |
| 1717 .empty()); | |
| 1718 } | |
| 1719 | |
| 1620 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 1720 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1621 | 1721 |
| 1622 } // namespace device | 1722 } // namespace device |
| OLD | NEW |