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

Unified Diff: sync/protocol/proto_value_conversions_unittest.cc

Issue 9663023: Log the sync communication that happens between client and server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 8 years, 9 months 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 | « sync/protocol/proto_value_conversions.cc ('k') | sync/sync.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/protocol/proto_value_conversions_unittest.cc
diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc
index 3d96378722f1684a1c95764f69d7f9b35344dd0b..1ed0859511db8ae510e976cb6c6cb0ece28082f6 100644
--- a/sync/protocol/proto_value_conversions_unittest.cc
+++ b/sync/protocol/proto_value_conversions_unittest.cc
@@ -187,5 +187,55 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) {
static_cast<int>(value->size()));
}
+namespace {
+void VerifySpecifics(DictionaryValue* value,
akalin 2012/03/19 21:31:38 I think it would be cleaner to have this something
lipalani1 2012/03/20 19:24:41 Done.
+ const std::string& path,
+ bool include_specifics) {
+ ListValue* entities_list;
akalin 2012/03/19 21:31:38 initialize to NULL
lipalani1 2012/03/20 19:24:41 Done.
+ DictionaryValue* entry_dictionary;
+ DictionaryValue* specifics_dictionary;
+ EXPECT_TRUE(value->GetList(path, &entities_list));
akalin 2012/03/19 21:31:38 use if(!...) { return false; }
lipalani1 2012/03/20 19:24:41 Done.
+ EXPECT_TRUE(entities_list->GetDictionary(0, &entry_dictionary));
+ EXPECT_EQ(entry_dictionary->GetDictionary("specifics",
+ &specifics_dictionary),
+ include_specifics);
+}
+} // namespace
+
+TEST_F(ProtoValueConversionsTest, ClientToServerMessageToValue) {
akalin 2012/03/19 21:31:38 add test-level comment. Something like // Create
lipalani1 2012/03/20 19:24:41 Done.
+ sync_pb::ClientToServerMessage message;
+ sync_pb::CommitMessage* commit_message = message.mutable_commit();
+ sync_pb::SyncEntity* entity = commit_message->add_entries();
+ sync_pb::EntitySpecifics* specifics = entity->mutable_specifics();
+
+ scoped_ptr<DictionaryValue> value_with_specifics(
+ ClientToServerMessageToValue(message, true /* include_specifics */));
+ EXPECT_FALSE(value_with_specifics->empty());
+ VerifySpecifics(value_with_specifics.get(), "commit.entries", true);
akalin 2012/03/19 21:31:38 true -> true /* include_specifics */ (everywhere
lipalani1 2012/03/20 19:24:41 The param is removed. On 2012/03/19 21:31:38, akal
+
+ scoped_ptr<DictionaryValue> value_without_specifics(
+ ClientToServerMessageToValue(message, false /* include_specifics */));
+ EXPECT_FALSE(value_without_specifics->empty());
+ VerifySpecifics(value_without_specifics.get(), "commit.entries", false);
+}
+
+TEST_F(ProtoValueConversionsTest, ClientToServerResponseToValue) {
akalin 2012/03/19 21:31:38 add test-level comment
lipalani1 2012/03/20 19:24:41 Done.
+ sync_pb::ClientToServerResponse message;
+ sync_pb::GetUpdatesResponse* response = message.mutable_get_updates();
+ sync_pb::SyncEntity* entity = response->add_entries();
+ sync_pb::EntitySpecifics* specifics = entity->mutable_specifics();
+
+ scoped_ptr<DictionaryValue> value_with_specifics(
+ ClientToServerResponseToValue(message, true /* include_specifics */));
+ EXPECT_FALSE(value_with_specifics->empty());
+ VerifySpecifics(value_with_specifics.get(), "get_updates.entries", true);
+
+
+ scoped_ptr<DictionaryValue> value_without_specifics(
+ ClientToServerResponseToValue(message, false /* include_specifics */));
+ EXPECT_FALSE(value_without_specifics->empty());
+ VerifySpecifics(value_without_specifics.get(), "get_updates.entries", false);
+}
+
} // namespace
} // namespace browser_sync
« no previous file with comments | « sync/protocol/proto_value_conversions.cc ('k') | sync/sync.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698