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 // 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 context_->set_account_name(syncdb_.name()); | 206 context_->set_account_name(syncdb_.name()); |
207 ASSERT_FALSE(context_->resolver()); | 207 ASSERT_FALSE(context_->resolver()); |
208 syncer_ = new Syncer(); | 208 syncer_ = new Syncer(); |
209 session_.reset(MakeSession()); | 209 session_.reset(MakeSession()); |
210 | 210 |
211 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 211 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
212 CHECK(dir.good()); | 212 CHECK(dir.good()); |
213 ReadTransaction trans(FROM_HERE, dir); | 213 ReadTransaction trans(FROM_HERE, dir); |
214 syncable::Directory::ChildHandles children; | 214 syncable::Directory::ChildHandles children; |
215 dir->GetChildHandlesById(&trans, trans.root_id(), &children); | 215 dir->GetChildHandlesById(&trans, trans.root_id(), &children); |
216 ASSERT_TRUE(0 == children.size()); | 216 ASSERT_EQ(0u, children.size()); |
217 saw_syncer_event_ = false; | 217 saw_syncer_event_ = false; |
218 root_id_ = TestIdFactory::root(); | 218 root_id_ = TestIdFactory::root(); |
219 parent_id_ = ids_.MakeServer("parent id"); | 219 parent_id_ = ids_.MakeServer("parent id"); |
220 child_id_ = ids_.MakeServer("child id"); | 220 child_id_ = ids_.MakeServer("child id"); |
221 } | 221 } |
222 | 222 |
223 virtual void TearDown() { | 223 virtual void TearDown() { |
224 mock_server_.reset(); | 224 mock_server_.reset(); |
225 delete syncer_; | 225 delete syncer_; |
226 syncer_ = NULL; | 226 syncer_ = NULL; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 } | 344 } |
345 } | 345 } |
346 test++; | 346 test++; |
347 } | 347 } |
348 } | 348 } |
349 LoopSyncShare(); | 349 LoopSyncShare(); |
350 ASSERT_TRUE(expected_positions.size() == | 350 ASSERT_TRUE(expected_positions.size() == |
351 mock_server_->committed_ids().size()); | 351 mock_server_->committed_ids().size()); |
352 // If this test starts failing, be aware other sort orders could be valid. | 352 // If this test starts failing, be aware other sort orders could be valid. |
353 for (size_t i = 0; i < expected_positions.size(); ++i) { | 353 for (size_t i = 0; i < expected_positions.size(); ++i) { |
354 EXPECT_TRUE(1 == expected_positions.count(i)); | 354 EXPECT_EQ(1u, expected_positions.count(i)); |
355 EXPECT_TRUE(expected_positions[i] == mock_server_->committed_ids()[i]); | 355 EXPECT_TRUE(expected_positions[i] == mock_server_->committed_ids()[i]); |
356 } | 356 } |
357 } | 357 } |
358 | 358 |
359 void DoTruncationTest(const ScopedDirLookup& dir, | 359 void DoTruncationTest(const ScopedDirLookup& dir, |
360 const vector<int64>& unsynced_handle_view, | 360 const vector<int64>& unsynced_handle_view, |
361 const vector<syncable::Id>& expected_id_order) { | 361 const vector<syncable::Id>& expected_id_order) { |
362 // The expected order is "x", "b", "c", "e", truncated appropriately. | 362 // The expected order is "x", "b", "c", "e", truncated appropriately. |
363 for (size_t limit = expected_id_order.size() + 2; limit > 0; --limit) { | 363 for (size_t limit = expected_id_order.size() + 2; limit > 0; --limit) { |
364 StatusController* status = session_->status_controller(); | 364 StatusController* status = session_->mutable_status_controller(); |
365 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); | 365 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); |
366 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); | 366 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); |
367 status->set_unsynced_handles(unsynced_handle_view); | 367 status->set_unsynced_handles(unsynced_handle_view); |
368 | 368 |
369 ModelSafeRoutingInfo routes; | 369 ModelSafeRoutingInfo routes; |
370 GetModelSafeRoutingInfo(&routes); | 370 GetModelSafeRoutingInfo(&routes); |
371 GetCommitIdsCommand command(limit); | 371 GetCommitIdsCommand command(limit); |
372 command.BuildCommitIds(session_->status_controller()->unsynced_handles(), | 372 command.BuildCommitIds( |
| 373 session_->status_controller().unsynced_handles(), |
373 session_->write_transaction(), routes); | 374 session_->write_transaction(), routes); |
374 vector<syncable::Id> output = | 375 vector<syncable::Id> output = |
375 command.ordered_commit_set_->GetAllCommitIds(); | 376 command.ordered_commit_set_->GetAllCommitIds(); |
376 size_t truncated_size = std::min(limit, expected_id_order.size()); | 377 size_t truncated_size = std::min(limit, expected_id_order.size()); |
377 ASSERT_TRUE(truncated_size == output.size()); | 378 ASSERT_TRUE(truncated_size == output.size()); |
378 for (size_t i = 0; i < truncated_size; ++i) { | 379 for (size_t i = 0; i < truncated_size; ++i) { |
379 ASSERT_TRUE(expected_id_order[i] == output[i]) | 380 ASSERT_TRUE(expected_id_order[i] == output[i]) |
380 << "At index " << i << " with batch size limited to " << limit; | 381 << "At index " << i << " with batch size limited to " << limit; |
381 } | 382 } |
382 sessions::OrderedCommitSet::Projection proj; | 383 sessions::OrderedCommitSet::Projection proj; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 503 |
503 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { | 504 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { |
504 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 505 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
505 ASSERT_TRUE(dir.good()); | 506 ASSERT_TRUE(dir.good()); |
506 { | 507 { |
507 Syncer::UnsyncedMetaHandles handles; | 508 Syncer::UnsyncedMetaHandles handles; |
508 { | 509 { |
509 ReadTransaction trans(FROM_HERE, dir); | 510 ReadTransaction trans(FROM_HERE, dir); |
510 SyncerUtil::GetUnsyncedEntries(&trans, &handles); | 511 SyncerUtil::GetUnsyncedEntries(&trans, &handles); |
511 } | 512 } |
512 ASSERT_TRUE(0 == handles.size()); | 513 ASSERT_EQ(0u, handles.size()); |
513 } | 514 } |
514 // TODO(sync): When we can dynamically connect and disconnect the mock | 515 // TODO(sync): When we can dynamically connect and disconnect the mock |
515 // ServerConnectionManager test disconnected GetUnsyncedEntries here. It's a | 516 // ServerConnectionManager test disconnected GetUnsyncedEntries here. It's a |
516 // regression for a very old bug. | 517 // regression for a very old bug. |
517 } | 518 } |
518 | 519 |
519 TEST_F(SyncerTest, GetCommitIdsCommandTruncates) { | 520 TEST_F(SyncerTest, GetCommitIdsCommandTruncates) { |
520 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 521 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
521 ASSERT_TRUE(dir.good()); | 522 ASSERT_TRUE(dir.good()); |
522 int64 handle_c = CreateUnsyncedDirectory("C", ids_.MakeLocal("c")); | 523 int64 handle_c = CreateUnsyncedDirectory("C", ids_.MakeLocal("c")); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); | 605 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); |
605 ASSERT_TRUE(D.good()); | 606 ASSERT_TRUE(D.good()); |
606 D.Put(IS_UNSYNCED, true); | 607 D.Put(IS_UNSYNCED, true); |
607 D.Put(SPECIFICS, encrypted_bookmark); | 608 D.Put(SPECIFICS, encrypted_bookmark); |
608 D.Put(NON_UNIQUE_NAME, "not encrypted"); | 609 D.Put(NON_UNIQUE_NAME, "not encrypted"); |
609 } | 610 } |
610 SyncShareAsDelegate(); | 611 SyncShareAsDelegate(); |
611 { | 612 { |
612 // We remove any unready entries from the status controller's unsynced | 613 // We remove any unready entries from the status controller's unsynced |
613 // handles, so this should remain 0 even though the entries didn't commit. | 614 // handles, so this should remain 0 even though the entries didn't commit. |
614 ASSERT_EQ(0U, session_->status_controller()->unsynced_handles().size()); | 615 ASSERT_EQ(0U, session_->status_controller().unsynced_handles().size()); |
615 // Nothing should have commited due to bookmarks being encrypted and | 616 // Nothing should have commited due to bookmarks being encrypted and |
616 // the cryptographer having pending keys. A would have been resolved | 617 // the cryptographer having pending keys. A would have been resolved |
617 // as a simple conflict, but still be unsynced until the next sync cycle. | 618 // as a simple conflict, but still be unsynced until the next sync cycle. |
618 ReadTransaction rtrans(FROM_HERE, dir); | 619 ReadTransaction rtrans(FROM_HERE, dir); |
619 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 620 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
620 ASSERT_TRUE(entryA.good()); | 621 ASSERT_TRUE(entryA.good()); |
621 EXPECT_TRUE(entryA.Get(IS_UNSYNCED)); | 622 EXPECT_TRUE(entryA.Get(IS_UNSYNCED)); |
622 Entry entryB(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2)); | 623 Entry entryB(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2)); |
623 ASSERT_TRUE(entryB.good()); | 624 ASSERT_TRUE(entryB.good()); |
624 EXPECT_TRUE(entryB.Get(IS_UNSYNCED)); | 625 EXPECT_TRUE(entryB.Get(IS_UNSYNCED)); |
625 Entry entryC(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(3)); | 626 Entry entryC(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(3)); |
626 ASSERT_TRUE(entryC.good()); | 627 ASSERT_TRUE(entryC.good()); |
627 EXPECT_TRUE(entryC.Get(IS_UNSYNCED)); | 628 EXPECT_TRUE(entryC.Get(IS_UNSYNCED)); |
628 Entry entryD(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(4)); | 629 Entry entryD(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(4)); |
629 ASSERT_TRUE(entryD.good()); | 630 ASSERT_TRUE(entryD.good()); |
630 EXPECT_TRUE(entryD.Get(IS_UNSYNCED)); | 631 EXPECT_TRUE(entryD.Get(IS_UNSYNCED)); |
631 | 632 |
632 // Resolve the pending keys. | 633 // Resolve the pending keys. |
633 syncdb_.manager()->GetCryptographer(&rtrans)->DecryptPendingKeys( | 634 syncdb_.manager()->GetCryptographer(&rtrans)->DecryptPendingKeys( |
634 key_params); | 635 key_params); |
635 } | 636 } |
636 SyncShareAsDelegate(); | 637 SyncShareAsDelegate(); |
637 { | 638 { |
638 ASSERT_EQ(0U, session_->status_controller()->unsynced_handles().size()); | 639 ASSERT_EQ(0U, session_->status_controller().unsynced_handles().size()); |
639 // All properly encrypted and non-conflicting items should commit. "A" was | 640 // All properly encrypted and non-conflicting items should commit. "A" was |
640 // conflicting, but last sync cycle resolved it as simple conflict, so on | 641 // conflicting, but last sync cycle resolved it as simple conflict, so on |
641 // this sync cycle it committed succesfullly. | 642 // this sync cycle it committed succesfullly. |
642 ReadTransaction rtrans(FROM_HERE, dir); | 643 ReadTransaction rtrans(FROM_HERE, dir); |
643 // Committed successfully. | 644 // Committed successfully. |
644 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 645 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
645 ASSERT_TRUE(entryA.good()); | 646 ASSERT_TRUE(entryA.good()); |
646 EXPECT_FALSE(entryA.Get(IS_UNSYNCED)); | 647 EXPECT_FALSE(entryA.Get(IS_UNSYNCED)); |
647 EXPECT_FALSE(entryA.Get(IS_UNAPPLIED_UPDATE)); | 648 EXPECT_FALSE(entryA.Get(IS_UNAPPLIED_UPDATE)); |
648 // Committed successfully. | 649 // Committed successfully. |
(...skipping 19 matching lines...) Expand all Loading... |
668 ASSERT_TRUE(C.good()); | 669 ASSERT_TRUE(C.good()); |
669 C.Put(SPECIFICS, encrypted_bookmark); | 670 C.Put(SPECIFICS, encrypted_bookmark); |
670 C.Put(NON_UNIQUE_NAME, kEncryptedString); | 671 C.Put(NON_UNIQUE_NAME, kEncryptedString); |
671 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); | 672 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); |
672 ASSERT_TRUE(D.good()); | 673 ASSERT_TRUE(D.good()); |
673 D.Put(SPECIFICS, encrypted_bookmark); | 674 D.Put(SPECIFICS, encrypted_bookmark); |
674 D.Put(NON_UNIQUE_NAME, kEncryptedString); | 675 D.Put(NON_UNIQUE_NAME, kEncryptedString); |
675 } | 676 } |
676 SyncShareAsDelegate(); | 677 SyncShareAsDelegate(); |
677 { | 678 { |
678 ASSERT_EQ(0U, session_->status_controller()->unsynced_handles().size()); | 679 ASSERT_EQ(0U, session_->status_controller().unsynced_handles().size()); |
679 // None should be unsynced anymore. | 680 // None should be unsynced anymore. |
680 ReadTransaction rtrans(FROM_HERE, dir); | 681 ReadTransaction rtrans(FROM_HERE, dir); |
681 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 682 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
682 ASSERT_TRUE(entryA.good()); | 683 ASSERT_TRUE(entryA.good()); |
683 EXPECT_FALSE(entryA.Get(IS_UNSYNCED)); | 684 EXPECT_FALSE(entryA.Get(IS_UNSYNCED)); |
684 EXPECT_FALSE(entryA.Get(IS_UNAPPLIED_UPDATE)); | 685 EXPECT_FALSE(entryA.Get(IS_UNAPPLIED_UPDATE)); |
685 Entry entryB(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2)); | 686 Entry entryB(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2)); |
686 ASSERT_TRUE(entryB.good()); | 687 ASSERT_TRUE(entryB.good()); |
687 EXPECT_FALSE(entryB.Get(IS_UNSYNCED)); | 688 EXPECT_FALSE(entryB.Get(IS_UNSYNCED)); |
688 EXPECT_FALSE(entryB.Get(IS_UNAPPLIED_UPDATE)); | 689 EXPECT_FALSE(entryB.Get(IS_UNAPPLIED_UPDATE)); |
689 Entry entryC(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(3)); | 690 Entry entryC(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(3)); |
690 ASSERT_TRUE(entryC.good()); | 691 ASSERT_TRUE(entryC.good()); |
691 EXPECT_FALSE(entryC.Get(IS_UNSYNCED)); | 692 EXPECT_FALSE(entryC.Get(IS_UNSYNCED)); |
692 EXPECT_FALSE(entryC.Get(IS_UNAPPLIED_UPDATE)); | 693 EXPECT_FALSE(entryC.Get(IS_UNAPPLIED_UPDATE)); |
693 Entry entryD(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(4)); | 694 Entry entryD(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(4)); |
694 ASSERT_TRUE(entryD.good()); | 695 ASSERT_TRUE(entryD.good()); |
695 EXPECT_FALSE(entryD.Get(IS_UNSYNCED)); | 696 EXPECT_FALSE(entryD.Get(IS_UNSYNCED)); |
696 EXPECT_FALSE(entryD.Get(IS_UNAPPLIED_UPDATE)); | 697 EXPECT_FALSE(entryD.Get(IS_UNAPPLIED_UPDATE)); |
697 } | 698 } |
698 } | 699 } |
699 | 700 |
700 // TODO(chron): More corner case unit tests around validation. | 701 // TODO(chron): More corner case unit tests around validation. |
701 TEST_F(SyncerTest, TestCommitMetahandleIterator) { | 702 TEST_F(SyncerTest, TestCommitMetahandleIterator) { |
702 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 703 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
703 ASSERT_TRUE(dir.good()); | 704 ASSERT_TRUE(dir.good()); |
704 StatusController* status = session_->status_controller(); | 705 StatusController* status = session_->mutable_status_controller(); |
705 const vector<int64>& unsynced(status->unsynced_handles()); | 706 const vector<int64>& unsynced(status->unsynced_handles()); |
706 | 707 |
707 { | 708 { |
708 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); | 709 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); |
709 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); | 710 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); |
710 | 711 |
711 sessions::OrderedCommitSet commit_set(session_->routing_info()); | 712 sessions::OrderedCommitSet commit_set(session_->routing_info()); |
712 GetCommitIdsCommand::CommitMetahandleIterator iterator(unsynced, &wtrans, | 713 GetCommitIdsCommand::CommitMetahandleIterator iterator(unsynced, &wtrans, |
713 &commit_set); | 714 &commit_set); |
714 EXPECT_FALSE(iterator.Valid()); | 715 EXPECT_FALSE(iterator.Valid()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 758 parent.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
758 parent.Put(syncable::BASE_VERSION, 1); | 759 parent.Put(syncable::BASE_VERSION, 1); |
759 parent.Put(syncable::ID, parent_id_); | 760 parent.Put(syncable::ID, parent_id_); |
760 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete"); | 761 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete"); |
761 ASSERT_TRUE(child.good()); | 762 ASSERT_TRUE(child.good()); |
762 child.Put(syncable::ID, child_id_); | 763 child.Put(syncable::ID, child_id_); |
763 child.Put(syncable::BASE_VERSION, 1); | 764 child.Put(syncable::BASE_VERSION, 1); |
764 WriteTestDataToEntry(&wtrans, &child); | 765 WriteTestDataToEntry(&wtrans, &child); |
765 } | 766 } |
766 | 767 |
767 StatusController* status = session_->status_controller(); | 768 const StatusController& status = session_->status_controller(); |
768 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 769 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
769 EXPECT_TRUE(2 == status->unsynced_handles().size()); | 770 EXPECT_EQ(2u, status.unsynced_handles().size()); |
770 ASSERT_TRUE(2 == mock_server_->committed_ids().size()); | 771 ASSERT_EQ(2u, mock_server_->committed_ids().size()); |
771 // If this test starts failing, be aware other sort orders could be valid. | 772 // If this test starts failing, be aware other sort orders could be valid. |
772 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 773 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
773 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 774 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
774 { | 775 { |
775 ReadTransaction rt(FROM_HERE, dir); | 776 ReadTransaction rt(FROM_HERE, dir); |
776 Entry entry(&rt, syncable::GET_BY_ID, child_id_); | 777 Entry entry(&rt, syncable::GET_BY_ID, child_id_); |
777 ASSERT_TRUE(entry.good()); | 778 ASSERT_TRUE(entry.good()); |
778 VerifyTestDataInEntry(&rt, &entry); | 779 VerifyTestDataInEntry(&rt, &entry); |
779 } | 780 } |
780 } | 781 } |
(...skipping 24 matching lines...) Expand all Loading... |
805 parent2.Put(syncable::IS_DIR, true); | 806 parent2.Put(syncable::IS_DIR, true); |
806 parent2.Put(syncable::SPECIFICS, DefaultPreferencesSpecifics()); | 807 parent2.Put(syncable::SPECIFICS, DefaultPreferencesSpecifics()); |
807 parent2.Put(syncable::BASE_VERSION, 1); | 808 parent2.Put(syncable::BASE_VERSION, 1); |
808 parent2.Put(syncable::ID, pref_node_id); | 809 parent2.Put(syncable::ID, pref_node_id); |
809 } | 810 } |
810 | 811 |
811 std::set<syncable::ModelType> types_to_purge; | 812 std::set<syncable::ModelType> types_to_purge; |
812 types_to_purge.insert(syncable::PREFERENCES); | 813 types_to_purge.insert(syncable::PREFERENCES); |
813 dir->PurgeEntriesWithTypeIn(types_to_purge); | 814 dir->PurgeEntriesWithTypeIn(types_to_purge); |
814 | 815 |
815 StatusController* status = session_->status_controller(); | 816 const StatusController& status = session_->status_controller(); |
816 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 817 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
817 EXPECT_EQ(2U, status->unsynced_handles().size()); | 818 EXPECT_EQ(2U, status.unsynced_handles().size()); |
818 ASSERT_EQ(2U, mock_server_->committed_ids().size()); | 819 ASSERT_EQ(2U, mock_server_->committed_ids().size()); |
819 // If this test starts failing, be aware other sort orders could be valid. | 820 // If this test starts failing, be aware other sort orders could be valid. |
820 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 821 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
821 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 822 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
822 { | 823 { |
823 ReadTransaction rt(FROM_HERE, dir); | 824 ReadTransaction rt(FROM_HERE, dir); |
824 Entry entry(&rt, syncable::GET_BY_ID, child_id_); | 825 Entry entry(&rt, syncable::GET_BY_ID, child_id_); |
825 ASSERT_TRUE(entry.good()); | 826 ASSERT_TRUE(entry.good()); |
826 VerifyTestDataInEntry(&rt, &entry); | 827 VerifyTestDataInEntry(&rt, &entry); |
827 } | 828 } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 grandchild.Put(syncable::ID, ids_.FromNumber(105)); | 1052 grandchild.Put(syncable::ID, ids_.FromNumber(105)); |
1052 grandchild.Put(syncable::IS_DEL, true); | 1053 grandchild.Put(syncable::IS_DEL, true); |
1053 grandchild.Put(syncable::IS_DIR, false); | 1054 grandchild.Put(syncable::IS_DIR, false); |
1054 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1055 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1055 grandchild.Put(syncable::BASE_VERSION, 1); | 1056 grandchild.Put(syncable::BASE_VERSION, 1); |
1056 grandchild.Put(syncable::MTIME, now_minus_2h); | 1057 grandchild.Put(syncable::MTIME, now_minus_2h); |
1057 } | 1058 } |
1058 } | 1059 } |
1059 | 1060 |
1060 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 1061 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
1061 EXPECT_TRUE(6 == session_->status_controller()->unsynced_handles().size()); | 1062 EXPECT_EQ(6u, session_->status_controller().unsynced_handles().size()); |
1062 ASSERT_TRUE(6 == mock_server_->committed_ids().size()); | 1063 ASSERT_EQ(6u, mock_server_->committed_ids().size()); |
1063 // This test will NOT unroll deletes because SERVER_PARENT_ID is not set. | 1064 // This test will NOT unroll deletes because SERVER_PARENT_ID is not set. |
1064 // It will treat these like moves. | 1065 // It will treat these like moves. |
1065 vector<syncable::Id> commit_ids(mock_server_->committed_ids()); | 1066 vector<syncable::Id> commit_ids(mock_server_->committed_ids()); |
1066 EXPECT_TRUE(ids_.FromNumber(100) == commit_ids[0]); | 1067 EXPECT_TRUE(ids_.FromNumber(100) == commit_ids[0]); |
1067 EXPECT_TRUE(ids_.FromNumber(101) == commit_ids[1]); | 1068 EXPECT_TRUE(ids_.FromNumber(101) == commit_ids[1]); |
1068 EXPECT_TRUE(ids_.FromNumber(102) == commit_ids[2]); | 1069 EXPECT_TRUE(ids_.FromNumber(102) == commit_ids[2]); |
1069 // We don't guarantee the delete orders in this test, only that they occur | 1070 // We don't guarantee the delete orders in this test, only that they occur |
1070 // at the end. | 1071 // at the end. |
1071 std::sort(commit_ids.begin() + 3, commit_ids.end()); | 1072 std::sort(commit_ids.begin() + 3, commit_ids.end()); |
1072 EXPECT_TRUE(ids_.FromNumber(103) == commit_ids[3]); | 1073 EXPECT_TRUE(ids_.FromNumber(103) == commit_ids[3]); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 MutableEntry child(&wtrans, syncable::CREATE, child_id_, "B"); | 1122 MutableEntry child(&wtrans, syncable::CREATE, child_id_, "B"); |
1122 ASSERT_TRUE(child.good()); | 1123 ASSERT_TRUE(child.good()); |
1123 child.Put(syncable::IS_UNSYNCED, true); | 1124 child.Put(syncable::IS_UNSYNCED, true); |
1124 child.Put(syncable::IS_DIR, true); | 1125 child.Put(syncable::IS_DIR, true); |
1125 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1126 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1126 child.Put(syncable::ID, ids_.FromNumber(105)); | 1127 child.Put(syncable::ID, ids_.FromNumber(105)); |
1127 child.Put(syncable::BASE_VERSION, 1); | 1128 child.Put(syncable::BASE_VERSION, 1); |
1128 } | 1129 } |
1129 | 1130 |
1130 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 1131 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
1131 EXPECT_TRUE(6 == session_->status_controller()->unsynced_handles().size()); | 1132 EXPECT_EQ(6u, session_->status_controller().unsynced_handles().size()); |
1132 ASSERT_TRUE(6 == mock_server_->committed_ids().size()); | 1133 ASSERT_EQ(6u, mock_server_->committed_ids().size()); |
1133 // If this test starts failing, be aware other sort orders could be valid. | 1134 // If this test starts failing, be aware other sort orders could be valid. |
1134 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1135 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
1135 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 1136 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
1136 EXPECT_TRUE(ids_.FromNumber(102) == mock_server_->committed_ids()[2]); | 1137 EXPECT_TRUE(ids_.FromNumber(102) == mock_server_->committed_ids()[2]); |
1137 EXPECT_TRUE(ids_.FromNumber(-103) == mock_server_->committed_ids()[3]); | 1138 EXPECT_TRUE(ids_.FromNumber(-103) == mock_server_->committed_ids()[3]); |
1138 EXPECT_TRUE(ids_.FromNumber(-104) == mock_server_->committed_ids()[4]); | 1139 EXPECT_TRUE(ids_.FromNumber(-104) == mock_server_->committed_ids()[4]); |
1139 EXPECT_TRUE(ids_.FromNumber(105) == mock_server_->committed_ids()[5]); | 1140 EXPECT_TRUE(ids_.FromNumber(105) == mock_server_->committed_ids()[5]); |
1140 } | 1141 } |
1141 | 1142 |
1142 TEST_F(SyncerTest, TestCommitListOrderingCounterexample) { | 1143 TEST_F(SyncerTest, TestCommitListOrderingCounterexample) { |
(...skipping 20 matching lines...) Expand all Loading... |
1163 child2.Put(syncable::IS_UNSYNCED, true); | 1164 child2.Put(syncable::IS_UNSYNCED, true); |
1164 child2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1165 child2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1165 child2.Put(syncable::ID, child2_id); | 1166 child2.Put(syncable::ID, child2_id); |
1166 | 1167 |
1167 parent.Put(syncable::BASE_VERSION, 1); | 1168 parent.Put(syncable::BASE_VERSION, 1); |
1168 child1.Put(syncable::BASE_VERSION, 1); | 1169 child1.Put(syncable::BASE_VERSION, 1); |
1169 child2.Put(syncable::BASE_VERSION, 1); | 1170 child2.Put(syncable::BASE_VERSION, 1); |
1170 } | 1171 } |
1171 | 1172 |
1172 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 1173 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
1173 EXPECT_TRUE(3 == session_->status_controller()->unsynced_handles().size()); | 1174 EXPECT_EQ(3u, session_->status_controller().unsynced_handles().size()); |
1174 ASSERT_TRUE(3 == mock_server_->committed_ids().size()); | 1175 ASSERT_EQ(3u, mock_server_->committed_ids().size()); |
1175 // If this test starts failing, be aware other sort orders could be valid. | 1176 // If this test starts failing, be aware other sort orders could be valid. |
1176 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1177 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
1177 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 1178 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
1178 EXPECT_TRUE(child2_id == mock_server_->committed_ids()[2]); | 1179 EXPECT_TRUE(child2_id == mock_server_->committed_ids()[2]); |
1179 } | 1180 } |
1180 | 1181 |
1181 TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) { | 1182 TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) { |
1182 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1183 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
1183 ASSERT_TRUE(dir.good()); | 1184 ASSERT_TRUE(dir.good()); |
1184 | 1185 |
(...skipping 27 matching lines...) Expand all Loading... |
1212 MutableEntry child(&wtrans, syncable::CREATE, parent2_id, child_name); | 1213 MutableEntry child(&wtrans, syncable::CREATE, parent2_id, child_name); |
1213 ASSERT_TRUE(child.good()); | 1214 ASSERT_TRUE(child.good()); |
1214 child.Put(syncable::IS_UNSYNCED, true); | 1215 child.Put(syncable::IS_UNSYNCED, true); |
1215 child.Put(syncable::IS_DIR, true); | 1216 child.Put(syncable::IS_DIR, true); |
1216 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1217 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1217 child.Put(syncable::ID, child_id); | 1218 child.Put(syncable::ID, child_id); |
1218 child.Put(syncable::BASE_VERSION, 1); | 1219 child.Put(syncable::BASE_VERSION, 1); |
1219 } | 1220 } |
1220 | 1221 |
1221 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 1222 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
1222 EXPECT_TRUE(3 == session_->status_controller()->unsynced_handles().size()); | 1223 EXPECT_EQ(3u, session_->status_controller().unsynced_handles().size()); |
1223 ASSERT_TRUE(3 == mock_server_->committed_ids().size()); | 1224 ASSERT_EQ(3u, mock_server_->committed_ids().size()); |
1224 // If this test starts failing, be aware other sort orders could be valid. | 1225 // If this test starts failing, be aware other sort orders could be valid. |
1225 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1226 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
1226 EXPECT_TRUE(parent2_id == mock_server_->committed_ids()[1]); | 1227 EXPECT_TRUE(parent2_id == mock_server_->committed_ids()[1]); |
1227 EXPECT_TRUE(child_id == mock_server_->committed_ids()[2]); | 1228 EXPECT_TRUE(child_id == mock_server_->committed_ids()[2]); |
1228 { | 1229 { |
1229 ReadTransaction rtrans(FROM_HERE, dir); | 1230 ReadTransaction rtrans(FROM_HERE, dir); |
1230 // Check that things committed correctly. | 1231 // Check that things committed correctly. |
1231 Entry entry_1(&rtrans, syncable::GET_BY_ID, parent_id_); | 1232 Entry entry_1(&rtrans, syncable::GET_BY_ID, parent_id_); |
1232 EXPECT_EQ(entry_1.Get(NON_UNIQUE_NAME), parent1_name); | 1233 EXPECT_EQ(entry_1.Get(NON_UNIQUE_NAME), parent1_name); |
1233 // Check that parent2 is a subfolder of parent1. | 1234 // Check that parent2 is a subfolder of parent1. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 MutableEntry child(&wtrans, syncable::CREATE, parent2_local_id, child_name); | 1287 MutableEntry child(&wtrans, syncable::CREATE, parent2_local_id, child_name); |
1287 ASSERT_TRUE(child.good()); | 1288 ASSERT_TRUE(child.good()); |
1288 child.Put(syncable::IS_UNSYNCED, true); | 1289 child.Put(syncable::IS_UNSYNCED, true); |
1289 child.Put(syncable::IS_DIR, true); | 1290 child.Put(syncable::IS_DIR, true); |
1290 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1291 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1291 child.Put(syncable::ID, child_local_id); | 1292 child.Put(syncable::ID, child_local_id); |
1292 meta_handle_b = child.Get(syncable::META_HANDLE); | 1293 meta_handle_b = child.Get(syncable::META_HANDLE); |
1293 } | 1294 } |
1294 | 1295 |
1295 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 1296 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
1296 EXPECT_TRUE(3 == session_->status_controller()->unsynced_handles().size()); | 1297 EXPECT_EQ(3u, session_->status_controller().unsynced_handles().size()); |
1297 ASSERT_TRUE(3 == mock_server_->committed_ids().size()); | 1298 ASSERT_EQ(3u, mock_server_->committed_ids().size()); |
1298 // If this test starts failing, be aware other sort orders could be valid. | 1299 // If this test starts failing, be aware other sort orders could be valid. |
1299 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1300 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
1300 EXPECT_TRUE(parent2_local_id == mock_server_->committed_ids()[1]); | 1301 EXPECT_TRUE(parent2_local_id == mock_server_->committed_ids()[1]); |
1301 EXPECT_TRUE(child_local_id == mock_server_->committed_ids()[2]); | 1302 EXPECT_TRUE(child_local_id == mock_server_->committed_ids()[2]); |
1302 { | 1303 { |
1303 ReadTransaction rtrans(FROM_HERE, dir); | 1304 ReadTransaction rtrans(FROM_HERE, dir); |
1304 | 1305 |
1305 Entry parent(&rtrans, syncable::GET_BY_ID, | 1306 Entry parent(&rtrans, syncable::GET_BY_ID, |
1306 GetOnlyEntryWithName(&rtrans, rtrans.root_id(), parent_name)); | 1307 GetOnlyEntryWithName(&rtrans, rtrans.root_id(), parent_name)); |
1307 ASSERT_TRUE(parent.good()); | 1308 ASSERT_TRUE(parent.good()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 | 1341 |
1341 TEST_F(SyncerTest, DontGetStuckWithTwoSameNames) { | 1342 TEST_F(SyncerTest, DontGetStuckWithTwoSameNames) { |
1342 // We should not get stuck here because we get | 1343 // We should not get stuck here because we get |
1343 // two server updates with exactly the same name. | 1344 // two server updates with exactly the same name. |
1344 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1345 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
1345 ASSERT_TRUE(dir.good()); | 1346 ASSERT_TRUE(dir.good()); |
1346 mock_server_->AddUpdateDirectory(1, 0, "foo:", 1, 10); | 1347 mock_server_->AddUpdateDirectory(1, 0, "foo:", 1, 10); |
1347 SyncShareAsDelegate(); | 1348 SyncShareAsDelegate(); |
1348 mock_server_->AddUpdateDirectory(2, 0, "foo:", 1, 20); | 1349 mock_server_->AddUpdateDirectory(2, 0, "foo:", 1, 20); |
1349 SyncRepeatedlyToTriggerStuckSignal(session_.get()); | 1350 SyncRepeatedlyToTriggerStuckSignal(session_.get()); |
1350 EXPECT_FALSE(session_->status_controller()->syncer_status().syncer_stuck); | 1351 EXPECT_FALSE(session_->status_controller().syncer_status().syncer_stuck); |
1351 saw_syncer_event_ = false; | 1352 saw_syncer_event_ = false; |
1352 } | 1353 } |
1353 | 1354 |
1354 TEST_F(SyncerTest, TestBasicUpdate) { | 1355 TEST_F(SyncerTest, TestBasicUpdate) { |
1355 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1356 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
1356 ASSERT_TRUE(dir.good()); | 1357 ASSERT_TRUE(dir.good()); |
1357 string id = "some_id"; | 1358 string id = "some_id"; |
1358 string parent_id = "0"; | 1359 string parent_id = "0"; |
1359 string name = "in_root"; | 1360 string name = "in_root"; |
1360 int64 version = 10; | 1361 int64 version = 10; |
(...skipping 27 matching lines...) Expand all Loading... |
1388 mock_server_->AddUpdateDirectory(2, 0, "in_root", 10, 10); | 1389 mock_server_->AddUpdateDirectory(2, 0, "in_root", 10, 10); |
1389 | 1390 |
1390 // Unknown parent: should never be applied. "-80" is a legal server ID, | 1391 // Unknown parent: should never be applied. "-80" is a legal server ID, |
1391 // because any string sent by the server is a legal server ID in the sync | 1392 // because any string sent by the server is a legal server ID in the sync |
1392 // protocol, but it's not the ID of any item known to the client. This | 1393 // protocol, but it's not the ID of any item known to the client. This |
1393 // update should succeed validation, but be stuck in the unapplied state | 1394 // update should succeed validation, but be stuck in the unapplied state |
1394 // until an item with the server ID "-80" arrives. | 1395 // until an item with the server ID "-80" arrives. |
1395 mock_server_->AddUpdateDirectory(3, -80, "bad_parent", 10, 10); | 1396 mock_server_->AddUpdateDirectory(3, -80, "bad_parent", 10, 10); |
1396 | 1397 |
1397 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 1398 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
1398 StatusController* status = session_->status_controller(); | 1399 StatusController* status = session_->mutable_status_controller(); |
1399 | 1400 |
1400 // Id 3 should be in conflict now. | 1401 // Id 3 should be in conflict now. |
1401 EXPECT_EQ(1, status->TotalNumConflictingItems()); | 1402 EXPECT_EQ(1, status->TotalNumConflictingItems()); |
1402 { | 1403 { |
1403 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 1404 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
1404 EXPECT_EQ(1, status->conflict_progress().ConflictingItemsSize()); | 1405 ASSERT_TRUE(status->conflict_progress()); |
| 1406 EXPECT_EQ(1, status->conflict_progress()->ConflictingItemsSize()); |
1405 } | 1407 } |
1406 | 1408 |
1407 // These entries will be used in the second set of updates. | 1409 // These entries will be used in the second set of updates. |
1408 mock_server_->AddUpdateDirectory(4, 0, "newer_version", 20, 10); | 1410 mock_server_->AddUpdateDirectory(4, 0, "newer_version", 20, 10); |
1409 mock_server_->AddUpdateDirectory(5, 0, "circular1", 10, 10); | 1411 mock_server_->AddUpdateDirectory(5, 0, "circular1", 10, 10); |
1410 mock_server_->AddUpdateDirectory(6, 5, "circular2", 10, 10); | 1412 mock_server_->AddUpdateDirectory(6, 5, "circular2", 10, 10); |
1411 mock_server_->AddUpdateDirectory(9, 3, "bad_parent_child", 10, 10); | 1413 mock_server_->AddUpdateDirectory(9, 3, "bad_parent_child", 10, 10); |
1412 mock_server_->AddUpdateDirectory(100, 9, "bad_parent_child2", 10, 10); | 1414 mock_server_->AddUpdateDirectory(100, 9, "bad_parent_child2", 10, 10); |
1413 mock_server_->AddUpdateDirectory(10, 0, "dir_to_bookmark", 10, 10); | 1415 mock_server_->AddUpdateDirectory(10, 0, "dir_to_bookmark", 10, 10); |
1414 | 1416 |
1415 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 1417 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
1416 // The three items with an unresolved parent should be unapplied (3, 9, 100). | 1418 // The three items with an unresolved parent should be unapplied (3, 9, 100). |
1417 // The name clash should also still be in conflict. | 1419 // The name clash should also still be in conflict. |
1418 EXPECT_EQ(3, status->TotalNumConflictingItems()); | 1420 EXPECT_EQ(3, status->TotalNumConflictingItems()); |
1419 { | 1421 { |
1420 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 1422 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
1421 EXPECT_EQ(3, status->conflict_progress().ConflictingItemsSize()); | 1423 ASSERT_TRUE(status->conflict_progress()); |
| 1424 EXPECT_EQ(3, status->conflict_progress()->ConflictingItemsSize()); |
1422 } | 1425 } |
1423 | 1426 |
1424 { | 1427 { |
1425 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | 1428 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
1426 // Even though it has the same name, it should work. | 1429 // Even though it has the same name, it should work. |
1427 Entry name_clash(&trans, GET_BY_ID, ids_.FromNumber(2)); | 1430 Entry name_clash(&trans, GET_BY_ID, ids_.FromNumber(2)); |
1428 ASSERT_TRUE(name_clash.good()); | 1431 ASSERT_TRUE(name_clash.good()); |
1429 EXPECT_FALSE(name_clash.Get(IS_UNAPPLIED_UPDATE)) | 1432 EXPECT_FALSE(name_clash.Get(IS_UNAPPLIED_UPDATE)) |
1430 << "Duplicate name SHOULD be OK."; | 1433 << "Duplicate name SHOULD be OK."; |
1431 | 1434 |
(...skipping 25 matching lines...) Expand all Loading... |
1457 | 1460 |
1458 // Version number older than last known: should fail verify & be dropped. | 1461 // Version number older than last known: should fail verify & be dropped. |
1459 mock_server_->AddUpdateDirectory(4, 0, "old_version", 10, 10); | 1462 mock_server_->AddUpdateDirectory(4, 0, "old_version", 10, 10); |
1460 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 1463 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
1461 { | 1464 { |
1462 ReadTransaction trans(FROM_HERE, dir); | 1465 ReadTransaction trans(FROM_HERE, dir); |
1463 | 1466 |
1464 Entry still_a_dir(&trans, GET_BY_ID, ids_.FromNumber(10)); | 1467 Entry still_a_dir(&trans, GET_BY_ID, ids_.FromNumber(10)); |
1465 ASSERT_TRUE(still_a_dir.good()); | 1468 ASSERT_TRUE(still_a_dir.good()); |
1466 EXPECT_FALSE(still_a_dir.Get(IS_UNAPPLIED_UPDATE)); | 1469 EXPECT_FALSE(still_a_dir.Get(IS_UNAPPLIED_UPDATE)); |
1467 EXPECT_TRUE(10 == still_a_dir.Get(BASE_VERSION)); | 1470 EXPECT_EQ(10u, still_a_dir.Get(BASE_VERSION)); |
1468 EXPECT_TRUE(10 == still_a_dir.Get(SERVER_VERSION)); | 1471 EXPECT_EQ(10u, still_a_dir.Get(SERVER_VERSION)); |
1469 EXPECT_TRUE(still_a_dir.Get(IS_DIR)); | 1472 EXPECT_TRUE(still_a_dir.Get(IS_DIR)); |
1470 | 1473 |
1471 Entry rename(&trans, GET_BY_ID, ids_.FromNumber(1)); | 1474 Entry rename(&trans, GET_BY_ID, ids_.FromNumber(1)); |
1472 ASSERT_TRUE(rename.good()); | 1475 ASSERT_TRUE(rename.good()); |
1473 EXPECT_EQ(root, rename.Get(PARENT_ID)); | 1476 EXPECT_EQ(root, rename.Get(PARENT_ID)); |
1474 EXPECT_EQ("new_name", rename.Get(NON_UNIQUE_NAME)); | 1477 EXPECT_EQ("new_name", rename.Get(NON_UNIQUE_NAME)); |
1475 EXPECT_FALSE(rename.Get(IS_UNAPPLIED_UPDATE)); | 1478 EXPECT_FALSE(rename.Get(IS_UNAPPLIED_UPDATE)); |
1476 EXPECT_TRUE(ids_.FromNumber(1) == rename.Get(ID)); | 1479 EXPECT_TRUE(ids_.FromNumber(1) == rename.Get(ID)); |
1477 EXPECT_TRUE(20 == rename.Get(BASE_VERSION)); | 1480 EXPECT_EQ(20u, rename.Get(BASE_VERSION)); |
1478 | 1481 |
1479 Entry name_clash(&trans, GET_BY_ID, ids_.FromNumber(2)); | 1482 Entry name_clash(&trans, GET_BY_ID, ids_.FromNumber(2)); |
1480 ASSERT_TRUE(name_clash.good()); | 1483 ASSERT_TRUE(name_clash.good()); |
1481 EXPECT_EQ(root, name_clash.Get(PARENT_ID)); | 1484 EXPECT_EQ(root, name_clash.Get(PARENT_ID)); |
1482 EXPECT_TRUE(ids_.FromNumber(2) == name_clash.Get(ID)); | 1485 EXPECT_TRUE(ids_.FromNumber(2) == name_clash.Get(ID)); |
1483 EXPECT_TRUE(10 == name_clash.Get(BASE_VERSION)); | 1486 EXPECT_EQ(10u, name_clash.Get(BASE_VERSION)); |
1484 EXPECT_EQ("in_root", name_clash.Get(NON_UNIQUE_NAME)); | 1487 EXPECT_EQ("in_root", name_clash.Get(NON_UNIQUE_NAME)); |
1485 | 1488 |
1486 Entry ignored_old_version(&trans, GET_BY_ID, ids_.FromNumber(4)); | 1489 Entry ignored_old_version(&trans, GET_BY_ID, ids_.FromNumber(4)); |
1487 ASSERT_TRUE(ignored_old_version.good()); | 1490 ASSERT_TRUE(ignored_old_version.good()); |
1488 EXPECT_TRUE( | 1491 EXPECT_TRUE( |
1489 ignored_old_version.Get(NON_UNIQUE_NAME) == "newer_version"); | 1492 ignored_old_version.Get(NON_UNIQUE_NAME) == "newer_version"); |
1490 EXPECT_FALSE(ignored_old_version.Get(IS_UNAPPLIED_UPDATE)); | 1493 EXPECT_FALSE(ignored_old_version.Get(IS_UNAPPLIED_UPDATE)); |
1491 EXPECT_TRUE(20 == ignored_old_version.Get(BASE_VERSION)); | 1494 EXPECT_EQ(20u, ignored_old_version.Get(BASE_VERSION)); |
1492 | 1495 |
1493 Entry circular_parent_issue(&trans, GET_BY_ID, ids_.FromNumber(5)); | 1496 Entry circular_parent_issue(&trans, GET_BY_ID, ids_.FromNumber(5)); |
1494 ASSERT_TRUE(circular_parent_issue.good()); | 1497 ASSERT_TRUE(circular_parent_issue.good()); |
1495 EXPECT_TRUE(circular_parent_issue.Get(IS_UNAPPLIED_UPDATE)) | 1498 EXPECT_TRUE(circular_parent_issue.Get(IS_UNAPPLIED_UPDATE)) |
1496 << "circular move should be in conflict"; | 1499 << "circular move should be in conflict"; |
1497 EXPECT_TRUE(circular_parent_issue.Get(PARENT_ID) == root_id_); | 1500 EXPECT_TRUE(circular_parent_issue.Get(PARENT_ID) == root_id_); |
1498 EXPECT_TRUE(circular_parent_issue.Get(SERVER_PARENT_ID) == | 1501 EXPECT_TRUE(circular_parent_issue.Get(SERVER_PARENT_ID) == |
1499 ids_.FromNumber(6)); | 1502 ids_.FromNumber(6)); |
1500 EXPECT_TRUE(10 == circular_parent_issue.Get(BASE_VERSION)); | 1503 EXPECT_EQ(10u, circular_parent_issue.Get(BASE_VERSION)); |
1501 | 1504 |
1502 Entry circular_parent_target(&trans, GET_BY_ID, ids_.FromNumber(6)); | 1505 Entry circular_parent_target(&trans, GET_BY_ID, ids_.FromNumber(6)); |
1503 ASSERT_TRUE(circular_parent_target.good()); | 1506 ASSERT_TRUE(circular_parent_target.good()); |
1504 EXPECT_FALSE(circular_parent_target.Get(IS_UNAPPLIED_UPDATE)); | 1507 EXPECT_FALSE(circular_parent_target.Get(IS_UNAPPLIED_UPDATE)); |
1505 EXPECT_TRUE(circular_parent_issue.Get(ID) == | 1508 EXPECT_TRUE(circular_parent_issue.Get(ID) == |
1506 circular_parent_target.Get(PARENT_ID)); | 1509 circular_parent_target.Get(PARENT_ID)); |
1507 EXPECT_TRUE(10 == circular_parent_target.Get(BASE_VERSION)); | 1510 EXPECT_EQ(10u, circular_parent_target.Get(BASE_VERSION)); |
1508 } | 1511 } |
1509 | 1512 |
1510 EXPECT_FALSE(saw_syncer_event_); | 1513 EXPECT_FALSE(saw_syncer_event_); |
1511 EXPECT_EQ(4, status->TotalNumConflictingItems()); | 1514 EXPECT_EQ(4, status->TotalNumConflictingItems()); |
1512 { | 1515 { |
1513 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 1516 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
1514 EXPECT_EQ(4, status->conflict_progress().ConflictingItemsSize()); | 1517 ASSERT_TRUE(status->conflict_progress()); |
| 1518 EXPECT_EQ(4, status->conflict_progress()->ConflictingItemsSize()); |
1515 } | 1519 } |
1516 } | 1520 } |
1517 | 1521 |
1518 TEST_F(SyncerTest, CommitTimeRename) { | 1522 TEST_F(SyncerTest, CommitTimeRename) { |
1519 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1523 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
1520 ASSERT_TRUE(dir.good()); | 1524 ASSERT_TRUE(dir.good()); |
1521 int64 metahandle_folder; | 1525 int64 metahandle_folder; |
1522 int64 metahandle_new_entry; | 1526 int64 metahandle_new_entry; |
1523 | 1527 |
1524 // Create a folder and an entry. | 1528 // Create a folder and an entry. |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 ASSERT_TRUE(entry.good()); | 1956 ASSERT_TRUE(entry.good()); |
1953 entry.Put(syncable::IS_DIR, true); | 1957 entry.Put(syncable::IS_DIR, true); |
1954 entry.Put(syncable::IS_UNSYNCED, true); | 1958 entry.Put(syncable::IS_UNSYNCED, true); |
1955 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1959 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
1956 } | 1960 } |
1957 | 1961 |
1958 mock_server_->SetMidCommitCallback( | 1962 mock_server_->SetMidCommitCallback( |
1959 NewCallback<EntryCreatedInNewFolderTest>(this, | 1963 NewCallback<EntryCreatedInNewFolderTest>(this, |
1960 &EntryCreatedInNewFolderTest::CreateFolderInBob)); | 1964 &EntryCreatedInNewFolderTest::CreateFolderInBob)); |
1961 syncer_->SyncShare(session_.get(), BUILD_COMMIT_REQUEST, SYNCER_END); | 1965 syncer_->SyncShare(session_.get(), BUILD_COMMIT_REQUEST, SYNCER_END); |
1962 EXPECT_TRUE(1 == mock_server_->committed_ids().size()); | 1966 EXPECT_EQ(1u, mock_server_->committed_ids().size()); |
1963 { | 1967 { |
1964 ReadTransaction trans(FROM_HERE, dir); | 1968 ReadTransaction trans(FROM_HERE, dir); |
1965 Entry parent_entry(&trans, syncable::GET_BY_ID, | 1969 Entry parent_entry(&trans, syncable::GET_BY_ID, |
1966 GetOnlyEntryWithName(&trans, TestIdFactory::root(), "bob")); | 1970 GetOnlyEntryWithName(&trans, TestIdFactory::root(), "bob")); |
1967 ASSERT_TRUE(parent_entry.good()); | 1971 ASSERT_TRUE(parent_entry.good()); |
1968 | 1972 |
1969 Id child_id = | 1973 Id child_id = |
1970 GetOnlyEntryWithName(&trans, parent_entry.Get(ID), "bob"); | 1974 GetOnlyEntryWithName(&trans, parent_entry.Get(ID), "bob"); |
1971 Entry child(&trans, syncable::GET_BY_ID, child_id); | 1975 Entry child(&trans, syncable::GET_BY_ID, child_id); |
1972 ASSERT_TRUE(child.good()); | 1976 ASSERT_TRUE(child.good()); |
(...skipping 18 matching lines...) Expand all Loading... |
1991 // Create an item. | 1995 // Create an item. |
1992 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | 1996 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
1993 MutableEntry fred_match(&trans, CREATE, trans.root_id(), | 1997 MutableEntry fred_match(&trans, CREATE, trans.root_id(), |
1994 "fred_match"); | 1998 "fred_match"); |
1995 ASSERT_TRUE(fred_match.good()); | 1999 ASSERT_TRUE(fred_match.good()); |
1996 metahandle_fred = fred_match.Get(META_HANDLE); | 2000 metahandle_fred = fred_match.Get(META_HANDLE); |
1997 WriteTestDataToEntry(&trans, &fred_match); | 2001 WriteTestDataToEntry(&trans, &fred_match); |
1998 } | 2002 } |
1999 // Commit it. | 2003 // Commit it. |
2000 SyncShareAsDelegate(); | 2004 SyncShareAsDelegate(); |
2001 EXPECT_TRUE(1 == mock_server_->committed_ids().size()); | 2005 EXPECT_EQ(1u, mock_server_->committed_ids().size()); |
2002 mock_server_->set_conflict_all_commits(true); | 2006 mock_server_->set_conflict_all_commits(true); |
2003 syncable::Id fred_match_id; | 2007 syncable::Id fred_match_id; |
2004 { | 2008 { |
2005 // Now receive a change from outside. | 2009 // Now receive a change from outside. |
2006 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | 2010 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
2007 MutableEntry fred_match(&trans, GET_BY_HANDLE, metahandle_fred); | 2011 MutableEntry fred_match(&trans, GET_BY_HANDLE, metahandle_fred); |
2008 ASSERT_TRUE(fred_match.good()); | 2012 ASSERT_TRUE(fred_match.good()); |
2009 EXPECT_TRUE(fred_match.Get(ID).ServerKnows()); | 2013 EXPECT_TRUE(fred_match.Get(ID).ServerKnows()); |
2010 fred_match_id = fred_match.Get(ID); | 2014 fred_match_id = fred_match.Get(ID); |
2011 mock_server_->AddUpdateBookmark(fred_match_id, trans.root_id(), | 2015 mock_server_->AddUpdateBookmark(fred_match_id, trans.root_id(), |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2051 Entry child(&trans, syncable::GET_BY_ID, child_id_); | 2055 Entry child(&trans, syncable::GET_BY_ID, child_id_); |
2052 ASSERT_TRUE(child.good()); | 2056 ASSERT_TRUE(child.good()); |
2053 EXPECT_TRUE(child.Get(syncable::IS_UNSYNCED)); | 2057 EXPECT_TRUE(child.Get(syncable::IS_UNSYNCED)); |
2054 EXPECT_FALSE(child.Get(syncable::IS_UNAPPLIED_UPDATE)); | 2058 EXPECT_FALSE(child.Get(syncable::IS_UNAPPLIED_UPDATE)); |
2055 EXPECT_TRUE(child.Get(SPECIFICS).HasExtension(sync_pb::bookmark)); | 2059 EXPECT_TRUE(child.Get(SPECIFICS).HasExtension(sync_pb::bookmark)); |
2056 EXPECT_EQ("Pete.htm", child.Get(NON_UNIQUE_NAME)); | 2060 EXPECT_EQ("Pete.htm", child.Get(NON_UNIQUE_NAME)); |
2057 VerifyTestBookmarkDataInEntry(&child); | 2061 VerifyTestBookmarkDataInEntry(&child); |
2058 } | 2062 } |
2059 | 2063 |
2060 // Only one entry, since we just overwrite one. | 2064 // Only one entry, since we just overwrite one. |
2061 EXPECT_TRUE(1 == children.size()); | 2065 EXPECT_EQ(1u, children.size()); |
2062 saw_syncer_event_ = false; | 2066 saw_syncer_event_ = false; |
2063 } | 2067 } |
2064 | 2068 |
2065 // We got this repro case when someone was editing bookmarks while sync was | 2069 // We got this repro case when someone was editing bookmarks while sync was |
2066 // occuring. The entry had changed out underneath the user. | 2070 // occuring. The entry had changed out underneath the user. |
2067 TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) { | 2071 TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) { |
2068 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2072 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
2069 CHECK(dir.good()); | 2073 CHECK(dir.good()); |
2070 const base::Time& test_time = ProtoTimeToTime(123456); | 2074 const base::Time& test_time = ProtoTimeToTime(123456); |
2071 int64 entry_metahandle; | 2075 int64 entry_metahandle; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2134 mock_server_->AddUpdateDirectory(parent_id, root_id_, "Folder", 10, 10); | 2138 mock_server_->AddUpdateDirectory(parent_id, root_id_, "Folder", 10, 10); |
2135 mock_server_->AddUpdateBookmark(child_id, parent_id, "test.htm", 10, 10); | 2139 mock_server_->AddUpdateBookmark(child_id, parent_id, "test.htm", 10, 10); |
2136 mock_server_->set_conflict_all_commits(true); | 2140 mock_server_->set_conflict_all_commits(true); |
2137 SyncShareAsDelegate(); | 2141 SyncShareAsDelegate(); |
2138 SyncShareAsDelegate(); | 2142 SyncShareAsDelegate(); |
2139 SyncShareAsDelegate(); | 2143 SyncShareAsDelegate(); |
2140 { | 2144 { |
2141 ReadTransaction trans(FROM_HERE, dir); | 2145 ReadTransaction trans(FROM_HERE, dir); |
2142 Directory::ChildHandles children; | 2146 Directory::ChildHandles children; |
2143 dir->GetChildHandlesById(&trans, root_id_, &children); | 2147 dir->GetChildHandlesById(&trans, root_id_, &children); |
2144 EXPECT_TRUE(1 == children.size()); | 2148 EXPECT_EQ(1u, children.size()); |
2145 dir->GetChildHandlesById(&trans, parent_id, &children); | 2149 dir->GetChildHandlesById(&trans, parent_id, &children); |
2146 EXPECT_TRUE(1 == children.size()); | 2150 EXPECT_EQ(1u, children.size()); |
2147 Directory::UnappliedUpdateMetaHandles unapplied; | 2151 Directory::UnappliedUpdateMetaHandles unapplied; |
2148 dir->GetUnappliedUpdateMetaHandles(&trans, &unapplied); | 2152 dir->GetUnappliedUpdateMetaHandles(&trans, &unapplied); |
2149 EXPECT_TRUE(0 == unapplied.size()); | 2153 EXPECT_EQ(0u, unapplied.size()); |
2150 syncable::Directory::UnsyncedMetaHandles unsynced; | 2154 syncable::Directory::UnsyncedMetaHandles unsynced; |
2151 dir->GetUnsyncedMetaHandles(&trans, &unsynced); | 2155 dir->GetUnsyncedMetaHandles(&trans, &unsynced); |
2152 EXPECT_TRUE(0 == unsynced.size()); | 2156 EXPECT_EQ(0u, unsynced.size()); |
2153 saw_syncer_event_ = false; | 2157 saw_syncer_event_ = false; |
2154 } | 2158 } |
2155 } | 2159 } |
2156 | 2160 |
2157 TEST_F(SyncerTest, CommittingNewDeleted) { | 2161 TEST_F(SyncerTest, CommittingNewDeleted) { |
2158 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2162 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
2159 CHECK(dir.good()); | 2163 CHECK(dir.good()); |
2160 { | 2164 { |
2161 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | 2165 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
2162 MutableEntry entry(&trans, CREATE, trans.root_id(), "bob"); | 2166 MutableEntry entry(&trans, CREATE, trans.root_id(), "bob"); |
2163 entry.Put(IS_UNSYNCED, true); | 2167 entry.Put(IS_UNSYNCED, true); |
2164 entry.Put(IS_DEL, true); | 2168 entry.Put(IS_DEL, true); |
2165 } | 2169 } |
2166 SyncShareAsDelegate(); | 2170 SyncShareAsDelegate(); |
2167 EXPECT_TRUE(0 == mock_server_->committed_ids().size()); | 2171 EXPECT_EQ(0u, mock_server_->committed_ids().size()); |
2168 } | 2172 } |
2169 | 2173 |
2170 // Original problem synopsis: | 2174 // Original problem synopsis: |
2171 // Check failed: entry->Get(BASE_VERSION) <= entry->Get(SERVER_VERSION) | 2175 // Check failed: entry->Get(BASE_VERSION) <= entry->Get(SERVER_VERSION) |
2172 // Client creates entry, client finishes committing entry. Between | 2176 // Client creates entry, client finishes committing entry. Between |
2173 // commit and getting update back, we delete the entry. | 2177 // commit and getting update back, we delete the entry. |
2174 // We get the update for the entry, but the local one was modified | 2178 // We get the update for the entry, but the local one was modified |
2175 // so we store the entry but don't apply it. IS_UNAPPLIED_UPDATE is set. | 2179 // so we store the entry but don't apply it. IS_UNAPPLIED_UPDATE is set. |
2176 // We commit deletion and get a new version number. | 2180 // We commit deletion and get a new version number. |
2177 // We apply unapplied updates again before we get the update about the deletion. | 2181 // We apply unapplied updates again before we get the update about the deletion. |
(...skipping 10 matching lines...) Expand all Loading... |
2188 entry.Put(SERVER_VERSION, 1); | 2192 entry.Put(SERVER_VERSION, 1); |
2189 entry.Put(SERVER_PARENT_ID, ids_.FromNumber(9999)); // Bad parent. | 2193 entry.Put(SERVER_PARENT_ID, ids_.FromNumber(9999)); // Bad parent. |
2190 entry.Put(IS_UNSYNCED, true); | 2194 entry.Put(IS_UNSYNCED, true); |
2191 entry.Put(IS_UNAPPLIED_UPDATE, true); | 2195 entry.Put(IS_UNAPPLIED_UPDATE, true); |
2192 entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2196 entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2193 entry.Put(SERVER_SPECIFICS, DefaultBookmarkSpecifics()); | 2197 entry.Put(SERVER_SPECIFICS, DefaultBookmarkSpecifics()); |
2194 entry.Put(IS_DEL, false); | 2198 entry.Put(IS_DEL, false); |
2195 } | 2199 } |
2196 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 2200 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
2197 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 2201 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
2198 EXPECT_TRUE(0 == session_->status_controller()->TotalNumConflictingItems()); | 2202 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
2199 saw_syncer_event_ = false; | 2203 saw_syncer_event_ = false; |
2200 } | 2204 } |
2201 | 2205 |
2202 // Original problem synopsis: | 2206 // Original problem synopsis: |
2203 // Illegal parent | 2207 // Illegal parent |
2204 // Unexpected error during sync if we: | 2208 // Unexpected error during sync if we: |
2205 // make a new folder bob | 2209 // make a new folder bob |
2206 // wait for sync | 2210 // wait for sync |
2207 // make a new folder fred | 2211 // make a new folder fred |
2208 // move bob into fred | 2212 // move bob into fred |
(...skipping 27 matching lines...) Expand all Loading... |
2236 MutableEntry existing(&trans, GET_BY_HANDLE, existing_metahandle); | 2240 MutableEntry existing(&trans, GET_BY_HANDLE, existing_metahandle); |
2237 ASSERT_TRUE(existing.good()); | 2241 ASSERT_TRUE(existing.good()); |
2238 existing.Put(PARENT_ID, newfolder.Get(ID)); | 2242 existing.Put(PARENT_ID, newfolder.Get(ID)); |
2239 existing.Put(IS_UNSYNCED, true); | 2243 existing.Put(IS_UNSYNCED, true); |
2240 EXPECT_TRUE(existing.Get(ID).ServerKnows()); | 2244 EXPECT_TRUE(existing.Get(ID).ServerKnows()); |
2241 | 2245 |
2242 newfolder.Put(IS_DEL, true); | 2246 newfolder.Put(IS_DEL, true); |
2243 existing.Put(IS_DEL, true); | 2247 existing.Put(IS_DEL, true); |
2244 } | 2248 } |
2245 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 2249 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
2246 StatusController* status(session_->status_controller()); | 2250 const StatusController& status(session_->status_controller()); |
2247 EXPECT_TRUE(0 == status->error().num_conflicting_commits); | 2251 EXPECT_EQ(0, status.error().num_conflicting_commits); |
2248 } | 2252 } |
2249 | 2253 |
2250 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { | 2254 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { |
2251 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2255 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
2252 CHECK(dir.good()); | 2256 CHECK(dir.good()); |
2253 int64 newfolder_metahandle; | 2257 int64 newfolder_metahandle; |
2254 | 2258 |
2255 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 2259 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
2256 SyncShareAsDelegate(); | 2260 SyncShareAsDelegate(); |
2257 { | 2261 { |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3231 ASSERT_TRUE(dir.good()); | 3235 ASSERT_TRUE(dir.good()); |
3232 | 3236 |
3233 const syncable::Id susan_id = TestIdFactory::FromNumber(susan_int_id_); | 3237 const syncable::Id susan_id = TestIdFactory::FromNumber(susan_int_id_); |
3234 ASSERT_GT(countdown_till_delete_, 0); | 3238 ASSERT_GT(countdown_till_delete_, 0); |
3235 if (0 != --countdown_till_delete_) | 3239 if (0 != --countdown_till_delete_) |
3236 return; | 3240 return; |
3237 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | 3241 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
3238 MutableEntry susan(&trans, GET_BY_ID, susan_id); | 3242 MutableEntry susan(&trans, GET_BY_ID, susan_id); |
3239 Directory::ChildHandles children; | 3243 Directory::ChildHandles children; |
3240 dir->GetChildHandlesById(&trans, susan.Get(ID), &children); | 3244 dir->GetChildHandlesById(&trans, susan.Get(ID), &children); |
3241 ASSERT_TRUE(0 == children.size()); | 3245 ASSERT_EQ(0u, children.size()); |
3242 susan.Put(IS_DEL, true); | 3246 susan.Put(IS_DEL, true); |
3243 susan.Put(IS_UNSYNCED, true); | 3247 susan.Put(IS_UNSYNCED, true); |
3244 } | 3248 } |
3245 | 3249 |
3246 protected: | 3250 protected: |
3247 int countdown_till_delete_; | 3251 int countdown_till_delete_; |
3248 }; | 3252 }; |
3249 | 3253 |
3250 TEST_F(SusanDeletingTest, | 3254 TEST_F(SusanDeletingTest, |
3251 NewServerItemInAFolderHierarchyWeHaveDeleted3) { | 3255 NewServerItemInAFolderHierarchyWeHaveDeleted3) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3296 ASSERT_TRUE(susan.good()); | 3300 ASSERT_TRUE(susan.good()); |
3297 EXPECT_FALSE(susan.Get(IS_UNAPPLIED_UPDATE)); | 3301 EXPECT_FALSE(susan.Get(IS_UNAPPLIED_UPDATE)); |
3298 EXPECT_TRUE(fred.Get(IS_UNAPPLIED_UPDATE)); | 3302 EXPECT_TRUE(fred.Get(IS_UNAPPLIED_UPDATE)); |
3299 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); | 3303 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); |
3300 EXPECT_FALSE(joe.Get(IS_UNAPPLIED_UPDATE)); | 3304 EXPECT_FALSE(joe.Get(IS_UNAPPLIED_UPDATE)); |
3301 EXPECT_TRUE(susan.Get(IS_UNSYNCED)); | 3305 EXPECT_TRUE(susan.Get(IS_UNSYNCED)); |
3302 EXPECT_FALSE(fred.Get(IS_UNSYNCED)); | 3306 EXPECT_FALSE(fred.Get(IS_UNSYNCED)); |
3303 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); | 3307 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); |
3304 EXPECT_TRUE(joe.Get(IS_UNSYNCED)); | 3308 EXPECT_TRUE(joe.Get(IS_UNSYNCED)); |
3305 } | 3309 } |
3306 EXPECT_TRUE(0 == countdown_till_delete_); | 3310 EXPECT_EQ(0, countdown_till_delete_); |
3307 delete syncer_->pre_conflict_resolution_closure_; | 3311 delete syncer_->pre_conflict_resolution_closure_; |
3308 syncer_->pre_conflict_resolution_closure_ = NULL; | 3312 syncer_->pre_conflict_resolution_closure_ = NULL; |
3309 LoopSyncShare(); | 3313 LoopSyncShare(); |
3310 LoopSyncShare(); | 3314 LoopSyncShare(); |
3311 { | 3315 { |
3312 ReadTransaction trans(FROM_HERE, dir); | 3316 ReadTransaction trans(FROM_HERE, dir); |
3313 Entry bob(&trans, GET_BY_ID, bob_id); | 3317 Entry bob(&trans, GET_BY_ID, bob_id); |
3314 ASSERT_TRUE(bob.good()); | 3318 ASSERT_TRUE(bob.good()); |
3315 Entry joe(&trans, GET_BY_ID, joe_id); | 3319 Entry joe(&trans, GET_BY_ID, joe_id); |
3316 ASSERT_TRUE(joe.good()); | 3320 ASSERT_TRUE(joe.good()); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3496 folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 3500 folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
3497 MutableEntry folder2(&trans, CREATE, trans.root_id(), "fred"); | 3501 MutableEntry folder2(&trans, CREATE, trans.root_id(), "fred"); |
3498 ASSERT_TRUE(folder2.good()); | 3502 ASSERT_TRUE(folder2.good()); |
3499 folder2.Put(IS_UNSYNCED, false); | 3503 folder2.Put(IS_UNSYNCED, false); |
3500 folder2.Put(IS_DIR, true); | 3504 folder2.Put(IS_DIR, true); |
3501 folder2.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 3505 folder2.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
3502 folder2.Put(BASE_VERSION, 3); | 3506 folder2.Put(BASE_VERSION, 3); |
3503 folder2.Put(ID, syncable::Id::CreateFromServerId("mock_server:10000")); | 3507 folder2.Put(ID, syncable::Id::CreateFromServerId("mock_server:10000")); |
3504 } | 3508 } |
3505 mock_server_->set_next_new_id(10000); | 3509 mock_server_->set_next_new_id(10000); |
3506 EXPECT_TRUE(1 == dir->unsynced_entity_count()); | 3510 EXPECT_EQ(1u, dir->unsynced_entity_count()); |
3507 // we get back a bad id in here (should never happen). | 3511 // we get back a bad id in here (should never happen). |
3508 SyncShareAsDelegate(); | 3512 SyncShareAsDelegate(); |
3509 EXPECT_TRUE(1 == dir->unsynced_entity_count()); | 3513 EXPECT_EQ(1u, dir->unsynced_entity_count()); |
3510 SyncShareAsDelegate(); // another bad id in here. | 3514 SyncShareAsDelegate(); // another bad id in here. |
3511 EXPECT_TRUE(0 == dir->unsynced_entity_count()); | 3515 EXPECT_EQ(0u, dir->unsynced_entity_count()); |
3512 saw_syncer_event_ = false; | 3516 saw_syncer_event_ = false; |
3513 } | 3517 } |
3514 | 3518 |
3515 TEST_F(SyncerTest, DeletedEntryWithBadParentInLoopCalculation) { | 3519 TEST_F(SyncerTest, DeletedEntryWithBadParentInLoopCalculation) { |
3516 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3520 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
3517 ASSERT_TRUE(dir.good()); | 3521 ASSERT_TRUE(dir.good()); |
3518 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 3522 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
3519 SyncShareAsDelegate(); | 3523 SyncShareAsDelegate(); |
3520 { | 3524 { |
3521 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | 3525 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3643 syncable::Id id[7]; | 3647 syncable::Id id[7]; |
3644 for (int i = 1; i < 7; i++) { | 3648 for (int i = 1; i < 7; i++) { |
3645 id[i] = id_factory.NewServerId(); | 3649 id[i] = id_factory.NewServerId(); |
3646 } | 3650 } |
3647 bool is_dirty = false; | 3651 bool is_dirty = false; |
3648 ConflictProgress c(&is_dirty); | 3652 ConflictProgress c(&is_dirty); |
3649 c.MergeSets(id[1], id[2]); | 3653 c.MergeSets(id[1], id[2]); |
3650 c.MergeSets(id[2], id[3]); | 3654 c.MergeSets(id[2], id[3]); |
3651 c.MergeSets(id[4], id[5]); | 3655 c.MergeSets(id[4], id[5]); |
3652 c.MergeSets(id[5], id[6]); | 3656 c.MergeSets(id[5], id[6]); |
3653 EXPECT_TRUE(6 == c.IdToConflictSetSize()); | 3657 EXPECT_EQ(6u, c.IdToConflictSetSize()); |
3654 EXPECT_FALSE(is_dirty); | 3658 EXPECT_FALSE(is_dirty); |
3655 for (int i = 1; i < 7; i++) { | 3659 for (int i = 1; i < 7; i++) { |
3656 EXPECT_TRUE(NULL != c.IdToConflictSetGet(id[i])); | 3660 EXPECT_TRUE(NULL != c.IdToConflictSetGet(id[i])); |
3657 EXPECT_TRUE(c.IdToConflictSetGet(id[(i & ~3) + 1]) == | 3661 EXPECT_TRUE(c.IdToConflictSetGet(id[(i & ~3) + 1]) == |
3658 c.IdToConflictSetGet(id[i])); | 3662 c.IdToConflictSetGet(id[i])); |
3659 } | 3663 } |
3660 c.MergeSets(id[1], id[6]); | 3664 c.MergeSets(id[1], id[6]); |
3661 for (int i = 1; i < 7; i++) { | 3665 for (int i = 1; i < 7; i++) { |
3662 EXPECT_TRUE(NULL != c.IdToConflictSetGet(id[i])); | 3666 EXPECT_TRUE(NULL != c.IdToConflictSetGet(id[i])); |
3663 EXPECT_TRUE(c.IdToConflictSetGet(id[1]) == c.IdToConflictSetGet(id[i])); | 3667 EXPECT_TRUE(c.IdToConflictSetGet(id[1]) == c.IdToConflictSetGet(id[i])); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3696 | 3700 |
3697 syncable::Id parent_id = ids_.MakeServer("Parent"); | 3701 syncable::Id parent_id = ids_.MakeServer("Parent"); |
3698 mock_server_->AddUpdateDirectory(parent_id, ids_.root(), "foo", 1, 1); | 3702 mock_server_->AddUpdateDirectory(parent_id, ids_.root(), "foo", 1, 1); |
3699 | 3703 |
3700 for (int i = 1; i <= one_bajillion; ++i) { | 3704 for (int i = 1; i <= one_bajillion; ++i) { |
3701 syncable::Id item_id = ids_.FromNumber(i); | 3705 syncable::Id item_id = ids_.FromNumber(i); |
3702 mock_server_->AddUpdateDirectory(item_id, parent_id, "dude", 1, 1); | 3706 mock_server_->AddUpdateDirectory(item_id, parent_id, "dude", 1, 1); |
3703 } | 3707 } |
3704 | 3708 |
3705 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 3709 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
3706 EXPECT_FALSE(session_->status_controller()->syncer_status().syncer_stuck); | 3710 EXPECT_FALSE(session_->status_controller().syncer_status().syncer_stuck); |
3707 } | 3711 } |
3708 | 3712 |
3709 // In this test a long changelog contains a child at the start of the changelog | 3713 // In this test a long changelog contains a child at the start of the changelog |
3710 // and a parent at the end. While these updates are in progress the client would | 3714 // and a parent at the end. While these updates are in progress the client would |
3711 // appear stuck. | 3715 // appear stuck. |
3712 TEST_F(SyncerTest, LongChangelistWithApplicationConflict) { | 3716 TEST_F(SyncerTest, LongChangelistWithApplicationConflict) { |
3713 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3717 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
3714 CHECK(dir.good()); | 3718 CHECK(dir.good()); |
3715 const int depth = 400; | 3719 const int depth = 400; |
3716 syncable::Id folder_id = ids_.FromNumber(1); | 3720 syncable::Id folder_id = ids_.FromNumber(1); |
3717 | 3721 |
3718 // First we an item in a folder in the root. However the folder won't come | 3722 // First we an item in a folder in the root. However the folder won't come |
3719 // till much later. | 3723 // till much later. |
3720 syncable::Id stuck_entry_id = TestIdFactory::FromNumber(99999); | 3724 syncable::Id stuck_entry_id = TestIdFactory::FromNumber(99999); |
3721 mock_server_->AddUpdateDirectory(stuck_entry_id, | 3725 mock_server_->AddUpdateDirectory(stuck_entry_id, |
3722 folder_id, "stuck", 1, 1); | 3726 folder_id, "stuck", 1, 1); |
3723 mock_server_->SetChangesRemaining(depth - 1); | 3727 mock_server_->SetChangesRemaining(depth - 1); |
3724 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 3728 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
3725 | 3729 |
3726 // Buffer up a very long series of downloads. | 3730 // Buffer up a very long series of downloads. |
3727 // We should never be stuck (conflict resolution shouldn't | 3731 // We should never be stuck (conflict resolution shouldn't |
3728 // kick in so long as we're making forward progress). | 3732 // kick in so long as we're making forward progress). |
3729 for (int i = 0; i < depth; i++) { | 3733 for (int i = 0; i < depth; i++) { |
3730 mock_server_->NextUpdateBatch(); | 3734 mock_server_->NextUpdateBatch(); |
3731 mock_server_->SetNewTimestamp(i + 1); | 3735 mock_server_->SetNewTimestamp(i + 1); |
3732 mock_server_->SetChangesRemaining(depth - i); | 3736 mock_server_->SetChangesRemaining(depth - i); |
3733 } | 3737 } |
3734 | 3738 |
3735 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 3739 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
3736 EXPECT_FALSE(session_->status_controller()->syncer_status().syncer_stuck); | 3740 EXPECT_FALSE(session_->status_controller().syncer_status().syncer_stuck); |
3737 | 3741 |
3738 // Ensure our folder hasn't somehow applied. | 3742 // Ensure our folder hasn't somehow applied. |
3739 { | 3743 { |
3740 ReadTransaction trans(FROM_HERE, dir); | 3744 ReadTransaction trans(FROM_HERE, dir); |
3741 Entry child(&trans, GET_BY_ID, stuck_entry_id); | 3745 Entry child(&trans, GET_BY_ID, stuck_entry_id); |
3742 EXPECT_TRUE(child.good()); | 3746 EXPECT_TRUE(child.good()); |
3743 EXPECT_TRUE(child.Get(IS_UNAPPLIED_UPDATE)); | 3747 EXPECT_TRUE(child.Get(IS_UNAPPLIED_UPDATE)); |
3744 EXPECT_TRUE(child.Get(IS_DEL)); | 3748 EXPECT_TRUE(child.Get(IS_DEL)); |
3745 EXPECT_FALSE(child.Get(IS_UNSYNCED)); | 3749 EXPECT_FALSE(child.Get(IS_UNSYNCED)); |
3746 } | 3750 } |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4019 ASSERT_TRUE(entry.good()); | 4023 ASSERT_TRUE(entry.good()); |
4020 entry.Put(PARENT_ID, folder_two_id); | 4024 entry.Put(PARENT_ID, folder_two_id); |
4021 entry.Put(IS_UNSYNCED, true); | 4025 entry.Put(IS_UNSYNCED, true); |
4022 // A new entry should send no "old parent." | 4026 // A new entry should send no "old parent." |
4023 MutableEntry create(&trans, CREATE, trans.root_id(), "new_folder"); | 4027 MutableEntry create(&trans, CREATE, trans.root_id(), "new_folder"); |
4024 create.Put(IS_UNSYNCED, true); | 4028 create.Put(IS_UNSYNCED, true); |
4025 create.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 4029 create.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
4026 } | 4030 } |
4027 SyncShareAsDelegate(); | 4031 SyncShareAsDelegate(); |
4028 const sync_pb::CommitMessage& commit = mock_server_->last_sent_commit(); | 4032 const sync_pb::CommitMessage& commit = mock_server_->last_sent_commit(); |
4029 ASSERT_TRUE(2 == commit.entries_size()); | 4033 ASSERT_EQ(2, commit.entries_size()); |
4030 EXPECT_TRUE(commit.entries(0).parent_id_string() == "2"); | 4034 EXPECT_TRUE(commit.entries(0).parent_id_string() == "2"); |
4031 EXPECT_TRUE(commit.entries(0).old_parent_id() == "0"); | 4035 EXPECT_TRUE(commit.entries(0).old_parent_id() == "0"); |
4032 EXPECT_FALSE(commit.entries(1).has_old_parent_id()); | 4036 EXPECT_FALSE(commit.entries(1).has_old_parent_id()); |
4033 } | 4037 } |
4034 | 4038 |
4035 TEST_F(SyncerTest, Test64BitVersionSupport) { | 4039 TEST_F(SyncerTest, Test64BitVersionSupport) { |
4036 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 4040 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
4037 CHECK(dir.good()); | 4041 CHECK(dir.good()); |
4038 int64 really_big_int = std::numeric_limits<int64>::max() - 12; | 4042 int64 really_big_int = std::numeric_limits<int64>::max() - 12; |
4039 const string name("ringo's dang orang ran rings around my o-ring"); | 4043 const string name("ringo's dang orang ran rings around my o-ring"); |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4758 EXPECT_GE(0, Get(metahandle_, BASE_VERSION)); | 4762 EXPECT_GE(0, Get(metahandle_, BASE_VERSION)); |
4759 EXPECT_GE(0, Get(metahandle_, SERVER_VERSION)); | 4763 EXPECT_GE(0, Get(metahandle_, SERVER_VERSION)); |
4760 } | 4764 } |
4761 | 4765 |
4762 protected: | 4766 protected: |
4763 const std::string client_tag_; | 4767 const std::string client_tag_; |
4764 int64 metahandle_; | 4768 int64 metahandle_; |
4765 }; | 4769 }; |
4766 | 4770 |
4767 TEST_F(SyncerUndeletionTest, UndeleteDuringCommit) { | 4771 TEST_F(SyncerUndeletionTest, UndeleteDuringCommit) { |
4768 StatusController* status = session_->status_controller(); | 4772 const StatusController& status = session_->status_controller(); |
4769 | 4773 |
4770 Create(); | 4774 Create(); |
4771 ExpectUnsyncedCreation(); | 4775 ExpectUnsyncedCreation(); |
4772 SyncShareAsDelegate(); | 4776 SyncShareAsDelegate(); |
4773 | 4777 |
4774 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4778 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4775 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4779 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4776 ExpectSyncedAndCreated(); | 4780 ExpectSyncedAndCreated(); |
4777 | 4781 |
4778 // Delete, begin committing the delete, then undelete while committing. | 4782 // Delete, begin committing the delete, then undelete while committing. |
4779 Delete(); | 4783 Delete(); |
4780 ExpectUnsyncedDeletion(); | 4784 ExpectUnsyncedDeletion(); |
4781 mock_server_->SetMidCommitCallback( | 4785 mock_server_->SetMidCommitCallback( |
4782 NewCallback<SyncerUndeletionTest>(this, | 4786 NewCallback<SyncerUndeletionTest>(this, |
4783 &SyncerUndeletionTest::Undelete)); | 4787 &SyncerUndeletionTest::Undelete)); |
4784 SyncShareAsDelegate(); | 4788 SyncShareAsDelegate(); |
4785 | 4789 |
4786 // The item ought to exist as an unsynced undeletion (meaning, | 4790 // The item ought to exist as an unsynced undeletion (meaning, |
4787 // we think that the next commit ought to be a recreation commit). | 4791 // we think that the next commit ought to be a recreation commit). |
4788 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4792 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4789 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4793 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4790 ExpectUnsyncedUndeletion(); | 4794 ExpectUnsyncedUndeletion(); |
4791 | 4795 |
4792 // Now, encounter a GetUpdates corresponding to the deletion from | 4796 // Now, encounter a GetUpdates corresponding to the deletion from |
4793 // the server. The undeletion should prevail again and be committed. | 4797 // the server. The undeletion should prevail again and be committed. |
4794 // None of this should trigger any conflict detection -- it is perfectly | 4798 // None of this should trigger any conflict detection -- it is perfectly |
4795 // normal to recieve updates from our own commits. | 4799 // normal to recieve updates from our own commits. |
4796 mock_server_->SetMidCommitCallback(NULL); | 4800 mock_server_->SetMidCommitCallback(NULL); |
4797 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); | 4801 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); |
4798 SyncShareAsDelegate(); | 4802 SyncShareAsDelegate(); |
4799 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4803 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4800 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4804 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4801 ExpectSyncedAndCreated(); | 4805 ExpectSyncedAndCreated(); |
4802 } | 4806 } |
4803 | 4807 |
4804 TEST_F(SyncerUndeletionTest, UndeleteBeforeCommit) { | 4808 TEST_F(SyncerUndeletionTest, UndeleteBeforeCommit) { |
4805 StatusController* status = session_->status_controller(); | 4809 const StatusController& status = session_->status_controller(); |
4806 | 4810 |
4807 Create(); | 4811 Create(); |
4808 ExpectUnsyncedCreation(); | 4812 ExpectUnsyncedCreation(); |
4809 SyncShareAsDelegate(); | 4813 SyncShareAsDelegate(); |
4810 | 4814 |
4811 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4815 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4812 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4816 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4813 ExpectSyncedAndCreated(); | 4817 ExpectSyncedAndCreated(); |
4814 | 4818 |
4815 // Delete and undelete, then sync to pick up the result. | 4819 // Delete and undelete, then sync to pick up the result. |
4816 Delete(); | 4820 Delete(); |
4817 ExpectUnsyncedDeletion(); | 4821 ExpectUnsyncedDeletion(); |
4818 Undelete(); | 4822 Undelete(); |
4819 ExpectUnsyncedEdit(); // Edit, not undelete: server thinks it exists. | 4823 ExpectUnsyncedEdit(); // Edit, not undelete: server thinks it exists. |
4820 SyncShareAsDelegate(); | 4824 SyncShareAsDelegate(); |
4821 | 4825 |
4822 // The item ought to have committed successfully. | 4826 // The item ought to have committed successfully. |
4823 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4827 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4824 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4828 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4825 ExpectSyncedAndCreated(); | 4829 ExpectSyncedAndCreated(); |
4826 EXPECT_EQ(2, Get(metahandle_, BASE_VERSION)); | 4830 EXPECT_EQ(2, Get(metahandle_, BASE_VERSION)); |
4827 | 4831 |
4828 // Now, encounter a GetUpdates corresponding to the just-committed | 4832 // Now, encounter a GetUpdates corresponding to the just-committed |
4829 // update. | 4833 // update. |
4830 mock_server_->AddUpdateFromLastCommit(); | 4834 mock_server_->AddUpdateFromLastCommit(); |
4831 SyncShareAsDelegate(); | 4835 SyncShareAsDelegate(); |
4832 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4836 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4833 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4837 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4834 ExpectSyncedAndCreated(); | 4838 ExpectSyncedAndCreated(); |
4835 } | 4839 } |
4836 | 4840 |
4837 TEST_F(SyncerUndeletionTest, UndeleteAfterCommitButBeforeGetUpdates) { | 4841 TEST_F(SyncerUndeletionTest, UndeleteAfterCommitButBeforeGetUpdates) { |
4838 StatusController* status = session_->status_controller(); | 4842 const StatusController& status = session_->status_controller(); |
4839 | 4843 |
4840 Create(); | 4844 Create(); |
4841 ExpectUnsyncedCreation(); | 4845 ExpectUnsyncedCreation(); |
4842 SyncShareAsDelegate(); | 4846 SyncShareAsDelegate(); |
4843 | 4847 |
4844 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4848 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4845 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4849 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4846 ExpectSyncedAndCreated(); | 4850 ExpectSyncedAndCreated(); |
4847 | 4851 |
4848 // Delete and commit. | 4852 // Delete and commit. |
4849 Delete(); | 4853 Delete(); |
4850 ExpectUnsyncedDeletion(); | 4854 ExpectUnsyncedDeletion(); |
4851 SyncShareAsDelegate(); | 4855 SyncShareAsDelegate(); |
4852 | 4856 |
4853 // The item ought to have committed successfully. | 4857 // The item ought to have committed successfully. |
4854 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4858 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4855 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4859 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4856 ExpectSyncedAndDeleted(); | 4860 ExpectSyncedAndDeleted(); |
4857 | 4861 |
4858 // Before the GetUpdates, the item is locally undeleted. | 4862 // Before the GetUpdates, the item is locally undeleted. |
4859 Undelete(); | 4863 Undelete(); |
4860 ExpectUnsyncedUndeletion(); | 4864 ExpectUnsyncedUndeletion(); |
4861 | 4865 |
4862 // Now, encounter a GetUpdates corresponding to the just-committed | 4866 // Now, encounter a GetUpdates corresponding to the just-committed |
4863 // deletion update. The undeletion should prevail. | 4867 // deletion update. The undeletion should prevail. |
4864 mock_server_->AddUpdateFromLastCommit(); | 4868 mock_server_->AddUpdateFromLastCommit(); |
4865 SyncShareAsDelegate(); | 4869 SyncShareAsDelegate(); |
4866 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4870 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4867 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4871 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4868 ExpectSyncedAndCreated(); | 4872 ExpectSyncedAndCreated(); |
4869 } | 4873 } |
4870 | 4874 |
4871 TEST_F(SyncerUndeletionTest, UndeleteAfterDeleteAndGetUpdates) { | 4875 TEST_F(SyncerUndeletionTest, UndeleteAfterDeleteAndGetUpdates) { |
4872 StatusController* status = session_->status_controller(); | 4876 const StatusController& status = session_->status_controller(); |
4873 | 4877 |
4874 Create(); | 4878 Create(); |
4875 ExpectUnsyncedCreation(); | 4879 ExpectUnsyncedCreation(); |
4876 SyncShareAsDelegate(); | 4880 SyncShareAsDelegate(); |
4877 | 4881 |
4878 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4882 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4879 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4883 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4880 ExpectSyncedAndCreated(); | 4884 ExpectSyncedAndCreated(); |
4881 | 4885 |
4882 mock_server_->AddUpdateFromLastCommit(); | 4886 mock_server_->AddUpdateFromLastCommit(); |
4883 SyncShareAsDelegate(); | 4887 SyncShareAsDelegate(); |
4884 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4888 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4885 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4889 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4886 ExpectSyncedAndCreated(); | 4890 ExpectSyncedAndCreated(); |
4887 | 4891 |
4888 // Delete and commit. | 4892 // Delete and commit. |
4889 Delete(); | 4893 Delete(); |
4890 ExpectUnsyncedDeletion(); | 4894 ExpectUnsyncedDeletion(); |
4891 SyncShareAsDelegate(); | 4895 SyncShareAsDelegate(); |
4892 | 4896 |
4893 // The item ought to have committed successfully. | 4897 // The item ought to have committed successfully. |
4894 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4898 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4895 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4899 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4896 ExpectSyncedAndDeleted(); | 4900 ExpectSyncedAndDeleted(); |
4897 | 4901 |
4898 // Now, encounter a GetUpdates corresponding to the just-committed | 4902 // Now, encounter a GetUpdates corresponding to the just-committed |
4899 // deletion update. Should be consistent. | 4903 // deletion update. Should be consistent. |
4900 mock_server_->AddUpdateFromLastCommit(); | 4904 mock_server_->AddUpdateFromLastCommit(); |
4901 SyncShareAsDelegate(); | 4905 SyncShareAsDelegate(); |
4902 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4906 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4903 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4907 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4904 ExpectSyncedAndDeleted(); | 4908 ExpectSyncedAndDeleted(); |
4905 | 4909 |
4906 // After the GetUpdates, the item is locally undeleted. | 4910 // After the GetUpdates, the item is locally undeleted. |
4907 Undelete(); | 4911 Undelete(); |
4908 ExpectUnsyncedUndeletion(); | 4912 ExpectUnsyncedUndeletion(); |
4909 | 4913 |
4910 // Now, encounter a GetUpdates corresponding to the just-committed | 4914 // Now, encounter a GetUpdates corresponding to the just-committed |
4911 // deletion update. The undeletion should prevail. | 4915 // deletion update. The undeletion should prevail. |
4912 SyncShareAsDelegate(); | 4916 SyncShareAsDelegate(); |
4913 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4917 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4914 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4918 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4915 ExpectSyncedAndCreated(); | 4919 ExpectSyncedAndCreated(); |
4916 } | 4920 } |
4917 | 4921 |
4918 // Test processing of undeletion GetUpdateses. | 4922 // Test processing of undeletion GetUpdateses. |
4919 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletes) { | 4923 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletes) { |
4920 StatusController* status = session_->status_controller(); | 4924 const StatusController& status = session_->status_controller(); |
4921 | 4925 |
4922 Create(); | 4926 Create(); |
4923 ExpectUnsyncedCreation(); | 4927 ExpectUnsyncedCreation(); |
4924 SyncShareAsDelegate(); | 4928 SyncShareAsDelegate(); |
4925 | 4929 |
4926 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4930 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4927 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4931 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4928 ExpectSyncedAndCreated(); | 4932 ExpectSyncedAndCreated(); |
4929 | 4933 |
4930 // Add a delete from the server. | 4934 // Add a delete from the server. |
4931 mock_server_->AddUpdateFromLastCommit(); | 4935 mock_server_->AddUpdateFromLastCommit(); |
4932 SyncShareAsDelegate(); | 4936 SyncShareAsDelegate(); |
4933 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4937 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4934 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4938 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4935 ExpectSyncedAndCreated(); | 4939 ExpectSyncedAndCreated(); |
4936 | 4940 |
4937 // Some other client deletes the item. | 4941 // Some other client deletes the item. |
4938 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); | 4942 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); |
4939 SyncShareAsDelegate(); | 4943 SyncShareAsDelegate(); |
4940 | 4944 |
4941 // The update ought to have applied successfully. | 4945 // The update ought to have applied successfully. |
4942 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4946 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4943 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4947 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4944 ExpectSyncedAndDeleted(); | 4948 ExpectSyncedAndDeleted(); |
4945 | 4949 |
4946 // Undelete it locally. | 4950 // Undelete it locally. |
4947 Undelete(); | 4951 Undelete(); |
4948 ExpectUnsyncedUndeletion(); | 4952 ExpectUnsyncedUndeletion(); |
4949 SyncShareAsDelegate(); | 4953 SyncShareAsDelegate(); |
4950 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4954 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4951 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4955 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4952 ExpectSyncedAndCreated(); | 4956 ExpectSyncedAndCreated(); |
4953 | 4957 |
4954 // Now, encounter a GetUpdates corresponding to the just-committed | 4958 // Now, encounter a GetUpdates corresponding to the just-committed |
4955 // deletion update. The undeletion should prevail. | 4959 // deletion update. The undeletion should prevail. |
4956 mock_server_->AddUpdateFromLastCommit(); | 4960 mock_server_->AddUpdateFromLastCommit(); |
4957 SyncShareAsDelegate(); | 4961 SyncShareAsDelegate(); |
4958 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4962 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4959 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4963 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4960 ExpectSyncedAndCreated(); | 4964 ExpectSyncedAndCreated(); |
4961 } | 4965 } |
4962 | 4966 |
4963 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletesImmediately) { | 4967 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletesImmediately) { |
4964 StatusController* status = session_->status_controller(); | 4968 const StatusController& status = session_->status_controller(); |
4965 | 4969 |
4966 Create(); | 4970 Create(); |
4967 ExpectUnsyncedCreation(); | 4971 ExpectUnsyncedCreation(); |
4968 SyncShareAsDelegate(); | 4972 SyncShareAsDelegate(); |
4969 | 4973 |
4970 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4974 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4971 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4975 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4972 ExpectSyncedAndCreated(); | 4976 ExpectSyncedAndCreated(); |
4973 | 4977 |
4974 // Some other client deletes the item before we get a chance | 4978 // Some other client deletes the item before we get a chance |
4975 // to GetUpdates our original request. | 4979 // to GetUpdates our original request. |
4976 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); | 4980 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); |
4977 SyncShareAsDelegate(); | 4981 SyncShareAsDelegate(); |
4978 | 4982 |
4979 // The update ought to have applied successfully. | 4983 // The update ought to have applied successfully. |
4980 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4984 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4981 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4985 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4982 ExpectSyncedAndDeleted(); | 4986 ExpectSyncedAndDeleted(); |
4983 | 4987 |
4984 // Undelete it locally. | 4988 // Undelete it locally. |
4985 Undelete(); | 4989 Undelete(); |
4986 ExpectUnsyncedUndeletion(); | 4990 ExpectUnsyncedUndeletion(); |
4987 SyncShareAsDelegate(); | 4991 SyncShareAsDelegate(); |
4988 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 4992 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4989 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4993 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4990 ExpectSyncedAndCreated(); | 4994 ExpectSyncedAndCreated(); |
4991 | 4995 |
4992 // Now, encounter a GetUpdates corresponding to the just-committed | 4996 // Now, encounter a GetUpdates corresponding to the just-committed |
4993 // deletion update. The undeletion should prevail. | 4997 // deletion update. The undeletion should prevail. |
4994 mock_server_->AddUpdateFromLastCommit(); | 4998 mock_server_->AddUpdateFromLastCommit(); |
4995 SyncShareAsDelegate(); | 4999 SyncShareAsDelegate(); |
4996 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 5000 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
4997 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5001 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4998 ExpectSyncedAndCreated(); | 5002 ExpectSyncedAndCreated(); |
4999 } | 5003 } |
5000 | 5004 |
5001 TEST_F(SyncerUndeletionTest, OtherClientUndeletes) { | 5005 TEST_F(SyncerUndeletionTest, OtherClientUndeletes) { |
5002 StatusController* status = session_->status_controller(); | 5006 const StatusController& status = session_->status_controller(); |
5003 | 5007 |
5004 Create(); | 5008 Create(); |
5005 ExpectUnsyncedCreation(); | 5009 ExpectUnsyncedCreation(); |
5006 SyncShareAsDelegate(); | 5010 SyncShareAsDelegate(); |
5007 | 5011 |
5008 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5012 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
5009 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 5013 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
5010 ExpectSyncedAndCreated(); | 5014 ExpectSyncedAndCreated(); |
5011 | 5015 |
5012 // Get the updates of our just-committed entry. | 5016 // Get the updates of our just-committed entry. |
5013 mock_server_->AddUpdateFromLastCommit(); | 5017 mock_server_->AddUpdateFromLastCommit(); |
5014 SyncShareAsDelegate(); | 5018 SyncShareAsDelegate(); |
5015 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5019 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
5016 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 5020 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
5017 ExpectSyncedAndCreated(); | 5021 ExpectSyncedAndCreated(); |
5018 | 5022 |
5019 // We delete the item. | 5023 // We delete the item. |
5020 Delete(); | 5024 Delete(); |
5021 ExpectUnsyncedDeletion(); | 5025 ExpectUnsyncedDeletion(); |
5022 SyncShareAsDelegate(); | 5026 SyncShareAsDelegate(); |
5023 | 5027 |
5024 // The update ought to have applied successfully. | 5028 // The update ought to have applied successfully. |
5025 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 5029 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
5026 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5030 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
5027 ExpectSyncedAndDeleted(); | 5031 ExpectSyncedAndDeleted(); |
5028 | 5032 |
5029 // Now, encounter a GetUpdates corresponding to the just-committed | 5033 // Now, encounter a GetUpdates corresponding to the just-committed |
5030 // deletion update. | 5034 // deletion update. |
5031 mock_server_->AddUpdateFromLastCommit(); | 5035 mock_server_->AddUpdateFromLastCommit(); |
5032 SyncShareAsDelegate(); | 5036 SyncShareAsDelegate(); |
5033 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 5037 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
5034 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5038 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
5035 ExpectSyncedAndDeleted(); | 5039 ExpectSyncedAndDeleted(); |
5036 | 5040 |
5037 // Some other client undeletes the item. | 5041 // Some other client undeletes the item. |
5038 mock_server_->AddUpdateBookmark(Get(metahandle_, ID), | 5042 mock_server_->AddUpdateBookmark(Get(metahandle_, ID), |
5039 Get(metahandle_, PARENT_ID), | 5043 Get(metahandle_, PARENT_ID), |
5040 "Thadeusz", 100, 1000); | 5044 "Thadeusz", 100, 1000); |
5041 mock_server_->SetLastUpdateClientTag(client_tag_); | 5045 mock_server_->SetLastUpdateClientTag(client_tag_); |
5042 SyncShareAsDelegate(); | 5046 SyncShareAsDelegate(); |
5043 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 5047 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
5044 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5048 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
5045 ExpectSyncedAndCreated(); | 5049 ExpectSyncedAndCreated(); |
5046 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME)); | 5050 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME)); |
5047 } | 5051 } |
5048 | 5052 |
5049 TEST_F(SyncerUndeletionTest, OtherClientUndeletesImmediately) { | 5053 TEST_F(SyncerUndeletionTest, OtherClientUndeletesImmediately) { |
5050 StatusController* status = session_->status_controller(); | 5054 const StatusController& status = session_->status_controller(); |
5051 | 5055 |
5052 Create(); | 5056 Create(); |
5053 ExpectUnsyncedCreation(); | 5057 ExpectUnsyncedCreation(); |
5054 SyncShareAsDelegate(); | 5058 SyncShareAsDelegate(); |
5055 | 5059 |
5056 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5060 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
5057 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 5061 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
5058 ExpectSyncedAndCreated(); | 5062 ExpectSyncedAndCreated(); |
5059 | 5063 |
5060 // Get the updates of our just-committed entry. | 5064 // Get the updates of our just-committed entry. |
5061 mock_server_->AddUpdateFromLastCommit(); | 5065 mock_server_->AddUpdateFromLastCommit(); |
5062 SyncShareAsDelegate(); | 5066 SyncShareAsDelegate(); |
5063 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5067 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
5064 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 5068 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
5065 ExpectSyncedAndCreated(); | 5069 ExpectSyncedAndCreated(); |
5066 | 5070 |
5067 // We delete the item. | 5071 // We delete the item. |
5068 Delete(); | 5072 Delete(); |
5069 ExpectUnsyncedDeletion(); | 5073 ExpectUnsyncedDeletion(); |
5070 SyncShareAsDelegate(); | 5074 SyncShareAsDelegate(); |
5071 | 5075 |
5072 // The update ought to have applied successfully. | 5076 // The update ought to have applied successfully. |
5073 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 5077 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
5074 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5078 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
5075 ExpectSyncedAndDeleted(); | 5079 ExpectSyncedAndDeleted(); |
5076 | 5080 |
5077 // Some other client undeletes before we see the update from our | 5081 // Some other client undeletes before we see the update from our |
5078 // commit. | 5082 // commit. |
5079 mock_server_->AddUpdateBookmark(Get(metahandle_, ID), | 5083 mock_server_->AddUpdateBookmark(Get(metahandle_, ID), |
5080 Get(metahandle_, PARENT_ID), | 5084 Get(metahandle_, PARENT_ID), |
5081 "Thadeusz", 100, 1000); | 5085 "Thadeusz", 100, 1000); |
5082 mock_server_->SetLastUpdateClientTag(client_tag_); | 5086 mock_server_->SetLastUpdateClientTag(client_tag_); |
5083 SyncShareAsDelegate(); | 5087 SyncShareAsDelegate(); |
5084 EXPECT_EQ(0, status->TotalNumConflictingItems()); | 5088 EXPECT_EQ(0, status.TotalNumConflictingItems()); |
5085 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5089 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
5086 ExpectSyncedAndCreated(); | 5090 ExpectSyncedAndCreated(); |
5087 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME)); | 5091 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME)); |
5088 } | 5092 } |
5089 | 5093 |
5090 // A group of tests exercising the syncer's handling of sibling ordering, as | 5094 // A group of tests exercising the syncer's handling of sibling ordering, as |
5091 // represented in the sync protocol. | 5095 // represented in the sync protocol. |
5092 class SyncerPositionUpdateTest : public SyncerTest { | 5096 class SyncerPositionUpdateTest : public SyncerTest { |
5093 public: | 5097 public: |
5094 SyncerPositionUpdateTest() : next_update_id_(1), next_revision_(1) {} | 5098 SyncerPositionUpdateTest() : next_update_id_(1), next_revision_(1) {} |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5302 Add(low_id_); | 5306 Add(low_id_); |
5303 Add(high_id_); | 5307 Add(high_id_); |
5304 SyncShareAsDelegate(); | 5308 SyncShareAsDelegate(); |
5305 ExpectLocalOrderIsByServerId(); | 5309 ExpectLocalOrderIsByServerId(); |
5306 } | 5310 } |
5307 | 5311 |
5308 const SyncerTest::CommitOrderingTest | 5312 const SyncerTest::CommitOrderingTest |
5309 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; | 5313 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; |
5310 | 5314 |
5311 } // namespace browser_sync | 5315 } // namespace browser_sync |
OLD | NEW |