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

Unified Diff: chrome/browser/sync/engine/syncer_unittest.cc

Issue 9460047: sync: remove use of protobuf extensions in protocol to reduce static init overhead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nigori access in testserver Created 8 years, 10 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
Index: chrome/browser/sync/engine/syncer_unittest.cc
diff --git a/chrome/browser/sync/engine/syncer_unittest.cc b/chrome/browser/sync/engine/syncer_unittest.cc
index d2e73d44baf5d22a0afc00fb3d762519825a2061..6ebbebfae8d292c82c5926f7affa03d0e9f915f8 100644
--- a/chrome/browser/sync/engine/syncer_unittest.cc
+++ b/chrome/browser/sync/engine/syncer_unittest.cc
@@ -240,8 +240,8 @@ class SyncerTest : public testing::Test,
EXPECT_FALSE(entry->Get(IS_DIR));
EXPECT_FALSE(entry->Get(IS_DEL));
sync_pb::EntitySpecifics specifics;
- specifics.MutableExtension(sync_pb::bookmark)->set_url("http://demo/");
- specifics.MutableExtension(sync_pb::bookmark)->set_favicon("PNG");
+ specifics.mutable_bookmark()->set_url("http://demo/");
+ specifics.mutable_bookmark()->set_favicon("PNG");
entry->Put(syncable::SPECIFICS, specifics);
entry->Put(syncable::IS_UNSYNCED, true);
}
@@ -252,9 +252,9 @@ class SyncerTest : public testing::Test,
}
void VerifyTestBookmarkDataInEntry(Entry* entry) {
const sync_pb::EntitySpecifics& specifics = entry->Get(syncable::SPECIFICS);
- EXPECT_TRUE(specifics.HasExtension(sync_pb::bookmark));
- EXPECT_EQ("PNG", specifics.GetExtension(sync_pb::bookmark).favicon());
- EXPECT_EQ("http://demo/", specifics.GetExtension(sync_pb::bookmark).url());
+ EXPECT_TRUE(specifics.has_bookmark());
+ EXPECT_EQ("PNG", specifics.bookmark().favicon());
+ EXPECT_EQ("http://demo/", specifics.bookmark().url());
}
void SyncRepeatedlyToTriggerConflictResolution(SyncSession* session) {
@@ -660,8 +660,8 @@ TEST_F(SyncerTest, GetCommitIdsFiltersUnreadyEntries) {
KeyParams key_params = {"localhost", "dummy", "foobar"};
KeyParams other_params = {"localhost", "dummy", "foobar2"};
sync_pb::EntitySpecifics bookmark, encrypted_bookmark;
- bookmark.MutableExtension(sync_pb::bookmark)->set_url("url");
- bookmark.MutableExtension(sync_pb::bookmark)->set_title("title");
+ bookmark.mutable_bookmark()->set_url("url");
+ bookmark.mutable_bookmark()->set_title("title");
AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark);
mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10);
mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10);
@@ -677,8 +677,7 @@ TEST_F(SyncerTest, GetCommitIdsFiltersUnreadyEntries) {
browser_sync::Cryptographer other_cryptographer;
other_cryptographer.AddKey(other_params);
sync_pb::EntitySpecifics specifics;
- sync_pb::NigoriSpecifics* nigori =
- specifics.MutableExtension(sync_pb::nigori);
+ sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
other_cryptographer.GetKeys(nigori->mutable_encrypted());
nigori->set_encrypt_bookmarks(true);
// Set up with an old passphrase, but have pending keys
@@ -780,19 +779,19 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) {
browser_sync::Cryptographer other_cryptographer;
other_cryptographer.AddKey(key_params);
sync_pb::EntitySpecifics bookmark, encrypted_bookmark, modified_bookmark;
- bookmark.MutableExtension(sync_pb::bookmark)->set_title("title");
+ bookmark.mutable_bookmark()->set_title("title");
other_cryptographer.Encrypt(bookmark,
encrypted_bookmark.mutable_encrypted());
AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark);
- modified_bookmark.MutableExtension(sync_pb::bookmark)->set_title("title2");
+ modified_bookmark.mutable_bookmark()->set_title("title2");
other_cryptographer.Encrypt(modified_bookmark,
modified_bookmark.mutable_encrypted());
sync_pb::EntitySpecifics pref, encrypted_pref, modified_pref;
- pref.MutableExtension(sync_pb::preference)->set_name("name");
+ pref.mutable_preference()->set_name("name");
AddDefaultExtensionValue(syncable::PREFERENCES, &encrypted_pref);
other_cryptographer.Encrypt(pref,
encrypted_pref.mutable_encrypted());
- modified_pref.MutableExtension(sync_pb::preference)->set_name("name2");
+ modified_pref.mutable_preference()->set_name("name2");
other_cryptographer.Encrypt(modified_pref,
modified_pref.mutable_encrypted());
{
@@ -800,8 +799,7 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) {
// have pending keys.
WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
sync_pb::EntitySpecifics specifics;
- sync_pb::NigoriSpecifics* nigori =
- specifics.MutableExtension(sync_pb::nigori);
+ sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
other_cryptographer.GetKeys(nigori->mutable_encrypted());
nigori->set_encrypt_bookmarks(true);
nigori->set_encrypt_preferences(true);
@@ -969,19 +967,17 @@ TEST_F(SyncerTest, NigoriConflicts) {
other_cryptographer.AddKey(other_key_params);
syncable::ModelTypeSet encrypted_types(syncable::PASSWORDS, syncable::NIGORI);
sync_pb::EntitySpecifics initial_nigori_specifics;
- initial_nigori_specifics.MutableExtension(sync_pb::nigori);
+ initial_nigori_specifics.mutable_nigori();
mock_server_->SetNigori(1, 10, 10, initial_nigori_specifics);
// Data for testing encryption/decryption.
sync_pb::EntitySpecifics other_encrypted_specifics;
- other_encrypted_specifics.MutableExtension(sync_pb::bookmark)->
- set_title("title");
+ other_encrypted_specifics.mutable_bookmark()->set_title("title");
other_cryptographer.Encrypt(
other_encrypted_specifics,
other_encrypted_specifics.mutable_encrypted());
sync_pb::EntitySpecifics our_encrypted_specifics;
- our_encrypted_specifics.MutableExtension(sync_pb::bookmark)->
- set_title("title2");
+ our_encrypted_specifics.mutable_bookmark()->set_title("title2");
// Receive the initial nigori node.
SyncShareAsDelegate();
@@ -990,8 +986,7 @@ TEST_F(SyncerTest, NigoriConflicts) {
// Local changes with different passphrase, different types, and sync_tabs.
WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
sync_pb::EntitySpecifics specifics;
- sync_pb::NigoriSpecifics* nigori =
- specifics.MutableExtension(sync_pb::nigori);
+ sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
syncdb_.manager()->GetCryptographer(&wtrans)->AddKey(local_key_params);
syncdb_.manager()->GetCryptographer(&wtrans)->Encrypt(
our_encrypted_specifics,
@@ -1014,8 +1009,7 @@ TEST_F(SyncerTest, NigoriConflicts) {
}
{
sync_pb::EntitySpecifics specifics;
- sync_pb::NigoriSpecifics* nigori =
- specifics.MutableExtension(sync_pb::nigori);
+ sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
other_cryptographer.GetKeys(nigori->mutable_encrypted());
nigori->set_encrypt_bookmarks(true);
nigori->set_encrypt_preferences(true);
@@ -1045,7 +1039,7 @@ TEST_F(SyncerTest, NigoriConflicts) {
syncdb_.manager()->GetCryptographer(&wtrans)->GetEncryptedTypes()));
EXPECT_TRUE(syncdb_.manager()->GetCryptographer(&wtrans)->
encrypt_everything());
- EXPECT_TRUE(specifics.GetExtension(sync_pb::nigori).sync_tabs());
+ EXPECT_TRUE(specifics.nigori().sync_tabs());
// Supply the pending keys. Afterwards, we should be able to decrypt both
// our own encrypted data and data encrypted by the other cryptographer,
// but the key provided by the other cryptographer should be the default.
@@ -1053,8 +1047,7 @@ TEST_F(SyncerTest, NigoriConflicts) {
DecryptPendingKeys(other_key_params));
EXPECT_FALSE(syncdb_.manager()->GetCryptographer(&wtrans)->
has_pending_keys());
- sync_pb::NigoriSpecifics* nigori =
- specifics.MutableExtension(sync_pb::nigori);
+ sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
syncdb_.manager()->GetCryptographer(&wtrans)->GetKeys(
nigori->mutable_encrypted());
syncdb_.manager()->GetCryptographer(&wtrans)->
@@ -1084,8 +1077,7 @@ TEST_F(SyncerTest, NigoriConflicts) {
other_encrypted_specifics.encrypted()));
EXPECT_TRUE(syncdb_.manager()->GetCryptographer(&wtrans)->
CanDecryptUsingDefaultKey(other_encrypted_specifics.encrypted()));
- EXPECT_TRUE(nigori_entry.Get(SPECIFICS).GetExtension(sync_pb::nigori)
- .sync_tabs());
+ EXPECT_TRUE(nigori_entry.Get(SPECIFICS).nigori().sync_tabs());
}
}
@@ -2383,7 +2375,7 @@ TEST_F(SyncerTest, DoublyChangedWithResolver) {
ASSERT_TRUE(child.good());
EXPECT_TRUE(child.Get(syncable::IS_UNSYNCED));
EXPECT_FALSE(child.Get(syncable::IS_UNAPPLIED_UPDATE));
- EXPECT_TRUE(child.Get(SPECIFICS).HasExtension(sync_pb::bookmark));
+ EXPECT_TRUE(child.Get(SPECIFICS).has_bookmark());
EXPECT_EQ("Pete.htm", child.Get(NON_UNIQUE_NAME));
VerifyTestBookmarkDataInEntry(&child);
}
@@ -2838,7 +2830,7 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) {
EXPECT_EQ("Bar.htm", server.Get(NON_UNIQUE_NAME));
EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME));
EXPECT_EQ("http://google.com", // Default from AddUpdateBookmark.
- server.Get(SPECIFICS).GetExtension(sync_pb::bookmark).url());
+ server.Get(SPECIFICS).bookmark().url());
}
}
@@ -2906,7 +2898,7 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) {
EXPECT_EQ("Bar.htm", server.Get(NON_UNIQUE_NAME));
EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME));
EXPECT_EQ("http://google.com", // Default from AddUpdateBookmark.
- server.Get(SPECIFICS).GetExtension(sync_pb::bookmark).url());
+ server.Get(SPECIFICS).bookmark().url());
}
}
@@ -3692,11 +3684,9 @@ TEST_F(SyncerTest, ClientTagUncommittedTagMatchesUpdate) {
int64 original_metahandle = 0;
sync_pb::EntitySpecifics local_bookmark(DefaultBookmarkSpecifics());
- local_bookmark.MutableExtension(sync_pb::bookmark)->
- set_url("http://foo/localsite");
+ local_bookmark.mutable_bookmark()->set_url("http://foo/localsite");
sync_pb::EntitySpecifics server_bookmark(DefaultBookmarkSpecifics());
- server_bookmark.MutableExtension(sync_pb::bookmark)->
- set_url("http://bar/serversite");
+ server_bookmark.mutable_bookmark()->set_url("http://bar/serversite");
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir);

Powered by Google App Engine
This is Rietveld 408576698