OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "chrome/browser/sync/engine/apply_updates_command.h" | 10 #include "chrome/browser/sync/engine/apply_updates_command.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 ApplyUpdatesCommandTest() : next_revision_(1) {} | 50 ApplyUpdatesCommandTest() : next_revision_(1) {} |
51 virtual ~ApplyUpdatesCommandTest() {} | 51 virtual ~ApplyUpdatesCommandTest() {} |
52 | 52 |
53 virtual void SetUp() { | 53 virtual void SetUp() { |
54 workers()->clear(); | 54 workers()->clear(); |
55 mutable_routing_info()->clear(); | 55 mutable_routing_info()->clear(); |
56 workers()->push_back( | 56 workers()->push_back( |
57 make_scoped_refptr(new FakeModelWorker(GROUP_UI))); | 57 make_scoped_refptr(new FakeModelWorker(GROUP_UI))); |
58 workers()->push_back( | 58 workers()->push_back( |
59 make_scoped_refptr(new FakeModelWorker(GROUP_PASSWORD))); | 59 make_scoped_refptr(new FakeModelWorker(GROUP_PASSWORD))); |
| 60 workers()->push_back( |
| 61 make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); |
60 (*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI; | 62 (*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI; |
61 (*mutable_routing_info())[syncable::PASSWORDS] = GROUP_PASSWORD; | 63 (*mutable_routing_info())[syncable::PASSWORDS] = GROUP_PASSWORD; |
62 (*mutable_routing_info())[syncable::NIGORI] = GROUP_PASSIVE; | 64 (*mutable_routing_info())[syncable::NIGORI] = GROUP_PASSIVE; |
63 SyncerCommandTest::SetUp(); | 65 SyncerCommandTest::SetUp(); |
64 ExpectNoGroupsToChange(apply_updates_command_); | |
65 } | 66 } |
66 | 67 |
67 // Create a new unapplied folder node with a parent. | 68 // Create a new unapplied folder node with a parent. |
68 void CreateUnappliedNewItemWithParent( | 69 void CreateUnappliedNewItemWithParent( |
69 const string& item_id, | 70 const string& item_id, |
70 const sync_pb::EntitySpecifics& specifics, | 71 const sync_pb::EntitySpecifics& specifics, |
71 const string& parent_id) { | 72 const string& parent_id) { |
72 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 73 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
73 ASSERT_TRUE(dir.good()); | 74 ASSERT_TRUE(dir.good()); |
74 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | 75 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 153 |
153 TEST_F(ApplyUpdatesCommandTest, Simple) { | 154 TEST_F(ApplyUpdatesCommandTest, Simple) { |
154 string root_server_id = syncable::GetNullId().GetServerId(); | 155 string root_server_id = syncable::GetNullId().GetServerId(); |
155 CreateUnappliedNewItemWithParent("parent", | 156 CreateUnappliedNewItemWithParent("parent", |
156 DefaultBookmarkSpecifics(), | 157 DefaultBookmarkSpecifics(), |
157 root_server_id); | 158 root_server_id); |
158 CreateUnappliedNewItemWithParent("child", | 159 CreateUnappliedNewItemWithParent("child", |
159 DefaultBookmarkSpecifics(), | 160 DefaultBookmarkSpecifics(), |
160 "parent"); | 161 "parent"); |
161 | 162 |
162 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
163 apply_updates_command_.ExecuteImpl(session()); | 163 apply_updates_command_.ExecuteImpl(session()); |
164 | 164 |
165 sessions::StatusController* status = session()->mutable_status_controller(); | 165 sessions::StatusController* status = session()->mutable_status_controller(); |
166 | 166 |
167 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 167 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
168 ASSERT_TRUE(status->update_progress()); | 168 ASSERT_TRUE(status->update_progress()); |
169 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 169 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
170 << "All updates should have been attempted"; | 170 << "All updates should have been attempted"; |
171 ASSERT_TRUE(status->conflict_progress()); | 171 ASSERT_TRUE(status->conflict_progress()); |
172 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 172 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
(...skipping 15 matching lines...) Expand all Loading... |
188 CreateUnappliedNewItemWithParent("parent", | 188 CreateUnappliedNewItemWithParent("parent", |
189 DefaultBookmarkSpecifics(), | 189 DefaultBookmarkSpecifics(), |
190 root_server_id); | 190 root_server_id); |
191 CreateUnappliedNewItemWithParent("a_child_created_second", | 191 CreateUnappliedNewItemWithParent("a_child_created_second", |
192 DefaultBookmarkSpecifics(), | 192 DefaultBookmarkSpecifics(), |
193 "parent"); | 193 "parent"); |
194 CreateUnappliedNewItemWithParent("x_child_created_second", | 194 CreateUnappliedNewItemWithParent("x_child_created_second", |
195 DefaultBookmarkSpecifics(), | 195 DefaultBookmarkSpecifics(), |
196 "parent"); | 196 "parent"); |
197 | 197 |
198 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
199 apply_updates_command_.ExecuteImpl(session()); | 198 apply_updates_command_.ExecuteImpl(session()); |
200 | 199 |
201 sessions::StatusController* status = session()->mutable_status_controller(); | 200 sessions::StatusController* status = session()->mutable_status_controller(); |
202 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 201 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
203 ASSERT_TRUE(status->update_progress()); | 202 ASSERT_TRUE(status->update_progress()); |
204 EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize()) | 203 EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize()) |
205 << "All updates should have been attempted"; | 204 << "All updates should have been attempted"; |
206 ASSERT_TRUE(status->conflict_progress()); | 205 ASSERT_TRUE(status->conflict_progress()); |
207 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 206 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
208 << "Simple update shouldn't result in conflicts, even if out-of-order"; | 207 << "Simple update shouldn't result in conflicts, even if out-of-order"; |
209 EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 208 EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
210 << "All updates should have been successfully applied"; | 209 << "All updates should have been successfully applied"; |
211 } | 210 } |
212 | 211 |
213 TEST_F(ApplyUpdatesCommandTest, NestedItemsWithUnknownParent) { | 212 TEST_F(ApplyUpdatesCommandTest, NestedItemsWithUnknownParent) { |
214 // We shouldn't be able to do anything with either of these items. | 213 // We shouldn't be able to do anything with either of these items. |
215 CreateUnappliedNewItemWithParent("some_item", | 214 CreateUnappliedNewItemWithParent("some_item", |
216 DefaultBookmarkSpecifics(), | 215 DefaultBookmarkSpecifics(), |
217 "unknown_parent"); | 216 "unknown_parent"); |
218 CreateUnappliedNewItemWithParent("some_other_item", | 217 CreateUnappliedNewItemWithParent("some_other_item", |
219 DefaultBookmarkSpecifics(), | 218 DefaultBookmarkSpecifics(), |
220 "some_item"); | 219 "some_item"); |
221 | 220 |
222 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
223 apply_updates_command_.ExecuteImpl(session()); | 221 apply_updates_command_.ExecuteImpl(session()); |
224 | 222 |
225 sessions::StatusController* status = session()->mutable_status_controller(); | 223 sessions::StatusController* status = session()->mutable_status_controller(); |
226 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 224 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
227 ASSERT_TRUE(status->update_progress()); | 225 ASSERT_TRUE(status->update_progress()); |
228 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 226 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
229 << "All updates should have been attempted"; | 227 << "All updates should have been attempted"; |
230 ASSERT_TRUE(status->conflict_progress()); | 228 ASSERT_TRUE(status->conflict_progress()); |
231 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 229 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) |
232 << "All updates with an unknown ancestors should be in conflict"; | 230 << "All updates with an unknown ancestors should be in conflict"; |
(...skipping 16 matching lines...) Expand all Loading... |
249 CreateUnappliedNewItemWithParent("second_known_item", | 247 CreateUnappliedNewItemWithParent("second_known_item", |
250 DefaultBookmarkSpecifics(), | 248 DefaultBookmarkSpecifics(), |
251 "first_known_item"); | 249 "first_known_item"); |
252 CreateUnappliedNewItemWithParent("third_known_item", | 250 CreateUnappliedNewItemWithParent("third_known_item", |
253 DefaultBookmarkSpecifics(), | 251 DefaultBookmarkSpecifics(), |
254 "fourth_known_item"); | 252 "fourth_known_item"); |
255 CreateUnappliedNewItemWithParent("fourth_known_item", | 253 CreateUnappliedNewItemWithParent("fourth_known_item", |
256 DefaultBookmarkSpecifics(), | 254 DefaultBookmarkSpecifics(), |
257 root_server_id); | 255 root_server_id); |
258 | 256 |
259 ExpectGroupToChange(apply_updates_command_, GROUP_UI); | |
260 apply_updates_command_.ExecuteImpl(session()); | 257 apply_updates_command_.ExecuteImpl(session()); |
261 | 258 |
262 sessions::StatusController* status = session()->mutable_status_controller(); | 259 sessions::StatusController* status = session()->mutable_status_controller(); |
263 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 260 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
264 ASSERT_TRUE(status->update_progress()); | 261 ASSERT_TRUE(status->update_progress()); |
265 EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize()) | 262 EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize()) |
266 << "All updates should have been attempted"; | 263 << "All updates should have been attempted"; |
267 ASSERT_TRUE(status->conflict_progress()); | 264 ASSERT_TRUE(status->conflict_progress()); |
268 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 265 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) |
269 << "The updates with unknown ancestors should be in conflict"; | 266 << "The updates with unknown ancestors should be in conflict"; |
(...skipping 18 matching lines...) Expand all Loading... |
288 cryptographer->AddKey(params); | 285 cryptographer->AddKey(params); |
289 | 286 |
290 sync_pb::EntitySpecifics specifics; | 287 sync_pb::EntitySpecifics specifics; |
291 sync_pb::PasswordSpecificsData data; | 288 sync_pb::PasswordSpecificsData data; |
292 data.set_origin("http://example.com"); | 289 data.set_origin("http://example.com"); |
293 | 290 |
294 cryptographer->Encrypt(data, | 291 cryptographer->Encrypt(data, |
295 specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); | 292 specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); |
296 CreateUnappliedNewItem("item", specifics, false); | 293 CreateUnappliedNewItem("item", specifics, false); |
297 | 294 |
298 ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD); | |
299 apply_updates_command_.ExecuteImpl(session()); | 295 apply_updates_command_.ExecuteImpl(session()); |
300 | 296 |
301 sessions::StatusController* status = session()->mutable_status_controller(); | 297 sessions::StatusController* status = session()->mutable_status_controller(); |
302 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); | 298 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); |
303 ASSERT_TRUE(status->update_progress()); | 299 ASSERT_TRUE(status->update_progress()); |
304 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 300 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
305 << "All updates should have been attempted"; | 301 << "All updates should have been attempted"; |
306 ASSERT_TRUE(status->conflict_progress()); | 302 ASSERT_TRUE(status->conflict_progress()); |
307 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 303 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
308 << "No update should be in conflict because they're all decryptable"; | 304 << "No update should be in conflict because they're all decryptable"; |
309 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) | 305 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) |
310 << "The updates that can be decrypted should be applied"; | 306 << "The updates that can be decrypted should be applied"; |
311 } | 307 } |
312 | 308 |
313 TEST_F(ApplyUpdatesCommandTest, UndecryptableData) { | 309 TEST_F(ApplyUpdatesCommandTest, UndecryptableData) { |
314 // Undecryptable updates should not be applied. | 310 // Undecryptable updates should not be applied. |
315 sync_pb::EntitySpecifics encrypted_bookmark; | 311 sync_pb::EntitySpecifics encrypted_bookmark; |
316 encrypted_bookmark.mutable_encrypted(); | 312 encrypted_bookmark.mutable_encrypted(); |
317 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); | 313 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); |
318 string root_server_id = syncable::GetNullId().GetServerId(); | 314 string root_server_id = syncable::GetNullId().GetServerId(); |
319 CreateUnappliedNewItemWithParent("folder", | 315 CreateUnappliedNewItemWithParent("folder", |
320 encrypted_bookmark, | 316 encrypted_bookmark, |
321 root_server_id); | 317 root_server_id); |
322 CreateUnappliedNewItem("item2", encrypted_bookmark, false); | 318 CreateUnappliedNewItem("item2", encrypted_bookmark, false); |
323 sync_pb::EntitySpecifics encrypted_password; | 319 sync_pb::EntitySpecifics encrypted_password; |
324 encrypted_password.MutableExtension(sync_pb::password); | 320 encrypted_password.MutableExtension(sync_pb::password); |
325 CreateUnappliedNewItem("item3", encrypted_password, false); | 321 CreateUnappliedNewItem("item3", encrypted_password, false); |
326 | 322 |
327 ExpectGroupsToChange(apply_updates_command_, GROUP_UI, GROUP_PASSWORD); | |
328 apply_updates_command_.ExecuteImpl(session()); | 323 apply_updates_command_.ExecuteImpl(session()); |
329 | 324 |
330 sessions::StatusController* status = session()->mutable_status_controller(); | 325 sessions::StatusController* status = session()->mutable_status_controller(); |
331 EXPECT_TRUE(status->HasConflictingUpdates()) | 326 EXPECT_TRUE(status->HasConflictingUpdates()) |
332 << "Updates that can't be decrypted should trigger the syncer to have " | 327 << "Updates that can't be decrypted should trigger the syncer to have " |
333 << "conflicting updates."; | 328 << "conflicting updates."; |
334 { | 329 { |
335 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 330 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
336 ASSERT_TRUE(status->update_progress()); | 331 ASSERT_TRUE(status->update_progress()); |
337 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 332 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 387 |
393 sync_pb::EntitySpecifics specifics; | 388 sync_pb::EntitySpecifics specifics; |
394 sync_pb::PasswordSpecificsData data; | 389 sync_pb::PasswordSpecificsData data; |
395 data.set_origin("http://example.com/2"); | 390 data.set_origin("http://example.com/2"); |
396 | 391 |
397 cryptographer.Encrypt(data, | 392 cryptographer.Encrypt(data, |
398 specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); | 393 specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); |
399 CreateUnappliedNewItem("item2", specifics, false); | 394 CreateUnappliedNewItem("item2", specifics, false); |
400 } | 395 } |
401 | 396 |
402 ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD); | |
403 apply_updates_command_.ExecuteImpl(session()); | 397 apply_updates_command_.ExecuteImpl(session()); |
404 | 398 |
405 sessions::StatusController* status = session()->mutable_status_controller(); | 399 sessions::StatusController* status = session()->mutable_status_controller(); |
406 EXPECT_TRUE(status->HasConflictingUpdates()) | 400 EXPECT_TRUE(status->HasConflictingUpdates()) |
407 << "Updates that can't be decrypted should trigger the syncer to have " | 401 << "Updates that can't be decrypted should trigger the syncer to have " |
408 << "conflicting updates."; | 402 << "conflicting updates."; |
409 { | 403 { |
410 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); | 404 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD); |
411 ASSERT_TRUE(status->update_progress()); | 405 ASSERT_TRUE(status->update_progress()); |
412 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) | 406 EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize()) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 sync_pb::EntitySpecifics specifics; | 441 sync_pb::EntitySpecifics specifics; |
448 sync_pb::NigoriSpecifics* nigori = | 442 sync_pb::NigoriSpecifics* nigori = |
449 specifics.MutableExtension(sync_pb::nigori); | 443 specifics.MutableExtension(sync_pb::nigori); |
450 other_cryptographer.GetKeys(nigori->mutable_encrypted()); | 444 other_cryptographer.GetKeys(nigori->mutable_encrypted()); |
451 nigori->set_encrypt_bookmarks(true); | 445 nigori->set_encrypt_bookmarks(true); |
452 encrypted_types.insert(syncable::BOOKMARKS); | 446 encrypted_types.insert(syncable::BOOKMARKS); |
453 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), | 447 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), |
454 specifics, true); | 448 specifics, true); |
455 EXPECT_FALSE(cryptographer->has_pending_keys()); | 449 EXPECT_FALSE(cryptographer->has_pending_keys()); |
456 | 450 |
457 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | |
458 apply_updates_command_.ExecuteImpl(session()); | 451 apply_updates_command_.ExecuteImpl(session()); |
459 | 452 |
460 sessions::StatusController* status = session()->mutable_status_controller(); | 453 sessions::StatusController* status = session()->mutable_status_controller(); |
461 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 454 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
462 ASSERT_TRUE(status->update_progress()); | 455 ASSERT_TRUE(status->update_progress()); |
463 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 456 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
464 << "All updates should have been attempted"; | 457 << "All updates should have been attempted"; |
465 ASSERT_TRUE(status->conflict_progress()); | 458 ASSERT_TRUE(status->conflict_progress()); |
466 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 459 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
467 << "The nigori update shouldn't be in conflict"; | 460 << "The nigori update shouldn't be in conflict"; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 specifics.MutableExtension(sync_pb::nigori); | 492 specifics.MutableExtension(sync_pb::nigori); |
500 other_cryptographer.GetKeys(nigori->mutable_encrypted()); | 493 other_cryptographer.GetKeys(nigori->mutable_encrypted()); |
501 nigori->set_encrypt_sessions(true); | 494 nigori->set_encrypt_sessions(true); |
502 nigori->set_encrypt_themes(true); | 495 nigori->set_encrypt_themes(true); |
503 encrypted_types.insert(syncable::SESSIONS); | 496 encrypted_types.insert(syncable::SESSIONS); |
504 encrypted_types.insert(syncable::THEMES); | 497 encrypted_types.insert(syncable::THEMES); |
505 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), | 498 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), |
506 specifics, true); | 499 specifics, true); |
507 EXPECT_FALSE(cryptographer->has_pending_keys()); | 500 EXPECT_FALSE(cryptographer->has_pending_keys()); |
508 | 501 |
509 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | |
510 apply_updates_command_.ExecuteImpl(session()); | 502 apply_updates_command_.ExecuteImpl(session()); |
511 | 503 |
512 sessions::StatusController* status = session()->mutable_status_controller(); | 504 sessions::StatusController* status = session()->mutable_status_controller(); |
513 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 505 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
514 ASSERT_TRUE(status->update_progress()); | 506 ASSERT_TRUE(status->update_progress()); |
515 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 507 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
516 << "All updates should have been attempted"; | 508 << "All updates should have been attempted"; |
517 ASSERT_TRUE(status->conflict_progress()); | 509 ASSERT_TRUE(status->conflict_progress()); |
518 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 510 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
519 << "The nigori update shouldn't be in conflict"; | 511 << "The nigori update shouldn't be in conflict"; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 579 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
588 ASSERT_TRUE(dir.good()); | 580 ASSERT_TRUE(dir.good()); |
589 ReadTransaction trans(FROM_HERE, dir); | 581 ReadTransaction trans(FROM_HERE, dir); |
590 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); | 582 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); |
591 | 583 |
592 Syncer::UnsyncedMetaHandles handles; | 584 Syncer::UnsyncedMetaHandles handles; |
593 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 585 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
594 EXPECT_EQ(2*batch_s+1, handles.size()); | 586 EXPECT_EQ(2*batch_s+1, handles.size()); |
595 } | 587 } |
596 | 588 |
597 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | |
598 apply_updates_command_.ExecuteImpl(session()); | 589 apply_updates_command_.ExecuteImpl(session()); |
599 | 590 |
600 sessions::StatusController* status = session()->mutable_status_controller(); | 591 sessions::StatusController* status = session()->mutable_status_controller(); |
601 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 592 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
602 ASSERT_TRUE(status->update_progress()); | 593 ASSERT_TRUE(status->update_progress()); |
603 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 594 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
604 << "All updates should have been attempted"; | 595 << "All updates should have been attempted"; |
605 ASSERT_TRUE(status->conflict_progress()); | 596 ASSERT_TRUE(status->conflict_progress()); |
606 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 597 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
607 << "No updates should be in conflict"; | 598 << "No updates should be in conflict"; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 // Ensure we have unsynced nodes that aren't properly encrypted. | 681 // Ensure we have unsynced nodes that aren't properly encrypted. |
691 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); | 682 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); |
692 ASSERT_TRUE(dir.good()); | 683 ASSERT_TRUE(dir.good()); |
693 ReadTransaction trans(FROM_HERE, dir); | 684 ReadTransaction trans(FROM_HERE, dir); |
694 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); | 685 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); |
695 Syncer::UnsyncedMetaHandles handles; | 686 Syncer::UnsyncedMetaHandles handles; |
696 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 687 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
697 EXPECT_EQ(2*batch_s+1, handles.size()); | 688 EXPECT_EQ(2*batch_s+1, handles.size()); |
698 } | 689 } |
699 | 690 |
700 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); | |
701 apply_updates_command_.ExecuteImpl(session()); | 691 apply_updates_command_.ExecuteImpl(session()); |
702 | 692 |
703 sessions::StatusController* status = session()->mutable_status_controller(); | 693 sessions::StatusController* status = session()->mutable_status_controller(); |
704 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 694 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
705 ASSERT_TRUE(status->update_progress()); | 695 ASSERT_TRUE(status->update_progress()); |
706 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) | 696 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) |
707 << "All updates should have been attempted"; | 697 << "All updates should have been attempted"; |
708 ASSERT_TRUE(status->conflict_progress()); | 698 ASSERT_TRUE(status->conflict_progress()); |
709 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) | 699 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) |
710 << "The unsynced changes don't trigger a blocking conflict with the " | 700 << "The unsynced changes don't trigger a blocking conflict with the " |
(...skipping 19 matching lines...) Expand all Loading... |
730 encrypted_types.insert(syncable::BOOKMARKS); | 720 encrypted_types.insert(syncable::BOOKMARKS); |
731 EXPECT_EQ(GetAllRealModelTypes(), cryptographer->GetEncryptedTypes()); | 721 EXPECT_EQ(GetAllRealModelTypes(), cryptographer->GetEncryptedTypes()); |
732 | 722 |
733 Syncer::UnsyncedMetaHandles handles; | 723 Syncer::UnsyncedMetaHandles handles; |
734 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 724 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
735 EXPECT_EQ(2*batch_s+1, handles.size()); | 725 EXPECT_EQ(2*batch_s+1, handles.size()); |
736 } | 726 } |
737 } | 727 } |
738 | 728 |
739 } // namespace browser_sync | 729 } // namespace browser_sync |
OLD | NEW |