Chromium Code Reviews| Index: device/bluetooth/bluetooth_advertisement_unittest.cc |
| diff --git a/device/bluetooth/bluetooth_advertisement_unittest.cc b/device/bluetooth/bluetooth_advertisement_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4ad970b3d99f982d622498398b36f8e7ca697ed0 |
| --- /dev/null |
| +++ b/device/bluetooth/bluetooth_advertisement_unittest.cc |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "device/bluetooth/bluetooth_advertisement.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +using device::BluetoothAdvertisement; |
|
armansito
2015/08/28 21:56:16
You declared "namespace device" below. You don't n
ortuno
2015/09/01 00:24:30
Done.
|
| + |
| +namespace device { |
|
armansito
2015/08/28 21:56:16
Add empty line after this. Also, did you mean to d
ortuno
2015/09/01 00:24:30
Done.
|
| +TEST(BluetoothAdvertisementTest, DataMembersAreAssignedCorrectly) { |
| + // Sample manufacturer data. |
| + BluetoothAdvertisement::ManufacturerData manufacturer_data; |
| + std::vector<uint8_t> sample_data(5, 0); |
| + manufacturer_data[0] = std::vector<uint8_t>(5, 0); |
| + // Sample UUID List. |
| + const BluetoothAdvertisement::UUIDList uuids(1, "1234"); |
| + // Sample Service Data. |
| + BluetoothAdvertisement::ServiceData service_data; |
| + service_data["1234"] = std::vector<uint8_t>(5, 0); |
| + |
| + BluetoothAdvertisement::Data data( |
| + BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST); |
| + ASSERT_EQ(data.type(), BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST); |
| + |
| + // Try without assiging Service UUID. |
| + ASSERT_FALSE(data.service_uuids().get()); |
| + // Assign Service UUID. |
| + data.set_service_uuids( |
| + make_scoped_ptr(new BluetoothAdvertisement::UUIDList(uuids))); |
| + // Retrieve Service UUID. |
| + ASSERT_EQ(*data.service_uuids(), uuids); |
| + // Retrieve again. |
| + ASSERT_FALSE(data.service_uuids().get()); |
| + |
| + // Try without assigning Manufacturer Data. |
| + ASSERT_FALSE(data.manufacturer_data().get()); |
| + // Assign Manufacturer Data. |
| + data.set_manufacturer_data(make_scoped_ptr( |
| + new BluetoothAdvertisement::ManufacturerData(manufacturer_data))); |
| + // Retrieve Manufacturer Data. |
| + ASSERT_EQ(*data.manufacturer_data(), manufacturer_data); |
| + // Retrieve again. |
| + ASSERT_FALSE(data.manufacturer_data().get()); |
| + |
| + // Try without assigning Solicit UUIDs. |
| + ASSERT_FALSE(data.solicit_uuids().get()); |
| + // Assign Solicit UUIDs. |
| + data.set_solicit_uuids( |
| + make_scoped_ptr(new BluetoothAdvertisement::UUIDList(uuids))); |
| + // Retrieve Solicit UUIDs. |
| + ASSERT_EQ(*data.solicit_uuids(), uuids); |
| + // Retieve again. |
| + ASSERT_FALSE(data.solicit_uuids().get()); |
| + |
| + // Try without assigning Service Data. |
| + ASSERT_FALSE(data.service_data().get()); |
| + // Assign Service Data. |
| + data.set_service_data( |
| + make_scoped_ptr(new BluetoothAdvertisement::ServiceData(service_data))); |
| + // Retrieve Service Data. |
| + ASSERT_EQ(*data.service_data(), service_data); |
| + // Retrieve again. |
| + ASSERT_FALSE(data.service_data().get()); |
| +} |
| + |
| +} // namespace |
|
armansito
2015/08/28 21:56:16
} // namespace device?
ortuno
2015/09/01 00:24:29
Done.
|