diff options
-rw-r--r-- | chromeos/dbus/bluetooth_le_advertisement_service_provider.cc | 2 | ||||
-rw-r--r-- | device/BUILD.gn | 1 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_advertisement.h | 4 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_advertisement_unittest.cc | 70 | ||||
-rw-r--r-- | device/device_tests.gyp | 1 |
5 files changed, 75 insertions, 3 deletions
diff --git a/chromeos/dbus/bluetooth_le_advertisement_service_provider.cc b/chromeos/dbus/bluetooth_le_advertisement_service_provider.cc index 3ed774c..e598322 100644 --- a/chromeos/dbus/bluetooth_le_advertisement_service_provider.cc +++ b/chromeos/dbus/bluetooth_le_advertisement_service_provider.cc @@ -355,7 +355,7 @@ class BluetoothAdvertisementServiceProviderImpl array_writer.OpenDictEntry(&entry_writer); - entry_writer.AppendVariantOfString(m.first); + entry_writer.AppendString(m.first); entry_writer.AppendArrayOfBytes(vector_as_array(&m.second), m.second.size()); diff --git a/device/BUILD.gn b/device/BUILD.gn index 9a26321..f147303 100644 --- a/device/BUILD.gn +++ b/device/BUILD.gn @@ -34,6 +34,7 @@ test("device_unittests") { "bluetooth/bluetooth_adapter_unittest.cc", "bluetooth/bluetooth_adapter_win_unittest.cc", "bluetooth/bluetooth_advertisement_chromeos_unittest.cc", + "bluetooth/bluetooth_advertisement_unittest.cc", "bluetooth/bluetooth_audio_sink_chromeos_unittest.cc", "bluetooth/bluetooth_chromeos_unittest.cc", "bluetooth/bluetooth_device_unittest.cc", diff --git a/device/bluetooth/bluetooth_advertisement.h b/device/bluetooth/bluetooth_advertisement.h index 46f19b1..eb4cebb 100644 --- a/device/bluetooth/bluetooth_advertisement.h +++ b/device/bluetooth/bluetooth_advertisement.h @@ -71,10 +71,10 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdvertisement manufacturer_data_ = manufacturer_data.Pass(); } void set_solicit_uuids(scoped_ptr<UUIDList> solicit_uuids) { - solicit_uuids = solicit_uuids_.Pass(); + solicit_uuids_ = solicit_uuids.Pass(); } void set_service_data(scoped_ptr<ServiceData> service_data) { - service_data = service_data_.Pass(); + service_data_ = service_data.Pass(); } void set_include_tx_power(bool include_tx_power) { diff --git a/device/bluetooth/bluetooth_advertisement_unittest.cc b/device/bluetooth/bluetooth_advertisement_unittest.cc new file mode 100644 index 0000000..fe95ba3 --- /dev/null +++ b/device/bluetooth/bluetooth_advertisement_unittest.cc @@ -0,0 +1,70 @@ +// 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" + +namespace device { + +namespace { + +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 + +} // namespace device diff --git a/device/device_tests.gyp b/device/device_tests.gyp index e1b3bad..82f3dcb 100644 --- a/device/device_tests.gyp +++ b/device/device_tests.gyp @@ -40,6 +40,7 @@ 'bluetooth/bluetooth_adapter_unittest.cc', 'bluetooth/bluetooth_adapter_win_unittest.cc', 'bluetooth/bluetooth_advertisement_chromeos_unittest.cc', + 'bluetooth/bluetooth_advertisement_unittest.cc', 'bluetooth/bluetooth_audio_sink_chromeos_unittest.cc', 'bluetooth/bluetooth_chromeos_unittest.cc', 'bluetooth/bluetooth_device_unittest.cc', |