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

Side by Side 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: Fix handling of NEW_CLIENT GU source 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 unified diff | Download patch
« no previous file with comments | « sync/engine/syncer_proto_util_unittest.cc ('k') | sync/internal_api/sync_manager_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Syncer unit tests. Unfortunately a lot of these tests 5 // Syncer unit tests. Unfortunately a lot of these tests
6 // are outdated and need to be reworked and updated. 6 // are outdated and need to be reworked and updated.
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <limits> 9 #include <limits>
10 #include <list> 10 #include <list>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 using sessions::SyncSessionContext; 109 using sessions::SyncSessionContext;
110 using sessions::SyncSession; 110 using sessions::SyncSession;
111 111
112 class SyncerTest : public testing::Test, 112 class SyncerTest : public testing::Test,
113 public SyncSession::Delegate, 113 public SyncSession::Delegate,
114 public SyncEngineEventListener { 114 public SyncEngineEventListener {
115 protected: 115 protected:
116 SyncerTest() 116 SyncerTest()
117 : syncer_(NULL), 117 : syncer_(NULL),
118 saw_syncer_event_(false), 118 saw_syncer_event_(false),
119 last_client_invalidation_hint_buffer_size_(10),
119 traffic_recorder_(0, 0) { 120 traffic_recorder_(0, 0) {
120 } 121 }
121 122
122 // SyncSession::Delegate implementation. 123 // SyncSession::Delegate implementation.
123 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) OVERRIDE { 124 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) OVERRIDE {
124 FAIL() << "Should not get silenced."; 125 FAIL() << "Should not get silenced.";
125 } 126 }
126 virtual bool IsSyncingCurrentlySilenced() OVERRIDE { 127 virtual bool IsSyncingCurrentlySilenced() OVERRIDE {
127 return false; 128 return false;
128 } 129 }
129 virtual void OnReceivedLongPollIntervalUpdate( 130 virtual void OnReceivedLongPollIntervalUpdate(
130 const base::TimeDelta& new_interval) OVERRIDE { 131 const base::TimeDelta& new_interval) OVERRIDE {
131 last_long_poll_interval_received_ = new_interval; 132 last_long_poll_interval_received_ = new_interval;
132 } 133 }
133 virtual void OnReceivedShortPollIntervalUpdate( 134 virtual void OnReceivedShortPollIntervalUpdate(
134 const base::TimeDelta& new_interval) OVERRIDE { 135 const base::TimeDelta& new_interval) OVERRIDE {
135 last_short_poll_interval_received_ = new_interval; 136 last_short_poll_interval_received_ = new_interval;
136 } 137 }
137 virtual void OnReceivedSessionsCommitDelay( 138 virtual void OnReceivedSessionsCommitDelay(
138 const base::TimeDelta& new_delay) OVERRIDE { 139 const base::TimeDelta& new_delay) OVERRIDE {
139 last_sessions_commit_delay_seconds_ = new_delay; 140 last_sessions_commit_delay_seconds_ = new_delay;
140 } 141 }
142 virtual void OnReceivedClientInvalidationHintBufferSize(
143 int size) OVERRIDE {
144 last_client_invalidation_hint_buffer_size_ = size;
145 }
141 virtual void OnShouldStopSyncingPermanently() OVERRIDE { 146 virtual void OnShouldStopSyncingPermanently() OVERRIDE {
142 } 147 }
143 virtual void OnSyncProtocolError( 148 virtual void OnSyncProtocolError(
144 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE { 149 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE {
145 } 150 }
146 151
147 void GetWorkers(std::vector<ModelSafeWorker*>* out) { 152 void GetWorkers(std::vector<ModelSafeWorker*>* out) {
148 out->push_back(worker_.get()); 153 out->push_back(worker_.get());
149 } 154 }
150 155
(...skipping 13 matching lines...) Expand all
164 case SyncEngineEvent::SYNC_CYCLE_BEGIN: // Fall through. 169 case SyncEngineEvent::SYNC_CYCLE_BEGIN: // Fall through.
165 case SyncEngineEvent::STATUS_CHANGED: 170 case SyncEngineEvent::STATUS_CHANGED:
166 case SyncEngineEvent::SYNC_CYCLE_ENDED: 171 case SyncEngineEvent::SYNC_CYCLE_ENDED:
167 return; 172 return;
168 default: 173 default:
169 CHECK(false) << "Handling unknown error type in unit tests!!"; 174 CHECK(false) << "Handling unknown error type in unit tests!!";
170 } 175 }
171 saw_syncer_event_ = true; 176 saw_syncer_event_ = true;
172 } 177 }
173 178
174 SyncSession* MakeSession() { 179 void SyncShareNudge() {
175 ModelSafeRoutingInfo info; 180 ModelSafeRoutingInfo info;
176 GetModelSafeRoutingInfo(&info); 181 GetModelSafeRoutingInfo(&info);
177 ModelTypeInvalidationMap invalidation_map = 182 ModelTypeInvalidationMap invalidation_map =
178 ModelSafeRoutingInfoToInvalidationMap(info, std::string()); 183 ModelSafeRoutingInfoToInvalidationMap(info, std::string());
179 sessions::SyncSourceInfo source_info(sync_pb::GetUpdatesCallerInfo::UNKNOWN, 184 sessions::SyncSourceInfo source_info(
180 invalidation_map); 185 sync_pb::GetUpdatesCallerInfo::LOCAL,
181 return new SyncSession(context_.get(), this, source_info); 186 invalidation_map);
182 } 187 // Use our dummy nudge tracker. These tests won't notice that it hasn't
188 // been tracking anything because the server is mocked out and ignores most
189 // of the content of requests sent by the client.
190 session_.reset(
191 SyncSession::BuildForNudge(context_.get(),
192 this,
193 source_info,
194 &nudge_tracker_));
183 195
184 void SyncShareNudge() {
185 session_.reset(MakeSession());
186 EXPECT_TRUE(syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END)); 196 EXPECT_TRUE(syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END));
187 } 197 }
188 198
189 void SyncShareConfigure() { 199 void SyncShareConfigure() {
190 session_.reset(MakeSession()); 200 ModelSafeRoutingInfo info;
201 GetModelSafeRoutingInfo(&info);
202 ModelTypeInvalidationMap invalidation_map =
203 ModelSafeRoutingInfoToInvalidationMap(info, std::string());
204 sessions::SyncSourceInfo source_info(
205 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION,
206 invalidation_map);
207 session_.reset(SyncSession::Build(context_.get(),
208 this,
209 source_info));
191 EXPECT_TRUE( 210 EXPECT_TRUE(
192 syncer_->SyncShare(session_.get(), DOWNLOAD_UPDATES, APPLY_UPDATES)); 211 syncer_->SyncShare(session_.get(), DOWNLOAD_UPDATES, APPLY_UPDATES));
193 } 212 }
194 213
195 virtual void SetUp() { 214 virtual void SetUp() {
196 dir_maker_.SetUp(); 215 dir_maker_.SetUp();
197 mock_server_.reset(new MockConnectionManager(directory())); 216 mock_server_.reset(new MockConnectionManager(directory()));
198 EnableDatatype(BOOKMARKS); 217 EnableDatatype(BOOKMARKS);
199 EnableDatatype(NIGORI); 218 EnableDatatype(NIGORI);
200 EnableDatatype(PREFERENCES); 219 EnableDatatype(PREFERENCES);
(...skipping 12 matching lines...) Expand all
213 232
214 context_.reset( 233 context_.reset(
215 new SyncSessionContext( 234 new SyncSessionContext(
216 mock_server_.get(), directory(), workers, 235 mock_server_.get(), directory(), workers,
217 &extensions_activity_monitor_, throttled_data_type_tracker_.get(), 236 &extensions_activity_monitor_, throttled_data_type_tracker_.get(),
218 listeners, NULL, &traffic_recorder_, 237 listeners, NULL, &traffic_recorder_,
219 true, // enable keystore encryption 238 true, // enable keystore encryption
220 "fake_invalidator_client_id")); 239 "fake_invalidator_client_id"));
221 context_->set_routing_info(routing_info); 240 context_->set_routing_info(routing_info);
222 syncer_ = new Syncer(); 241 syncer_ = new Syncer();
223 session_.reset(MakeSession());
224 242
225 syncable::ReadTransaction trans(FROM_HERE, directory()); 243 syncable::ReadTransaction trans(FROM_HERE, directory());
226 syncable::Directory::ChildHandles children; 244 syncable::Directory::ChildHandles children;
227 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); 245 directory()->GetChildHandlesById(&trans, trans.root_id(), &children);
228 ASSERT_EQ(0u, children.size()); 246 ASSERT_EQ(0u, children.size());
229 saw_syncer_event_ = false; 247 saw_syncer_event_ = false;
230 root_id_ = TestIdFactory::root(); 248 root_id_ = TestIdFactory::root();
231 parent_id_ = ids_.MakeServer("parent id"); 249 parent_id_ = ids_.MakeServer("parent id");
232 child_id_ = ids_.MakeServer("child id"); 250 child_id_ = ids_.MakeServer("child id");
233 directory()->set_store_birthday(mock_server_->store_birthday()); 251 directory()->set_store_birthday(mock_server_->store_birthday());
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 scoped_ptr<MockConnectionManager> mock_server_; 574 scoped_ptr<MockConnectionManager> mock_server_;
557 575
558 Syncer* syncer_; 576 Syncer* syncer_;
559 577
560 scoped_ptr<SyncSession> session_; 578 scoped_ptr<SyncSession> session_;
561 scoped_ptr<SyncSessionContext> context_; 579 scoped_ptr<SyncSessionContext> context_;
562 bool saw_syncer_event_; 580 bool saw_syncer_event_;
563 base::TimeDelta last_short_poll_interval_received_; 581 base::TimeDelta last_short_poll_interval_received_;
564 base::TimeDelta last_long_poll_interval_received_; 582 base::TimeDelta last_long_poll_interval_received_;
565 base::TimeDelta last_sessions_commit_delay_seconds_; 583 base::TimeDelta last_sessions_commit_delay_seconds_;
584 int last_client_invalidation_hint_buffer_size_;
566 scoped_refptr<ModelSafeWorker> worker_; 585 scoped_refptr<ModelSafeWorker> worker_;
567 586
568 ModelTypeSet enabled_datatypes_; 587 ModelTypeSet enabled_datatypes_;
569 TrafficRecorder traffic_recorder_; 588 TrafficRecorder traffic_recorder_;
589 sessions::NudgeTracker nudge_tracker_;
570 590
571 DISALLOW_COPY_AND_ASSIGN(SyncerTest); 591 DISALLOW_COPY_AND_ASSIGN(SyncerTest);
572 }; 592 };
573 593
574 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { 594 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) {
575 { 595 {
576 Syncer::UnsyncedMetaHandles handles; 596 Syncer::UnsyncedMetaHandles handles;
577 { 597 {
578 syncable::ReadTransaction trans(FROM_HERE, directory()); 598 syncable::ReadTransaction trans(FROM_HERE, directory());
579 GetUnsyncedEntries(&trans, &handles); 599 GetUnsyncedEntries(&trans, &handles);
(...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "bob"); 2255 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "bob");
2236 ASSERT_TRUE(entry.good()); 2256 ASSERT_TRUE(entry.good());
2237 entry.Put(syncable::IS_DIR, true); 2257 entry.Put(syncable::IS_DIR, true);
2238 entry.Put(syncable::IS_UNSYNCED, true); 2258 entry.Put(syncable::IS_UNSYNCED, true);
2239 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); 2259 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
2240 } 2260 }
2241 2261
2242 mock_server_->SetMidCommitCallback( 2262 mock_server_->SetMidCommitCallback(
2243 base::Bind(&EntryCreatedInNewFolderTest::CreateFolderInBob, 2263 base::Bind(&EntryCreatedInNewFolderTest::CreateFolderInBob,
2244 base::Unretained(this))); 2264 base::Unretained(this)));
2245 syncer_->SyncShare(session_.get(), COMMIT, SYNCER_END); 2265 SyncShareNudge();
2246 // We loop until no unsynced handles remain, so we will commit both ids. 2266 // We loop until no unsynced handles remain, so we will commit both ids.
2247 EXPECT_EQ(2u, mock_server_->committed_ids().size()); 2267 EXPECT_EQ(2u, mock_server_->committed_ids().size());
2248 { 2268 {
2249 syncable::ReadTransaction trans(FROM_HERE, directory()); 2269 syncable::ReadTransaction trans(FROM_HERE, directory());
2250 Entry parent_entry(&trans, syncable::GET_BY_ID, 2270 Entry parent_entry(&trans, syncable::GET_BY_ID,
2251 GetOnlyEntryWithName(&trans, TestIdFactory::root(), "bob")); 2271 GetOnlyEntryWithName(&trans, TestIdFactory::root(), "bob"));
2252 ASSERT_TRUE(parent_entry.good()); 2272 ASSERT_TRUE(parent_entry.good());
2253 2273
2254 Id child_id = 2274 Id child_id =
2255 GetOnlyEntryWithName(&trans, parent_entry.Get(ID), "bob"); 2275 GetOnlyEntryWithName(&trans, parent_entry.Get(ID), "bob");
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 entry.Put(ID, ids_.FromNumber(20)); 2493 entry.Put(ID, ids_.FromNumber(20));
2474 entry.Put(BASE_VERSION, 1); 2494 entry.Put(BASE_VERSION, 1);
2475 entry.Put(SERVER_VERSION, 1); 2495 entry.Put(SERVER_VERSION, 1);
2476 entry.Put(SERVER_PARENT_ID, ids_.FromNumber(9999)); // Bad parent. 2496 entry.Put(SERVER_PARENT_ID, ids_.FromNumber(9999)); // Bad parent.
2477 entry.Put(IS_UNSYNCED, true); 2497 entry.Put(IS_UNSYNCED, true);
2478 entry.Put(IS_UNAPPLIED_UPDATE, true); 2498 entry.Put(IS_UNAPPLIED_UPDATE, true);
2479 entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); 2499 entry.Put(SPECIFICS, DefaultBookmarkSpecifics());
2480 entry.Put(SERVER_SPECIFICS, DefaultBookmarkSpecifics()); 2500 entry.Put(SERVER_SPECIFICS, DefaultBookmarkSpecifics());
2481 entry.Put(IS_DEL, false); 2501 entry.Put(IS_DEL, false);
2482 } 2502 }
2483 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); 2503 SyncShareNudge();
2484 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END);
2485 EXPECT_EQ(1, session_->status_controller().TotalNumConflictingItems()); 2504 EXPECT_EQ(1, session_->status_controller().TotalNumConflictingItems());
2486 saw_syncer_event_ = false; 2505 saw_syncer_event_ = false;
2487 } 2506 }
2488 2507
2489 // Original problem synopsis: 2508 // Original problem synopsis:
2490 // Illegal parent 2509 // Illegal parent
2491 // Unexpected error during sync if we: 2510 // Unexpected error during sync if we:
2492 // make a new folder bob 2511 // make a new folder bob
2493 // wait for sync 2512 // wait for sync
2494 // make a new folder fred 2513 // make a new folder fred
2495 // move bob into fred 2514 // move bob into fred
2496 // remove bob 2515 // remove bob
2497 // remove fred 2516 // remove fred
2498 // if no syncing occured midway, bob will have an illegal parent 2517 // if no syncing occured midway, bob will have an illegal parent
2499 TEST_F(SyncerTest, DeletingEntryInFolder) { 2518 TEST_F(SyncerTest, DeletingEntryInFolder) {
2500 // This test is a little fake. 2519 // This test is a little fake.
2501 int64 existing_metahandle; 2520 int64 existing_metahandle;
2502 { 2521 {
2503 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); 2522 WriteTransaction trans(FROM_HERE, UNITTEST, directory());
2504 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "existing"); 2523 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "existing");
2505 ASSERT_TRUE(entry.good()); 2524 ASSERT_TRUE(entry.good());
2506 entry.Put(IS_DIR, true); 2525 entry.Put(IS_DIR, true);
2507 entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); 2526 entry.Put(SPECIFICS, DefaultBookmarkSpecifics());
2508 entry.Put(IS_UNSYNCED, true); 2527 entry.Put(IS_UNSYNCED, true);
2509 existing_metahandle = entry.Get(META_HANDLE); 2528 existing_metahandle = entry.Get(META_HANDLE);
2510 } 2529 }
2511 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); 2530 SyncShareNudge();
2512 { 2531 {
2513 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); 2532 WriteTransaction trans(FROM_HERE, UNITTEST, directory());
2514 MutableEntry newfolder(&trans, CREATE, BOOKMARKS, trans.root_id(), "new"); 2533 MutableEntry newfolder(&trans, CREATE, BOOKMARKS, trans.root_id(), "new");
2515 ASSERT_TRUE(newfolder.good()); 2534 ASSERT_TRUE(newfolder.good());
2516 newfolder.Put(IS_DIR, true); 2535 newfolder.Put(IS_DIR, true);
2517 newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics()); 2536 newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics());
2518 newfolder.Put(IS_UNSYNCED, true); 2537 newfolder.Put(IS_UNSYNCED, true);
2519 2538
2520 MutableEntry existing(&trans, GET_BY_HANDLE, existing_metahandle); 2539 MutableEntry existing(&trans, GET_BY_HANDLE, existing_metahandle);
2521 ASSERT_TRUE(existing.good()); 2540 ASSERT_TRUE(existing.good());
2522 existing.Put(PARENT_ID, newfolder.Get(ID)); 2541 existing.Put(PARENT_ID, newfolder.Get(ID));
2523 existing.Put(IS_UNSYNCED, true); 2542 existing.Put(IS_UNSYNCED, true);
2524 EXPECT_TRUE(existing.Get(ID).ServerKnows()); 2543 EXPECT_TRUE(existing.Get(ID).ServerKnows());
2525 2544
2526 newfolder.Put(IS_DEL, true); 2545 newfolder.Put(IS_DEL, true);
2527 existing.Put(IS_DEL, true); 2546 existing.Put(IS_DEL, true);
2528 } 2547 }
2529 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); 2548 SyncShareNudge();
2530 EXPECT_EQ(0, status().num_server_conflicts()); 2549 EXPECT_EQ(0, status().num_server_conflicts());
2531 } 2550 }
2532 2551
2533 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { 2552 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) {
2534 int64 newfolder_metahandle; 2553 int64 newfolder_metahandle;
2535 2554
2536 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10, 2555 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10,
2537 foreign_cache_guid(), "-1"); 2556 foreign_cache_guid(), "-1");
2538 SyncShareNudge(); 2557 SyncShareNudge();
2539 { 2558 {
2540 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); 2559 WriteTransaction trans(FROM_HERE, UNITTEST, directory());
2541 MutableEntry newfolder( 2560 MutableEntry newfolder(
2542 &trans, CREATE, BOOKMARKS, ids_.FromNumber(1), "local"); 2561 &trans, CREATE, BOOKMARKS, ids_.FromNumber(1), "local");
2543 ASSERT_TRUE(newfolder.good()); 2562 ASSERT_TRUE(newfolder.good());
2544 newfolder.Put(IS_UNSYNCED, true); 2563 newfolder.Put(IS_UNSYNCED, true);
2545 newfolder.Put(IS_DIR, true); 2564 newfolder.Put(IS_DIR, true);
2546 newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics()); 2565 newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics());
2547 newfolder_metahandle = newfolder.Get(META_HANDLE); 2566 newfolder_metahandle = newfolder.Get(META_HANDLE);
2548 } 2567 }
2549 mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20, 2568 mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20,
2550 foreign_cache_guid(), "-1"); 2569 foreign_cache_guid(), "-1");
2551 mock_server_->SetLastUpdateDeleted(); 2570 mock_server_->SetLastUpdateDeleted();
2552 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, APPLY_UPDATES); 2571 SyncShareConfigure();
2553 { 2572 {
2554 syncable::ReadTransaction trans(FROM_HERE, directory()); 2573 syncable::ReadTransaction trans(FROM_HERE, directory());
2555 Entry entry(&trans, syncable::GET_BY_HANDLE, newfolder_metahandle); 2574 Entry entry(&trans, syncable::GET_BY_HANDLE, newfolder_metahandle);
2556 ASSERT_TRUE(entry.good()); 2575 ASSERT_TRUE(entry.good());
2557 } 2576 }
2558 } 2577 }
2559 2578
2560 TEST_F(SyncerTest, FolderSwapUpdate) { 2579 TEST_F(SyncerTest, FolderSwapUpdate) {
2561 mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10, 2580 mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10,
2562 foreign_cache_guid(), "-7801"); 2581 foreign_cache_guid(), "-7801");
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 const int depth = 400; 3216 const int depth = 400;
3198 syncable::Id folder_id = ids_.FromNumber(1); 3217 syncable::Id folder_id = ids_.FromNumber(1);
3199 3218
3200 // First we an item in a folder in the root. However the folder won't come 3219 // First we an item in a folder in the root. However the folder won't come
3201 // till much later. 3220 // till much later.
3202 syncable::Id stuck_entry_id = TestIdFactory::FromNumber(99999); 3221 syncable::Id stuck_entry_id = TestIdFactory::FromNumber(99999);
3203 mock_server_->AddUpdateDirectory(stuck_entry_id, 3222 mock_server_->AddUpdateDirectory(stuck_entry_id,
3204 folder_id, "stuck", 1, 1, 3223 folder_id, "stuck", 1, 1,
3205 foreign_cache_guid(), "-99999"); 3224 foreign_cache_guid(), "-99999");
3206 mock_server_->SetChangesRemaining(depth - 1); 3225 mock_server_->SetChangesRemaining(depth - 1);
3207 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); 3226 SyncShareNudge();
3208 3227
3209 // Buffer up a very long series of downloads. 3228 // Buffer up a very long series of downloads.
3210 // We should never be stuck (conflict resolution shouldn't 3229 // We should never be stuck (conflict resolution shouldn't
3211 // kick in so long as we're making forward progress). 3230 // kick in so long as we're making forward progress).
3212 for (int i = 0; i < depth; i++) { 3231 for (int i = 0; i < depth; i++) {
3213 mock_server_->NextUpdateBatch(); 3232 mock_server_->NextUpdateBatch();
3214 mock_server_->SetNewTimestamp(i + 1); 3233 mock_server_->SetNewTimestamp(i + 1);
3215 mock_server_->SetChangesRemaining(depth - i); 3234 mock_server_->SetChangesRemaining(depth - i);
3216 } 3235 }
3217 3236
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
3425 } 3444 }
3426 } 3445 }
3427 3446
3428 TEST_F(SyncerTest, TestClientCommandDuringUpdate) { 3447 TEST_F(SyncerTest, TestClientCommandDuringUpdate) {
3429 using sync_pb::ClientCommand; 3448 using sync_pb::ClientCommand;
3430 3449
3431 ClientCommand* command = new ClientCommand(); 3450 ClientCommand* command = new ClientCommand();
3432 command->set_set_sync_poll_interval(8); 3451 command->set_set_sync_poll_interval(8);
3433 command->set_set_sync_long_poll_interval(800); 3452 command->set_set_sync_long_poll_interval(800);
3434 command->set_sessions_commit_delay_seconds(3141); 3453 command->set_sessions_commit_delay_seconds(3141);
3454 command->set_client_invalidation_hint_buffer_size(11);
3435 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1, 3455 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1,
3436 foreign_cache_guid(), "-1"); 3456 foreign_cache_guid(), "-1");
3437 mock_server_->SetGUClientCommand(command); 3457 mock_server_->SetGUClientCommand(command);
3438 SyncShareNudge(); 3458 SyncShareNudge();
3439 3459
3440 EXPECT_TRUE(TimeDelta::FromSeconds(8) == 3460 EXPECT_TRUE(TimeDelta::FromSeconds(8) ==
3441 last_short_poll_interval_received_); 3461 last_short_poll_interval_received_);
3442 EXPECT_TRUE(TimeDelta::FromSeconds(800) == 3462 EXPECT_TRUE(TimeDelta::FromSeconds(800) ==
3443 last_long_poll_interval_received_); 3463 last_long_poll_interval_received_);
3444 EXPECT_TRUE(TimeDelta::FromSeconds(3141) == 3464 EXPECT_TRUE(TimeDelta::FromSeconds(3141) ==
3445 last_sessions_commit_delay_seconds_); 3465 last_sessions_commit_delay_seconds_);
3466 EXPECT_EQ(11, last_client_invalidation_hint_buffer_size_);
3446 3467
3447 command = new ClientCommand(); 3468 command = new ClientCommand();
3448 command->set_set_sync_poll_interval(180); 3469 command->set_set_sync_poll_interval(180);
3449 command->set_set_sync_long_poll_interval(190); 3470 command->set_set_sync_long_poll_interval(190);
3450 command->set_sessions_commit_delay_seconds(2718); 3471 command->set_sessions_commit_delay_seconds(2718);
3472 command->set_client_invalidation_hint_buffer_size(9);
3451 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1, 3473 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1,
3452 foreign_cache_guid(), "-1"); 3474 foreign_cache_guid(), "-1");
3453 mock_server_->SetGUClientCommand(command); 3475 mock_server_->SetGUClientCommand(command);
3454 SyncShareNudge(); 3476 SyncShareNudge();
3455 3477
3456 EXPECT_TRUE(TimeDelta::FromSeconds(180) == 3478 EXPECT_TRUE(TimeDelta::FromSeconds(180) ==
3457 last_short_poll_interval_received_); 3479 last_short_poll_interval_received_);
3458 EXPECT_TRUE(TimeDelta::FromSeconds(190) == 3480 EXPECT_TRUE(TimeDelta::FromSeconds(190) ==
3459 last_long_poll_interval_received_); 3481 last_long_poll_interval_received_);
3460 EXPECT_TRUE(TimeDelta::FromSeconds(2718) == 3482 EXPECT_TRUE(TimeDelta::FromSeconds(2718) ==
3461 last_sessions_commit_delay_seconds_); 3483 last_sessions_commit_delay_seconds_);
3484 EXPECT_EQ(9, last_client_invalidation_hint_buffer_size_);
3462 } 3485 }
3463 3486
3464 TEST_F(SyncerTest, TestClientCommandDuringCommit) { 3487 TEST_F(SyncerTest, TestClientCommandDuringCommit) {
3465 using sync_pb::ClientCommand; 3488 using sync_pb::ClientCommand;
3466 3489
3467 ClientCommand* command = new ClientCommand(); 3490 ClientCommand* command = new ClientCommand();
3468 command->set_set_sync_poll_interval(8); 3491 command->set_set_sync_poll_interval(8);
3469 command->set_set_sync_long_poll_interval(800); 3492 command->set_set_sync_long_poll_interval(800);
3470 command->set_sessions_commit_delay_seconds(3141); 3493 command->set_sessions_commit_delay_seconds(3141);
3494 command->set_client_invalidation_hint_buffer_size(11);
3471 CreateUnsyncedDirectory("X", "id_X"); 3495 CreateUnsyncedDirectory("X", "id_X");
3472 mock_server_->SetCommitClientCommand(command); 3496 mock_server_->SetCommitClientCommand(command);
3473 SyncShareNudge(); 3497 SyncShareNudge();
3474 3498
3475 EXPECT_TRUE(TimeDelta::FromSeconds(8) == 3499 EXPECT_TRUE(TimeDelta::FromSeconds(8) ==
3476 last_short_poll_interval_received_); 3500 last_short_poll_interval_received_);
3477 EXPECT_TRUE(TimeDelta::FromSeconds(800) == 3501 EXPECT_TRUE(TimeDelta::FromSeconds(800) ==
3478 last_long_poll_interval_received_); 3502 last_long_poll_interval_received_);
3479 EXPECT_TRUE(TimeDelta::FromSeconds(3141) == 3503 EXPECT_TRUE(TimeDelta::FromSeconds(3141) ==
3480 last_sessions_commit_delay_seconds_); 3504 last_sessions_commit_delay_seconds_);
3505 EXPECT_EQ(11, last_client_invalidation_hint_buffer_size_);
3481 3506
3482 command = new ClientCommand(); 3507 command = new ClientCommand();
3483 command->set_set_sync_poll_interval(180); 3508 command->set_set_sync_poll_interval(180);
3484 command->set_set_sync_long_poll_interval(190); 3509 command->set_set_sync_long_poll_interval(190);
3485 command->set_sessions_commit_delay_seconds(2718); 3510 command->set_sessions_commit_delay_seconds(2718);
3511 command->set_client_invalidation_hint_buffer_size(9);
3486 CreateUnsyncedDirectory("Y", "id_Y"); 3512 CreateUnsyncedDirectory("Y", "id_Y");
3487 mock_server_->SetCommitClientCommand(command); 3513 mock_server_->SetCommitClientCommand(command);
3488 SyncShareNudge(); 3514 SyncShareNudge();
3489 3515
3490 EXPECT_TRUE(TimeDelta::FromSeconds(180) == 3516 EXPECT_TRUE(TimeDelta::FromSeconds(180) ==
3491 last_short_poll_interval_received_); 3517 last_short_poll_interval_received_);
3492 EXPECT_TRUE(TimeDelta::FromSeconds(190) == 3518 EXPECT_TRUE(TimeDelta::FromSeconds(190) ==
3493 last_long_poll_interval_received_); 3519 last_long_poll_interval_received_);
3494 EXPECT_TRUE(TimeDelta::FromSeconds(2718) == 3520 EXPECT_TRUE(TimeDelta::FromSeconds(2718) ==
3495 last_sessions_commit_delay_seconds_); 3521 last_sessions_commit_delay_seconds_);
3522 EXPECT_EQ(9, last_client_invalidation_hint_buffer_size_);
3496 } 3523 }
3497 3524
3498 TEST_F(SyncerTest, EnsureWeSendUpOldParent) { 3525 TEST_F(SyncerTest, EnsureWeSendUpOldParent) {
3499 syncable::Id folder_one_id = ids_.FromNumber(1); 3526 syncable::Id folder_one_id = ids_.FromNumber(1);
3500 syncable::Id folder_two_id = ids_.FromNumber(2); 3527 syncable::Id folder_two_id = ids_.FromNumber(2);
3501 3528
3502 mock_server_->AddUpdateDirectory(folder_one_id, TestIdFactory::root(), 3529 mock_server_->AddUpdateDirectory(folder_one_id, TestIdFactory::root(),
3503 "folder_one", 1, 1, foreign_cache_guid(), "-1"); 3530 "folder_one", 1, 1, foreign_cache_guid(), "-1");
3504 mock_server_->AddUpdateDirectory(folder_two_id, TestIdFactory::root(), 3531 mock_server_->AddUpdateDirectory(folder_two_id, TestIdFactory::root(),
3505 "folder_two", 1, 1, foreign_cache_guid(), "-2"); 3532 "folder_two", 1, 1, foreign_cache_guid(), "-2");
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
4792 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 4819 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
4793 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 4820 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
4794 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 4821 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
4795 } else { 4822 } else {
4796 EXPECT_TRUE(final_monitor_records.empty()) 4823 EXPECT_TRUE(final_monitor_records.empty())
4797 << "Should not restore records after successful bookmark commit."; 4824 << "Should not restore records after successful bookmark commit.";
4798 } 4825 }
4799 } 4826 }
4800 4827
4801 } // namespace syncer 4828 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/syncer_proto_util_unittest.cc ('k') | sync/internal_api/sync_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698