Index: dbus/property_unittest.cc |
diff --git a/dbus/property_unittest.cc b/dbus/property_unittest.cc |
index 1e86817a9a71672e07b084068f362467b6fa1340..f4c9658ee007ad56ba3a5e1a28835c4bbce0c2ad 100644 |
--- a/dbus/property_unittest.cc |
+++ b/dbus/property_unittest.cc |
@@ -35,6 +35,8 @@ class PropertyTest : public testing::Test { |
Property<std::vector<std::string> > methods; |
Property<std::vector<ObjectPath> > objects; |
Property<std::vector<uint8> > bytes; |
+ Property<std::map<std::string, std::string>> string_map; |
+ Property<std::vector<std::pair<std::vector<uint8>, uint16>>> ip_port_list; |
Properties(ObjectProxy* object_proxy, |
PropertyChangedCallback property_changed_callback) |
@@ -46,6 +48,8 @@ class PropertyTest : public testing::Test { |
RegisterProperty("Methods", &methods); |
RegisterProperty("Objects", &objects); |
RegisterProperty("Bytes", &bytes); |
+ RegisterProperty("StringMap", &string_map); |
+ RegisterProperty("IPList", &ip_port_list); |
} |
}; |
@@ -127,7 +131,7 @@ class PropertyTest : public testing::Test { |
} |
// Name, Version, Methods, Objects |
- static const int kExpectedSignalUpdates = 5; |
+ static const int kExpectedSignalUpdates = 7; |
// Waits for initial values to be set. |
void WaitForGetAll() { |
@@ -180,6 +184,27 @@ TEST_F(PropertyTest, InitialValues) { |
EXPECT_EQ('e', bytes[1]); |
EXPECT_EQ('s', bytes[2]); |
EXPECT_EQ('t', bytes[3]); |
+ |
+ std::map<std::string, std::string> string_map = |
+ properties_->string_map.value(); |
+ ASSERT_EQ(4U, string_map.size()); |
+ EXPECT_EQ("1", string_map["One"]); |
+ EXPECT_EQ("2", string_map["Two"]); |
+ EXPECT_EQ("3", string_map["Three"]); |
+ EXPECT_EQ("4", string_map["Four"]); |
+ |
+ std::vector<std::pair<std::vector<uint8>, uint16>> ip_list = |
+ properties_->ip_port_list.value(); |
+ ASSERT_EQ(5U, ip_list.size()); |
+ for (size_t i = 0; i < ip_list.size(); ++i) { |
+ EXPECT_EQ(5U, ip_list[i].first.size()); |
+ EXPECT_EQ('T', ip_list[i].first[0]); |
+ EXPECT_EQ('e', ip_list[i].first[1]); |
+ EXPECT_EQ('s', ip_list[i].first[2]); |
+ EXPECT_EQ('t', ip_list[i].first[3]); |
+ EXPECT_EQ('0' + i, ip_list[i].first[4]); |
+ EXPECT_EQ(i, ip_list[i].second); |
+ } |
} |
TEST_F(PropertyTest, UpdatedValues) { |
@@ -244,6 +269,41 @@ TEST_F(PropertyTest, UpdatedValues) { |
EXPECT_EQ('e', bytes[1]); |
EXPECT_EQ('s', bytes[2]); |
EXPECT_EQ('t', bytes[3]); |
+ |
+ // Update the value of the "Bytes" property, this value should not change |
+ // and should not grow to contain duplicate entries. |
+ properties_->bytes.Get(base::Bind(&PropertyTest::PropertyCallback, |
+ base::Unretained(this), "StringMap")); |
+ WaitForCallback("StringMap"); |
+ WaitForUpdates(1); |
+ |
+ std::map<std::string, std::string> string_map = |
+ properties_->string_map.value(); |
+ ASSERT_EQ(4U, string_map.size()); |
+ EXPECT_EQ("1", string_map["One"]); |
+ EXPECT_EQ("2", string_map["Two"]); |
+ EXPECT_EQ("3", string_map["Three"]); |
+ EXPECT_EQ("4", string_map["Four"]); |
+ |
+ // Update the value of the "Bytes" property, this value should not change |
+ // and should not grow to contain duplicate entries. |
+ properties_->bytes.Get(base::Bind(&PropertyTest::PropertyCallback, |
+ base::Unretained(this), "IPList")); |
+ WaitForCallback("IPList"); |
+ WaitForUpdates(1); |
+ |
+ std::vector<std::pair<std::vector<uint8>, uint16>> ip_list = |
+ properties_->ip_port_list.value(); |
+ ASSERT_EQ(5U, ip_list.size()); |
+ for (size_t i = 0; i < ip_list.size(); ++i) { |
+ EXPECT_EQ(5U, ip_list[i].first.size()); |
+ EXPECT_EQ('T', ip_list[i].first[0]); |
+ EXPECT_EQ('e', ip_list[i].first[1]); |
+ EXPECT_EQ('s', ip_list[i].first[2]); |
+ EXPECT_EQ('t', ip_list[i].first[3]); |
+ EXPECT_EQ('0' + i, ip_list[i].first[4]); |
+ EXPECT_EQ(i, ip_list[i].second); |
+ } |
hashimoto
2015/02/06 07:45:12
Instead of changing test_service.cc, how about add
dtapuska
2015/02/06 15:56:01
Done.
|
} |
TEST_F(PropertyTest, Get) { |