| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_advertisement.h" | 5 #include "device/bluetooth/bluetooth_advertisement.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 service_data["1234"] = std::vector<uint8_t>(5, 0); | 27 service_data["1234"] = std::vector<uint8_t>(5, 0); |
| 28 | 28 |
| 29 BluetoothAdvertisement::Data data( | 29 BluetoothAdvertisement::Data data( |
| 30 BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST); | 30 BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST); |
| 31 ASSERT_EQ(data.type(), BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST); | 31 ASSERT_EQ(data.type(), BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST); |
| 32 | 32 |
| 33 // Try without assiging Service UUID. | 33 // Try without assiging Service UUID. |
| 34 ASSERT_FALSE(data.service_uuids().get()); | 34 ASSERT_FALSE(data.service_uuids().get()); |
| 35 // Assign Service UUID. | 35 // Assign Service UUID. |
| 36 data.set_service_uuids( | 36 data.set_service_uuids( |
| 37 base::WrapUnique(new BluetoothAdvertisement::UUIDList(uuids))); | 37 base::MakeUnique<BluetoothAdvertisement::UUIDList>(uuids)); |
| 38 // Retrieve Service UUID. | 38 // Retrieve Service UUID. |
| 39 ASSERT_EQ(*data.service_uuids(), uuids); | 39 ASSERT_EQ(*data.service_uuids(), uuids); |
| 40 // Retrieve again. | 40 // Retrieve again. |
| 41 ASSERT_FALSE(data.service_uuids().get()); | 41 ASSERT_FALSE(data.service_uuids().get()); |
| 42 | 42 |
| 43 // Try without assigning Manufacturer Data. | 43 // Try without assigning Manufacturer Data. |
| 44 ASSERT_FALSE(data.manufacturer_data().get()); | 44 ASSERT_FALSE(data.manufacturer_data().get()); |
| 45 // Assign Manufacturer Data. | 45 // Assign Manufacturer Data. |
| 46 data.set_manufacturer_data(base::WrapUnique( | 46 data.set_manufacturer_data( |
| 47 new BluetoothAdvertisement::ManufacturerData(manufacturer_data))); | 47 base::MakeUnique<BluetoothAdvertisement::ManufacturerData>( |
| 48 manufacturer_data)); |
| 48 // Retrieve Manufacturer Data. | 49 // Retrieve Manufacturer Data. |
| 49 ASSERT_EQ(*data.manufacturer_data(), manufacturer_data); | 50 ASSERT_EQ(*data.manufacturer_data(), manufacturer_data); |
| 50 // Retrieve again. | 51 // Retrieve again. |
| 51 ASSERT_FALSE(data.manufacturer_data().get()); | 52 ASSERT_FALSE(data.manufacturer_data().get()); |
| 52 | 53 |
| 53 // Try without assigning Solicit UUIDs. | 54 // Try without assigning Solicit UUIDs. |
| 54 ASSERT_FALSE(data.solicit_uuids().get()); | 55 ASSERT_FALSE(data.solicit_uuids().get()); |
| 55 // Assign Solicit UUIDs. | 56 // Assign Solicit UUIDs. |
| 56 data.set_solicit_uuids( | 57 data.set_solicit_uuids( |
| 57 base::WrapUnique(new BluetoothAdvertisement::UUIDList(uuids))); | 58 base::MakeUnique<BluetoothAdvertisement::UUIDList>(uuids)); |
| 58 // Retrieve Solicit UUIDs. | 59 // Retrieve Solicit UUIDs. |
| 59 ASSERT_EQ(*data.solicit_uuids(), uuids); | 60 ASSERT_EQ(*data.solicit_uuids(), uuids); |
| 60 // Retieve again. | 61 // Retieve again. |
| 61 ASSERT_FALSE(data.solicit_uuids().get()); | 62 ASSERT_FALSE(data.solicit_uuids().get()); |
| 62 | 63 |
| 63 // Try without assigning Service Data. | 64 // Try without assigning Service Data. |
| 64 ASSERT_FALSE(data.service_data().get()); | 65 ASSERT_FALSE(data.service_data().get()); |
| 65 // Assign Service Data. | 66 // Assign Service Data. |
| 66 data.set_service_data( | 67 data.set_service_data( |
| 67 base::WrapUnique(new BluetoothAdvertisement::ServiceData(service_data))); | 68 base::MakeUnique<BluetoothAdvertisement::ServiceData>(service_data)); |
| 68 // Retrieve Service Data. | 69 // Retrieve Service Data. |
| 69 ASSERT_EQ(*data.service_data(), service_data); | 70 ASSERT_EQ(*data.service_data(), service_data); |
| 70 // Retrieve again. | 71 // Retrieve again. |
| 71 ASSERT_FALSE(data.service_data().get()); | 72 ASSERT_FALSE(data.service_data().get()); |
| 72 } | 73 } |
| 73 | 74 |
| 74 } // namespace | 75 } // namespace |
| 75 | 76 |
| 76 } // namespace device | 77 } // namespace device |
| OLD | NEW |