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

Unified Diff: components/sync/engine_impl/syncer_unittest.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 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 | « components/sync/engine_impl/syncer_types.h ('k') | components/sync/engine_impl/syncer_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/engine_impl/syncer_unittest.cc
diff --git a/sync/engine/syncer_unittest.cc b/components/sync/engine_impl/syncer_unittest.cc
similarity index 90%
rename from sync/engine/syncer_unittest.cc
rename to components/sync/engine_impl/syncer_unittest.cc
index c5dd3de10e975e3941645c9025741f01f4a3a333..554ee7783e1d311c56884e7ac8a5cf13dfd1aae8 100644
--- a/sync/engine/syncer_unittest.cc
+++ b/components/sync/engine_impl/syncer_unittest.cc
@@ -5,7 +5,7 @@
// Syncer unit tests. Unfortunately a lot of these tests
// are outdated and need to be reworked and updated.
-#include "sync/engine/syncer.h"
+#include "components/sync/engine_impl/syncer.h"
#include <stddef.h>
#include <stdint.h>
@@ -29,40 +29,40 @@
#include "base/test/histogram_tester.h"
#include "base/time/time.h"
#include "build/build_config.h"
-#include "sync/engine/backoff_delay_provider.h"
-#include "sync/engine/get_commit_ids.h"
-#include "sync/engine/net/server_connection_manager.h"
-#include "sync/engine/sync_scheduler_impl.h"
-#include "sync/engine/syncer_proto_util.h"
-#include "sync/internal_api/public/base/cancelation_signal.h"
-#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/engine/model_safe_worker.h"
-#include "sync/internal_api/public/sessions/commit_counters.h"
-#include "sync/internal_api/public/sessions/status_counters.h"
-#include "sync/internal_api/public/sessions/update_counters.h"
-#include "sync/protocol/bookmark_specifics.pb.h"
-#include "sync/protocol/nigori_specifics.pb.h"
-#include "sync/protocol/preference_specifics.pb.h"
-#include "sync/protocol/sync.pb.h"
-#include "sync/sessions/sync_session_context.h"
-#include "sync/syncable/mutable_entry.h"
-#include "sync/syncable/nigori_util.h"
-#include "sync/syncable/syncable_delete_journal.h"
-#include "sync/syncable/syncable_read_transaction.h"
-#include "sync/syncable/syncable_util.h"
-#include "sync/syncable/syncable_write_transaction.h"
-#include "sync/test/engine/fake_model_worker.h"
-#include "sync/test/engine/mock_connection_manager.h"
-#include "sync/test/engine/mock_nudge_handler.h"
-#include "sync/test/engine/test_directory_setter_upper.h"
-#include "sync/test/engine/test_id_factory.h"
-#include "sync/test/engine/test_syncable_utils.h"
-#include "sync/test/fake_encryptor.h"
-#include "sync/test/fake_sync_encryption_handler.h"
-#include "sync/test/sessions/mock_debug_info_getter.h"
-#include "sync/util/cryptographer.h"
-#include "sync/util/extensions_activity.h"
-#include "sync/util/time.h"
+#include "components/sync/base/cancelation_signal.h"
+#include "components/sync/base/cryptographer.h"
+#include "components/sync/base/extensions_activity.h"
+#include "components/sync/base/model_type.h"
+#include "components/sync/base/time.h"
+#include "components/sync/engine/model_safe_worker.h"
+#include "components/sync/engine_impl/backoff_delay_provider.h"
+#include "components/sync/engine_impl/get_commit_ids.h"
+#include "components/sync/engine_impl/net/server_connection_manager.h"
+#include "components/sync/engine_impl/sync_scheduler_impl.h"
+#include "components/sync/engine_impl/syncer_proto_util.h"
+#include "components/sync/protocol/bookmark_specifics.pb.h"
+#include "components/sync/protocol/nigori_specifics.pb.h"
+#include "components/sync/protocol/preference_specifics.pb.h"
+#include "components/sync/protocol/sync.pb.h"
+#include "components/sync/sessions/commit_counters.h"
+#include "components/sync/sessions/status_counters.h"
+#include "components/sync/sessions/update_counters.h"
+#include "components/sync/sessions_impl/sync_session_context.h"
+#include "components/sync/syncable/mutable_entry.h"
+#include "components/sync/syncable/nigori_util.h"
+#include "components/sync/syncable/syncable_delete_journal.h"
+#include "components/sync/syncable/syncable_read_transaction.h"
+#include "components/sync/syncable/syncable_util.h"
+#include "components/sync/syncable/syncable_write_transaction.h"
+#include "components/sync/test/engine/fake_model_worker.h"
+#include "components/sync/test/engine/mock_connection_manager.h"
+#include "components/sync/test/engine/mock_nudge_handler.h"
+#include "components/sync/test/engine/test_directory_setter_upper.h"
+#include "components/sync/test/engine/test_id_factory.h"
+#include "components/sync/test/engine/test_syncable_utils.h"
+#include "components/sync/test/fake_encryptor.h"
+#include "components/sync/test/fake_sync_encryption_handler.h"
+#include "components/sync/test/sessions/mock_debug_info_getter.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -191,8 +191,7 @@ class SyncerTest : public testing::Test,
SyncerTest()
: extensions_activity_(new ExtensionsActivity),
syncer_(NULL),
- last_client_invalidation_hint_buffer_size_(10) {
-}
+ last_client_invalidation_hint_buffer_size_(10) {}
// SyncSession::Delegate implementation.
void OnThrottled(const base::TimeDelta& throttle_duration) override {
@@ -232,8 +231,8 @@ class SyncerTest : public testing::Test,
void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) {
// We're just testing the sync engine here, so we shunt everything to
// the SyncerThread. Datatypes which aren't enabled aren't in the map.
- for (ModelTypeSet::Iterator it = enabled_datatypes_.First();
- it.Good(); it.Inc()) {
+ for (ModelTypeSet::Iterator it = enabled_datatypes_.First(); it.Good();
+ it.Inc()) {
(*out)[it.Get()] = GROUP_PASSIVE;
}
}
@@ -267,29 +266,28 @@ class SyncerTest : public testing::Test,
nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS));
return syncer_->NormalSyncShare(context_->GetEnabledTypes(),
- &nudge_tracker_, session_.get());
+ &nudge_tracker_, session_.get());
}
bool SyncShareConfigure() {
ResetSession();
return syncer_->ConfigureSyncShare(
- context_->GetEnabledTypes(),
- sync_pb::GetUpdatesCallerInfo::RECONFIGURATION,
- session_.get());
+ context_->GetEnabledTypes(),
+ sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, session_.get());
}
void SetUp() override {
dir_maker_.SetUp();
- mock_server_.reset(new MockConnectionManager(directory(),
- &cancelation_signal_));
+ mock_server_.reset(
+ new MockConnectionManager(directory(), &cancelation_signal_));
debug_info_getter_.reset(new MockDebugInfoGetter);
EnableDatatype(BOOKMARKS);
EnableDatatype(EXTENSIONS);
EnableDatatype(NIGORI);
EnableDatatype(PREFERENCES);
EnableDatatype(NIGORI);
- workers_.push_back(scoped_refptr<ModelSafeWorker>(
- new FakeModelWorker(GROUP_PASSIVE)));
+ workers_.push_back(
+ scoped_refptr<ModelSafeWorker>(new FakeModelWorker(GROUP_PASSIVE)));
std::vector<SyncEngineEventListener*> listeners;
listeners.push_back(this);
@@ -302,20 +300,15 @@ class SyncerTest : public testing::Test,
&debug_info_cache_);
context_.reset(new SyncSessionContext(
- mock_server_.get(),
- directory(),
- extensions_activity_.get(),
- listeners,
- debug_info_getter_.get(),
- model_type_registry_.get(),
+ mock_server_.get(), directory(), extensions_activity_.get(), listeners,
+ debug_info_getter_.get(), model_type_registry_.get(),
true, // enable keystore encryption
false, // force enable pre-commit GU avoidance experiment
"fake_invalidator_client_id"));
context_->SetRoutingInfo(routing_info);
syncer_ = new Syncer(&cancelation_signal_);
scheduler_.reset(new SyncSchedulerImpl(
- "TestSyncScheduler",
- BackoffDelayProvider::FromDefaults(),
+ "TestSyncScheduler", BackoffDelayProvider::FromDefaults(),
context_.get(),
// scheduler_ owned syncer_ now and will manage the memory of syncer_
syncer_));
@@ -397,7 +390,7 @@ class SyncerTest : public testing::Test,
// Enumeration of alterations to entries for commit ordering tests.
enum EntryFeature {
LIST_END = 0, // Denotes the end of the list of features from below.
- SYNCED, // Items are unsynced by default
+ SYNCED, // Items are unsynced by default
DELETED,
OLD_MTIME,
MOVED_FROM_ROOT,
@@ -450,7 +443,7 @@ class SyncerTest : public testing::Test,
const base::Time& now_minus_2h =
base::Time::Now() - base::TimeDelta::FromHours(2);
entry.PutMtime(now_plus_30s);
- for (size_t i = 0 ; i < arraysize(test->features) ; ++i) {
+ for (size_t i = 0; i < arraysize(test->features); ++i) {
switch (test->features[i]) {
case LIST_END:
break;
@@ -496,29 +489,23 @@ class SyncerTest : public testing::Test,
return debug_info_cache_.GetLatestStatusCounters(type);
}
- Directory* directory() {
- return dir_maker_.directory();
- }
+ Directory* directory() { return dir_maker_.directory(); }
- const std::string local_cache_guid() {
- return directory()->cache_guid();
- }
+ const std::string local_cache_guid() { return directory()->cache_guid(); }
- const std::string foreign_cache_guid() {
- return "kqyg7097kro6GSUod+GSg==";
- }
+ const std::string foreign_cache_guid() { return "kqyg7097kro6GSUod+GSg=="; }
int64_t CreateUnsyncedDirectory(const string& entry_name,
const string& idstring) {
return CreateUnsyncedDirectory(entry_name,
- syncable::Id::CreateFromServerId(idstring));
+ syncable::Id::CreateFromServerId(idstring));
}
int64_t CreateUnsyncedDirectory(const string& entry_name,
const syncable::Id& id) {
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(
- &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), entry_name);
+ MutableEntry entry(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(),
+ entry_name);
EXPECT_TRUE(entry.good());
entry.PutIsUnsynced(true);
entry.PutIsDir(true);
@@ -601,7 +588,7 @@ class SyncerTest : public testing::Test,
base::TimeDelta last_sessions_commit_delay_;
base::TimeDelta last_bookmarks_commit_delay_;
int last_client_invalidation_hint_buffer_size_;
- std::vector<scoped_refptr<ModelSafeWorker> > workers_;
+ std::vector<scoped_refptr<ModelSafeWorker>> workers_;
ModelTypeSet enabled_datatypes_;
sessions::NudgeTracker nudge_tracker_;
@@ -630,8 +617,8 @@ TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) {
sync_pb::EntitySpecifics bookmark_data;
AddDefaultFieldValue(BOOKMARKS, &bookmark_data);
- mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
{
@@ -805,18 +792,18 @@ TEST_F(SyncerTest, GetCommitIdsFiltersUnreadyEntries) {
bookmark.mutable_bookmark()->set_url("url");
bookmark.mutable_bookmark()->set_title("title");
AddDefaultFieldValue(BOOKMARKS, &encrypted_bookmark);
- mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10,
- foreign_cache_guid(), "-2");
- mock_server_->AddUpdateDirectory(3, 0, "C", 10, 10,
- foreign_cache_guid(), "-3");
- mock_server_->AddUpdateDirectory(4, 0, "D", 10, 10,
- foreign_cache_guid(), "-4");
+ mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10, foreign_cache_guid(),
+ "-2");
+ mock_server_->AddUpdateDirectory(3, 0, "C", 10, 10, foreign_cache_guid(),
+ "-3");
+ mock_server_->AddUpdateDirectory(4, 0, "D", 10, 10, foreign_cache_guid(),
+ "-4");
EXPECT_TRUE(SyncShareNudge());
// Server side change will put A in conflict.
- mock_server_->AddUpdateDirectory(1, 0, "A", 20, 20,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "A", 20, 20, foreign_cache_guid(),
+ "-1");
{
// Mark bookmarks as encrypted and set the cryptographer to have pending
// keys.
@@ -830,7 +817,7 @@ TEST_F(SyncerTest, GetCommitIdsFiltersUnreadyEntries) {
// Set up with an old passphrase, but have pending keys
GetCryptographer(&wtrans)->AddKey(key_params);
GetCryptographer(&wtrans)->Encrypt(bookmark,
- encrypted_bookmark.mutable_encrypted());
+ encrypted_bookmark.mutable_encrypted());
GetCryptographer(&wtrans)->SetPendingKeys(nigori->encryption_keybag());
// In conflict but properly encrypted.
@@ -1065,8 +1052,8 @@ TEST_F(SyncerTest, GetCommitIds_VerifyDeletionCommitOrderMaxEntries) {
entry.PutIsDir(true);
entry.PutBaseVersion(5);
entry.PutServerVersion(5);
- entry.PutParentId(ids_.FromNumber(i/2));
- entry.PutServerParentId(ids_.FromNumber(i/2));
+ entry.PutParentId(ids_.FromNumber(i / 2));
+ entry.PutServerParentId(ids_.FromNumber(i / 2));
entry.PutServerIsDir(true);
entry.PutIsUnsynced(true);
entry.PutSpecifics(DefaultBookmarkSpecifics());
@@ -1098,8 +1085,7 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) {
other_cryptographer.AddKey(key_params);
sync_pb::EntitySpecifics bookmark, encrypted_bookmark, modified_bookmark;
bookmark.mutable_bookmark()->set_title("title");
- other_cryptographer.Encrypt(bookmark,
- encrypted_bookmark.mutable_encrypted());
+ other_cryptographer.Encrypt(bookmark, encrypted_bookmark.mutable_encrypted());
AddDefaultFieldValue(BOOKMARKS, &encrypted_bookmark);
modified_bookmark.mutable_bookmark()->set_title("title2");
other_cryptographer.Encrypt(modified_bookmark,
@@ -1107,11 +1093,9 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) {
sync_pb::EntitySpecifics pref, encrypted_pref, modified_pref;
pref.mutable_preference()->set_name("name");
AddDefaultFieldValue(PREFERENCES, &encrypted_pref);
- other_cryptographer.Encrypt(pref,
- encrypted_pref.mutable_encrypted());
+ other_cryptographer.Encrypt(pref, encrypted_pref.mutable_encrypted());
modified_pref.mutable_preference()->set_name("name2");
- other_cryptographer.Encrypt(modified_pref,
- modified_pref.mutable_encrypted());
+ other_cryptographer.Encrypt(modified_pref, modified_pref.mutable_encrypted());
{
// Mark bookmarks and preferences as encrypted and set the cryptographer to
// have pending keys.
@@ -1147,8 +1131,8 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) {
VERIFY_ENTRY(4, false, false, false, 0, 10, 10, ids_, &rtrans);
Entry entry1(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1));
- ASSERT_TRUE(entry1.GetUniquePosition().Equals(
- entry1.GetServerUniquePosition()));
+ ASSERT_TRUE(
+ entry1.GetUniquePosition().Equals(entry1.GetServerUniquePosition()));
pos1 = entry1.GetUniquePosition();
Entry entry2(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2));
pos2 = entry2.GetUniquePosition();
@@ -1159,17 +1143,16 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) {
// Server side encryption will not be applied due to undecryptable data.
// At this point, BASE_SERVER_SPECIFICS should be filled for all four items.
mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 20, 20, true, 0,
- encrypted_bookmark,
- foreign_cache_guid(), "-1");
+ encrypted_bookmark, foreign_cache_guid(),
+ "-1");
mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 20, 20, false, 2,
- encrypted_bookmark,
- foreign_cache_guid(), "-2");
+ encrypted_bookmark, foreign_cache_guid(),
+ "-2");
mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 20, 20, false, 1,
- encrypted_bookmark,
- foreign_cache_guid(), "-3");
+ encrypted_bookmark, foreign_cache_guid(),
+ "-3");
mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 20, 20, false, 0,
- encrypted_pref,
- foreign_cache_guid(), "-4");
+ encrypted_pref, foreign_cache_guid(), "-4");
EXPECT_TRUE(SyncShareNudge());
{
// All should be unapplied due to being undecryptable and have a valid
@@ -1184,15 +1167,14 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) {
// Server side change that don't modify anything should not affect
// BASE_SERVER_SPECIFICS (such as name changes and mtime changes).
mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 30, 30, true, 0,
- encrypted_bookmark,
- foreign_cache_guid(), "-1");
+ encrypted_bookmark, foreign_cache_guid(),
+ "-1");
mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 30, 30, false, 2,
- encrypted_bookmark,
- foreign_cache_guid(), "-2");
+ encrypted_bookmark, foreign_cache_guid(),
+ "-2");
// Item 3 doesn't change.
mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 30, 30, false, 0,
- encrypted_pref,
- foreign_cache_guid(), "-4");
+ encrypted_pref, foreign_cache_guid(), "-4");
EXPECT_TRUE(SyncShareNudge());
{
// Items 1, 2, and 4 should have newer server versions, 3 remains the same.
@@ -1211,8 +1193,8 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) {
foreign_cache_guid(), "-1");
// Reordered to after item 2.
mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 30, 30, false, 3,
- encrypted_bookmark,
- foreign_cache_guid(), "-3");
+ encrypted_bookmark, foreign_cache_guid(),
+ "-3");
EXPECT_TRUE(SyncShareNudge());
{
// Items 2 and 4 should be the only ones with BASE_SERVER_SPECIFICS set.
@@ -1359,8 +1341,7 @@ TEST_F(SyncerTest, TestPurgeWhileUnsynced) {
parent2.PutId(pref_node_id);
}
- directory()->PurgeEntriesWithTypeIn(ModelTypeSet(PREFERENCES),
- ModelTypeSet(),
+ directory()->PurgeEntriesWithTypeIn(ModelTypeSet(PREFERENCES), ModelTypeSet(),
ModelTypeSet());
EXPECT_TRUE(SyncShareNudge());
@@ -1397,8 +1378,7 @@ TEST_F(SyncerTest, TestPurgeWhileUnapplied) {
parent.PutId(parent_id_);
}
- directory()->PurgeEntriesWithTypeIn(ModelTypeSet(BOOKMARKS),
- ModelTypeSet(),
+ directory()->PurgeEntriesWithTypeIn(ModelTypeSet(BOOKMARKS), ModelTypeSet(),
ModelTypeSet());
EXPECT_TRUE(SyncShareNudge());
@@ -1439,8 +1419,7 @@ TEST_F(SyncerTest, TestPurgeWithJournal) {
}
directory()->PurgeEntriesWithTypeIn(ModelTypeSet(PREFERENCES, BOOKMARKS),
- ModelTypeSet(BOOKMARKS),
- ModelTypeSet());
+ ModelTypeSet(BOOKMARKS), ModelTypeSet());
{
// Verify bookmark nodes are saved in delete journal but not preference
// node.
@@ -1514,30 +1493,30 @@ TEST_F(SyncerTest, ResetVersions) {
TEST_F(SyncerTest, TestCommitListOrderingTwoItemsTall) {
CommitOrderingTest items[] = {
- {1, ids_.FromNumber(-1001), ids_.FromNumber(-1000)},
- {0, ids_.FromNumber(-1000), ids_.FromNumber(0)},
- CommitOrderingTest::MakeLastCommitItem(),
+ {1, ids_.FromNumber(-1001), ids_.FromNumber(-1000)},
+ {0, ids_.FromNumber(-1000), ids_.FromNumber(0)},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
TEST_F(SyncerTest, TestCommitListOrderingThreeItemsTall) {
CommitOrderingTest items[] = {
- {1, ids_.FromNumber(-2001), ids_.FromNumber(-2000)},
- {0, ids_.FromNumber(-2000), ids_.FromNumber(0)},
- {2, ids_.FromNumber(-2002), ids_.FromNumber(-2001)},
- CommitOrderingTest::MakeLastCommitItem(),
+ {1, ids_.FromNumber(-2001), ids_.FromNumber(-2000)},
+ {0, ids_.FromNumber(-2000), ids_.FromNumber(0)},
+ {2, ids_.FromNumber(-2002), ids_.FromNumber(-2001)},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
TEST_F(SyncerTest, TestCommitListOrderingFourItemsTall) {
CommitOrderingTest items[] = {
- {3, ids_.FromNumber(-2003), ids_.FromNumber(-2002)},
- {1, ids_.FromNumber(-2001), ids_.FromNumber(-2000)},
- {0, ids_.FromNumber(-2000), ids_.FromNumber(0)},
- {2, ids_.FromNumber(-2002), ids_.FromNumber(-2001)},
- CommitOrderingTest::MakeLastCommitItem(),
+ {3, ids_.FromNumber(-2003), ids_.FromNumber(-2002)},
+ {1, ids_.FromNumber(-2001), ids_.FromNumber(-2000)},
+ {0, ids_.FromNumber(-2000), ids_.FromNumber(0)},
+ {2, ids_.FromNumber(-2002), ids_.FromNumber(-2001)},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
@@ -1545,52 +1524,51 @@ TEST_F(SyncerTest, TestCommitListOrderingFourItemsTall) {
TEST_F(SyncerTest, TestCommitListOrderingThreeItemsTallLimitedSize) {
context_->set_max_commit_batch_size(2);
CommitOrderingTest items[] = {
- {1, ids_.FromNumber(-2001), ids_.FromNumber(-2000)},
- {0, ids_.FromNumber(-2000), ids_.FromNumber(0)},
- {2, ids_.FromNumber(-2002), ids_.FromNumber(-2001)},
- CommitOrderingTest::MakeLastCommitItem(),
+ {1, ids_.FromNumber(-2001), ids_.FromNumber(-2000)},
+ {0, ids_.FromNumber(-2000), ids_.FromNumber(0)},
+ {2, ids_.FromNumber(-2002), ids_.FromNumber(-2001)},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
TEST_F(SyncerTest, TestCommitListOrderingSingleDeletedItem) {
CommitOrderingTest items[] = {
- {0, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED}},
- CommitOrderingTest::MakeLastCommitItem(),
+ {0, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED}},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
TEST_F(SyncerTest, TestCommitListOrderingSingleUncommittedDeletedItem) {
CommitOrderingTest items[] = {
- {-1, ids_.FromNumber(-1000), ids_.FromNumber(0), {DELETED}},
- CommitOrderingTest::MakeLastCommitItem(),
+ {-1, ids_.FromNumber(-1000), ids_.FromNumber(0), {DELETED}},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
TEST_F(SyncerTest, TestCommitListOrderingSingleDeletedItemWithUnroll) {
CommitOrderingTest items[] = {
- {0, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED}},
- CommitOrderingTest::MakeLastCommitItem(),
+ {0, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED}},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
-TEST_F(SyncerTest,
- TestCommitListOrderingSingleLongDeletedItemWithUnroll) {
+TEST_F(SyncerTest, TestCommitListOrderingSingleLongDeletedItemWithUnroll) {
CommitOrderingTest items[] = {
- {0, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
- CommitOrderingTest::MakeLastCommitItem(),
+ {0, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
TEST_F(SyncerTest, TestCommitListOrderingTwoLongDeletedItemWithUnroll) {
CommitOrderingTest items[] = {
- {1, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
- {0, ids_.FromNumber(1001), ids_.FromNumber(1000), {DELETED, OLD_MTIME}},
- CommitOrderingTest::MakeLastCommitItem(),
+ {1, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
+ {0, ids_.FromNumber(1001), ids_.FromNumber(1000), {DELETED, OLD_MTIME}},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
@@ -1598,31 +1576,31 @@ TEST_F(SyncerTest, TestCommitListOrderingTwoLongDeletedItemWithUnroll) {
TEST_F(SyncerTest, TestCommitListOrdering3LongDeletedItemsWithSizeLimit) {
context_->set_max_commit_batch_size(2);
CommitOrderingTest items[] = {
- {2, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
- {1, ids_.FromNumber(1001), ids_.FromNumber(1000), {DELETED, OLD_MTIME}},
- {0, ids_.FromNumber(1002), ids_.FromNumber(1001), {DELETED, OLD_MTIME}},
- CommitOrderingTest::MakeLastCommitItem(),
+ {2, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
+ {1, ids_.FromNumber(1001), ids_.FromNumber(1000), {DELETED, OLD_MTIME}},
+ {0, ids_.FromNumber(1002), ids_.FromNumber(1001), {DELETED, OLD_MTIME}},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
TEST_F(SyncerTest, TestCommitListOrderingTwoDeletedItemsWithUnroll) {
CommitOrderingTest items[] = {
- {1, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED}},
- {0, ids_.FromNumber(1001), ids_.FromNumber(1000), {DELETED}},
- CommitOrderingTest::MakeLastCommitItem(),
+ {1, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED}},
+ {0, ids_.FromNumber(1001), ids_.FromNumber(1000), {DELETED}},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
TEST_F(SyncerTest, TestCommitListOrderingComplexDeletionScenario) {
CommitOrderingTest items[] = {
- {2, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
- {-1, ids_.FromNumber(1001), ids_.FromNumber(0), {SYNCED}},
- {1, ids_.FromNumber(1002), ids_.FromNumber(1001), {DELETED, OLD_MTIME}},
- {-1, ids_.FromNumber(1003), ids_.FromNumber(1001), {SYNCED}},
- {0, ids_.FromNumber(1004), ids_.FromNumber(1003), {DELETED}},
- CommitOrderingTest::MakeLastCommitItem(),
+ {2, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
+ {-1, ids_.FromNumber(1001), ids_.FromNumber(0), {SYNCED}},
+ {1, ids_.FromNumber(1002), ids_.FromNumber(1001), {DELETED, OLD_MTIME}},
+ {-1, ids_.FromNumber(1003), ids_.FromNumber(1001), {SYNCED}},
+ {0, ids_.FromNumber(1004), ids_.FromNumber(1003), {DELETED}},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
@@ -1630,23 +1608,25 @@ TEST_F(SyncerTest, TestCommitListOrderingComplexDeletionScenario) {
TEST_F(SyncerTest,
TestCommitListOrderingComplexDeletionScenarioWith2RecentDeletes) {
CommitOrderingTest items[] = {
- {3, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
- {-1, ids_.FromNumber(1001), ids_.FromNumber(0), {SYNCED}},
- {2, ids_.FromNumber(1002), ids_.FromNumber(1001), {DELETED, OLD_MTIME}},
- {-1, ids_.FromNumber(1003), ids_.FromNumber(1001), {SYNCED}},
- {1, ids_.FromNumber(1004), ids_.FromNumber(1003), {DELETED}},
- {0, ids_.FromNumber(1005), ids_.FromNumber(1003), {DELETED}},
- CommitOrderingTest::MakeLastCommitItem(),
+ {3, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
+ {-1, ids_.FromNumber(1001), ids_.FromNumber(0), {SYNCED}},
+ {2, ids_.FromNumber(1002), ids_.FromNumber(1001), {DELETED, OLD_MTIME}},
+ {-1, ids_.FromNumber(1003), ids_.FromNumber(1001), {SYNCED}},
+ {1, ids_.FromNumber(1004), ids_.FromNumber(1003), {DELETED}},
+ {0, ids_.FromNumber(1005), ids_.FromNumber(1003), {DELETED}},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
TEST_F(SyncerTest, TestCommitListOrderingDeleteMovedItems) {
CommitOrderingTest items[] = {
- {1, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
- {0, ids_.FromNumber(1001), ids_.FromNumber(1000), {DELETED, OLD_MTIME,
- MOVED_FROM_ROOT}},
- CommitOrderingTest::MakeLastCommitItem(),
+ {1, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}},
+ {0,
+ ids_.FromNumber(1001),
+ ids_.FromNumber(1000),
+ {DELETED, OLD_MTIME, MOVED_FROM_ROOT}},
+ CommitOrderingTest::MakeLastCommitItem(),
};
RunCommitOrderingTest(items);
}
@@ -1664,16 +1644,16 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) {
parent.PutSpecifics(DefaultBookmarkSpecifics());
parent.PutId(ids_.FromNumber(100));
parent.PutBaseVersion(1);
- MutableEntry child(
- &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(100), "Bob");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, ids_.FromNumber(100),
+ "Bob");
ASSERT_TRUE(child.good());
child.PutIsUnsynced(true);
child.PutIsDir(true);
child.PutSpecifics(DefaultBookmarkSpecifics());
child.PutId(ids_.FromNumber(101));
child.PutBaseVersion(1);
- MutableEntry grandchild(
- &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(101), "Bob");
+ MutableEntry grandchild(&wtrans, CREATE, BOOKMARKS, ids_.FromNumber(101),
+ "Bob");
ASSERT_TRUE(grandchild.good());
grandchild.PutId(ids_.FromNumber(102));
grandchild.PutIsUnsynced(true);
@@ -1692,8 +1672,8 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) {
parent.PutIsDel(true);
parent.PutBaseVersion(1);
parent.PutMtime(now_minus_2h);
- MutableEntry child(
- &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(103), "Pete");
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, ids_.FromNumber(103),
+ "Pete");
ASSERT_TRUE(child.good());
child.PutId(ids_.FromNumber(104));
child.PutIsUnsynced(true);
@@ -1702,8 +1682,8 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) {
child.PutIsDel(true);
child.PutBaseVersion(1);
child.PutMtime(now_minus_2h);
- MutableEntry grandchild(
- &wtrans, CREATE, BOOKMARKS, ids_.FromNumber(104), "Pete");
+ MutableEntry grandchild(&wtrans, CREATE, BOOKMARKS, ids_.FromNumber(104),
+ "Pete");
ASSERT_TRUE(grandchild.good());
grandchild.PutId(ids_.FromNumber(105));
grandchild.PutIsUnsynced(true);
@@ -1873,16 +1853,14 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) {
syncable::Id child_id = ids_.NewServerId();
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent2(
- &wtrans, CREATE, BOOKMARKS, parent_id_, parent2_name);
+ MutableEntry parent2(&wtrans, CREATE, BOOKMARKS, parent_id_, parent2_name);
ASSERT_TRUE(parent2.good());
parent2.PutIsUnsynced(true);
parent2.PutIsDir(true);
parent2.PutSpecifics(DefaultBookmarkSpecifics());
parent2.PutId(parent2_id);
- MutableEntry child(
- &wtrans, CREATE, BOOKMARKS, parent2_id, child_name);
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent2_id, child_name);
ASSERT_TRUE(child.good());
child.PutIsUnsynced(true);
child.PutIsDir(true);
@@ -1903,9 +1881,7 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) {
Entry entry_1(&rtrans, syncable::GET_BY_ID, parent_id_);
EXPECT_EQ(parent1_name, entry_1.GetNonUniqueName());
// Check that parent2 is a subfolder of parent1.
- EXPECT_EQ(1, CountEntriesWithName(&rtrans,
- parent_id_,
- parent2_name));
+ EXPECT_EQ(1, CountEntriesWithName(&rtrans, parent_id_, parent2_name));
// Parent2 was a local ID and thus should have changed on commit!
Entry pre_commit_entry_parent2(&rtrans, syncable::GET_BY_ID, parent2_id);
@@ -1928,9 +1904,7 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParentAndChild) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry parent(&wtrans,
- CREATE, BOOKMARKS,
- wtrans.root_id(),
+ MutableEntry parent(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(),
parent_name);
ASSERT_TRUE(parent.good());
parent.PutIsUnsynced(true);
@@ -1952,8 +1926,8 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParentAndChild) {
parent2.PutSpecifics(DefaultBookmarkSpecifics());
parent2.PutId(parent2_local_id);
- MutableEntry child(
- &wtrans, CREATE, BOOKMARKS, parent2_local_id, child_name);
+ MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent2_local_id,
+ child_name);
ASSERT_TRUE(child.good());
child.PutIsUnsynced(true);
child.PutIsDir(true);
@@ -1982,8 +1956,7 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParentAndChild) {
EXPECT_TRUE(parent2.GetId().ServerKnows());
// Id changed on commit, so this should fail.
- Entry local_parent2_id_entry(&rtrans,
- syncable::GET_BY_ID,
+ Entry local_parent2_id_entry(&rtrans, syncable::GET_BY_ID,
parent2_local_id);
ASSERT_FALSE(local_parent2_id_entry.good());
@@ -1995,15 +1968,15 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParentAndChild) {
TEST_F(SyncerTest, UpdateWithZeroLengthName) {
// One illegal update
- mock_server_->AddUpdateDirectory(
- 1, 0, std::string(), 1, 10, foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, std::string(), 1, 10,
+ foreign_cache_guid(), "-1");
// And one legal one that we're going to delete.
- mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge());
// Delete the legal one. The new update has a null name.
- mock_server_->AddUpdateDirectory(
- 2, 0, std::string(), 2, 20, foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(2, 0, std::string(), 2, 20,
+ foreign_cache_guid(), "-2");
mock_server_->SetLastUpdateDeleted();
EXPECT_TRUE(SyncShareNudge());
}
@@ -2020,8 +1993,7 @@ TEST_F(SyncerTest, TestBasicUpdate) {
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- Entry entry(&trans, GET_BY_ID,
- syncable::Id::CreateFromServerId("some_id"));
+ Entry entry(&trans, GET_BY_ID, syncable::Id::CreateFromServerId("some_id"));
ASSERT_TRUE(entry.good());
EXPECT_TRUE(entry.GetIsDir());
EXPECT_EQ(version, entry.GetServerVersion());
@@ -2188,8 +2160,8 @@ TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) {
int64_t metahandle_folder;
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(
- &trans, CREATE, BOOKMARKS, trans.root_id(), "new_folder");
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(),
+ "new_folder");
ASSERT_TRUE(entry.good());
entry.PutIsDir(true);
entry.PutSpecifics(DefaultBookmarkSpecifics());
@@ -2238,9 +2210,9 @@ TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) {
// The following update should cause the folder to both apply the update, as
// well as reassociate the id.
- mock_server_->AddUpdateDirectory(new_folder_id, root_id_,
- "new_folder", new_version, timestamp,
- local_cache_guid(), folder_id.GetServerId());
+ mock_server_->AddUpdateDirectory(new_folder_id, root_id_, "new_folder",
+ new_version, timestamp, local_cache_guid(),
+ folder_id.GetServerId());
// We don't want it accidentally committed, just the update applied.
mock_server_->set_conflict_all_commits(true);
@@ -2303,9 +2275,9 @@ TEST_F(SyncerTest, CommitReuniteUpdate) {
syncable::Id new_entry_id = syncable::Id::CreateFromServerId("server_id");
// Generate an update from the server with a relevant ID reassignment.
- mock_server_->AddUpdateBookmark(new_entry_id, root_id_,
- "new_entry", new_version, timestamp,
- local_cache_guid(), entry_id.GetServerId());
+ mock_server_->AddUpdateBookmark(new_entry_id, root_id_, "new_entry",
+ new_version, timestamp, local_cache_guid(),
+ entry_id.GetServerId());
// We don't want it accidentally committed, just the update applied.
mock_server_->set_conflict_all_commits(true);
@@ -2354,9 +2326,9 @@ TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) {
syncable::Id new_entry_id = syncable::Id::CreateFromServerId("server_id");
// Generate an update from the server with a relevant ID reassignment.
- mock_server_->AddUpdateBookmark(new_entry_id, root_id_,
- "new_entry", new_version, timestamp,
- local_cache_guid(), entry_id.GetServerId());
+ mock_server_->AddUpdateBookmark(new_entry_id, root_id_, "new_entry",
+ new_version, timestamp, local_cache_guid(),
+ entry_id.GetServerId());
// We don't want it accidentally committed, just the update applied.
mock_server_->set_conflict_all_commits(true);
@@ -2364,8 +2336,8 @@ TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) {
// Purposefully delete the entry now before the update application finishes.
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- Id new_entry_id = GetOnlyEntryWithName(
- &trans, trans.root_id(), "new_entry");
+ Id new_entry_id =
+ GetOnlyEntryWithName(&trans, trans.root_id(), "new_entry");
MutableEntry entry(&trans, GET_BY_ID, new_entry_id);
ASSERT_TRUE(entry.good());
entry.PutIsDel(true);
@@ -2375,8 +2347,8 @@ TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) {
EXPECT_TRUE(SyncShareNudge());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
- Id new_entry_id = GetOnlyEntryWithName(
- &trans, trans.root_id(), "new_entry");
+ Id new_entry_id =
+ GetOnlyEntryWithName(&trans, trans.root_id(), "new_entry");
Entry entry(&trans, GET_BY_ID, new_entry_id);
ASSERT_TRUE(entry.good());
EXPECT_FALSE(entry.GetIsDel());
@@ -2389,10 +2361,10 @@ TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) {
// TODO(chron): Add more unsanitized name tests.
TEST_F(SyncerTest, ConflictMatchingEntryHandlesUnsanitizedNames) {
- mock_server_->AddUpdateDirectory(1, 0, "A/A", 10, 10,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateDirectory(2, 0, "B/B", 10, 10,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(1, 0, "A/A", 10, 10, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateDirectory(2, 0, "B/B", 10, 10, foreign_cache_guid(),
+ "-2");
mock_server_->set_conflict_all_commits(true);
EXPECT_TRUE(SyncShareNudge());
{
@@ -2430,10 +2402,10 @@ TEST_F(SyncerTest, ConflictMatchingEntryHandlesUnsanitizedNames) {
}
TEST_F(SyncerTest, ConflictMatchingEntryHandlesNormalNames) {
- mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10, foreign_cache_guid(),
+ "-2");
mock_server_->set_conflict_all_commits(true);
EXPECT_TRUE(SyncShareNudge());
{
@@ -2473,19 +2445,18 @@ TEST_F(SyncerTest, ConflictMatchingEntryHandlesNormalNames) {
TEST_F(SyncerTest, ReverseFolderOrderingTest) {
mock_server_->AddUpdateDirectory(4, 3, "ggchild", 10, 10,
foreign_cache_guid(), "-4");
- mock_server_->AddUpdateDirectory(3, 2, "gchild", 10, 10,
- foreign_cache_guid(), "-3");
+ mock_server_->AddUpdateDirectory(3, 2, "gchild", 10, 10, foreign_cache_guid(),
+ "-3");
mock_server_->AddUpdateDirectory(5, 4, "gggchild", 10, 10,
foreign_cache_guid(), "-5");
- mock_server_->AddUpdateDirectory(2, 1, "child", 10, 10,
- foreign_cache_guid(), "-2");
- mock_server_->AddUpdateDirectory(1, 0, "parent", 10, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(2, 1, "child", 10, 10, foreign_cache_guid(),
+ "-2");
+ mock_server_->AddUpdateDirectory(1, 0, "parent", 10, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
syncable::ReadTransaction trans(FROM_HERE, directory());
- Id child_id = GetOnlyEntryWithName(
- &trans, ids_.FromNumber(4), "gggchild");
+ Id child_id = GetOnlyEntryWithName(&trans, ids_.FromNumber(4), "gggchild");
Entry child(&trans, GET_BY_ID, child_id);
ASSERT_TRUE(child.good());
}
@@ -2494,15 +2465,12 @@ class EntryCreatedInNewFolderTest : public SyncerTest {
public:
void CreateFolderInBob() {
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry bob(&trans,
- syncable::GET_BY_ID,
- GetOnlyEntryWithName(&trans,
- TestIdFactory::root(),
- "bob"));
+ MutableEntry bob(
+ &trans, syncable::GET_BY_ID,
+ GetOnlyEntryWithName(&trans, TestIdFactory::root(), "bob"));
ASSERT_TRUE(bob.good());
- MutableEntry entry2(
- &trans, CREATE, BOOKMARKS, bob.GetId(), "bob");
+ MutableEntry entry2(&trans, CREATE, BOOKMARKS, bob.GetId(), "bob");
ASSERT_TRUE(entry2.good());
entry2.PutIsDir(true);
entry2.PutIsUnsynced(true);
@@ -2520,20 +2488,19 @@ TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) {
entry.PutSpecifics(DefaultBookmarkSpecifics());
}
- mock_server_->SetMidCommitCallback(
- base::Bind(&EntryCreatedInNewFolderTest::CreateFolderInBob,
- base::Unretained(this)));
+ mock_server_->SetMidCommitCallback(base::Bind(
+ &EntryCreatedInNewFolderTest::CreateFolderInBob, base::Unretained(this)));
EXPECT_TRUE(SyncShareNudge());
// We loop until no unsynced handles remain, so we will commit both ids.
EXPECT_EQ(2u, mock_server_->committed_ids().size());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
- Entry parent_entry(&trans, syncable::GET_BY_ID,
+ Entry parent_entry(
+ &trans, syncable::GET_BY_ID,
GetOnlyEntryWithName(&trans, TestIdFactory::root(), "bob"));
ASSERT_TRUE(parent_entry.good());
- Id child_id =
- GetOnlyEntryWithName(&trans, parent_entry.GetId(), "bob");
+ Id child_id = GetOnlyEntryWithName(&trans, parent_entry.GetId(), "bob");
Entry child(&trans, syncable::GET_BY_ID, child_id);
ASSERT_TRUE(child.good());
EXPECT_EQ(parent_entry.GetId(), child.GetParentId());
@@ -2541,8 +2508,8 @@ TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) {
}
TEST_F(SyncerTest, NegativeIDInUpdate) {
- mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40,
- foreign_cache_guid(), "-100");
+ mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40, foreign_cache_guid(),
+ "-100");
EXPECT_TRUE(SyncShareNudge());
// The negative id would make us CHECK!
}
@@ -2573,10 +2540,11 @@ TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) {
EXPECT_TRUE(fred_match.GetId().ServerKnows());
fred_match_id = fred_match.GetId();
mock_server_->AddUpdateBookmark(fred_match_id, trans.root_id(),
- "fred_match", 40, 40, local_cache_guid(), orig_id.GetServerId());
+ "fred_match", 40, 40, local_cache_guid(),
+ orig_id.GetServerId());
}
// Run the syncer.
- for (int i = 0 ; i < 30 ; ++i) {
+ for (int i = 0; i < 30; ++i) {
EXPECT_TRUE(SyncShareNudge());
}
}
@@ -3029,21 +2997,21 @@ TEST_F(SyncerTest, ConflictWithImplicitParent) {
TEST_F(SyncerTest, DeletingEntryWithLocalEdits) {
int64_t newfolder_metahandle;
- mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry newfolder(
- &trans, CREATE, BOOKMARKS, ids_.FromNumber(1), "local");
+ MutableEntry newfolder(&trans, CREATE, BOOKMARKS, ids_.FromNumber(1),
+ "local");
ASSERT_TRUE(newfolder.good());
newfolder.PutIsUnsynced(true);
newfolder.PutIsDir(true);
newfolder.PutSpecifics(DefaultBookmarkSpecifics());
newfolder_metahandle = newfolder.GetMetahandle();
}
- mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20, foreign_cache_guid(),
+ "-1");
mock_server_->SetLastUpdateDeleted();
SyncShareConfigure();
{
@@ -3054,15 +3022,15 @@ TEST_F(SyncerTest, DeletingEntryWithLocalEdits) {
}
TEST_F(SyncerTest, FolderSwapUpdate) {
- mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10,
- foreign_cache_guid(), "-7801");
- mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10,
- foreign_cache_guid(), "-1024");
+ mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10, foreign_cache_guid(),
+ "-7801");
+ mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10, foreign_cache_guid(),
+ "-1024");
EXPECT_TRUE(SyncShareNudge());
- mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20,
- foreign_cache_guid(), "-1024");
- mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20,
- foreign_cache_guid(), "-7801");
+ mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20, foreign_cache_guid(),
+ "-1024");
+ mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20, foreign_cache_guid(),
+ "-7801");
EXPECT_TRUE(SyncShareNudge());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
@@ -3078,10 +3046,10 @@ TEST_F(SyncerTest, FolderSwapUpdate) {
}
TEST_F(SyncerTest, NameCollidingFolderSwapWorksFine) {
- mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10,
- foreign_cache_guid(), "-7801");
- mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10,
- foreign_cache_guid(), "-1024");
+ mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10, foreign_cache_guid(),
+ "-7801");
+ mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10, foreign_cache_guid(),
+ "-1024");
mock_server_->AddUpdateDirectory(4096, 0, "alice", 1, 10,
foreign_cache_guid(), "-4096");
EXPECT_TRUE(SyncShareNudge());
@@ -3100,12 +3068,12 @@ TEST_F(SyncerTest, NameCollidingFolderSwapWorksFine) {
EXPECT_EQ("alice", id3.GetNonUniqueName());
EXPECT_EQ(root_id_, id3.GetParentId());
}
- mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20,
- foreign_cache_guid(), "-1024");
- mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20,
- foreign_cache_guid(), "-7801");
- mock_server_->AddUpdateDirectory(4096, 0, "bob", 2, 20,
- foreign_cache_guid(), "-4096");
+ mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20, foreign_cache_guid(),
+ "-1024");
+ mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20, foreign_cache_guid(),
+ "-7801");
+ mock_server_->AddUpdateDirectory(4096, 0, "bob", 2, 20, foreign_cache_guid(),
+ "-4096");
EXPECT_TRUE(SyncShareNudge());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
@@ -3361,7 +3329,7 @@ TEST_F(SyncerTest, HugeConflict) {
// Generate a huge deep tree which should all fail to apply at first.
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- for (int i = 0; i < item_count ; i++) {
+ for (int i = 0; i < item_count; i++) {
syncable::Id next_id = ids_.NewServerId();
syncable::Id local_id = ids_.NewLocalId();
tree_ids.push_back(next_id);
@@ -3386,8 +3354,8 @@ TEST_F(SyncerTest, HugeConflict) {
}
// Add the missing parent directory.
- mock_server_->AddUpdateDirectory(parent_id, TestIdFactory::root(),
- "BOB", 2, 20, foreign_cache_guid(), "-3500");
+ mock_server_->AddUpdateDirectory(parent_id, TestIdFactory::root(), "BOB", 2,
+ 20, foreign_cache_guid(), "-3500");
EXPECT_TRUE(SyncShareNudge());
// Now they should all be OK.
@@ -3403,8 +3371,8 @@ TEST_F(SyncerTest, HugeConflict) {
}
TEST_F(SyncerTest, DontCrashOnCaseChange) {
- mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
@@ -3413,31 +3381,31 @@ TEST_F(SyncerTest, DontCrashOnCaseChange) {
e.PutIsUnsynced(true);
}
mock_server_->set_conflict_all_commits(true);
- mock_server_->AddUpdateDirectory(1, 0, "BOB", 2, 20,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "BOB", 2, 20, foreign_cache_guid(),
+ "-1");
EXPECT_FALSE(SyncShareNudge()); // USED TO CAUSE AN ASSERT
}
TEST_F(SyncerTest, UnsyncedItemAndUpdate) {
- mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
mock_server_->set_conflict_all_commits(true);
- mock_server_->AddUpdateDirectory(2, 0, "bob", 2, 20,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(2, 0, "bob", 2, 20, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge()); // USED TO CAUSE AN ASSERT
}
TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) {
- mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
int64_t local_folder_handle;
syncable::Id local_folder_id;
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry new_entry(
- &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bar.htm");
+ MutableEntry new_entry(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(),
+ "Bar.htm");
ASSERT_TRUE(new_entry.good());
local_folder_id = new_entry.GetId();
local_folder_handle = new_entry.GetMetahandle();
@@ -3447,8 +3415,8 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) {
ASSERT_TRUE(old.good());
WriteTestDataToEntry(&wtrans, &old);
}
- mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20, foreign_cache_guid(),
+ "-1");
mock_server_->set_conflict_all_commits(true);
EXPECT_FALSE(SyncShareNudge());
{
@@ -3472,8 +3440,8 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) {
// Now add a server change to make the two names equal. There should
// be no conflict with that, since names are not unique.
- mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 30, 30,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 30, 30, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
@@ -3489,22 +3457,22 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) {
EXPECT_EQ("Bar.htm", server.GetNonUniqueName());
EXPECT_EQ("Bar.htm", local.GetNonUniqueName());
EXPECT_EQ("http://google.com", // Default from AddUpdateBookmark.
- server.GetSpecifics().bookmark().url());
+ server.GetSpecifics().bookmark().url());
}
}
// Same as NewEntryAnddServerEntrySharePath, but using the old-style protocol.
TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) {
mock_server_->set_use_legacy_bookmarks_protocol(true);
- mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
int64_t local_folder_handle;
syncable::Id local_folder_id;
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry new_entry(
- &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bar.htm");
+ MutableEntry new_entry(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(),
+ "Bar.htm");
ASSERT_TRUE(new_entry.good());
local_folder_id = new_entry.GetId();
local_folder_handle = new_entry.GetMetahandle();
@@ -3514,8 +3482,8 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) {
ASSERT_TRUE(old.good());
WriteTestDataToEntry(&wtrans, &old);
}
- mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20, foreign_cache_guid(),
+ "-1");
mock_server_->set_conflict_all_commits(true);
EXPECT_FALSE(SyncShareNudge());
{
@@ -3539,8 +3507,8 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) {
// Now add a server change to make the two names equal. There should
// be no conflict with that, since names are not unique.
- mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 30, 30,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 30, 30, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
@@ -3556,17 +3524,17 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) {
EXPECT_EQ("Bar.htm", server.GetNonUniqueName());
EXPECT_EQ("Bar.htm", local.GetNonUniqueName());
EXPECT_EQ("http://google.com", // Default from AddUpdateBookmark.
- server.GetSpecifics().bookmark().url());
+ server.GetSpecifics().bookmark().url());
}
}
// Circular links should be resolved by the server.
TEST_F(SyncerTest, SiblingDirectoriesBecomeCircular) {
// we don't currently resolve this. This test ensures we don't.
- mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
@@ -3576,8 +3544,8 @@ TEST_F(SyncerTest, SiblingDirectoriesBecomeCircular) {
A.PutParentId(ids_.FromNumber(2));
A.PutNonUniqueName("B");
}
- mock_server_->AddUpdateDirectory(2, 1, "A", 20, 20,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(2, 1, "A", 20, 20, foreign_cache_guid(),
+ "-2");
mock_server_->set_conflict_all_commits(true);
EXPECT_FALSE(SyncShareNudge());
{
@@ -3593,10 +3561,10 @@ TEST_F(SyncerTest, SiblingDirectoriesBecomeCircular) {
TEST_F(SyncerTest, SwapEntryNames) {
// Simple transaction test.
- mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10, foreign_cache_guid(),
+ "-2");
mock_server_->set_conflict_all_commits(true);
EXPECT_TRUE(SyncShareNudge());
{
@@ -3615,10 +3583,10 @@ TEST_F(SyncerTest, SwapEntryNames) {
}
TEST_F(SyncerTest, DualDeletionWithNewItemNameClash) {
- mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateBookmark(2, 0, "B", 10, 10,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateBookmark(2, 0, "B", 10, 10, foreign_cache_guid(),
+ "-2");
mock_server_->set_conflict_all_commits(true);
EXPECT_TRUE(SyncShareNudge());
{
@@ -3628,8 +3596,8 @@ TEST_F(SyncerTest, DualDeletionWithNewItemNameClash) {
WriteTestDataToEntry(&trans, &B);
B.PutIsDel(true);
}
- mock_server_->AddUpdateBookmark(2, 0, "A", 11, 11,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateBookmark(2, 0, "A", 11, 11, foreign_cache_guid(),
+ "-2");
mock_server_->SetLastUpdateDeleted();
EXPECT_TRUE(SyncShareNudge());
{
@@ -3647,8 +3615,8 @@ TEST_F(SyncerTest, DualDeletionWithNewItemNameClash) {
TEST_F(SyncerTest, ResolveWeWroteTheyDeleted) {
int64_t bob_metahandle;
- mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
@@ -3657,8 +3625,8 @@ TEST_F(SyncerTest, ResolveWeWroteTheyDeleted) {
bob_metahandle = bob.GetMetahandle();
WriteTestDataToEntry(&trans, &bob);
}
- mock_server_->AddUpdateBookmark(1, 0, "bob", 2, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(1, 0, "bob", 2, 10, foreign_cache_guid(),
+ "-1");
mock_server_->SetLastUpdateDeleted();
mock_server_->set_conflict_all_commits(true);
EXPECT_FALSE(SyncShareNudge());
@@ -3704,8 +3672,8 @@ TEST_F(SyncerTest, DuplicateIDReturn) {
}
TEST_F(SyncerTest, DeletedEntryWithBadParentInLoopCalculation) {
- mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
@@ -3716,8 +3684,8 @@ TEST_F(SyncerTest, DeletedEntryWithBadParentInLoopCalculation) {
bob.PutIsDel(true);
bob.PutIsUnsynced(true);
}
- mock_server_->AddUpdateDirectory(2, 1, "fred", 1, 10,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(2, 1, "fred", 1, 10, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge());
EXPECT_TRUE(SyncShareNudge());
}
@@ -3727,8 +3695,8 @@ TEST_F(SyncerTest, ConflictResolverMergesLocalDeleteAndServerUpdate) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry local_deleted(
- &trans, CREATE, BOOKMARKS, trans.root_id(), "name");
+ MutableEntry local_deleted(&trans, CREATE, BOOKMARKS, trans.root_id(),
+ "name");
local_id = local_deleted.GetId();
local_deleted.PutId(ids_.FromNumber(1));
local_deleted.PutBaseVersion(1);
@@ -3739,8 +3707,7 @@ TEST_F(SyncerTest, ConflictResolverMergesLocalDeleteAndServerUpdate) {
}
mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10,
- local_cache_guid(),
- local_id.GetServerId());
+ local_cache_guid(), local_id.GetServerId());
// We don't care about actually committing, just the resolution.
mock_server_->set_conflict_all_commits(true);
@@ -3767,8 +3734,8 @@ TEST_F(SyncerTest, ConflictResolverAcceptsServerDeleteForExtensions) {
int64_t metahandle;
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry extension(
- &trans, CREATE, EXTENSIONS, trans.root_id(), "extension_name");
+ MutableEntry extension(&trans, CREATE, EXTENSIONS, trans.root_id(),
+ "extension_name");
ASSERT_TRUE(extension.good());
sync_pb::EntitySpecifics specifics;
AddDefaultFieldValue(EXTENSIONS, &specifics);
@@ -3796,7 +3763,6 @@ TEST_F(SyncerTest, ConflictResolverAcceptsServerDeleteForExtensions) {
id = entry.GetId();
}
-
// Simulate another client deleting the item.
{
syncable::ReadTransaction trans(FROM_HERE, directory());
@@ -3840,8 +3806,8 @@ TEST_F(SyncerTest, UpdateFlipsTheFolderBit) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry local_deleted(
- &trans, CREATE, BOOKMARKS, trans.root_id(), "name");
+ MutableEntry local_deleted(&trans, CREATE, BOOKMARKS, trans.root_id(),
+ "name");
local_deleted.PutId(ids_.FromNumber(1));
local_deleted.PutBaseVersion(1);
local_deleted.PutIsDel(true);
@@ -3877,13 +3843,13 @@ TEST_F(SyncerTest, UpdateFlipsTheFolderBit) {
// that needs updates, resulting in CHECK.
TEST_F(SyncerTest, MergingExistingItems) {
mock_server_->set_conflict_all_commits(true);
- mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10,
- local_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10, local_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry entry(
- &trans, CREATE, BOOKMARKS, trans.root_id(), "Copy of base");
+ MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(),
+ "Copy of base");
WriteTestDataToEntry(&trans, &entry);
}
mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50,
@@ -3901,9 +3867,8 @@ TEST_F(SyncerTest, LongChangelistWithApplicationConflict) {
// First we an item in a folder in the root. However the folder won't come
// till much later.
syncable::Id stuck_entry_id = TestIdFactory::FromNumber(99999);
- mock_server_->AddUpdateDirectory(stuck_entry_id,
- folder_id, "stuck", 1, 1,
- foreign_cache_guid(), "-99999");
+ mock_server_->AddUpdateDirectory(stuck_entry_id, folder_id, "stuck", 1, 1,
+ foreign_cache_guid(), "-99999");
mock_server_->SetChangesRemaining(depth - 1);
EXPECT_TRUE(SyncShareNudge());
@@ -3929,9 +3894,8 @@ TEST_F(SyncerTest, LongChangelistWithApplicationConflict) {
}
// And finally the folder.
- mock_server_->AddUpdateDirectory(folder_id,
- TestIdFactory::root(), "folder", 1, 1,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(folder_id, TestIdFactory::root(), "folder",
+ 1, 1, foreign_cache_guid(), "-1");
mock_server_->SetChangesRemaining(0);
EXPECT_TRUE(SyncShareNudge());
EXPECT_TRUE(SyncShareNudge());
@@ -3949,10 +3913,10 @@ TEST_F(SyncerTest, LongChangelistWithApplicationConflict) {
TEST_F(SyncerTest, DontMergeTwoExistingItems) {
mock_server_->set_conflict_all_commits(true);
- mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateBookmark(2, 0, "base2", 10, 10,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateBookmark(2, 0, "base2", 10, 10, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
@@ -3980,13 +3944,13 @@ TEST_F(SyncerTest, DontMergeTwoExistingItems) {
TEST_F(SyncerTest, TestUndeleteUpdate) {
mock_server_->set_conflict_all_commits(true);
- mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateDirectory(2, 1, "bar", 1, 2,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateDirectory(2, 1, "bar", 1, 2, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge());
- mock_server_->AddUpdateDirectory(2, 1, "bar", 2, 3,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(2, 1, "bar", 2, 3, foreign_cache_guid(),
+ "-2");
mock_server_->SetLastUpdateDeleted();
EXPECT_TRUE(SyncShareNudge());
@@ -3998,14 +3962,14 @@ TEST_F(SyncerTest, TestUndeleteUpdate) {
EXPECT_TRUE(entry.GetIsDel());
metahandle = entry.GetMetahandle();
}
- mock_server_->AddUpdateDirectory(1, 0, "foo", 2, 4,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "foo", 2, 4, foreign_cache_guid(),
+ "-1");
mock_server_->SetLastUpdateDeleted();
EXPECT_TRUE(SyncShareNudge());
// This used to be rejected as it's an undeletion. Now, it results in moving
// the delete path aside.
- mock_server_->AddUpdateDirectory(2, 1, "bar", 3, 5,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(2, 1, "bar", 3, 5, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
@@ -4019,10 +3983,10 @@ TEST_F(SyncerTest, TestUndeleteUpdate) {
}
TEST_F(SyncerTest, TestMoveSanitizedNamedFolder) {
- mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateDirectory(2, 0, ":::", 1, 2,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateDirectory(2, 0, ":::", 1, 2, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge());
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
@@ -4033,15 +3997,15 @@ TEST_F(SyncerTest, TestMoveSanitizedNamedFolder) {
}
EXPECT_TRUE(SyncShareNudge());
// We use the same sync ts as before so our times match up.
- mock_server_->AddUpdateDirectory(2, 1, ":::", 2, 2,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateDirectory(2, 1, ":::", 2, 2, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge());
}
// Don't crash when this occurs.
TEST_F(SyncerTest, UpdateWhereParentIsNotAFolder) {
- mock_server_->AddUpdateBookmark(1, 0, "B", 10, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(1, 0, "B", 10, 10, foreign_cache_guid(),
+ "-1");
mock_server_->AddUpdateDirectory(2, 1, "BookmarkParent", 10, 10,
foreign_cache_guid(), "-2");
// Used to cause a CHECK
@@ -4062,11 +4026,10 @@ TEST_F(SyncerTest, DirectoryUpdateTest) {
Id in_in_root_id = ids_.NewServerId();
mock_server_->AddUpdateDirectory(in_root_id, TestIdFactory::root(),
- "in_root_name", 2, 2,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateDirectory(in_in_root_id, in_root_id,
- "in_in_root_name", 3, 3,
- foreign_cache_guid(), "-2");
+ "in_root_name", 2, 2, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateDirectory(in_in_root_id, in_root_id, "in_in_root_name",
+ 3, 3, foreign_cache_guid(), "-2");
EXPECT_TRUE(SyncShareNudge());
{
syncable::ReadTransaction trans(FROM_HERE, directory());
@@ -4137,8 +4100,8 @@ TEST_F(SyncerTest, TestClientCommandDuringUpdate) {
GetSpecificsFieldNumberFromModelType(BOOKMARKS));
bookmark_delay->set_delay_ms(950);
command->set_client_invalidation_hint_buffer_size(11);
- mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1, foreign_cache_guid(),
+ "-1");
mock_server_->SetGUClientCommand(command);
EXPECT_TRUE(SyncShareNudge());
@@ -4157,8 +4120,8 @@ TEST_F(SyncerTest, TestClientCommandDuringUpdate) {
GetSpecificsFieldNumberFromModelType(BOOKMARKS));
bookmark_delay->set_delay_ms(1050);
command->set_client_invalidation_hint_buffer_size(9);
- mock_server_->AddUpdateDirectory(
- 1, 0, "in_root", 1, 1, foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1, foreign_cache_guid(),
+ "-1");
mock_server_->SetGUClientCommand(command);
EXPECT_TRUE(SyncShareNudge());
@@ -4217,9 +4180,11 @@ TEST_F(SyncerTest, EnsureWeSendUpOldParent) {
syncable::Id folder_two_id = ids_.FromNumber(2);
mock_server_->AddUpdateDirectory(folder_one_id, TestIdFactory::root(),
- "folder_one", 1, 1, foreign_cache_guid(), "-1");
+ "folder_one", 1, 1, foreign_cache_guid(),
+ "-1");
mock_server_->AddUpdateDirectory(folder_two_id, TestIdFactory::root(),
- "folder_two", 1, 1, foreign_cache_guid(), "-2");
+ "folder_two", 1, 1, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge());
{
// A moved entry should send an "old parent."
@@ -4229,8 +4194,8 @@ TEST_F(SyncerTest, EnsureWeSendUpOldParent) {
entry.PutParentId(folder_two_id);
entry.PutIsUnsynced(true);
// A new entry should send no "old parent."
- MutableEntry create(
- &trans, CREATE, BOOKMARKS, trans.root_id(), "new_folder");
+ MutableEntry create(&trans, CREATE, BOOKMARKS, trans.root_id(),
+ "new_folder");
create.PutIsUnsynced(true);
create.PutSpecifics(DefaultBookmarkSpecifics());
}
@@ -4268,8 +4233,8 @@ TEST_F(SyncerTest, TestSimpleUndelete) {
Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root();
mock_server_->set_conflict_all_commits(true);
// Let there be an entry from the server.
- mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
// Check it out and delete it.
{
@@ -4295,8 +4260,8 @@ TEST_F(SyncerTest, TestSimpleUndelete) {
}
EXPECT_TRUE(SyncShareNudge());
// Update from server confirming deletion.
- mock_server_->AddUpdateBookmark(id, root, "foo", 2, 11,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(id, root, "foo", 2, 11, foreign_cache_guid(),
+ "-1");
mock_server_->SetLastUpdateDeleted();
EXPECT_TRUE(SyncShareNudge());
// IS_DEL AND SERVER_IS_DEL now both true.
@@ -4310,8 +4275,8 @@ TEST_F(SyncerTest, TestSimpleUndelete) {
EXPECT_TRUE(entry.GetServerIsDel());
}
// Undelete from server.
- mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
// IS_DEL and SERVER_IS_DEL now both false.
{
@@ -4329,8 +4294,8 @@ TEST_F(SyncerTest, TestUndeleteWithMissingDeleteUpdate) {
Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root();
// Let there be a entry, from the server.
mock_server_->set_conflict_all_commits(true);
- mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
// Check it out and delete it.
{
@@ -4357,8 +4322,8 @@ TEST_F(SyncerTest, TestUndeleteWithMissingDeleteUpdate) {
EXPECT_TRUE(SyncShareNudge());
// Say we do not get an update from server confirming deletion. Undelete
// from server
- mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12,
- foreign_cache_guid(), "-1");
+ mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12, foreign_cache_guid(),
+ "-1");
EXPECT_TRUE(SyncShareNudge());
// IS_DEL and SERVER_IS_DEL now both false.
{
@@ -4377,10 +4342,10 @@ TEST_F(SyncerTest, TestUndeleteIgnoreCorrectlyUnappliedUpdate) {
Id root = TestIdFactory::root();
// Duplicate! expect path clashing!
mock_server_->set_conflict_all_commits(true);
- mock_server_->AddUpdateBookmark(id1, root, "foo", 1, 10,
- foreign_cache_guid(), "-1");
- mock_server_->AddUpdateBookmark(id2, root, "foo", 1, 10,
- foreign_cache_guid(), "-2");
+ mock_server_->AddUpdateBookmark(id1, root, "foo", 1, 10, foreign_cache_guid(),
+ "-1");
+ mock_server_->AddUpdateBookmark(id2, root, "foo", 1, 10, foreign_cache_guid(),
+ "-2");
EXPECT_TRUE(SyncShareNudge());
mock_server_->AddUpdateBookmark(id2, root, "foo2", 2, 20,
foreign_cache_guid(), "-2");
@@ -4468,8 +4433,7 @@ TEST_F(SyncerTest, ClientTagUncommittedTagMatchesUpdate) {
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry pref(
- &trans, CREATE, PREFERENCES, ids_.root(), "name");
+ MutableEntry pref(&trans, CREATE, PREFERENCES, ids_.root(), "name");
ASSERT_TRUE(pref.good());
pref.PutUniqueClientTag("tag");
pref.PutIsUnsynced(true);
@@ -4480,8 +4444,7 @@ TEST_F(SyncerTest, ClientTagUncommittedTagMatchesUpdate) {
syncable::Id server_id = TestIdFactory::MakeServer("id");
mock_server_->AddUpdatePref(server_id.GetServerId(),
- ids_.root().GetServerId(),
- "tag", 10, 100);
+ ids_.root().GetServerId(), "tag", 10, 100);
mock_server_->set_conflict_all_commits(true);
EXPECT_FALSE(SyncShareNudge());
@@ -4527,8 +4490,7 @@ TEST_F(SyncerTest, ClientTagConflictWithDeletedLocalEntry) {
{
// Create a deleted local entry with a unique client tag.
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry pref(
- &trans, CREATE, PREFERENCES, ids_.root(), "name");
+ MutableEntry pref(&trans, CREATE, PREFERENCES, ids_.root(), "name");
ASSERT_TRUE(pref.good());
ASSERT_FALSE(pref.GetId().ServerKnows());
pref.PutUniqueClientTag("tag");
@@ -4543,8 +4505,7 @@ TEST_F(SyncerTest, ClientTagConflictWithDeletedLocalEntry) {
// Prepare an update with the same unique client tag.
syncable::Id server_id = TestIdFactory::MakeServer("id");
mock_server_->AddUpdatePref(server_id.GetServerId(),
- ids_.root().GetServerId(),
- "tag", 10, 100);
+ ids_.root().GetServerId(), "tag", 10, 100);
EXPECT_TRUE(SyncShareNudge());
// The local entry will be overwritten.
@@ -4826,11 +4787,11 @@ TEST_F(SyncerTest, UniqueServerTagUpdates) {
}
// Now download some tagged items as updates.
- mock_server_->AddUpdateDirectory(
- 1, 0, "update1", 1, 10, std::string(), std::string());
+ mock_server_->AddUpdateDirectory(1, 0, "update1", 1, 10, std::string(),
+ std::string());
mock_server_->SetLastUpdateServerTag("alpha");
- mock_server_->AddUpdateDirectory(
- 2, 0, "update2", 2, 20, std::string(), std::string());
+ mock_server_->AddUpdateDirectory(2, 0, "update2", 2, 20, std::string(),
+ std::string());
mock_server_->SetLastUpdateServerTag("bob");
EXPECT_TRUE(SyncShareNudge());
@@ -5074,13 +5035,11 @@ TEST_F(SyncerTest, ProgressMarkerOnlyUpdateCreatesRootFolder) {
// and hence are not covered by e.g. the Undeletion tests below.
class SyncerBookmarksTest : public SyncerTest {
public:
- SyncerBookmarksTest() : metahandle_(syncable::kInvalidMetaHandle) {
- }
+ SyncerBookmarksTest() : metahandle_(syncable::kInvalidMetaHandle) {}
void Create() {
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry bookmark(
- &trans, CREATE, BOOKMARKS, ids_.root(), "clientname");
+ MutableEntry bookmark(&trans, CREATE, BOOKMARKS, ids_.root(), "clientname");
ASSERT_TRUE(bookmark.good());
bookmark.PutSpecifics(DefaultBookmarkSpecifics());
EXPECT_FALSE(bookmark.GetIsUnappliedUpdate());
@@ -5333,14 +5292,12 @@ TEST_F(SyncerBookmarksTest, CreateThenUpdateAndDeleteDuringCommit) {
class SyncerUndeletionTest : public SyncerTest {
public:
SyncerUndeletionTest()
- : client_tag_("foobar"),
- metahandle_(syncable::kInvalidMetaHandle) {
- }
+ : client_tag_("foobar"), metahandle_(syncable::kInvalidMetaHandle) {}
void Create() {
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- MutableEntry perm_folder(
- &trans, CREATE, PREFERENCES, ids_.root(), "clientname");
+ MutableEntry perm_folder(&trans, CREATE, PREFERENCES, ids_.root(),
+ "clientname");
ASSERT_TRUE(perm_folder.good());
perm_folder.PutUniqueClientTag(client_tag_);
perm_folder.PutIsUnsynced(true);
@@ -5771,10 +5728,9 @@ TEST_F(SyncerUndeletionTest, OtherClientUndeletes) {
{
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
- mock_server_->AddUpdatePref(
- entry.GetId().GetServerId(),
- entry.GetParentId().GetServerId(),
- client_tag_, 100, 1000);
+ mock_server_->AddUpdatePref(entry.GetId().GetServerId(),
+ entry.GetParentId().GetServerId(), client_tag_,
+ 100, 1000);
}
mock_server_->SetLastUpdateClientTag(client_tag_);
EXPECT_TRUE(SyncShareNudge());
@@ -5820,10 +5776,9 @@ TEST_F(SyncerUndeletionTest, OtherClientUndeletesImmediately) {
{
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, GET_BY_HANDLE, metahandle_);
- mock_server_->AddUpdatePref(
- entry.GetId().GetServerId(),
- entry.GetParentId().GetServerId(),
- client_tag_, 100, 1000);
+ mock_server_->AddUpdatePref(entry.GetId().GetServerId(),
+ entry.GetParentId().GetServerId(), client_tag_,
+ 100, 1000);
}
mock_server_->SetLastUpdateClientTag(client_tag_);
EXPECT_TRUE(SyncShareNudge());
@@ -5838,9 +5793,8 @@ enum {
TEST_PARAM_BIT_COUNT
};
-class MixedResult :
- public SyncerTest,
- public ::testing::WithParamInterface<int> {
+class MixedResult : public SyncerTest,
+ public ::testing::WithParamInterface<int> {
protected:
bool ShouldFailBookmarkCommit() {
return (GetParam() & (1 << TEST_PARAM_BOOKMARK_ENABLE_BIT)) == 0;
@@ -5862,8 +5816,8 @@ TEST_P(MixedResult, ExtensionsActivity) {
ASSERT_TRUE(pref.good());
pref.PutIsUnsynced(true);
- MutableEntry bookmark(
- &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "bookmark");
+ MutableEntry bookmark(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(),
+ "bookmark");
ASSERT_TRUE(bookmark.good());
bookmark.PutIsUnsynced(true);
@@ -5897,7 +5851,7 @@ TEST_P(MixedResult, ExtensionsActivity) {
EXPECT_EQ("ABC", final_monitor_records["ABC"].extension_id);
EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
- EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
+ EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
} else {
EXPECT_TRUE(final_monitor_records.empty())
<< "Should not restore records after successful bookmark commit.";
« no previous file with comments | « components/sync/engine_impl/syncer_types.h ('k') | components/sync/engine_impl/syncer_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698