Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Unified Diff: dbus/property_unittest.cc

Issue 2421713002: arc: bluetooth: Expose missing advertise data. (Closed)
Patch Set: Add BlueZ unittests / more comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/property.cc ('k') | device/bluetooth/bluetooth_adapter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/property_unittest.cc
diff --git a/dbus/property_unittest.cc b/dbus/property_unittest.cc
index 8208581c4e0c7897a1bd8a5401417c2d05b067a4..79aeecff04112cfc82cb671418616e691db5fc8e 100644
--- a/dbus/property_unittest.cc
+++ b/dbus/property_unittest.cc
@@ -487,4 +487,59 @@ TEST(PropertyTestStatic, SerializeStringToByteVectorMap) {
EXPECT_EQ(test_map, test_property.value());
}
+TEST(PropertyTestStatic, ReadWriteUInt16ToByteVectorMap) {
+ std::unique_ptr<Response> message(Response::CreateEmpty());
+ MessageWriter writer(message.get());
+ MessageWriter variant_writer(nullptr);
+ MessageWriter dict_writer(nullptr);
+
+ writer.OpenVariant("a{qv}", &variant_writer);
+ variant_writer.OpenArray("{qv}", &dict_writer);
+
+ const uint16_t keys[] = {11, 12, 13, 14};
+ const std::vector<uint8_t> values[] = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}};
+ for (unsigned i = 0; i < arraysize(keys); ++i) {
+ MessageWriter entry_writer(nullptr);
+ dict_writer.OpenDictEntry(&entry_writer);
+
+ entry_writer.AppendUint16(keys[i]);
+
+ MessageWriter value_varient_writer(nullptr);
+ entry_writer.OpenVariant("ay", &value_varient_writer);
+ value_varient_writer.AppendArrayOfBytes(values[i].data(), values[i].size());
+ entry_writer.CloseContainer(&value_varient_writer);
+
+ dict_writer.CloseContainer(&entry_writer);
+ }
+
+ variant_writer.CloseContainer(&dict_writer);
+ writer.CloseContainer(&variant_writer);
+
+ MessageReader reader(message.get());
+ Property<std::unordered_map<uint16_t, std::vector<uint8_t>>> test_property;
+ EXPECT_TRUE(test_property.PopValueFromReader(&reader));
+
+ ASSERT_EQ(arraysize(keys), test_property.value().size());
+ for (unsigned i = 0; i < arraysize(keys); ++i)
+ EXPECT_EQ(values[i], test_property.value().at(keys[i]));
+}
+
+TEST(PropertyTestStatic, SerializeUInt16ToByteVectorMap) {
+ std::unordered_map<uint16_t, std::vector<uint8_t>> test_map;
+ test_map[11] = {1, 2, 3};
+ test_map[12] = {0xab, 0xcd};
+ test_map[13] = {0x0};
+
+ std::unique_ptr<Response> message(Response::CreateEmpty());
+ MessageWriter writer(message.get());
+
+ Property<std::unordered_map<uint16_t, std::vector<uint8_t>>> test_property;
+ test_property.ReplaceSetValueForTesting(test_map);
+ test_property.AppendSetValueToWriter(&writer);
+
+ MessageReader reader(message.get());
+ EXPECT_TRUE(test_property.PopValueFromReader(&reader));
+ EXPECT_EQ(test_map, test_property.value());
+}
+
} // namespace dbus
« no previous file with comments | « dbus/property.cc ('k') | device/bluetooth/bluetooth_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698