OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "device/bluetooth/bluetooth_advertisement.h" | |
6 #include "testing/gtest/include/gtest/gtest.h" | |
7 | |
8 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.
| |
9 | |
10 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.
| |
11 TEST(BluetoothAdvertisementTest, DataMembersAreAssignedCorrectly) { | |
12 // Sample manufacturer data. | |
13 BluetoothAdvertisement::ManufacturerData manufacturer_data; | |
14 std::vector<uint8_t> sample_data(5, 0); | |
15 manufacturer_data[0] = std::vector<uint8_t>(5, 0); | |
16 // Sample UUID List. | |
17 const BluetoothAdvertisement::UUIDList uuids(1, "1234"); | |
18 // Sample Service Data. | |
19 BluetoothAdvertisement::ServiceData service_data; | |
20 service_data["1234"] = std::vector<uint8_t>(5, 0); | |
21 | |
22 BluetoothAdvertisement::Data data( | |
23 BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST); | |
24 ASSERT_EQ(data.type(), BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST); | |
25 | |
26 // Try without assiging Service UUID. | |
27 ASSERT_FALSE(data.service_uuids().get()); | |
28 // Assign Service UUID. | |
29 data.set_service_uuids( | |
30 make_scoped_ptr(new BluetoothAdvertisement::UUIDList(uuids))); | |
31 // Retrieve Service UUID. | |
32 ASSERT_EQ(*data.service_uuids(), uuids); | |
33 // Retrieve again. | |
34 ASSERT_FALSE(data.service_uuids().get()); | |
35 | |
36 // Try without assigning Manufacturer Data. | |
37 ASSERT_FALSE(data.manufacturer_data().get()); | |
38 // Assign Manufacturer Data. | |
39 data.set_manufacturer_data(make_scoped_ptr( | |
40 new BluetoothAdvertisement::ManufacturerData(manufacturer_data))); | |
41 // Retrieve Manufacturer Data. | |
42 ASSERT_EQ(*data.manufacturer_data(), manufacturer_data); | |
43 // Retrieve again. | |
44 ASSERT_FALSE(data.manufacturer_data().get()); | |
45 | |
46 // Try without assigning Solicit UUIDs. | |
47 ASSERT_FALSE(data.solicit_uuids().get()); | |
48 // Assign Solicit UUIDs. | |
49 data.set_solicit_uuids( | |
50 make_scoped_ptr(new BluetoothAdvertisement::UUIDList(uuids))); | |
51 // Retrieve Solicit UUIDs. | |
52 ASSERT_EQ(*data.solicit_uuids(), uuids); | |
53 // Retieve again. | |
54 ASSERT_FALSE(data.solicit_uuids().get()); | |
55 | |
56 // Try without assigning Service Data. | |
57 ASSERT_FALSE(data.service_data().get()); | |
58 // Assign Service Data. | |
59 data.set_service_data( | |
60 make_scoped_ptr(new BluetoothAdvertisement::ServiceData(service_data))); | |
61 // Retrieve Service Data. | |
62 ASSERT_EQ(*data.service_data(), service_data); | |
63 // Retrieve again. | |
64 ASSERT_FALSE(data.service_data().get()); | |
65 } | |
66 | |
67 } // namespace | |
armansito
2015/08/28 21:56:16
} // namespace device?
ortuno
2015/09/01 00:24:29
Done.
| |
OLD | NEW |