#include "device/bluetooth/bluetooth_advertisement.h"
#include <stdint.h>
#include <memory>
#include "base/memory/ptr_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
namespace {
TEST(BluetoothAdvertisementTest, DataMembersAreAssignedCorrectly) {
BluetoothAdvertisement::ManufacturerData manufacturer_data;
std::vector<uint8_t> sample_data(5, 0);
manufacturer_data[0] = std::vector<uint8_t>(5, 0);
const BluetoothAdvertisement::UUIDList uuids(1, "1234");
BluetoothAdvertisement::ServiceData service_data;
service_data["1234"] = std::vector<uint8_t>(5, 0);
BluetoothAdvertisement::ScanResponseData scan_response_data;
scan_response_data[0x16] = std::vector<uint8_t>(5, 0);
BluetoothAdvertisement::Data data(
BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST);
ASSERT_EQ(data.type(), BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST);
ASSERT_FALSE(data.service_uuids());
data.set_service_uuids(uuids);
ASSERT_EQ(*data.service_uuids(), uuids);
ASSERT_FALSE(data.service_uuids());
ASSERT_FALSE(data.manufacturer_data());
data.set_manufacturer_data(manufacturer_data);
ASSERT_EQ(*data.manufacturer_data(), manufacturer_data);
ASSERT_FALSE(data.manufacturer_data());
ASSERT_FALSE(data.solicit_uuids());
data.set_solicit_uuids(uuids);
ASSERT_EQ(*data.solicit_uuids(), uuids);
ASSERT_FALSE(data.solicit_uuids());
ASSERT_FALSE(data.service_data());
data.set_service_data(service_data);
ASSERT_EQ(*data.service_data(), service_data);
ASSERT_FALSE(data.service_data());
ASSERT_FALSE(data.scan_response_data());
data.set_scan_response_data(scan_response_data);
ASSERT_EQ(*data.scan_response_data(), scan_response_data);
ASSERT_FALSE(data.scan_response_data());
}
}
}