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

Unified Diff: sync/engine/syncer_unittest.cc

Issue 14963002: sync: Report GetUpdate triggers to the server (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review response: lots of renames Created 7 years, 7 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: sync/engine/syncer_unittest.cc
diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc
index 196f77ac195d10691ea22c9552686ac9acf7c3ef..cb698c44149649ccf892574595372fc0d3757341 100644
--- a/sync/engine/syncer_unittest.cc
+++ b/sync/engine/syncer_unittest.cc
@@ -171,23 +171,36 @@ class SyncerTest : public testing::Test,
saw_syncer_event_ = true;
}
- SyncSession* MakeSession() {
+ void SyncShareNudge() {
ModelSafeRoutingInfo info;
GetModelSafeRoutingInfo(&info);
ModelTypeInvalidationMap invalidation_map =
ModelSafeRoutingInfoToInvalidationMap(info, std::string());
- sessions::SyncSourceInfo source_info(sync_pb::GetUpdatesCallerInfo::UNKNOWN,
- invalidation_map);
- return new SyncSession(context_.get(), this, source_info);
- }
+ sessions::SyncSourceInfo source_info(
+ sync_pb::GetUpdatesCallerInfo::LOCAL,
+ invalidation_map);
+ // Use our dummy nudge tracker. These tests won't notice that it hasn't
+ // been tracking anything.
tim (not reviewing) 2013/05/07 20:34:13 "... because they don't target scheduling logic an
rlarocque 2013/05/07 21:50:57 Done.
+ session_.reset(
+ SyncSession::BuildForNudge(context_.get(),
+ this,
+ source_info,
+ &nudge_tracker_));
- void SyncShareNudge() {
- session_.reset(MakeSession());
EXPECT_TRUE(syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END));
}
void SyncShareConfigure() {
- session_.reset(MakeSession());
+ ModelSafeRoutingInfo info;
+ GetModelSafeRoutingInfo(&info);
+ ModelTypeInvalidationMap invalidation_map =
+ ModelSafeRoutingInfoToInvalidationMap(info, std::string());
+ sessions::SyncSourceInfo source_info(
+ sync_pb::GetUpdatesCallerInfo::RECONFIGURATION,
+ invalidation_map);
+ session_.reset(SyncSession::BuildForNonNudge(context_.get(),
+ this,
+ source_info));
EXPECT_TRUE(
syncer_->SyncShare(session_.get(), DOWNLOAD_UPDATES, APPLY_UPDATES));
}
@@ -220,7 +233,6 @@ class SyncerTest : public testing::Test,
"fake_invalidator_client_id"));
context_->set_routing_info(routing_info);
syncer_ = new Syncer();
- session_.reset(MakeSession());
syncable::ReadTransaction trans(FROM_HERE, directory());
syncable::Directory::ChildHandles children;
@@ -567,6 +579,7 @@ class SyncerTest : public testing::Test,
ModelTypeSet enabled_datatypes_;
TrafficRecorder traffic_recorder_;
+ sessions::NudgeTracker nudge_tracker_;
DISALLOW_COPY_AND_ASSIGN(SyncerTest);
};
@@ -2242,7 +2255,7 @@ TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) {
mock_server_->SetMidCommitCallback(
base::Bind(&EntryCreatedInNewFolderTest::CreateFolderInBob,
base::Unretained(this)));
- syncer_->SyncShare(session_.get(), COMMIT, SYNCER_END);
+ SyncShareNudge();
// We loop until no unsynced handles remain, so we will commit both ids.
EXPECT_EQ(2u, mock_server_->committed_ids().size());
{
@@ -2480,8 +2493,7 @@ TEST_F(SyncerTest, UnappliedUpdateDuringCommit) {
entry.Put(SERVER_SPECIFICS, DefaultBookmarkSpecifics());
entry.Put(IS_DEL, false);
}
- syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END);
- syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END);
+ SyncShareNudge();
EXPECT_EQ(1, session_->status_controller().TotalNumConflictingItems());
saw_syncer_event_ = false;
}
@@ -2508,7 +2520,7 @@ TEST_F(SyncerTest, DeletingEntryInFolder) {
entry.Put(IS_UNSYNCED, true);
existing_metahandle = entry.Get(META_HANDLE);
}
- syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END);
+ SyncShareNudge();
{
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
MutableEntry newfolder(&trans, CREATE, BOOKMARKS, trans.root_id(), "new");
@@ -2526,7 +2538,7 @@ TEST_F(SyncerTest, DeletingEntryInFolder) {
newfolder.Put(IS_DEL, true);
existing.Put(IS_DEL, true);
}
- syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END);
+ SyncShareNudge();
EXPECT_EQ(0, status().num_server_conflicts());
}
@@ -2549,7 +2561,7 @@ TEST_F(SyncerTest, DeletingEntryWithLocalEdits) {
mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20,
foreign_cache_guid(), "-1");
mock_server_->SetLastUpdateDeleted();
- syncer_->SyncShare(session_.get(), SYNCER_BEGIN, APPLY_UPDATES);
+ SyncShareConfigure();
{
syncable::ReadTransaction trans(FROM_HERE, directory());
Entry entry(&trans, syncable::GET_BY_HANDLE, newfolder_metahandle);
@@ -3204,7 +3216,7 @@ TEST_F(SyncerTest, LongChangelistWithApplicationConflict) {
folder_id, "stuck", 1, 1,
foreign_cache_guid(), "-99999");
mock_server_->SetChangesRemaining(depth - 1);
- syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END);
+ SyncShareNudge();
// Buffer up a very long series of downloads.
// We should never be stuck (conflict resolution shouldn't

Powered by Google App Engine
This is Rietveld 408576698