OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Syncer unit tests. Unfortunately a lot of these tests | 5 // Syncer unit tests. Unfortunately a lot of these tests |
6 // are outdated and need to be reworked and updated. | 6 // are outdated and need to be reworked and updated. |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <list> | 10 #include <list> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "sync/engine/get_commit_ids_command.h" | 26 #include "sync/engine/get_commit_ids_command.h" |
27 #include "sync/engine/model_safe_worker.h" | 27 #include "sync/engine/model_safe_worker.h" |
28 #include "sync/engine/net/server_connection_manager.h" | 28 #include "sync/engine/net/server_connection_manager.h" |
29 #include "sync/engine/nigori_util.h" | 29 #include "sync/engine/nigori_util.h" |
30 #include "sync/engine/process_updates_command.h" | 30 #include "sync/engine/process_updates_command.h" |
31 #include "sync/engine/syncer.h" | 31 #include "sync/engine/syncer.h" |
32 #include "sync/engine/syncer_proto_util.h" | 32 #include "sync/engine/syncer_proto_util.h" |
33 #include "sync/engine/syncer_util.h" | 33 #include "sync/engine/syncer_util.h" |
34 #include "sync/engine/syncproto.h" | 34 #include "sync/engine/syncproto.h" |
35 #include "sync/engine/traffic_recorder.h" | 35 #include "sync/engine/traffic_recorder.h" |
36 #include "sync/engine/sync_scheduler.h" | |
37 #include "sync/protocol/bookmark_specifics.pb.h" | 36 #include "sync/protocol/bookmark_specifics.pb.h" |
38 #include "sync/protocol/nigori_specifics.pb.h" | 37 #include "sync/protocol/nigori_specifics.pb.h" |
39 #include "sync/protocol/preference_specifics.pb.h" | 38 #include "sync/protocol/preference_specifics.pb.h" |
40 #include "sync/protocol/sync.pb.h" | 39 #include "sync/protocol/sync.pb.h" |
41 #include "sync/sessions/sync_session_context.h" | 40 #include "sync/sessions/sync_session_context.h" |
42 #include "sync/syncable/model_type.h" | 41 #include "sync/syncable/model_type.h" |
43 #include "sync/syncable/syncable.h" | 42 #include "sync/syncable/syncable.h" |
44 #include "sync/test/engine/fake_model_worker.h" | 43 #include "sync/test/engine/fake_model_worker.h" |
45 #include "sync/test/engine/mock_connection_manager.h" | 44 #include "sync/test/engine/mock_connection_manager.h" |
46 #include "sync/test/engine/test_directory_setter_upper.h" | 45 #include "sync/test/engine/test_directory_setter_upper.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 std::vector<ModelSafeWorker*> workers; | 179 std::vector<ModelSafeWorker*> workers; |
181 GetModelSafeRoutingInfo(&info); | 180 GetModelSafeRoutingInfo(&info); |
182 GetWorkers(&workers); | 181 GetWorkers(&workers); |
183 syncable::ModelTypePayloadMap types = | 182 syncable::ModelTypePayloadMap types = |
184 syncable::ModelTypePayloadMapFromRoutingInfo(info, std::string()); | 183 syncable::ModelTypePayloadMapFromRoutingInfo(info, std::string()); |
185 return new SyncSession(context_.get(), this, | 184 return new SyncSession(context_.get(), this, |
186 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, types), | 185 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, types), |
187 info, workers); | 186 info, workers); |
188 } | 187 } |
189 | 188 |
190 bool SyncShareAsDelegate( | 189 bool SyncShareAsDelegate() { |
191 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) { | |
192 SyncerStep start; | |
193 SyncerStep end; | |
194 SyncScheduler::SetSyncerStepsForPurpose(purpose, &start, &end); | |
195 | |
196 session_.reset(MakeSession()); | 190 session_.reset(MakeSession()); |
197 syncer_->SyncShare(session_.get(), start, end); | 191 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
198 return session_->HasMoreToSync(); | 192 return session_->HasMoreToSync(); |
199 } | 193 } |
200 | 194 |
201 bool SyncShareNudge() { | |
202 session_.reset(MakeSession()); | |
203 return SyncShareAsDelegate(SyncScheduler::SyncSessionJob::NUDGE); | |
204 } | |
205 | |
206 bool SyncShareConfigure() { | |
207 session_.reset(MakeSession()); | |
208 return SyncShareAsDelegate(SyncScheduler::SyncSessionJob::CONFIGURATION); | |
209 } | |
210 | |
211 void LoopSyncShare() { | 195 void LoopSyncShare() { |
212 bool should_loop = false; | 196 bool should_loop = false; |
213 int loop_iterations = 0; | 197 int loop_iterations = 0; |
214 do { | 198 do { |
215 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; | 199 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; |
216 should_loop = SyncShareNudge(); | 200 should_loop = SyncShareAsDelegate(); |
217 } while (should_loop); | 201 } while (should_loop); |
218 } | 202 } |
219 | 203 |
220 virtual void SetUp() { | 204 virtual void SetUp() { |
221 dir_maker_.SetUp(); | 205 dir_maker_.SetUp(); |
222 mock_server_.reset(new MockConnectionManager(directory())); | 206 mock_server_.reset(new MockConnectionManager(directory())); |
223 EnableDatatype(syncable::BOOKMARKS); | 207 EnableDatatype(syncable::BOOKMARKS); |
224 EnableDatatype(syncable::NIGORI); | 208 EnableDatatype(syncable::NIGORI); |
225 EnableDatatype(syncable::PREFERENCES); | 209 EnableDatatype(syncable::PREFERENCES); |
226 EnableDatatype(syncable::NIGORI); | 210 EnableDatatype(syncable::NIGORI); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 // TODO(sync): When we can dynamically connect and disconnect the mock | 535 // TODO(sync): When we can dynamically connect and disconnect the mock |
552 // ServerConnectionManager test disconnected GetUnsyncedEntries here. It's a | 536 // ServerConnectionManager test disconnected GetUnsyncedEntries here. It's a |
553 // regression for a very old bug. | 537 // regression for a very old bug. |
554 } | 538 } |
555 | 539 |
556 TEST_F(SyncerTest, GetCommitIdsCommandTruncates) { | 540 TEST_F(SyncerTest, GetCommitIdsCommandTruncates) { |
557 syncable::Id root = ids_.root(); | 541 syncable::Id root = ids_.root(); |
558 // Create two server entries. | 542 // Create two server entries. |
559 mock_server_->AddUpdateDirectory(ids_.MakeServer("x"), root, "X", 10, 10); | 543 mock_server_->AddUpdateDirectory(ids_.MakeServer("x"), root, "X", 10, 10); |
560 mock_server_->AddUpdateDirectory(ids_.MakeServer("w"), root, "W", 10, 10); | 544 mock_server_->AddUpdateDirectory(ids_.MakeServer("w"), root, "W", 10, 10); |
561 SyncShareNudge(); | 545 SyncShareAsDelegate(); |
562 | 546 |
563 // Create some new client entries. | 547 // Create some new client entries. |
564 CreateUnsyncedDirectory("C", ids_.MakeLocal("c")); | 548 CreateUnsyncedDirectory("C", ids_.MakeLocal("c")); |
565 CreateUnsyncedDirectory("B", ids_.MakeLocal("b")); | 549 CreateUnsyncedDirectory("B", ids_.MakeLocal("b")); |
566 CreateUnsyncedDirectory("D", ids_.MakeLocal("d")); | 550 CreateUnsyncedDirectory("D", ids_.MakeLocal("d")); |
567 CreateUnsyncedDirectory("E", ids_.MakeLocal("e")); | 551 CreateUnsyncedDirectory("E", ids_.MakeLocal("e")); |
568 CreateUnsyncedDirectory("J", ids_.MakeLocal("j")); | 552 CreateUnsyncedDirectory("J", ids_.MakeLocal("j")); |
569 | 553 |
570 { | 554 { |
571 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 555 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 expected_order.push_back(ids_.MakeLocal("e")); | 589 expected_order.push_back(ids_.MakeLocal("e")); |
606 DoTruncationTest(unsynced_handle_view, expected_order); | 590 DoTruncationTest(unsynced_handle_view, expected_order); |
607 } | 591 } |
608 | 592 |
609 TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) { | 593 TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) { |
610 const syncable::ModelTypeSet throttled_types(syncable::BOOKMARKS); | 594 const syncable::ModelTypeSet throttled_types(syncable::BOOKMARKS); |
611 sync_pb::EntitySpecifics bookmark_data; | 595 sync_pb::EntitySpecifics bookmark_data; |
612 AddDefaultFieldValue(syncable::BOOKMARKS, &bookmark_data); | 596 AddDefaultFieldValue(syncable::BOOKMARKS, &bookmark_data); |
613 | 597 |
614 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 598 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
615 SyncShareNudge(); | 599 SyncShareAsDelegate(); |
616 | 600 |
617 { | 601 { |
618 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 602 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
619 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 603 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
620 ASSERT_TRUE(A.good()); | 604 ASSERT_TRUE(A.good()); |
621 A.Put(IS_UNSYNCED, true); | 605 A.Put(IS_UNSYNCED, true); |
622 A.Put(SPECIFICS, bookmark_data); | 606 A.Put(SPECIFICS, bookmark_data); |
623 A.Put(NON_UNIQUE_NAME, "bookmark"); | 607 A.Put(NON_UNIQUE_NAME, "bookmark"); |
624 } | 608 } |
625 | 609 |
626 // Now set the throttled types. | 610 // Now set the throttled types. |
627 context_->SetUnthrottleTime( | 611 context_->SetUnthrottleTime( |
628 throttled_types, | 612 throttled_types, |
629 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1200)); | 613 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1200)); |
630 SyncShareNudge(); | 614 SyncShareAsDelegate(); |
631 | 615 |
632 { | 616 { |
633 // Nothing should have been committed as bookmarks is throttled. | 617 // Nothing should have been committed as bookmarks is throttled. |
634 ReadTransaction rtrans(FROM_HERE, directory()); | 618 ReadTransaction rtrans(FROM_HERE, directory()); |
635 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 619 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
636 ASSERT_TRUE(entryA.good()); | 620 ASSERT_TRUE(entryA.good()); |
637 EXPECT_TRUE(entryA.Get(IS_UNSYNCED)); | 621 EXPECT_TRUE(entryA.Get(IS_UNSYNCED)); |
638 } | 622 } |
639 | 623 |
640 // Now unthrottle. | 624 // Now unthrottle. |
641 context_->SetUnthrottleTime( | 625 context_->SetUnthrottleTime( |
642 throttled_types, | 626 throttled_types, |
643 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1200)); | 627 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1200)); |
644 SyncShareNudge(); | 628 SyncShareAsDelegate(); |
645 { | 629 { |
646 // It should have been committed. | 630 // It should have been committed. |
647 ReadTransaction rtrans(FROM_HERE, directory()); | 631 ReadTransaction rtrans(FROM_HERE, directory()); |
648 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 632 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
649 ASSERT_TRUE(entryA.good()); | 633 ASSERT_TRUE(entryA.good()); |
650 EXPECT_FALSE(entryA.Get(IS_UNSYNCED)); | 634 EXPECT_FALSE(entryA.Get(IS_UNSYNCED)); |
651 } | 635 } |
652 } | 636 } |
653 | 637 |
654 // We use a macro so we can preserve the error location. | 638 // We use a macro so we can preserve the error location. |
(...skipping 19 matching lines...) Expand all Loading... |
674 KeyParams key_params = {"localhost", "dummy", "foobar"}; | 658 KeyParams key_params = {"localhost", "dummy", "foobar"}; |
675 KeyParams other_params = {"localhost", "dummy", "foobar2"}; | 659 KeyParams other_params = {"localhost", "dummy", "foobar2"}; |
676 sync_pb::EntitySpecifics bookmark, encrypted_bookmark; | 660 sync_pb::EntitySpecifics bookmark, encrypted_bookmark; |
677 bookmark.mutable_bookmark()->set_url("url"); | 661 bookmark.mutable_bookmark()->set_url("url"); |
678 bookmark.mutable_bookmark()->set_title("title"); | 662 bookmark.mutable_bookmark()->set_title("title"); |
679 AddDefaultFieldValue(syncable::BOOKMARKS, &encrypted_bookmark); | 663 AddDefaultFieldValue(syncable::BOOKMARKS, &encrypted_bookmark); |
680 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 664 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
681 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); | 665 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); |
682 mock_server_->AddUpdateDirectory(3, 0, "C", 10, 10); | 666 mock_server_->AddUpdateDirectory(3, 0, "C", 10, 10); |
683 mock_server_->AddUpdateDirectory(4, 0, "D", 10, 10); | 667 mock_server_->AddUpdateDirectory(4, 0, "D", 10, 10); |
684 SyncShareNudge(); | 668 SyncShareAsDelegate(); |
685 // Server side change will put A in conflict. | 669 // Server side change will put A in conflict. |
686 mock_server_->AddUpdateDirectory(1, 0, "A", 20, 20); | 670 mock_server_->AddUpdateDirectory(1, 0, "A", 20, 20); |
687 { | 671 { |
688 // Mark bookmarks as encrypted and set the cryptographer to have pending | 672 // Mark bookmarks as encrypted and set the cryptographer to have pending |
689 // keys. | 673 // keys. |
690 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 674 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
691 browser_sync::Cryptographer other_cryptographer(&encryptor_); | 675 browser_sync::Cryptographer other_cryptographer(&encryptor_); |
692 other_cryptographer.AddKey(other_params); | 676 other_cryptographer.AddKey(other_params); |
693 sync_pb::EntitySpecifics specifics; | 677 sync_pb::EntitySpecifics specifics; |
694 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); | 678 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); |
(...skipping 22 matching lines...) Expand all Loading... |
717 ASSERT_TRUE(C.good()); | 701 ASSERT_TRUE(C.good()); |
718 C.Put(IS_UNSYNCED, true); | 702 C.Put(IS_UNSYNCED, true); |
719 C.Put(NON_UNIQUE_NAME, kEncryptedString); | 703 C.Put(NON_UNIQUE_NAME, kEncryptedString); |
720 // Unencrypted non_unique_name. | 704 // Unencrypted non_unique_name. |
721 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); | 705 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); |
722 ASSERT_TRUE(D.good()); | 706 ASSERT_TRUE(D.good()); |
723 D.Put(IS_UNSYNCED, true); | 707 D.Put(IS_UNSYNCED, true); |
724 D.Put(SPECIFICS, encrypted_bookmark); | 708 D.Put(SPECIFICS, encrypted_bookmark); |
725 D.Put(NON_UNIQUE_NAME, "not encrypted"); | 709 D.Put(NON_UNIQUE_NAME, "not encrypted"); |
726 } | 710 } |
727 SyncShareNudge(); | 711 SyncShareAsDelegate(); |
728 { | 712 { |
729 // We remove any unready entries from the status controller's unsynced | 713 // We remove any unready entries from the status controller's unsynced |
730 // handles, so this should remain 0 even though the entries didn't commit. | 714 // handles, so this should remain 0 even though the entries didn't commit. |
731 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | 715 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); |
732 // Nothing should have commited due to bookmarks being encrypted and | 716 // Nothing should have commited due to bookmarks being encrypted and |
733 // the cryptographer having pending keys. A would have been resolved | 717 // the cryptographer having pending keys. A would have been resolved |
734 // as a simple conflict, but still be unsynced until the next sync cycle. | 718 // as a simple conflict, but still be unsynced until the next sync cycle. |
735 ReadTransaction rtrans(FROM_HERE, directory()); | 719 ReadTransaction rtrans(FROM_HERE, directory()); |
736 VERIFY_ENTRY(1, false, true, false, 0, 20, 20, ids_, &rtrans); | 720 VERIFY_ENTRY(1, false, true, false, 0, 20, 20, ids_, &rtrans); |
737 VERIFY_ENTRY(2, false, true, false, 0, 10, 10, ids_, &rtrans); | 721 VERIFY_ENTRY(2, false, true, false, 0, 10, 10, ids_, &rtrans); |
738 VERIFY_ENTRY(3, false, true, false, 0, 10, 10, ids_, &rtrans); | 722 VERIFY_ENTRY(3, false, true, false, 0, 10, 10, ids_, &rtrans); |
739 VERIFY_ENTRY(4, false, true, false, 0, 10, 10, ids_, &rtrans); | 723 VERIFY_ENTRY(4, false, true, false, 0, 10, 10, ids_, &rtrans); |
740 | 724 |
741 // Resolve the pending keys. | 725 // Resolve the pending keys. |
742 cryptographer(&rtrans)->DecryptPendingKeys(other_params); | 726 cryptographer(&rtrans)->DecryptPendingKeys(other_params); |
743 } | 727 } |
744 SyncShareNudge(); | 728 SyncShareAsDelegate(); |
745 { | 729 { |
746 // 2 unsynced handles to reflect the items that committed succesfully. | 730 // 2 unsynced handles to reflect the items that committed succesfully. |
747 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size()); | 731 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size()); |
748 // All properly encrypted and non-conflicting items should commit. "A" was | 732 // All properly encrypted and non-conflicting items should commit. "A" was |
749 // conflicting, but last sync cycle resolved it as simple conflict, so on | 733 // conflicting, but last sync cycle resolved it as simple conflict, so on |
750 // this sync cycle it committed succesfullly. | 734 // this sync cycle it committed succesfullly. |
751 ReadTransaction rtrans(FROM_HERE, directory()); | 735 ReadTransaction rtrans(FROM_HERE, directory()); |
752 // Committed successfully. | 736 // Committed successfully. |
753 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans); | 737 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans); |
754 // Committed successfully. | 738 // Committed successfully. |
755 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans); | 739 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans); |
756 // Was not properly encrypted. | 740 // Was not properly encrypted. |
757 VERIFY_ENTRY(3, false, true, false, 0, 10, 10, ids_, &rtrans); | 741 VERIFY_ENTRY(3, false, true, false, 0, 10, 10, ids_, &rtrans); |
758 // Was not properly encrypted. | 742 // Was not properly encrypted. |
759 VERIFY_ENTRY(4, false, true, false, 0, 10, 10, ids_, &rtrans); | 743 VERIFY_ENTRY(4, false, true, false, 0, 10, 10, ids_, &rtrans); |
760 } | 744 } |
761 { | 745 { |
762 // Fix the remaining items. | 746 // Fix the remaining items. |
763 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 747 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
764 MutableEntry C(&wtrans, GET_BY_ID, ids_.FromNumber(3)); | 748 MutableEntry C(&wtrans, GET_BY_ID, ids_.FromNumber(3)); |
765 ASSERT_TRUE(C.good()); | 749 ASSERT_TRUE(C.good()); |
766 C.Put(SPECIFICS, encrypted_bookmark); | 750 C.Put(SPECIFICS, encrypted_bookmark); |
767 C.Put(NON_UNIQUE_NAME, kEncryptedString); | 751 C.Put(NON_UNIQUE_NAME, kEncryptedString); |
768 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); | 752 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); |
769 ASSERT_TRUE(D.good()); | 753 ASSERT_TRUE(D.good()); |
770 D.Put(SPECIFICS, encrypted_bookmark); | 754 D.Put(SPECIFICS, encrypted_bookmark); |
771 D.Put(NON_UNIQUE_NAME, kEncryptedString); | 755 D.Put(NON_UNIQUE_NAME, kEncryptedString); |
772 } | 756 } |
773 SyncShareNudge(); | 757 SyncShareAsDelegate(); |
774 { | 758 { |
775 // We attempted to commit two items. | 759 // We attempted to commit two items. |
776 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size()); | 760 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size()); |
777 EXPECT_TRUE(session_->status_controller().did_commit_items()); | 761 EXPECT_TRUE(session_->status_controller().did_commit_items()); |
778 // None should be unsynced anymore. | 762 // None should be unsynced anymore. |
779 ReadTransaction rtrans(FROM_HERE, directory()); | 763 ReadTransaction rtrans(FROM_HERE, directory()); |
780 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans); | 764 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans); |
781 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans); | 765 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans); |
782 VERIFY_ENTRY(3, false, false, false, 0, 11, 11, ids_, &rtrans); | 766 VERIFY_ENTRY(3, false, false, false, 0, 11, 11, ids_, &rtrans); |
783 VERIFY_ENTRY(4, false, false, false, 0, 11, 11, ids_, &rtrans); | 767 VERIFY_ENTRY(4, false, false, false, 0, 11, 11, ids_, &rtrans); |
(...skipping 30 matching lines...) Expand all Loading... |
814 nigori->set_encrypt_bookmarks(true); | 798 nigori->set_encrypt_bookmarks(true); |
815 nigori->set_encrypt_preferences(true); | 799 nigori->set_encrypt_preferences(true); |
816 cryptographer(&wtrans)->Update(*nigori); | 800 cryptographer(&wtrans)->Update(*nigori); |
817 EXPECT_TRUE(cryptographer(&wtrans)->has_pending_keys()); | 801 EXPECT_TRUE(cryptographer(&wtrans)->has_pending_keys()); |
818 } | 802 } |
819 | 803 |
820 mock_server_->AddUpdateSpecifics(1, 0, "A", 10, 10, true, 0, bookmark); | 804 mock_server_->AddUpdateSpecifics(1, 0, "A", 10, 10, true, 0, bookmark); |
821 mock_server_->AddUpdateSpecifics(2, 1, "B", 10, 10, false, 2, bookmark); | 805 mock_server_->AddUpdateSpecifics(2, 1, "B", 10, 10, false, 2, bookmark); |
822 mock_server_->AddUpdateSpecifics(3, 1, "C", 10, 10, false, 1, bookmark); | 806 mock_server_->AddUpdateSpecifics(3, 1, "C", 10, 10, false, 1, bookmark); |
823 mock_server_->AddUpdateSpecifics(4, 0, "D", 10, 10, false, 0, pref); | 807 mock_server_->AddUpdateSpecifics(4, 0, "D", 10, 10, false, 0, pref); |
824 SyncShareNudge(); | 808 SyncShareAsDelegate(); |
825 { | 809 { |
826 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | 810 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); |
827 // Initial state. Everything is normal. | 811 // Initial state. Everything is normal. |
828 ReadTransaction rtrans(FROM_HERE, directory()); | 812 ReadTransaction rtrans(FROM_HERE, directory()); |
829 VERIFY_ENTRY(1, false, false, false, 0, 10, 10, ids_, &rtrans); | 813 VERIFY_ENTRY(1, false, false, false, 0, 10, 10, ids_, &rtrans); |
830 VERIFY_ENTRY(2, false, false, false, 1, 10, 10, ids_, &rtrans); | 814 VERIFY_ENTRY(2, false, false, false, 1, 10, 10, ids_, &rtrans); |
831 VERIFY_ENTRY(3, false, false, false, 1, 10, 10, ids_, &rtrans); | 815 VERIFY_ENTRY(3, false, false, false, 1, 10, 10, ids_, &rtrans); |
832 VERIFY_ENTRY(4, false, false, false, 0, 10, 10, ids_, &rtrans); | 816 VERIFY_ENTRY(4, false, false, false, 0, 10, 10, ids_, &rtrans); |
833 } | 817 } |
834 | 818 |
835 // Server side encryption will not be applied due to undecryptable data. | 819 // Server side encryption will not be applied due to undecryptable data. |
836 // At this point, BASE_SERVER_SPECIFICS should be filled for all four items. | 820 // At this point, BASE_SERVER_SPECIFICS should be filled for all four items. |
837 mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 20, 20, true, 0, | 821 mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 20, 20, true, 0, |
838 encrypted_bookmark); | 822 encrypted_bookmark); |
839 mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 20, 20, false, 2, | 823 mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 20, 20, false, 2, |
840 encrypted_bookmark); | 824 encrypted_bookmark); |
841 mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 20, 20, false, 1, | 825 mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 20, 20, false, 1, |
842 encrypted_bookmark); | 826 encrypted_bookmark); |
843 mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 20, 20, false, 0, | 827 mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 20, 20, false, 0, |
844 encrypted_pref); | 828 encrypted_pref); |
845 SyncShareNudge(); | 829 SyncShareAsDelegate(); |
846 { | 830 { |
847 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | 831 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); |
848 // All should be unapplied due to being undecryptable and have a valid | 832 // All should be unapplied due to being undecryptable and have a valid |
849 // BASE_SERVER_SPECIFICS. | 833 // BASE_SERVER_SPECIFICS. |
850 ReadTransaction rtrans(FROM_HERE, directory()); | 834 ReadTransaction rtrans(FROM_HERE, directory()); |
851 VERIFY_ENTRY(1, true, false, true, 0, 10, 20, ids_, &rtrans); | 835 VERIFY_ENTRY(1, true, false, true, 0, 10, 20, ids_, &rtrans); |
852 VERIFY_ENTRY(2, true, false, true, 1, 10, 20, ids_, &rtrans); | 836 VERIFY_ENTRY(2, true, false, true, 1, 10, 20, ids_, &rtrans); |
853 VERIFY_ENTRY(3, true, false, true, 1, 10, 20, ids_, &rtrans); | 837 VERIFY_ENTRY(3, true, false, true, 1, 10, 20, ids_, &rtrans); |
854 VERIFY_ENTRY(4, true, false, true, 0, 10, 20, ids_, &rtrans); | 838 VERIFY_ENTRY(4, true, false, true, 0, 10, 20, ids_, &rtrans); |
855 } | 839 } |
856 | 840 |
857 // Server side change that don't modify anything should not affect | 841 // Server side change that don't modify anything should not affect |
858 // BASE_SERVER_SPECIFICS (such as name changes and mtime changes). | 842 // BASE_SERVER_SPECIFICS (such as name changes and mtime changes). |
859 mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 30, 30, true, 0, | 843 mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 30, 30, true, 0, |
860 encrypted_bookmark); | 844 encrypted_bookmark); |
861 mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 30, 30, false, 2, | 845 mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 30, 30, false, 2, |
862 encrypted_bookmark); | 846 encrypted_bookmark); |
863 // Item 3 doesn't change. | 847 // Item 3 doesn't change. |
864 mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 30, 30, false, 0, | 848 mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 30, 30, false, 0, |
865 encrypted_pref); | 849 encrypted_pref); |
866 SyncShareNudge(); | 850 SyncShareAsDelegate(); |
867 { | 851 { |
868 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | 852 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); |
869 // Items 1, 2, and 4 should have newer server versions, 3 remains the same. | 853 // Items 1, 2, and 4 should have newer server versions, 3 remains the same. |
870 // All should remain unapplied due to be undecryptable. | 854 // All should remain unapplied due to be undecryptable. |
871 ReadTransaction rtrans(FROM_HERE, directory()); | 855 ReadTransaction rtrans(FROM_HERE, directory()); |
872 VERIFY_ENTRY(1, true, false, true, 0, 10, 30, ids_, &rtrans); | 856 VERIFY_ENTRY(1, true, false, true, 0, 10, 30, ids_, &rtrans); |
873 VERIFY_ENTRY(2, true, false, true, 1, 10, 30, ids_, &rtrans); | 857 VERIFY_ENTRY(2, true, false, true, 1, 10, 30, ids_, &rtrans); |
874 VERIFY_ENTRY(3, true, false, true, 1, 10, 20, ids_, &rtrans); | 858 VERIFY_ENTRY(3, true, false, true, 1, 10, 20, ids_, &rtrans); |
875 VERIFY_ENTRY(4, true, false, true, 0, 10, 30, ids_, &rtrans); | 859 VERIFY_ENTRY(4, true, false, true, 0, 10, 30, ids_, &rtrans); |
876 } | 860 } |
877 | 861 |
878 // Positional changes, parent changes, and specifics changes should reset | 862 // Positional changes, parent changes, and specifics changes should reset |
879 // BASE_SERVER_SPECIFICS. | 863 // BASE_SERVER_SPECIFICS. |
880 // Became unencrypted. | 864 // Became unencrypted. |
881 mock_server_->AddUpdateSpecifics(1, 0, "A", 40, 40, true, 0, bookmark); | 865 mock_server_->AddUpdateSpecifics(1, 0, "A", 40, 40, true, 0, bookmark); |
882 // Reordered to after item 2. | 866 // Reordered to after item 2. |
883 mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 30, 30, false, 3, | 867 mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 30, 30, false, 3, |
884 encrypted_bookmark); | 868 encrypted_bookmark); |
885 SyncShareNudge(); | 869 SyncShareAsDelegate(); |
886 { | 870 { |
887 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | 871 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); |
888 // Items 2 and 4 should be the only ones with BASE_SERVER_SPECIFICS set. | 872 // Items 2 and 4 should be the only ones with BASE_SERVER_SPECIFICS set. |
889 // Items 1 is now unencrypted, so should have applied normally. | 873 // Items 1 is now unencrypted, so should have applied normally. |
890 ReadTransaction rtrans(FROM_HERE, directory()); | 874 ReadTransaction rtrans(FROM_HERE, directory()); |
891 VERIFY_ENTRY(1, false, false, false, 0, 40, 40, ids_, &rtrans); | 875 VERIFY_ENTRY(1, false, false, false, 0, 40, 40, ids_, &rtrans); |
892 VERIFY_ENTRY(2, true, false, true, 1, 10, 30, ids_, &rtrans); | 876 VERIFY_ENTRY(2, true, false, true, 1, 10, 30, ids_, &rtrans); |
893 VERIFY_ENTRY(3, true, false, false, 1, 10, 30, ids_, &rtrans); | 877 VERIFY_ENTRY(3, true, false, false, 1, 10, 30, ids_, &rtrans); |
894 VERIFY_ENTRY(4, true, false, true, 0, 10, 30, ids_, &rtrans); | 878 VERIFY_ENTRY(4, true, false, true, 0, 10, 30, ids_, &rtrans); |
895 } | 879 } |
(...skipping 15 matching lines...) Expand all Loading... |
911 ASSERT_TRUE(C.good()); | 895 ASSERT_TRUE(C.good()); |
912 C.Put(SPECIFICS, modified_bookmark); | 896 C.Put(SPECIFICS, modified_bookmark); |
913 C.Put(NON_UNIQUE_NAME, kEncryptedString); | 897 C.Put(NON_UNIQUE_NAME, kEncryptedString); |
914 C.Put(IS_UNSYNCED, true); | 898 C.Put(IS_UNSYNCED, true); |
915 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); | 899 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); |
916 ASSERT_TRUE(D.good()); | 900 ASSERT_TRUE(D.good()); |
917 D.Put(SPECIFICS, modified_pref); | 901 D.Put(SPECIFICS, modified_pref); |
918 D.Put(NON_UNIQUE_NAME, kEncryptedString); | 902 D.Put(NON_UNIQUE_NAME, kEncryptedString); |
919 D.Put(IS_UNSYNCED, true); | 903 D.Put(IS_UNSYNCED, true); |
920 } | 904 } |
921 SyncShareNudge(); | 905 SyncShareAsDelegate(); |
922 { | 906 { |
923 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | 907 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); |
924 // Item 1 remains unsynced due to there being pending keys. | 908 // Item 1 remains unsynced due to there being pending keys. |
925 // Items 2, 3, 4 should remain unsynced since they were not up to date. | 909 // Items 2, 3, 4 should remain unsynced since they were not up to date. |
926 ReadTransaction rtrans(FROM_HERE, directory()); | 910 ReadTransaction rtrans(FROM_HERE, directory()); |
927 VERIFY_ENTRY(1, false, true, false, 0, 40, 40, ids_, &rtrans); | 911 VERIFY_ENTRY(1, false, true, false, 0, 40, 40, ids_, &rtrans); |
928 VERIFY_ENTRY(2, true, true, true, 1, 10, 30, ids_, &rtrans); | 912 VERIFY_ENTRY(2, true, true, true, 1, 10, 30, ids_, &rtrans); |
929 VERIFY_ENTRY(3, true, true, false, 1, 10, 30, ids_, &rtrans); | 913 VERIFY_ENTRY(3, true, true, false, 1, 10, 30, ids_, &rtrans); |
930 VERIFY_ENTRY(4, true, true, true, 0, 10, 30, ids_, &rtrans); | 914 VERIFY_ENTRY(4, true, true, true, 0, 10, 30, ids_, &rtrans); |
931 } | 915 } |
932 | 916 |
933 { | 917 { |
934 ReadTransaction rtrans(FROM_HERE, directory()); | 918 ReadTransaction rtrans(FROM_HERE, directory()); |
935 // Resolve the pending keys. | 919 // Resolve the pending keys. |
936 cryptographer(&rtrans)->DecryptPendingKeys(key_params); | 920 cryptographer(&rtrans)->DecryptPendingKeys(key_params); |
937 } | 921 } |
938 // First cycle resolves conflicts, second cycle commits changes. | 922 // First cycle resolves conflicts, second cycle commits changes. |
939 SyncShareNudge(); | 923 SyncShareAsDelegate(); |
940 EXPECT_EQ(2, session_->status_controller().syncer_status(). | 924 EXPECT_EQ(2, session_->status_controller().syncer_status(). |
941 num_server_overwrites); | 925 num_server_overwrites); |
942 EXPECT_EQ(1, session_->status_controller().syncer_status(). | 926 EXPECT_EQ(1, session_->status_controller().syncer_status(). |
943 num_local_overwrites); | 927 num_local_overwrites); |
944 // We attempted to commit item 1. | 928 // We attempted to commit item 1. |
945 EXPECT_EQ(1U, session_->status_controller().unsynced_handles().size()); | 929 EXPECT_EQ(1U, session_->status_controller().unsynced_handles().size()); |
946 EXPECT_TRUE(session_->status_controller().did_commit_items()); | 930 EXPECT_TRUE(session_->status_controller().did_commit_items()); |
947 SyncShareNudge(); | 931 SyncShareAsDelegate(); |
948 { | 932 { |
949 // Everything should be resolved now. The local changes should have | 933 // Everything should be resolved now. The local changes should have |
950 // overwritten the server changes for 2 and 4, while the server changes | 934 // overwritten the server changes for 2 and 4, while the server changes |
951 // overwrote the local for entry 3. | 935 // overwrote the local for entry 3. |
952 // We attempted to commit two handles. | 936 // We attempted to commit two handles. |
953 EXPECT_EQ(0, session_->status_controller().syncer_status(). | 937 EXPECT_EQ(0, session_->status_controller().syncer_status(). |
954 num_server_overwrites); | 938 num_server_overwrites); |
955 EXPECT_EQ(0, session_->status_controller().syncer_status(). | 939 EXPECT_EQ(0, session_->status_controller().syncer_status(). |
956 num_local_overwrites); | 940 num_local_overwrites); |
957 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size()); | 941 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size()); |
(...skipping 24 matching lines...) Expand all Loading... |
982 other_encrypted_specifics.mutable_encrypted()); | 966 other_encrypted_specifics.mutable_encrypted()); |
983 sync_pb::EntitySpecifics our_encrypted_specifics; | 967 sync_pb::EntitySpecifics our_encrypted_specifics; |
984 our_encrypted_specifics.mutable_bookmark()->set_title("title2"); | 968 our_encrypted_specifics.mutable_bookmark()->set_title("title2"); |
985 syncable::ModelTypeSet encrypted_types = syncable::ModelTypeSet::All(); | 969 syncable::ModelTypeSet encrypted_types = syncable::ModelTypeSet::All(); |
986 | 970 |
987 | 971 |
988 // Receive the initial nigori node. | 972 // Receive the initial nigori node. |
989 sync_pb::EntitySpecifics initial_nigori_specifics; | 973 sync_pb::EntitySpecifics initial_nigori_specifics; |
990 initial_nigori_specifics.mutable_nigori(); | 974 initial_nigori_specifics.mutable_nigori(); |
991 mock_server_->SetNigori(1, 10, 10, initial_nigori_specifics); | 975 mock_server_->SetNigori(1, 10, 10, initial_nigori_specifics); |
992 SyncShareNudge(); | 976 SyncShareAsDelegate(); |
993 | 977 |
994 { | 978 { |
995 // Set up the current nigori node (containing both keys and encrypt | 979 // Set up the current nigori node (containing both keys and encrypt |
996 // everything). | 980 // everything). |
997 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 981 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
998 sync_pb::EntitySpecifics specifics; | 982 sync_pb::EntitySpecifics specifics; |
999 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); | 983 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); |
1000 cryptographer(&wtrans)->AddKey(old_key); | 984 cryptographer(&wtrans)->AddKey(old_key); |
1001 cryptographer(&wtrans)->AddKey(current_key); | 985 cryptographer(&wtrans)->AddKey(current_key); |
1002 cryptographer(&wtrans)->Encrypt( | 986 cryptographer(&wtrans)->Encrypt( |
1003 our_encrypted_specifics, | 987 our_encrypted_specifics, |
1004 our_encrypted_specifics.mutable_encrypted()); | 988 our_encrypted_specifics.mutable_encrypted()); |
1005 cryptographer(&wtrans)->GetKeys( | 989 cryptographer(&wtrans)->GetKeys( |
1006 nigori->mutable_encrypted()); | 990 nigori->mutable_encrypted()); |
1007 cryptographer(&wtrans)->set_encrypt_everything(); | 991 cryptographer(&wtrans)->set_encrypt_everything(); |
1008 cryptographer(&wtrans)->UpdateNigoriFromEncryptedTypes(nigori); | 992 cryptographer(&wtrans)->UpdateNigoriFromEncryptedTypes(nigori); |
1009 MutableEntry nigori_entry(&wtrans, GET_BY_SERVER_TAG, | 993 MutableEntry nigori_entry(&wtrans, GET_BY_SERVER_TAG, |
1010 syncable::ModelTypeToRootTag(syncable::NIGORI)); | 994 syncable::ModelTypeToRootTag(syncable::NIGORI)); |
1011 ASSERT_TRUE(nigori_entry.good()); | 995 ASSERT_TRUE(nigori_entry.good()); |
1012 nigori_entry.Put(SPECIFICS, specifics); | 996 nigori_entry.Put(SPECIFICS, specifics); |
1013 nigori_entry.Put(IS_UNSYNCED, true); | 997 nigori_entry.Put(IS_UNSYNCED, true); |
1014 EXPECT_FALSE(cryptographer(&wtrans)->has_pending_keys()); | 998 EXPECT_FALSE(cryptographer(&wtrans)->has_pending_keys()); |
1015 EXPECT_TRUE(encrypted_types.Equals( | 999 EXPECT_TRUE(encrypted_types.Equals( |
1016 cryptographer(&wtrans)->GetEncryptedTypes())); | 1000 cryptographer(&wtrans)->GetEncryptedTypes())); |
1017 } | 1001 } |
1018 | 1002 |
1019 SyncShareNudge(); // Commit it. | 1003 SyncShareAsDelegate(); // Commit it. |
1020 | 1004 |
1021 // Now set up the old nigori node and add it as a server update. | 1005 // Now set up the old nigori node and add it as a server update. |
1022 sync_pb::EntitySpecifics old_nigori_specifics; | 1006 sync_pb::EntitySpecifics old_nigori_specifics; |
1023 sync_pb::NigoriSpecifics *old_nigori = old_nigori_specifics.mutable_nigori(); | 1007 sync_pb::NigoriSpecifics *old_nigori = old_nigori_specifics.mutable_nigori(); |
1024 other_cryptographer.GetKeys(old_nigori->mutable_encrypted()); | 1008 other_cryptographer.GetKeys(old_nigori->mutable_encrypted()); |
1025 other_cryptographer.UpdateNigoriFromEncryptedTypes(old_nigori); | 1009 other_cryptographer.UpdateNigoriFromEncryptedTypes(old_nigori); |
1026 mock_server_->SetNigori(1, 30, 30, old_nigori_specifics); | 1010 mock_server_->SetNigori(1, 30, 30, old_nigori_specifics); |
1027 | 1011 |
1028 SyncShareNudge(); // Download the old nigori and apply it. | 1012 SyncShareAsDelegate(); // Download the old nigori and apply it. |
1029 | 1013 |
1030 { | 1014 { |
1031 // Ensure everything is committed and stable now. The cryptographer | 1015 // Ensure everything is committed and stable now. The cryptographer |
1032 // should be able to decrypt both sets of keys and still be encrypting with | 1016 // should be able to decrypt both sets of keys and still be encrypting with |
1033 // the newest, and the encrypted types should be the most recent | 1017 // the newest, and the encrypted types should be the most recent |
1034 ReadTransaction trans(FROM_HERE, directory()); | 1018 ReadTransaction trans(FROM_HERE, directory()); |
1035 Entry nigori_entry(&trans, GET_BY_SERVER_TAG, | 1019 Entry nigori_entry(&trans, GET_BY_SERVER_TAG, |
1036 syncable::ModelTypeToRootTag(syncable::NIGORI)); | 1020 syncable::ModelTypeToRootTag(syncable::NIGORI)); |
1037 ASSERT_TRUE(nigori_entry.good()); | 1021 ASSERT_TRUE(nigori_entry.good()); |
1038 EXPECT_FALSE(nigori_entry.Get(IS_UNAPPLIED_UPDATE)); | 1022 EXPECT_FALSE(nigori_entry.Get(IS_UNAPPLIED_UPDATE)); |
(...skipping 28 matching lines...) Expand all Loading... |
1067 // Data for testing encryption/decryption. | 1051 // Data for testing encryption/decryption. |
1068 sync_pb::EntitySpecifics other_encrypted_specifics; | 1052 sync_pb::EntitySpecifics other_encrypted_specifics; |
1069 other_encrypted_specifics.mutable_bookmark()->set_title("title"); | 1053 other_encrypted_specifics.mutable_bookmark()->set_title("title"); |
1070 other_cryptographer.Encrypt( | 1054 other_cryptographer.Encrypt( |
1071 other_encrypted_specifics, | 1055 other_encrypted_specifics, |
1072 other_encrypted_specifics.mutable_encrypted()); | 1056 other_encrypted_specifics.mutable_encrypted()); |
1073 sync_pb::EntitySpecifics our_encrypted_specifics; | 1057 sync_pb::EntitySpecifics our_encrypted_specifics; |
1074 our_encrypted_specifics.mutable_bookmark()->set_title("title2"); | 1058 our_encrypted_specifics.mutable_bookmark()->set_title("title2"); |
1075 | 1059 |
1076 // Receive the initial nigori node. | 1060 // Receive the initial nigori node. |
1077 SyncShareNudge(); | 1061 SyncShareAsDelegate(); |
1078 encrypted_types = syncable::ModelTypeSet::All(); | 1062 encrypted_types = syncable::ModelTypeSet::All(); |
1079 { | 1063 { |
1080 // Local changes with different passphrase, different types, and sync_tabs. | 1064 // Local changes with different passphrase, different types, and sync_tabs. |
1081 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1065 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1082 sync_pb::EntitySpecifics specifics; | 1066 sync_pb::EntitySpecifics specifics; |
1083 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); | 1067 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); |
1084 cryptographer(&wtrans)->AddKey(local_key_params); | 1068 cryptographer(&wtrans)->AddKey(local_key_params); |
1085 cryptographer(&wtrans)->Encrypt( | 1069 cryptographer(&wtrans)->Encrypt( |
1086 our_encrypted_specifics, | 1070 our_encrypted_specifics, |
1087 our_encrypted_specifics.mutable_encrypted()); | 1071 our_encrypted_specifics.mutable_encrypted()); |
(...skipping 20 matching lines...) Expand all Loading... |
1108 nigori->set_encrypt_everything(false); | 1092 nigori->set_encrypt_everything(false); |
1109 nigori->set_using_explicit_passphrase(true); | 1093 nigori->set_using_explicit_passphrase(true); |
1110 mock_server_->SetNigori(1, 20, 20, specifics); | 1094 mock_server_->SetNigori(1, 20, 20, specifics); |
1111 } | 1095 } |
1112 | 1096 |
1113 // Will result in downloading the server nigori, which puts the local nigori | 1097 // Will result in downloading the server nigori, which puts the local nigori |
1114 // in a state of conflict. This is resolved by merging the local and server | 1098 // in a state of conflict. This is resolved by merging the local and server |
1115 // data (with priority given to the server's encryption keys if they are | 1099 // data (with priority given to the server's encryption keys if they are |
1116 // undecryptable), which we then commit. The cryptographer should have pending | 1100 // undecryptable), which we then commit. The cryptographer should have pending |
1117 // keys and merge the set of encrypted types. | 1101 // keys and merge the set of encrypted types. |
1118 SyncShareNudge(); // Resolve conflict in this cycle. | 1102 SyncShareAsDelegate(); // Resolve conflict in this cycle. |
1119 SyncShareNudge(); // Commit local change in this cycle. | 1103 SyncShareAsDelegate(); // Commit local change in this cycle. |
1120 { | 1104 { |
1121 // Ensure the nigori data merged (encrypted types, sync_tabs). | 1105 // Ensure the nigori data merged (encrypted types, sync_tabs). |
1122 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1106 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1123 MutableEntry nigori_entry(&wtrans, GET_BY_SERVER_TAG, | 1107 MutableEntry nigori_entry(&wtrans, GET_BY_SERVER_TAG, |
1124 syncable::ModelTypeToRootTag(syncable::NIGORI)); | 1108 syncable::ModelTypeToRootTag(syncable::NIGORI)); |
1125 ASSERT_TRUE(nigori_entry.good()); | 1109 ASSERT_TRUE(nigori_entry.good()); |
1126 EXPECT_FALSE(nigori_entry.Get(IS_UNAPPLIED_UPDATE)); | 1110 EXPECT_FALSE(nigori_entry.Get(IS_UNAPPLIED_UPDATE)); |
1127 EXPECT_FALSE(nigori_entry.Get(IS_UNSYNCED)); | 1111 EXPECT_FALSE(nigori_entry.Get(IS_UNSYNCED)); |
1128 sync_pb::EntitySpecifics specifics = nigori_entry.Get(SPECIFICS); | 1112 sync_pb::EntitySpecifics specifics = nigori_entry.Get(SPECIFICS); |
1129 EXPECT_TRUE(cryptographer(&wtrans)->has_pending_keys()); | 1113 EXPECT_TRUE(cryptographer(&wtrans)->has_pending_keys()); |
1130 EXPECT_TRUE(encrypted_types.Equals( | 1114 EXPECT_TRUE(encrypted_types.Equals( |
1131 cryptographer(&wtrans)->GetEncryptedTypes())); | 1115 cryptographer(&wtrans)->GetEncryptedTypes())); |
1132 EXPECT_TRUE(cryptographer(&wtrans)->encrypt_everything()); | 1116 EXPECT_TRUE(cryptographer(&wtrans)->encrypt_everything()); |
1133 EXPECT_TRUE(specifics.nigori().sync_tabs()); | 1117 EXPECT_TRUE(specifics.nigori().sync_tabs()); |
1134 EXPECT_TRUE(specifics.nigori().using_explicit_passphrase()); | 1118 EXPECT_TRUE(specifics.nigori().using_explicit_passphrase()); |
1135 // Supply the pending keys. Afterwards, we should be able to decrypt both | 1119 // Supply the pending keys. Afterwards, we should be able to decrypt both |
1136 // our own encrypted data and data encrypted by the other cryptographer, | 1120 // our own encrypted data and data encrypted by the other cryptographer, |
1137 // but the key provided by the other cryptographer should be the default. | 1121 // but the key provided by the other cryptographer should be the default. |
1138 EXPECT_TRUE(cryptographer(&wtrans)->DecryptPendingKeys(other_key_params)); | 1122 EXPECT_TRUE(cryptographer(&wtrans)->DecryptPendingKeys(other_key_params)); |
1139 EXPECT_FALSE(cryptographer(&wtrans)->has_pending_keys()); | 1123 EXPECT_FALSE(cryptographer(&wtrans)->has_pending_keys()); |
1140 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); | 1124 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); |
1141 cryptographer(&wtrans)->GetKeys(nigori->mutable_encrypted()); | 1125 cryptographer(&wtrans)->GetKeys(nigori->mutable_encrypted()); |
1142 cryptographer(&wtrans)->UpdateNigoriFromEncryptedTypes(nigori); | 1126 cryptographer(&wtrans)->UpdateNigoriFromEncryptedTypes(nigori); |
1143 // Normally this would be written as part of SetPassphrase, but we do it | 1127 // Normally this would be written as part of SetPassphrase, but we do it |
1144 // manually for the test. | 1128 // manually for the test. |
1145 nigori_entry.Put(SPECIFICS, specifics); | 1129 nigori_entry.Put(SPECIFICS, specifics); |
1146 nigori_entry.Put(IS_UNSYNCED, true); | 1130 nigori_entry.Put(IS_UNSYNCED, true); |
1147 } | 1131 } |
1148 | 1132 |
1149 SyncShareNudge(); | 1133 SyncShareAsDelegate(); |
1150 { | 1134 { |
1151 // Ensure everything is committed and stable now. The cryptographer | 1135 // Ensure everything is committed and stable now. The cryptographer |
1152 // should be able to decrypt both sets of keys, sync_tabs should be true, | 1136 // should be able to decrypt both sets of keys, sync_tabs should be true, |
1153 // and the encrypted types should have been unioned. | 1137 // and the encrypted types should have been unioned. |
1154 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1138 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1155 MutableEntry nigori_entry(&wtrans, GET_BY_SERVER_TAG, | 1139 MutableEntry nigori_entry(&wtrans, GET_BY_SERVER_TAG, |
1156 syncable::ModelTypeToRootTag(syncable::NIGORI)); | 1140 syncable::ModelTypeToRootTag(syncable::NIGORI)); |
1157 ASSERT_TRUE(nigori_entry.good()); | 1141 ASSERT_TRUE(nigori_entry.good()); |
1158 EXPECT_FALSE(nigori_entry.Get(IS_UNAPPLIED_UPDATE)); | 1142 EXPECT_FALSE(nigori_entry.Get(IS_UNAPPLIED_UPDATE)); |
1159 EXPECT_FALSE(nigori_entry.Get(IS_UNSYNCED)); | 1143 EXPECT_FALSE(nigori_entry.Get(IS_UNSYNCED)); |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 EXPECT_TRUE(entry_b.Get(syncable::ID).ServerKnows()); | 1712 EXPECT_TRUE(entry_b.Get(syncable::ID).ServerKnows()); |
1729 EXPECT_TRUE(parent2.Get(syncable::ID) == entry_b.Get(syncable::PARENT_ID)); | 1713 EXPECT_TRUE(parent2.Get(syncable::ID) == entry_b.Get(syncable::PARENT_ID)); |
1730 } | 1714 } |
1731 } | 1715 } |
1732 | 1716 |
1733 TEST_F(SyncerTest, UpdateWithZeroLengthName) { | 1717 TEST_F(SyncerTest, UpdateWithZeroLengthName) { |
1734 // One illegal update | 1718 // One illegal update |
1735 mock_server_->AddUpdateDirectory(1, 0, "", 1, 10); | 1719 mock_server_->AddUpdateDirectory(1, 0, "", 1, 10); |
1736 // And one legal one that we're going to delete. | 1720 // And one legal one that we're going to delete. |
1737 mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10); | 1721 mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10); |
1738 SyncShareNudge(); | 1722 SyncShareAsDelegate(); |
1739 // Delete the legal one. The new update has a null name. | 1723 // Delete the legal one. The new update has a null name. |
1740 mock_server_->AddUpdateDirectory(2, 0, "", 2, 20); | 1724 mock_server_->AddUpdateDirectory(2, 0, "", 2, 20); |
1741 mock_server_->SetLastUpdateDeleted(); | 1725 mock_server_->SetLastUpdateDeleted(); |
1742 SyncShareNudge(); | 1726 SyncShareAsDelegate(); |
1743 } | 1727 } |
1744 | 1728 |
1745 TEST_F(SyncerTest, TestBasicUpdate) { | 1729 TEST_F(SyncerTest, TestBasicUpdate) { |
1746 string id = "some_id"; | 1730 string id = "some_id"; |
1747 string parent_id = "0"; | 1731 string parent_id = "0"; |
1748 string name = "in_root"; | 1732 string name = "in_root"; |
1749 int64 version = 10; | 1733 int64 version = 10; |
1750 int64 timestamp = 10; | 1734 int64 timestamp = 10; |
1751 mock_server_->AddUpdateDirectory(id, parent_id, name, version, timestamp); | 1735 mock_server_->AddUpdateDirectory(id, parent_id, name, version, timestamp); |
1752 | 1736 |
1753 SyncShareNudge(); | 1737 SyncShareAsDelegate(); |
1754 { | 1738 { |
1755 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 1739 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
1756 Entry entry(&trans, GET_BY_ID, | 1740 Entry entry(&trans, GET_BY_ID, |
1757 syncable::Id::CreateFromServerId("some_id")); | 1741 syncable::Id::CreateFromServerId("some_id")); |
1758 ASSERT_TRUE(entry.good()); | 1742 ASSERT_TRUE(entry.good()); |
1759 EXPECT_TRUE(entry.Get(IS_DIR)); | 1743 EXPECT_TRUE(entry.Get(IS_DIR)); |
1760 EXPECT_TRUE(entry.Get(SERVER_VERSION) == version); | 1744 EXPECT_TRUE(entry.Get(SERVER_VERSION) == version); |
1761 EXPECT_TRUE(entry.Get(BASE_VERSION) == version); | 1745 EXPECT_TRUE(entry.Get(BASE_VERSION) == version); |
1762 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 1746 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
1763 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 1747 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 | 1905 |
1922 MutableEntry entry(&trans, CREATE, parent.Get(ID), "new_entry"); | 1906 MutableEntry entry(&trans, CREATE, parent.Get(ID), "new_entry"); |
1923 ASSERT_TRUE(entry.good()); | 1907 ASSERT_TRUE(entry.good()); |
1924 metahandle_new_entry = entry.Get(META_HANDLE); | 1908 metahandle_new_entry = entry.Get(META_HANDLE); |
1925 WriteTestDataToEntry(&trans, &entry); | 1909 WriteTestDataToEntry(&trans, &entry); |
1926 } | 1910 } |
1927 | 1911 |
1928 // Mix in a directory creation too for later. | 1912 // Mix in a directory creation too for later. |
1929 mock_server_->AddUpdateDirectory(2, 0, "dir_in_root", 10, 10); | 1913 mock_server_->AddUpdateDirectory(2, 0, "dir_in_root", 10, 10); |
1930 mock_server_->SetCommitTimeRename("renamed_"); | 1914 mock_server_->SetCommitTimeRename("renamed_"); |
1931 SyncShareNudge(); | 1915 SyncShareAsDelegate(); |
1932 | 1916 |
1933 // Verify it was correctly renamed. | 1917 // Verify it was correctly renamed. |
1934 { | 1918 { |
1935 ReadTransaction trans(FROM_HERE, directory()); | 1919 ReadTransaction trans(FROM_HERE, directory()); |
1936 Entry entry_folder(&trans, GET_BY_HANDLE, metahandle_folder); | 1920 Entry entry_folder(&trans, GET_BY_HANDLE, metahandle_folder); |
1937 ASSERT_TRUE(entry_folder.good()); | 1921 ASSERT_TRUE(entry_folder.good()); |
1938 EXPECT_EQ("renamed_Folder", entry_folder.Get(NON_UNIQUE_NAME)); | 1922 EXPECT_EQ("renamed_Folder", entry_folder.Get(NON_UNIQUE_NAME)); |
1939 | 1923 |
1940 Entry entry_new(&trans, GET_BY_HANDLE, metahandle_new_entry); | 1924 Entry entry_new(&trans, GET_BY_HANDLE, metahandle_new_entry); |
1941 ASSERT_TRUE(entry_new.good()); | 1925 ASSERT_TRUE(entry_new.good()); |
(...skipping 20 matching lines...) Expand all Loading... |
1962 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 1946 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
1963 MutableEntry parent(&trans, CREATE, root_id_, "Folder"); | 1947 MutableEntry parent(&trans, CREATE, root_id_, "Folder"); |
1964 ASSERT_TRUE(parent.good()); | 1948 ASSERT_TRUE(parent.good()); |
1965 parent.Put(IS_DIR, true); | 1949 parent.Put(IS_DIR, true); |
1966 parent.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 1950 parent.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
1967 parent.Put(IS_UNSYNCED, true); | 1951 parent.Put(IS_UNSYNCED, true); |
1968 metahandle = parent.Get(META_HANDLE); | 1952 metahandle = parent.Get(META_HANDLE); |
1969 } | 1953 } |
1970 | 1954 |
1971 mock_server_->SetCommitTimeRename(i18nString); | 1955 mock_server_->SetCommitTimeRename(i18nString); |
1972 SyncShareNudge(); | 1956 SyncShareAsDelegate(); |
1973 | 1957 |
1974 // Verify it was correctly renamed. | 1958 // Verify it was correctly renamed. |
1975 { | 1959 { |
1976 ReadTransaction trans(FROM_HERE, directory()); | 1960 ReadTransaction trans(FROM_HERE, directory()); |
1977 string expected_folder_name(i18nString); | 1961 string expected_folder_name(i18nString); |
1978 expected_folder_name.append("Folder"); | 1962 expected_folder_name.append("Folder"); |
1979 | 1963 |
1980 | 1964 |
1981 Entry entry_folder(&trans, GET_BY_HANDLE, metahandle); | 1965 Entry entry_folder(&trans, GET_BY_HANDLE, metahandle); |
1982 ASSERT_TRUE(entry_folder.good()); | 1966 ASSERT_TRUE(entry_folder.good()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2042 // well as reassociate the id. | 2026 // well as reassociate the id. |
2043 mock_server_->AddUpdateDirectory(new_folder_id, root_id_, | 2027 mock_server_->AddUpdateDirectory(new_folder_id, root_id_, |
2044 "new_folder", new_version, timestamp); | 2028 "new_folder", new_version, timestamp); |
2045 mock_server_->SetLastUpdateOriginatorFields( | 2029 mock_server_->SetLastUpdateOriginatorFields( |
2046 directory()->cache_guid(), folder_id.GetServerId()); | 2030 directory()->cache_guid(), folder_id.GetServerId()); |
2047 | 2031 |
2048 // We don't want it accidentally committed, just the update applied. | 2032 // We don't want it accidentally committed, just the update applied. |
2049 mock_server_->set_conflict_all_commits(true); | 2033 mock_server_->set_conflict_all_commits(true); |
2050 | 2034 |
2051 // Alright! Apply that update! | 2035 // Alright! Apply that update! |
2052 SyncShareNudge(); | 2036 SyncShareAsDelegate(); |
2053 { | 2037 { |
2054 // The folder's ID should have been updated. | 2038 // The folder's ID should have been updated. |
2055 ReadTransaction trans(FROM_HERE, directory()); | 2039 ReadTransaction trans(FROM_HERE, directory()); |
2056 Entry folder(&trans, GET_BY_HANDLE, metahandle_folder); | 2040 Entry folder(&trans, GET_BY_HANDLE, metahandle_folder); |
2057 ASSERT_TRUE(folder.good()); | 2041 ASSERT_TRUE(folder.good()); |
2058 EXPECT_EQ("new_folder", folder.Get(NON_UNIQUE_NAME)); | 2042 EXPECT_EQ("new_folder", folder.Get(NON_UNIQUE_NAME)); |
2059 EXPECT_TRUE(new_version == folder.Get(BASE_VERSION)); | 2043 EXPECT_TRUE(new_version == folder.Get(BASE_VERSION)); |
2060 EXPECT_TRUE(new_folder_id == folder.Get(ID)); | 2044 EXPECT_TRUE(new_folder_id == folder.Get(ID)); |
2061 EXPECT_TRUE(folder.Get(ID).ServerKnows()); | 2045 EXPECT_TRUE(folder.Get(ID).ServerKnows()); |
2062 EXPECT_EQ(trans.root_id(), folder.Get(PARENT_ID)); | 2046 EXPECT_EQ(trans.root_id(), folder.Get(PARENT_ID)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 // Generate an update from the server with a relevant ID reassignment. | 2092 // Generate an update from the server with a relevant ID reassignment. |
2109 mock_server_->AddUpdateBookmark(new_entry_id, root_id_, | 2093 mock_server_->AddUpdateBookmark(new_entry_id, root_id_, |
2110 "new_entry", new_version, timestamp); | 2094 "new_entry", new_version, timestamp); |
2111 mock_server_->SetLastUpdateOriginatorFields( | 2095 mock_server_->SetLastUpdateOriginatorFields( |
2112 directory()->cache_guid(), entry_id.GetServerId()); | 2096 directory()->cache_guid(), entry_id.GetServerId()); |
2113 | 2097 |
2114 // We don't want it accidentally committed, just the update applied. | 2098 // We don't want it accidentally committed, just the update applied. |
2115 mock_server_->set_conflict_all_commits(true); | 2099 mock_server_->set_conflict_all_commits(true); |
2116 | 2100 |
2117 // Alright! Apply that update! | 2101 // Alright! Apply that update! |
2118 SyncShareNudge(); | 2102 SyncShareAsDelegate(); |
2119 { | 2103 { |
2120 ReadTransaction trans(FROM_HERE, directory()); | 2104 ReadTransaction trans(FROM_HERE, directory()); |
2121 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); | 2105 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); |
2122 ASSERT_TRUE(entry.good()); | 2106 ASSERT_TRUE(entry.good()); |
2123 EXPECT_TRUE(new_version == entry.Get(BASE_VERSION)); | 2107 EXPECT_TRUE(new_version == entry.Get(BASE_VERSION)); |
2124 EXPECT_TRUE(new_entry_id == entry.Get(ID)); | 2108 EXPECT_TRUE(new_entry_id == entry.Get(ID)); |
2125 EXPECT_EQ("new_entry", entry.Get(NON_UNIQUE_NAME)); | 2109 EXPECT_EQ("new_entry", entry.Get(NON_UNIQUE_NAME)); |
2126 } | 2110 } |
2127 } | 2111 } |
2128 | 2112 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 { | 2155 { |
2172 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2156 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2173 Id new_entry_id = GetOnlyEntryWithName( | 2157 Id new_entry_id = GetOnlyEntryWithName( |
2174 &trans, trans.root_id(), "new_entry"); | 2158 &trans, trans.root_id(), "new_entry"); |
2175 MutableEntry entry(&trans, GET_BY_ID, new_entry_id); | 2159 MutableEntry entry(&trans, GET_BY_ID, new_entry_id); |
2176 ASSERT_TRUE(entry.good()); | 2160 ASSERT_TRUE(entry.good()); |
2177 entry.Put(syncable::IS_DEL, true); | 2161 entry.Put(syncable::IS_DEL, true); |
2178 } | 2162 } |
2179 | 2163 |
2180 // Just don't CHECK fail in sync, have the update split. | 2164 // Just don't CHECK fail in sync, have the update split. |
2181 SyncShareNudge(); | 2165 SyncShareAsDelegate(); |
2182 { | 2166 { |
2183 ReadTransaction trans(FROM_HERE, directory()); | 2167 ReadTransaction trans(FROM_HERE, directory()); |
2184 Id new_entry_id = GetOnlyEntryWithName( | 2168 Id new_entry_id = GetOnlyEntryWithName( |
2185 &trans, trans.root_id(), "new_entry"); | 2169 &trans, trans.root_id(), "new_entry"); |
2186 Entry entry(&trans, GET_BY_ID, new_entry_id); | 2170 Entry entry(&trans, GET_BY_ID, new_entry_id); |
2187 ASSERT_TRUE(entry.good()); | 2171 ASSERT_TRUE(entry.good()); |
2188 EXPECT_FALSE(entry.Get(IS_DEL)); | 2172 EXPECT_FALSE(entry.Get(IS_DEL)); |
2189 | 2173 |
2190 Entry old_entry(&trans, GET_BY_ID, entry_id); | 2174 Entry old_entry(&trans, GET_BY_ID, entry_id); |
2191 ASSERT_TRUE(old_entry.good()); | 2175 ASSERT_TRUE(old_entry.good()); |
2192 EXPECT_TRUE(old_entry.Get(IS_DEL)); | 2176 EXPECT_TRUE(old_entry.Get(IS_DEL)); |
2193 } | 2177 } |
2194 } | 2178 } |
2195 | 2179 |
2196 // TODO(chron): Add more unsanitized name tests. | 2180 // TODO(chron): Add more unsanitized name tests. |
2197 TEST_F(SyncerTest, ConflictMatchingEntryHandlesUnsanitizedNames) { | 2181 TEST_F(SyncerTest, ConflictMatchingEntryHandlesUnsanitizedNames) { |
2198 mock_server_->AddUpdateDirectory(1, 0, "A/A", 10, 10); | 2182 mock_server_->AddUpdateDirectory(1, 0, "A/A", 10, 10); |
2199 mock_server_->AddUpdateDirectory(2, 0, "B/B", 10, 10); | 2183 mock_server_->AddUpdateDirectory(2, 0, "B/B", 10, 10); |
2200 mock_server_->set_conflict_all_commits(true); | 2184 mock_server_->set_conflict_all_commits(true); |
2201 SyncShareNudge(); | 2185 SyncShareAsDelegate(); |
2202 { | 2186 { |
2203 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2187 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2204 | 2188 |
2205 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2189 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2206 ASSERT_TRUE(A.good()); | 2190 ASSERT_TRUE(A.good()); |
2207 A.Put(IS_UNSYNCED, true); | 2191 A.Put(IS_UNSYNCED, true); |
2208 A.Put(IS_UNAPPLIED_UPDATE, true); | 2192 A.Put(IS_UNAPPLIED_UPDATE, true); |
2209 A.Put(SERVER_VERSION, 20); | 2193 A.Put(SERVER_VERSION, 20); |
2210 | 2194 |
2211 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 2195 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
(...skipping 19 matching lines...) Expand all Loading... |
2231 EXPECT_TRUE(B.Get(IS_UNSYNCED) == false); | 2215 EXPECT_TRUE(B.Get(IS_UNSYNCED) == false); |
2232 EXPECT_TRUE(B.Get(IS_UNAPPLIED_UPDATE) == false); | 2216 EXPECT_TRUE(B.Get(IS_UNAPPLIED_UPDATE) == false); |
2233 EXPECT_TRUE(B.Get(SERVER_VERSION) == 20); | 2217 EXPECT_TRUE(B.Get(SERVER_VERSION) == 20); |
2234 } | 2218 } |
2235 } | 2219 } |
2236 | 2220 |
2237 TEST_F(SyncerTest, ConflictMatchingEntryHandlesNormalNames) { | 2221 TEST_F(SyncerTest, ConflictMatchingEntryHandlesNormalNames) { |
2238 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 2222 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
2239 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); | 2223 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); |
2240 mock_server_->set_conflict_all_commits(true); | 2224 mock_server_->set_conflict_all_commits(true); |
2241 SyncShareNudge(); | 2225 SyncShareAsDelegate(); |
2242 { | 2226 { |
2243 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2227 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2244 | 2228 |
2245 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2229 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2246 ASSERT_TRUE(A.good()); | 2230 ASSERT_TRUE(A.good()); |
2247 A.Put(IS_UNSYNCED, true); | 2231 A.Put(IS_UNSYNCED, true); |
2248 A.Put(IS_UNAPPLIED_UPDATE, true); | 2232 A.Put(IS_UNAPPLIED_UPDATE, true); |
2249 A.Put(SERVER_VERSION, 20); | 2233 A.Put(SERVER_VERSION, 20); |
2250 | 2234 |
2251 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 2235 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 Id child_id = | 2319 Id child_id = |
2336 GetOnlyEntryWithName(&trans, parent_entry.Get(ID), "bob"); | 2320 GetOnlyEntryWithName(&trans, parent_entry.Get(ID), "bob"); |
2337 Entry child(&trans, syncable::GET_BY_ID, child_id); | 2321 Entry child(&trans, syncable::GET_BY_ID, child_id); |
2338 ASSERT_TRUE(child.good()); | 2322 ASSERT_TRUE(child.good()); |
2339 EXPECT_EQ(parent_entry.Get(ID), child.Get(PARENT_ID)); | 2323 EXPECT_EQ(parent_entry.Get(ID), child.Get(PARENT_ID)); |
2340 } | 2324 } |
2341 } | 2325 } |
2342 | 2326 |
2343 TEST_F(SyncerTest, NegativeIDInUpdate) { | 2327 TEST_F(SyncerTest, NegativeIDInUpdate) { |
2344 mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40); | 2328 mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40); |
2345 SyncShareNudge(); | 2329 SyncShareAsDelegate(); |
2346 // The negative id would make us CHECK! | 2330 // The negative id would make us CHECK! |
2347 } | 2331 } |
2348 | 2332 |
2349 TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { | 2333 TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { |
2350 int64 metahandle_fred; | 2334 int64 metahandle_fred; |
2351 { | 2335 { |
2352 // Create an item. | 2336 // Create an item. |
2353 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2337 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2354 MutableEntry fred_match(&trans, CREATE, trans.root_id(), | 2338 MutableEntry fred_match(&trans, CREATE, trans.root_id(), |
2355 "fred_match"); | 2339 "fred_match"); |
2356 ASSERT_TRUE(fred_match.good()); | 2340 ASSERT_TRUE(fred_match.good()); |
2357 metahandle_fred = fred_match.Get(META_HANDLE); | 2341 metahandle_fred = fred_match.Get(META_HANDLE); |
2358 WriteTestDataToEntry(&trans, &fred_match); | 2342 WriteTestDataToEntry(&trans, &fred_match); |
2359 } | 2343 } |
2360 // Commit it. | 2344 // Commit it. |
2361 SyncShareNudge(); | 2345 SyncShareAsDelegate(); |
2362 EXPECT_EQ(1u, mock_server_->committed_ids().size()); | 2346 EXPECT_EQ(1u, mock_server_->committed_ids().size()); |
2363 mock_server_->set_conflict_all_commits(true); | 2347 mock_server_->set_conflict_all_commits(true); |
2364 syncable::Id fred_match_id; | 2348 syncable::Id fred_match_id; |
2365 { | 2349 { |
2366 // Now receive a change from outside. | 2350 // Now receive a change from outside. |
2367 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2351 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2368 MutableEntry fred_match(&trans, GET_BY_HANDLE, metahandle_fred); | 2352 MutableEntry fred_match(&trans, GET_BY_HANDLE, metahandle_fred); |
2369 ASSERT_TRUE(fred_match.good()); | 2353 ASSERT_TRUE(fred_match.good()); |
2370 EXPECT_TRUE(fred_match.Get(ID).ServerKnows()); | 2354 EXPECT_TRUE(fred_match.Get(ID).ServerKnows()); |
2371 fred_match_id = fred_match.Get(ID); | 2355 fred_match_id = fred_match.Get(ID); |
2372 mock_server_->AddUpdateBookmark(fred_match_id, trans.root_id(), | 2356 mock_server_->AddUpdateBookmark(fred_match_id, trans.root_id(), |
2373 "fred_match", 40, 40); | 2357 "fred_match", 40, 40); |
2374 } | 2358 } |
2375 // Run the syncer. | 2359 // Run the syncer. |
2376 for (int i = 0 ; i < 30 ; ++i) { | 2360 for (int i = 0 ; i < 30 ; ++i) { |
2377 SyncShareNudge(); | 2361 SyncShareAsDelegate(); |
2378 } | 2362 } |
2379 } | 2363 } |
2380 | 2364 |
2381 /** | 2365 /** |
2382 * In the event that we have a double changed entry, that is changed on both | 2366 * In the event that we have a double changed entry, that is changed on both |
2383 * the client and the server, the conflict resolver should just drop one of | 2367 * the client and the server, the conflict resolver should just drop one of |
2384 * them and accept the other. | 2368 * them and accept the other. |
2385 */ | 2369 */ |
2386 | 2370 |
2387 TEST_F(SyncerTest, DoublyChangedWithResolver) { | 2371 TEST_F(SyncerTest, DoublyChangedWithResolver) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2430 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2414 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2431 MutableEntry entry(&wtrans, syncable::CREATE, root_id_, "Pete"); | 2415 MutableEntry entry(&wtrans, syncable::CREATE, root_id_, "Pete"); |
2432 ASSERT_TRUE(entry.good()); | 2416 ASSERT_TRUE(entry.good()); |
2433 EXPECT_FALSE(entry.Get(ID).ServerKnows()); | 2417 EXPECT_FALSE(entry.Get(ID).ServerKnows()); |
2434 entry.Put(syncable::IS_DIR, true); | 2418 entry.Put(syncable::IS_DIR, true); |
2435 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 2419 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
2436 entry.Put(syncable::IS_UNSYNCED, true); | 2420 entry.Put(syncable::IS_UNSYNCED, true); |
2437 entry.Put(syncable::MTIME, test_time); | 2421 entry.Put(syncable::MTIME, test_time); |
2438 entry_metahandle = entry.Get(META_HANDLE); | 2422 entry_metahandle = entry.Get(META_HANDLE); |
2439 } | 2423 } |
2440 SyncShareNudge(); | 2424 SyncShareAsDelegate(); |
2441 syncable::Id id; | 2425 syncable::Id id; |
2442 int64 version; | 2426 int64 version; |
2443 int64 server_position_in_parent; | 2427 int64 server_position_in_parent; |
2444 { | 2428 { |
2445 ReadTransaction trans(FROM_HERE, directory()); | 2429 ReadTransaction trans(FROM_HERE, directory()); |
2446 Entry entry(&trans, syncable::GET_BY_HANDLE, entry_metahandle); | 2430 Entry entry(&trans, syncable::GET_BY_HANDLE, entry_metahandle); |
2447 ASSERT_TRUE(entry.good()); | 2431 ASSERT_TRUE(entry.good()); |
2448 id = entry.Get(ID); | 2432 id = entry.Get(ID); |
2449 EXPECT_TRUE(id.ServerKnows()); | 2433 EXPECT_TRUE(id.ServerKnows()); |
2450 version = entry.Get(BASE_VERSION); | 2434 version = entry.Get(BASE_VERSION); |
2451 server_position_in_parent = entry.Get(SERVER_POSITION_IN_PARENT); | 2435 server_position_in_parent = entry.Get(SERVER_POSITION_IN_PARENT); |
2452 } | 2436 } |
2453 sync_pb::SyncEntity* update = mock_server_->AddUpdateFromLastCommit(); | 2437 sync_pb::SyncEntity* update = mock_server_->AddUpdateFromLastCommit(); |
2454 EXPECT_EQ("Pete", update->name()); | 2438 EXPECT_EQ("Pete", update->name()); |
2455 EXPECT_EQ(id.GetServerId(), update->id_string()); | 2439 EXPECT_EQ(id.GetServerId(), update->id_string()); |
2456 EXPECT_EQ(root_id_.GetServerId(), update->parent_id_string()); | 2440 EXPECT_EQ(root_id_.GetServerId(), update->parent_id_string()); |
2457 EXPECT_EQ(version, update->version()); | 2441 EXPECT_EQ(version, update->version()); |
2458 EXPECT_EQ(server_position_in_parent, update->position_in_parent()); | 2442 EXPECT_EQ(server_position_in_parent, update->position_in_parent()); |
2459 SyncShareNudge(); | 2443 SyncShareAsDelegate(); |
2460 { | 2444 { |
2461 ReadTransaction trans(FROM_HERE, directory()); | 2445 ReadTransaction trans(FROM_HERE, directory()); |
2462 Entry entry(&trans, syncable::GET_BY_ID, id); | 2446 Entry entry(&trans, syncable::GET_BY_ID, id); |
2463 ASSERT_TRUE(entry.good()); | 2447 ASSERT_TRUE(entry.good()); |
2464 EXPECT_TRUE(entry.Get(MTIME) == test_time); | 2448 EXPECT_TRUE(entry.Get(MTIME) == test_time); |
2465 } | 2449 } |
2466 } | 2450 } |
2467 | 2451 |
2468 TEST_F(SyncerTest, ParentAndChildBothMatch) { | 2452 TEST_F(SyncerTest, ParentAndChildBothMatch) { |
2469 const syncable::FullModelTypeSet all_types = | 2453 const syncable::FullModelTypeSet all_types = |
(...skipping 14 matching lines...) Expand all Loading... |
2484 MutableEntry child(&wtrans, CREATE, parent.Get(ID), "test.htm"); | 2468 MutableEntry child(&wtrans, CREATE, parent.Get(ID), "test.htm"); |
2485 ASSERT_TRUE(child.good()); | 2469 ASSERT_TRUE(child.good()); |
2486 child.Put(ID, child_id); | 2470 child.Put(ID, child_id); |
2487 child.Put(BASE_VERSION, 1); | 2471 child.Put(BASE_VERSION, 1); |
2488 child.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2472 child.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2489 WriteTestDataToEntry(&wtrans, &child); | 2473 WriteTestDataToEntry(&wtrans, &child); |
2490 } | 2474 } |
2491 mock_server_->AddUpdateDirectory(parent_id, root_id_, "Folder", 10, 10); | 2475 mock_server_->AddUpdateDirectory(parent_id, root_id_, "Folder", 10, 10); |
2492 mock_server_->AddUpdateBookmark(child_id, parent_id, "test.htm", 10, 10); | 2476 mock_server_->AddUpdateBookmark(child_id, parent_id, "test.htm", 10, 10); |
2493 mock_server_->set_conflict_all_commits(true); | 2477 mock_server_->set_conflict_all_commits(true); |
2494 SyncShareNudge(); | 2478 SyncShareAsDelegate(); |
2495 SyncShareNudge(); | 2479 SyncShareAsDelegate(); |
2496 SyncShareNudge(); | 2480 SyncShareAsDelegate(); |
2497 { | 2481 { |
2498 ReadTransaction trans(FROM_HERE, directory()); | 2482 ReadTransaction trans(FROM_HERE, directory()); |
2499 Directory::ChildHandles children; | 2483 Directory::ChildHandles children; |
2500 directory()->GetChildHandlesById(&trans, root_id_, &children); | 2484 directory()->GetChildHandlesById(&trans, root_id_, &children); |
2501 EXPECT_EQ(1u, children.size()); | 2485 EXPECT_EQ(1u, children.size()); |
2502 directory()->GetChildHandlesById(&trans, parent_id, &children); | 2486 directory()->GetChildHandlesById(&trans, parent_id, &children); |
2503 EXPECT_EQ(1u, children.size()); | 2487 EXPECT_EQ(1u, children.size()); |
2504 std::vector<int64> unapplied; | 2488 std::vector<int64> unapplied; |
2505 directory()->GetUnappliedUpdateMetaHandles(&trans, all_types, &unapplied); | 2489 directory()->GetUnappliedUpdateMetaHandles(&trans, all_types, &unapplied); |
2506 EXPECT_EQ(0u, unapplied.size()); | 2490 EXPECT_EQ(0u, unapplied.size()); |
2507 syncable::Directory::UnsyncedMetaHandles unsynced; | 2491 syncable::Directory::UnsyncedMetaHandles unsynced; |
2508 directory()->GetUnsyncedMetaHandles(&trans, &unsynced); | 2492 directory()->GetUnsyncedMetaHandles(&trans, &unsynced); |
2509 EXPECT_EQ(0u, unsynced.size()); | 2493 EXPECT_EQ(0u, unsynced.size()); |
2510 saw_syncer_event_ = false; | 2494 saw_syncer_event_ = false; |
2511 } | 2495 } |
2512 } | 2496 } |
2513 | 2497 |
2514 TEST_F(SyncerTest, CommittingNewDeleted) { | 2498 TEST_F(SyncerTest, CommittingNewDeleted) { |
2515 { | 2499 { |
2516 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2500 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2517 MutableEntry entry(&trans, CREATE, trans.root_id(), "bob"); | 2501 MutableEntry entry(&trans, CREATE, trans.root_id(), "bob"); |
2518 entry.Put(IS_UNSYNCED, true); | 2502 entry.Put(IS_UNSYNCED, true); |
2519 entry.Put(IS_DEL, true); | 2503 entry.Put(IS_DEL, true); |
2520 } | 2504 } |
2521 SyncShareNudge(); | 2505 SyncShareAsDelegate(); |
2522 EXPECT_EQ(0u, mock_server_->committed_ids().size()); | 2506 EXPECT_EQ(0u, mock_server_->committed_ids().size()); |
2523 } | 2507 } |
2524 | 2508 |
2525 // Original problem synopsis: | 2509 // Original problem synopsis: |
2526 // Check failed: entry->Get(BASE_VERSION) <= entry->Get(SERVER_VERSION) | 2510 // Check failed: entry->Get(BASE_VERSION) <= entry->Get(SERVER_VERSION) |
2527 // Client creates entry, client finishes committing entry. Between | 2511 // Client creates entry, client finishes committing entry. Between |
2528 // commit and getting update back, we delete the entry. | 2512 // commit and getting update back, we delete the entry. |
2529 // We get the update for the entry, but the local one was modified | 2513 // We get the update for the entry, but the local one was modified |
2530 // so we store the entry but don't apply it. IS_UNAPPLIED_UPDATE is set. | 2514 // so we store the entry but don't apply it. IS_UNAPPLIED_UPDATE is set. |
2531 // We commit deletion and get a new version number. | 2515 // We commit deletion and get a new version number. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2594 } | 2578 } |
2595 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 2579 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
2596 const StatusController& status(session_->status_controller()); | 2580 const StatusController& status(session_->status_controller()); |
2597 EXPECT_EQ(0, status.TotalNumServerConflictingItems()); | 2581 EXPECT_EQ(0, status.TotalNumServerConflictingItems()); |
2598 } | 2582 } |
2599 | 2583 |
2600 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { | 2584 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { |
2601 int64 newfolder_metahandle; | 2585 int64 newfolder_metahandle; |
2602 | 2586 |
2603 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 2587 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
2604 SyncShareNudge(); | 2588 SyncShareAsDelegate(); |
2605 { | 2589 { |
2606 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2590 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2607 MutableEntry newfolder(&trans, CREATE, ids_.FromNumber(1), "local"); | 2591 MutableEntry newfolder(&trans, CREATE, ids_.FromNumber(1), "local"); |
2608 ASSERT_TRUE(newfolder.good()); | 2592 ASSERT_TRUE(newfolder.good()); |
2609 newfolder.Put(IS_UNSYNCED, true); | 2593 newfolder.Put(IS_UNSYNCED, true); |
2610 newfolder.Put(IS_DIR, true); | 2594 newfolder.Put(IS_DIR, true); |
2611 newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2595 newfolder.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2612 newfolder_metahandle = newfolder.Get(META_HANDLE); | 2596 newfolder_metahandle = newfolder.Get(META_HANDLE); |
2613 } | 2597 } |
2614 mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20); | 2598 mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20); |
2615 mock_server_->SetLastUpdateDeleted(); | 2599 mock_server_->SetLastUpdateDeleted(); |
2616 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, APPLY_UPDATES); | 2600 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, APPLY_UPDATES); |
2617 { | 2601 { |
2618 ReadTransaction trans(FROM_HERE, directory()); | 2602 ReadTransaction trans(FROM_HERE, directory()); |
2619 Entry entry(&trans, syncable::GET_BY_HANDLE, newfolder_metahandle); | 2603 Entry entry(&trans, syncable::GET_BY_HANDLE, newfolder_metahandle); |
2620 ASSERT_TRUE(entry.good()); | 2604 ASSERT_TRUE(entry.good()); |
2621 } | 2605 } |
2622 } | 2606 } |
2623 | 2607 |
2624 TEST_F(SyncerTest, FolderSwapUpdate) { | 2608 TEST_F(SyncerTest, FolderSwapUpdate) { |
2625 mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10); | 2609 mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10); |
2626 mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10); | 2610 mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10); |
2627 SyncShareNudge(); | 2611 SyncShareAsDelegate(); |
2628 mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20); | 2612 mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20); |
2629 mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20); | 2613 mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20); |
2630 SyncShareNudge(); | 2614 SyncShareAsDelegate(); |
2631 { | 2615 { |
2632 ReadTransaction trans(FROM_HERE, directory()); | 2616 ReadTransaction trans(FROM_HERE, directory()); |
2633 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); | 2617 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); |
2634 ASSERT_TRUE(id1.good()); | 2618 ASSERT_TRUE(id1.good()); |
2635 EXPECT_TRUE("fred" == id1.Get(NON_UNIQUE_NAME)); | 2619 EXPECT_TRUE("fred" == id1.Get(NON_UNIQUE_NAME)); |
2636 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); | 2620 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); |
2637 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); | 2621 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); |
2638 ASSERT_TRUE(id2.good()); | 2622 ASSERT_TRUE(id2.good()); |
2639 EXPECT_TRUE("bob" == id2.Get(NON_UNIQUE_NAME)); | 2623 EXPECT_TRUE("bob" == id2.Get(NON_UNIQUE_NAME)); |
2640 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); | 2624 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); |
2641 } | 2625 } |
2642 saw_syncer_event_ = false; | 2626 saw_syncer_event_ = false; |
2643 } | 2627 } |
2644 | 2628 |
2645 TEST_F(SyncerTest, NameCollidingFolderSwapWorksFine) { | 2629 TEST_F(SyncerTest, NameCollidingFolderSwapWorksFine) { |
2646 mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10); | 2630 mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10); |
2647 mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10); | 2631 mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10); |
2648 mock_server_->AddUpdateDirectory(4096, 0, "alice", 1, 10); | 2632 mock_server_->AddUpdateDirectory(4096, 0, "alice", 1, 10); |
2649 SyncShareNudge(); | 2633 SyncShareAsDelegate(); |
2650 { | 2634 { |
2651 ReadTransaction trans(FROM_HERE, directory()); | 2635 ReadTransaction trans(FROM_HERE, directory()); |
2652 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); | 2636 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); |
2653 ASSERT_TRUE(id1.good()); | 2637 ASSERT_TRUE(id1.good()); |
2654 EXPECT_TRUE("bob" == id1.Get(NON_UNIQUE_NAME)); | 2638 EXPECT_TRUE("bob" == id1.Get(NON_UNIQUE_NAME)); |
2655 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); | 2639 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); |
2656 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); | 2640 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); |
2657 ASSERT_TRUE(id2.good()); | 2641 ASSERT_TRUE(id2.good()); |
2658 EXPECT_TRUE("fred" == id2.Get(NON_UNIQUE_NAME)); | 2642 EXPECT_TRUE("fred" == id2.Get(NON_UNIQUE_NAME)); |
2659 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); | 2643 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); |
2660 Entry id3(&trans, GET_BY_ID, ids_.FromNumber(4096)); | 2644 Entry id3(&trans, GET_BY_ID, ids_.FromNumber(4096)); |
2661 ASSERT_TRUE(id3.good()); | 2645 ASSERT_TRUE(id3.good()); |
2662 EXPECT_TRUE("alice" == id3.Get(NON_UNIQUE_NAME)); | 2646 EXPECT_TRUE("alice" == id3.Get(NON_UNIQUE_NAME)); |
2663 EXPECT_TRUE(root_id_ == id3.Get(PARENT_ID)); | 2647 EXPECT_TRUE(root_id_ == id3.Get(PARENT_ID)); |
2664 } | 2648 } |
2665 mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20); | 2649 mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20); |
2666 mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20); | 2650 mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20); |
2667 mock_server_->AddUpdateDirectory(4096, 0, "bob", 2, 20); | 2651 mock_server_->AddUpdateDirectory(4096, 0, "bob", 2, 20); |
2668 SyncShareNudge(); | 2652 SyncShareAsDelegate(); |
2669 { | 2653 { |
2670 ReadTransaction trans(FROM_HERE, directory()); | 2654 ReadTransaction trans(FROM_HERE, directory()); |
2671 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); | 2655 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); |
2672 ASSERT_TRUE(id1.good()); | 2656 ASSERT_TRUE(id1.good()); |
2673 EXPECT_TRUE("fred" == id1.Get(NON_UNIQUE_NAME)); | 2657 EXPECT_TRUE("fred" == id1.Get(NON_UNIQUE_NAME)); |
2674 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); | 2658 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); |
2675 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); | 2659 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); |
2676 ASSERT_TRUE(id2.good()); | 2660 ASSERT_TRUE(id2.good()); |
2677 EXPECT_TRUE("bob" == id2.Get(NON_UNIQUE_NAME)); | 2661 EXPECT_TRUE("bob" == id2.Get(NON_UNIQUE_NAME)); |
2678 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); | 2662 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); |
(...skipping 13 matching lines...) Expand all Loading... |
2692 for (uint32 i = 0; i < items_to_commit; i++) { | 2676 for (uint32 i = 0; i < items_to_commit; i++) { |
2693 string nameutf8 = base::StringPrintf("%d", i); | 2677 string nameutf8 = base::StringPrintf("%d", i); |
2694 string name(nameutf8.begin(), nameutf8.end()); | 2678 string name(nameutf8.begin(), nameutf8.end()); |
2695 MutableEntry e(&trans, CREATE, trans.root_id(), name); | 2679 MutableEntry e(&trans, CREATE, trans.root_id(), name); |
2696 e.Put(IS_UNSYNCED, true); | 2680 e.Put(IS_UNSYNCED, true); |
2697 e.Put(IS_DIR, true); | 2681 e.Put(IS_DIR, true); |
2698 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2682 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2699 } | 2683 } |
2700 } | 2684 } |
2701 uint32 num_loops = 0; | 2685 uint32 num_loops = 0; |
2702 while (SyncShareNudge()) { | 2686 while (SyncShareAsDelegate()) { |
2703 num_loops++; | 2687 num_loops++; |
2704 ASSERT_LT(num_loops, max_batches * 2); | 2688 ASSERT_LT(num_loops, max_batches * 2); |
2705 } | 2689 } |
2706 EXPECT_GE(mock_server_->commit_messages().size(), max_batches); | 2690 EXPECT_GE(mock_server_->commit_messages().size(), max_batches); |
2707 } | 2691 } |
2708 | 2692 |
2709 TEST_F(SyncerTest, HugeConflict) { | 2693 TEST_F(SyncerTest, HugeConflict) { |
2710 int item_count = 300; // We should be able to do 300 or 3000 w/o issue. | 2694 int item_count = 300; // We should be able to do 300 or 3000 w/o issue. |
2711 | 2695 |
2712 syncable::Id parent_id = ids_.NewServerId(); | 2696 syncable::Id parent_id = ids_.NewServerId(); |
2713 syncable::Id last_id = parent_id; | 2697 syncable::Id last_id = parent_id; |
2714 vector<syncable::Id> tree_ids; | 2698 vector<syncable::Id> tree_ids; |
2715 | 2699 |
2716 // Create a lot of updates for which the parent does not exist yet. | 2700 // Create a lot of updates for which the parent does not exist yet. |
2717 // Generate a huge deep tree which should all fail to apply at first. | 2701 // Generate a huge deep tree which should all fail to apply at first. |
2718 { | 2702 { |
2719 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2703 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2720 for (int i = 0; i < item_count ; i++) { | 2704 for (int i = 0; i < item_count ; i++) { |
2721 syncable::Id next_id = ids_.NewServerId(); | 2705 syncable::Id next_id = ids_.NewServerId(); |
2722 tree_ids.push_back(next_id); | 2706 tree_ids.push_back(next_id); |
2723 mock_server_->AddUpdateDirectory(next_id, last_id, "BOB", 2, 20); | 2707 mock_server_->AddUpdateDirectory(next_id, last_id, "BOB", 2, 20); |
2724 last_id = next_id; | 2708 last_id = next_id; |
2725 } | 2709 } |
2726 } | 2710 } |
2727 SyncShareNudge(); | 2711 SyncShareAsDelegate(); |
2728 | 2712 |
2729 // Check they're in the expected conflict state. | 2713 // Check they're in the expected conflict state. |
2730 { | 2714 { |
2731 ReadTransaction trans(FROM_HERE, directory()); | 2715 ReadTransaction trans(FROM_HERE, directory()); |
2732 for (int i = 0; i < item_count; i++) { | 2716 for (int i = 0; i < item_count; i++) { |
2733 Entry e(&trans, GET_BY_ID, tree_ids[i]); | 2717 Entry e(&trans, GET_BY_ID, tree_ids[i]); |
2734 // They should all exist but none should be applied. | 2718 // They should all exist but none should be applied. |
2735 ASSERT_TRUE(e.good()); | 2719 ASSERT_TRUE(e.good()); |
2736 EXPECT_TRUE(e.Get(IS_DEL)); | 2720 EXPECT_TRUE(e.Get(IS_DEL)); |
2737 EXPECT_TRUE(e.Get(IS_UNAPPLIED_UPDATE)); | 2721 EXPECT_TRUE(e.Get(IS_UNAPPLIED_UPDATE)); |
2738 } | 2722 } |
2739 } | 2723 } |
2740 | 2724 |
2741 // Add the missing parent directory. | 2725 // Add the missing parent directory. |
2742 mock_server_->AddUpdateDirectory(parent_id, TestIdFactory::root(), | 2726 mock_server_->AddUpdateDirectory(parent_id, TestIdFactory::root(), |
2743 "BOB", 2, 20); | 2727 "BOB", 2, 20); |
2744 SyncShareNudge(); | 2728 SyncShareAsDelegate(); |
2745 | 2729 |
2746 // Now they should all be OK. | 2730 // Now they should all be OK. |
2747 { | 2731 { |
2748 ReadTransaction trans(FROM_HERE, directory()); | 2732 ReadTransaction trans(FROM_HERE, directory()); |
2749 for (int i = 0; i < item_count; i++) { | 2733 for (int i = 0; i < item_count; i++) { |
2750 Entry e(&trans, GET_BY_ID, tree_ids[i]); | 2734 Entry e(&trans, GET_BY_ID, tree_ids[i]); |
2751 ASSERT_TRUE(e.good()); | 2735 ASSERT_TRUE(e.good()); |
2752 EXPECT_FALSE(e.Get(IS_DEL)); | 2736 EXPECT_FALSE(e.Get(IS_DEL)); |
2753 EXPECT_FALSE(e.Get(IS_UNAPPLIED_UPDATE)); | 2737 EXPECT_FALSE(e.Get(IS_UNAPPLIED_UPDATE)); |
2754 } | 2738 } |
2755 } | 2739 } |
2756 } | 2740 } |
2757 | 2741 |
2758 TEST_F(SyncerTest, DontCrashOnCaseChange) { | 2742 TEST_F(SyncerTest, DontCrashOnCaseChange) { |
2759 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 2743 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
2760 SyncShareNudge(); | 2744 SyncShareAsDelegate(); |
2761 { | 2745 { |
2762 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2746 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2763 MutableEntry e(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2747 MutableEntry e(&trans, GET_BY_ID, ids_.FromNumber(1)); |
2764 ASSERT_TRUE(e.good()); | 2748 ASSERT_TRUE(e.good()); |
2765 e.Put(IS_UNSYNCED, true); | 2749 e.Put(IS_UNSYNCED, true); |
2766 } | 2750 } |
2767 mock_server_->set_conflict_all_commits(true); | 2751 mock_server_->set_conflict_all_commits(true); |
2768 mock_server_->AddUpdateDirectory(1, 0, "BOB", 2, 20); | 2752 mock_server_->AddUpdateDirectory(1, 0, "BOB", 2, 20); |
2769 SyncShareNudge(); // USED TO CAUSE AN ASSERT | 2753 SyncShareAsDelegate(); // USED TO CAUSE AN ASSERT |
2770 saw_syncer_event_ = false; | 2754 saw_syncer_event_ = false; |
2771 } | 2755 } |
2772 | 2756 |
2773 TEST_F(SyncerTest, UnsyncedItemAndUpdate) { | 2757 TEST_F(SyncerTest, UnsyncedItemAndUpdate) { |
2774 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 2758 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
2775 SyncShareNudge(); | 2759 SyncShareAsDelegate(); |
2776 mock_server_->set_conflict_all_commits(true); | 2760 mock_server_->set_conflict_all_commits(true); |
2777 mock_server_->AddUpdateDirectory(2, 0, "bob", 2, 20); | 2761 mock_server_->AddUpdateDirectory(2, 0, "bob", 2, 20); |
2778 SyncShareNudge(); // USED TO CAUSE AN ASSERT | 2762 SyncShareAsDelegate(); // USED TO CAUSE AN ASSERT |
2779 saw_syncer_event_ = false; | 2763 saw_syncer_event_ = false; |
2780 } | 2764 } |
2781 | 2765 |
2782 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) { | 2766 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) { |
2783 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10); | 2767 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10); |
2784 SyncShareNudge(); | 2768 SyncShareAsDelegate(); |
2785 int64 local_folder_handle; | 2769 int64 local_folder_handle; |
2786 syncable::Id local_folder_id; | 2770 syncable::Id local_folder_id; |
2787 { | 2771 { |
2788 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2772 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2789 MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), "Bar.htm"); | 2773 MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), "Bar.htm"); |
2790 ASSERT_TRUE(new_entry.good()); | 2774 ASSERT_TRUE(new_entry.good()); |
2791 local_folder_id = new_entry.Get(ID); | 2775 local_folder_id = new_entry.Get(ID); |
2792 local_folder_handle = new_entry.Get(META_HANDLE); | 2776 local_folder_handle = new_entry.Get(META_HANDLE); |
2793 new_entry.Put(IS_UNSYNCED, true); | 2777 new_entry.Put(IS_UNSYNCED, true); |
2794 new_entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2778 new_entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2795 MutableEntry old(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2779 MutableEntry old(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2796 ASSERT_TRUE(old.good()); | 2780 ASSERT_TRUE(old.good()); |
2797 WriteTestDataToEntry(&wtrans, &old); | 2781 WriteTestDataToEntry(&wtrans, &old); |
2798 } | 2782 } |
2799 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20); | 2783 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20); |
2800 mock_server_->set_conflict_all_commits(true); | 2784 mock_server_->set_conflict_all_commits(true); |
2801 SyncShareNudge(); | 2785 SyncShareAsDelegate(); |
2802 saw_syncer_event_ = false; | 2786 saw_syncer_event_ = false; |
2803 { | 2787 { |
2804 // Update #20 should have been dropped in favor of the local version. | 2788 // Update #20 should have been dropped in favor of the local version. |
2805 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2789 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2806 MutableEntry server(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2790 MutableEntry server(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2807 MutableEntry local(&wtrans, GET_BY_HANDLE, local_folder_handle); | 2791 MutableEntry local(&wtrans, GET_BY_HANDLE, local_folder_handle); |
2808 ASSERT_TRUE(server.good()); | 2792 ASSERT_TRUE(server.good()); |
2809 ASSERT_TRUE(local.good()); | 2793 ASSERT_TRUE(local.good()); |
2810 EXPECT_TRUE(local.Get(META_HANDLE) != server.Get(META_HANDLE)); | 2794 EXPECT_TRUE(local.Get(META_HANDLE) != server.Get(META_HANDLE)); |
2811 EXPECT_FALSE(server.Get(IS_UNAPPLIED_UPDATE)); | 2795 EXPECT_FALSE(server.Get(IS_UNAPPLIED_UPDATE)); |
2812 EXPECT_FALSE(local.Get(IS_UNAPPLIED_UPDATE)); | 2796 EXPECT_FALSE(local.Get(IS_UNAPPLIED_UPDATE)); |
2813 EXPECT_TRUE(server.Get(IS_UNSYNCED)); | 2797 EXPECT_TRUE(server.Get(IS_UNSYNCED)); |
2814 EXPECT_TRUE(local.Get(IS_UNSYNCED)); | 2798 EXPECT_TRUE(local.Get(IS_UNSYNCED)); |
2815 EXPECT_EQ("Foo.htm", server.Get(NON_UNIQUE_NAME)); | 2799 EXPECT_EQ("Foo.htm", server.Get(NON_UNIQUE_NAME)); |
2816 EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME)); | 2800 EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME)); |
2817 } | 2801 } |
2818 // Allow local changes to commit. | 2802 // Allow local changes to commit. |
2819 mock_server_->set_conflict_all_commits(false); | 2803 mock_server_->set_conflict_all_commits(false); |
2820 SyncShareNudge(); | 2804 SyncShareAsDelegate(); |
2821 saw_syncer_event_ = false; | 2805 saw_syncer_event_ = false; |
2822 | 2806 |
2823 // Now add a server change to make the two names equal. There should | 2807 // Now add a server change to make the two names equal. There should |
2824 // be no conflict with that, since names are not unique. | 2808 // be no conflict with that, since names are not unique. |
2825 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 30, 30); | 2809 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 30, 30); |
2826 SyncShareNudge(); | 2810 SyncShareAsDelegate(); |
2827 saw_syncer_event_ = false; | 2811 saw_syncer_event_ = false; |
2828 { | 2812 { |
2829 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2813 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2830 MutableEntry server(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2814 MutableEntry server(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2831 MutableEntry local(&wtrans, GET_BY_HANDLE, local_folder_handle); | 2815 MutableEntry local(&wtrans, GET_BY_HANDLE, local_folder_handle); |
2832 ASSERT_TRUE(server.good()); | 2816 ASSERT_TRUE(server.good()); |
2833 ASSERT_TRUE(local.good()); | 2817 ASSERT_TRUE(local.good()); |
2834 EXPECT_TRUE(local.Get(META_HANDLE) != server.Get(META_HANDLE)); | 2818 EXPECT_TRUE(local.Get(META_HANDLE) != server.Get(META_HANDLE)); |
2835 EXPECT_FALSE(server.Get(IS_UNAPPLIED_UPDATE)); | 2819 EXPECT_FALSE(server.Get(IS_UNAPPLIED_UPDATE)); |
2836 EXPECT_FALSE(local.Get(IS_UNAPPLIED_UPDATE)); | 2820 EXPECT_FALSE(local.Get(IS_UNAPPLIED_UPDATE)); |
2837 EXPECT_FALSE(server.Get(IS_UNSYNCED)); | 2821 EXPECT_FALSE(server.Get(IS_UNSYNCED)); |
2838 EXPECT_FALSE(local.Get(IS_UNSYNCED)); | 2822 EXPECT_FALSE(local.Get(IS_UNSYNCED)); |
2839 EXPECT_EQ("Bar.htm", server.Get(NON_UNIQUE_NAME)); | 2823 EXPECT_EQ("Bar.htm", server.Get(NON_UNIQUE_NAME)); |
2840 EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME)); | 2824 EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME)); |
2841 EXPECT_EQ("http://google.com", // Default from AddUpdateBookmark. | 2825 EXPECT_EQ("http://google.com", // Default from AddUpdateBookmark. |
2842 server.Get(SPECIFICS).bookmark().url()); | 2826 server.Get(SPECIFICS).bookmark().url()); |
2843 } | 2827 } |
2844 } | 2828 } |
2845 | 2829 |
2846 // Same as NewEntryAnddServerEntrySharePath, but using the old-style protocol. | 2830 // Same as NewEntryAnddServerEntrySharePath, but using the old-style protocol. |
2847 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) { | 2831 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) { |
2848 mock_server_->set_use_legacy_bookmarks_protocol(true); | 2832 mock_server_->set_use_legacy_bookmarks_protocol(true); |
2849 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10); | 2833 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10); |
2850 SyncShareNudge(); | 2834 SyncShareAsDelegate(); |
2851 int64 local_folder_handle; | 2835 int64 local_folder_handle; |
2852 syncable::Id local_folder_id; | 2836 syncable::Id local_folder_id; |
2853 { | 2837 { |
2854 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2838 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2855 MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), "Bar.htm"); | 2839 MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), "Bar.htm"); |
2856 ASSERT_TRUE(new_entry.good()); | 2840 ASSERT_TRUE(new_entry.good()); |
2857 local_folder_id = new_entry.Get(ID); | 2841 local_folder_id = new_entry.Get(ID); |
2858 local_folder_handle = new_entry.Get(META_HANDLE); | 2842 local_folder_handle = new_entry.Get(META_HANDLE); |
2859 new_entry.Put(IS_UNSYNCED, true); | 2843 new_entry.Put(IS_UNSYNCED, true); |
2860 new_entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2844 new_entry.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2861 MutableEntry old(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2845 MutableEntry old(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2862 ASSERT_TRUE(old.good()); | 2846 ASSERT_TRUE(old.good()); |
2863 WriteTestDataToEntry(&wtrans, &old); | 2847 WriteTestDataToEntry(&wtrans, &old); |
2864 } | 2848 } |
2865 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20); | 2849 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20); |
2866 mock_server_->set_conflict_all_commits(true); | 2850 mock_server_->set_conflict_all_commits(true); |
2867 SyncShareNudge(); | 2851 SyncShareAsDelegate(); |
2868 saw_syncer_event_ = false; | 2852 saw_syncer_event_ = false; |
2869 { | 2853 { |
2870 // Update #20 should have been dropped in favor of the local version. | 2854 // Update #20 should have been dropped in favor of the local version. |
2871 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2855 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2872 MutableEntry server(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2856 MutableEntry server(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2873 MutableEntry local(&wtrans, GET_BY_HANDLE, local_folder_handle); | 2857 MutableEntry local(&wtrans, GET_BY_HANDLE, local_folder_handle); |
2874 ASSERT_TRUE(server.good()); | 2858 ASSERT_TRUE(server.good()); |
2875 ASSERT_TRUE(local.good()); | 2859 ASSERT_TRUE(local.good()); |
2876 EXPECT_TRUE(local.Get(META_HANDLE) != server.Get(META_HANDLE)); | 2860 EXPECT_TRUE(local.Get(META_HANDLE) != server.Get(META_HANDLE)); |
2877 EXPECT_FALSE(server.Get(IS_UNAPPLIED_UPDATE)); | 2861 EXPECT_FALSE(server.Get(IS_UNAPPLIED_UPDATE)); |
2878 EXPECT_FALSE(local.Get(IS_UNAPPLIED_UPDATE)); | 2862 EXPECT_FALSE(local.Get(IS_UNAPPLIED_UPDATE)); |
2879 EXPECT_TRUE(server.Get(IS_UNSYNCED)); | 2863 EXPECT_TRUE(server.Get(IS_UNSYNCED)); |
2880 EXPECT_TRUE(local.Get(IS_UNSYNCED)); | 2864 EXPECT_TRUE(local.Get(IS_UNSYNCED)); |
2881 EXPECT_EQ("Foo.htm", server.Get(NON_UNIQUE_NAME)); | 2865 EXPECT_EQ("Foo.htm", server.Get(NON_UNIQUE_NAME)); |
2882 EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME)); | 2866 EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME)); |
2883 } | 2867 } |
2884 // Allow local changes to commit. | 2868 // Allow local changes to commit. |
2885 mock_server_->set_conflict_all_commits(false); | 2869 mock_server_->set_conflict_all_commits(false); |
2886 SyncShareNudge(); | 2870 SyncShareAsDelegate(); |
2887 saw_syncer_event_ = false; | 2871 saw_syncer_event_ = false; |
2888 | 2872 |
2889 // Now add a server change to make the two names equal. There should | 2873 // Now add a server change to make the two names equal. There should |
2890 // be no conflict with that, since names are not unique. | 2874 // be no conflict with that, since names are not unique. |
2891 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 30, 30); | 2875 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 30, 30); |
2892 SyncShareNudge(); | 2876 SyncShareAsDelegate(); |
2893 saw_syncer_event_ = false; | 2877 saw_syncer_event_ = false; |
2894 { | 2878 { |
2895 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2879 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2896 MutableEntry server(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2880 MutableEntry server(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2897 MutableEntry local(&wtrans, GET_BY_HANDLE, local_folder_handle); | 2881 MutableEntry local(&wtrans, GET_BY_HANDLE, local_folder_handle); |
2898 ASSERT_TRUE(server.good()); | 2882 ASSERT_TRUE(server.good()); |
2899 ASSERT_TRUE(local.good()); | 2883 ASSERT_TRUE(local.good()); |
2900 EXPECT_TRUE(local.Get(META_HANDLE) != server.Get(META_HANDLE)); | 2884 EXPECT_TRUE(local.Get(META_HANDLE) != server.Get(META_HANDLE)); |
2901 EXPECT_FALSE(server.Get(IS_UNAPPLIED_UPDATE)); | 2885 EXPECT_FALSE(server.Get(IS_UNAPPLIED_UPDATE)); |
2902 EXPECT_FALSE(local.Get(IS_UNAPPLIED_UPDATE)); | 2886 EXPECT_FALSE(local.Get(IS_UNAPPLIED_UPDATE)); |
2903 EXPECT_FALSE(server.Get(IS_UNSYNCED)); | 2887 EXPECT_FALSE(server.Get(IS_UNSYNCED)); |
2904 EXPECT_FALSE(local.Get(IS_UNSYNCED)); | 2888 EXPECT_FALSE(local.Get(IS_UNSYNCED)); |
2905 EXPECT_EQ("Bar.htm", server.Get(NON_UNIQUE_NAME)); | 2889 EXPECT_EQ("Bar.htm", server.Get(NON_UNIQUE_NAME)); |
2906 EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME)); | 2890 EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME)); |
2907 EXPECT_EQ("http://google.com", // Default from AddUpdateBookmark. | 2891 EXPECT_EQ("http://google.com", // Default from AddUpdateBookmark. |
2908 server.Get(SPECIFICS).bookmark().url()); | 2892 server.Get(SPECIFICS).bookmark().url()); |
2909 } | 2893 } |
2910 } | 2894 } |
2911 | 2895 |
2912 // Circular links should be resolved by the server. | 2896 // Circular links should be resolved by the server. |
2913 TEST_F(SyncerTest, SiblingDirectoriesBecomeCircular) { | 2897 TEST_F(SyncerTest, SiblingDirectoriesBecomeCircular) { |
2914 // we don't currently resolve this. This test ensures we don't. | 2898 // we don't currently resolve this. This test ensures we don't. |
2915 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 2899 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
2916 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); | 2900 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); |
2917 SyncShareNudge(); | 2901 SyncShareAsDelegate(); |
2918 { | 2902 { |
2919 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2903 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2920 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2904 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2921 ASSERT_TRUE(A.good()); | 2905 ASSERT_TRUE(A.good()); |
2922 A.Put(IS_UNSYNCED, true); | 2906 A.Put(IS_UNSYNCED, true); |
2923 ASSERT_TRUE(A.Put(PARENT_ID, ids_.FromNumber(2))); | 2907 ASSERT_TRUE(A.Put(PARENT_ID, ids_.FromNumber(2))); |
2924 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, "B")); | 2908 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, "B")); |
2925 } | 2909 } |
2926 mock_server_->AddUpdateDirectory(2, 1, "A", 20, 20); | 2910 mock_server_->AddUpdateDirectory(2, 1, "A", 20, 20); |
2927 mock_server_->set_conflict_all_commits(true); | 2911 mock_server_->set_conflict_all_commits(true); |
2928 SyncShareNudge(); | 2912 SyncShareAsDelegate(); |
2929 saw_syncer_event_ = false; | 2913 saw_syncer_event_ = false; |
2930 { | 2914 { |
2931 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2915 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2932 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2916 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2933 ASSERT_TRUE(A.good()); | 2917 ASSERT_TRUE(A.good()); |
2934 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 2918 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
2935 ASSERT_TRUE(B.good()); | 2919 ASSERT_TRUE(B.good()); |
2936 EXPECT_TRUE(A.Get(NON_UNIQUE_NAME) == "B"); | 2920 EXPECT_TRUE(A.Get(NON_UNIQUE_NAME) == "B"); |
2937 EXPECT_TRUE(B.Get(NON_UNIQUE_NAME) == "B"); | 2921 EXPECT_TRUE(B.Get(NON_UNIQUE_NAME) == "B"); |
2938 } | 2922 } |
2939 } | 2923 } |
2940 | 2924 |
2941 TEST_F(SyncerTest, SwapEntryNames) { | 2925 TEST_F(SyncerTest, SwapEntryNames) { |
2942 // Simple transaction test. | 2926 // Simple transaction test. |
2943 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 2927 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
2944 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); | 2928 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); |
2945 mock_server_->set_conflict_all_commits(true); | 2929 mock_server_->set_conflict_all_commits(true); |
2946 SyncShareNudge(); | 2930 SyncShareAsDelegate(); |
2947 { | 2931 { |
2948 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2932 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2949 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2933 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
2950 ASSERT_TRUE(A.good()); | 2934 ASSERT_TRUE(A.good()); |
2951 A.Put(IS_UNSYNCED, true); | 2935 A.Put(IS_UNSYNCED, true); |
2952 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 2936 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
2953 ASSERT_TRUE(B.good()); | 2937 ASSERT_TRUE(B.good()); |
2954 B.Put(IS_UNSYNCED, true); | 2938 B.Put(IS_UNSYNCED, true); |
2955 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, "C")); | 2939 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, "C")); |
2956 ASSERT_TRUE(B.Put(NON_UNIQUE_NAME, "A")); | 2940 ASSERT_TRUE(B.Put(NON_UNIQUE_NAME, "A")); |
2957 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, "B")); | 2941 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, "B")); |
2958 } | 2942 } |
2959 SyncShareNudge(); | 2943 SyncShareAsDelegate(); |
2960 saw_syncer_event_ = false; | 2944 saw_syncer_event_ = false; |
2961 } | 2945 } |
2962 | 2946 |
2963 TEST_F(SyncerTest, DualDeletionWithNewItemNameClash) { | 2947 TEST_F(SyncerTest, DualDeletionWithNewItemNameClash) { |
2964 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 2948 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
2965 mock_server_->AddUpdateBookmark(2, 0, "B", 10, 10); | 2949 mock_server_->AddUpdateBookmark(2, 0, "B", 10, 10); |
2966 mock_server_->set_conflict_all_commits(true); | 2950 mock_server_->set_conflict_all_commits(true); |
2967 SyncShareNudge(); | 2951 SyncShareAsDelegate(); |
2968 { | 2952 { |
2969 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2953 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2970 MutableEntry B(&trans, GET_BY_ID, ids_.FromNumber(2)); | 2954 MutableEntry B(&trans, GET_BY_ID, ids_.FromNumber(2)); |
2971 ASSERT_TRUE(B.good()); | 2955 ASSERT_TRUE(B.good()); |
2972 WriteTestDataToEntry(&trans, &B); | 2956 WriteTestDataToEntry(&trans, &B); |
2973 B.Put(IS_DEL, true); | 2957 B.Put(IS_DEL, true); |
2974 } | 2958 } |
2975 mock_server_->AddUpdateBookmark(2, 0, "A", 11, 11); | 2959 mock_server_->AddUpdateBookmark(2, 0, "A", 11, 11); |
2976 mock_server_->SetLastUpdateDeleted(); | 2960 mock_server_->SetLastUpdateDeleted(); |
2977 SyncShareNudge(); | 2961 SyncShareAsDelegate(); |
2978 { | 2962 { |
2979 ReadTransaction trans(FROM_HERE, directory()); | 2963 ReadTransaction trans(FROM_HERE, directory()); |
2980 Entry B(&trans, GET_BY_ID, ids_.FromNumber(2)); | 2964 Entry B(&trans, GET_BY_ID, ids_.FromNumber(2)); |
2981 ASSERT_TRUE(B.good()); | 2965 ASSERT_TRUE(B.good()); |
2982 EXPECT_FALSE(B.Get(IS_UNSYNCED)); | 2966 EXPECT_FALSE(B.Get(IS_UNSYNCED)); |
2983 EXPECT_FALSE(B.Get(IS_UNAPPLIED_UPDATE)); | 2967 EXPECT_FALSE(B.Get(IS_UNAPPLIED_UPDATE)); |
2984 } | 2968 } |
2985 saw_syncer_event_ = false; | 2969 saw_syncer_event_ = false; |
2986 } | 2970 } |
2987 | 2971 |
2988 TEST_F(SyncerTest, ResolveWeWroteTheyDeleted) { | 2972 TEST_F(SyncerTest, ResolveWeWroteTheyDeleted) { |
2989 int64 bob_metahandle; | 2973 int64 bob_metahandle; |
2990 | 2974 |
2991 mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10); | 2975 mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10); |
2992 SyncShareNudge(); | 2976 SyncShareAsDelegate(); |
2993 { | 2977 { |
2994 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2978 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2995 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2979 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
2996 ASSERT_TRUE(bob.good()); | 2980 ASSERT_TRUE(bob.good()); |
2997 bob_metahandle = bob.Get(META_HANDLE); | 2981 bob_metahandle = bob.Get(META_HANDLE); |
2998 WriteTestDataToEntry(&trans, &bob); | 2982 WriteTestDataToEntry(&trans, &bob); |
2999 } | 2983 } |
3000 mock_server_->AddUpdateBookmark(1, 0, "bob", 2, 10); | 2984 mock_server_->AddUpdateBookmark(1, 0, "bob", 2, 10); |
3001 mock_server_->SetLastUpdateDeleted(); | 2985 mock_server_->SetLastUpdateDeleted(); |
3002 mock_server_->set_conflict_all_commits(true); | 2986 mock_server_->set_conflict_all_commits(true); |
3003 SyncShareNudge(); | 2987 SyncShareAsDelegate(); |
3004 SyncShareNudge(); | 2988 SyncShareAsDelegate(); |
3005 { | 2989 { |
3006 ReadTransaction trans(FROM_HERE, directory()); | 2990 ReadTransaction trans(FROM_HERE, directory()); |
3007 Entry bob(&trans, GET_BY_HANDLE, bob_metahandle); | 2991 Entry bob(&trans, GET_BY_HANDLE, bob_metahandle); |
3008 ASSERT_TRUE(bob.good()); | 2992 ASSERT_TRUE(bob.good()); |
3009 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); | 2993 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); |
3010 EXPECT_FALSE(bob.Get(ID).ServerKnows()); | 2994 EXPECT_FALSE(bob.Get(ID).ServerKnows()); |
3011 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); | 2995 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); |
3012 EXPECT_FALSE(bob.Get(IS_DEL)); | 2996 EXPECT_FALSE(bob.Get(IS_DEL)); |
3013 } | 2997 } |
3014 saw_syncer_event_ = false; | 2998 saw_syncer_event_ = false; |
(...skipping 13 matching lines...) Expand all Loading... |
3028 ASSERT_TRUE(folder2.good()); | 3012 ASSERT_TRUE(folder2.good()); |
3029 folder2.Put(IS_UNSYNCED, false); | 3013 folder2.Put(IS_UNSYNCED, false); |
3030 folder2.Put(IS_DIR, true); | 3014 folder2.Put(IS_DIR, true); |
3031 folder2.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 3015 folder2.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
3032 folder2.Put(BASE_VERSION, 3); | 3016 folder2.Put(BASE_VERSION, 3); |
3033 folder2.Put(ID, syncable::Id::CreateFromServerId("mock_server:10000")); | 3017 folder2.Put(ID, syncable::Id::CreateFromServerId("mock_server:10000")); |
3034 } | 3018 } |
3035 mock_server_->set_next_new_id(10000); | 3019 mock_server_->set_next_new_id(10000); |
3036 EXPECT_EQ(1u, directory()->unsynced_entity_count()); | 3020 EXPECT_EQ(1u, directory()->unsynced_entity_count()); |
3037 // we get back a bad id in here (should never happen). | 3021 // we get back a bad id in here (should never happen). |
3038 SyncShareNudge(); | 3022 SyncShareAsDelegate(); |
3039 EXPECT_EQ(1u, directory()->unsynced_entity_count()); | 3023 EXPECT_EQ(1u, directory()->unsynced_entity_count()); |
3040 SyncShareNudge(); // another bad id in here. | 3024 SyncShareAsDelegate(); // another bad id in here. |
3041 EXPECT_EQ(0u, directory()->unsynced_entity_count()); | 3025 EXPECT_EQ(0u, directory()->unsynced_entity_count()); |
3042 saw_syncer_event_ = false; | 3026 saw_syncer_event_ = false; |
3043 } | 3027 } |
3044 | 3028 |
3045 TEST_F(SyncerTest, DeletedEntryWithBadParentInLoopCalculation) { | 3029 TEST_F(SyncerTest, DeletedEntryWithBadParentInLoopCalculation) { |
3046 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 3030 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
3047 SyncShareNudge(); | 3031 SyncShareAsDelegate(); |
3048 { | 3032 { |
3049 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3033 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3050 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 3034 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
3051 ASSERT_TRUE(bob.good()); | 3035 ASSERT_TRUE(bob.good()); |
3052 // This is valid, because the parent could have gone away a long time ago. | 3036 // This is valid, because the parent could have gone away a long time ago. |
3053 bob.Put(PARENT_ID, ids_.FromNumber(54)); | 3037 bob.Put(PARENT_ID, ids_.FromNumber(54)); |
3054 bob.Put(IS_DEL, true); | 3038 bob.Put(IS_DEL, true); |
3055 bob.Put(IS_UNSYNCED, true); | 3039 bob.Put(IS_UNSYNCED, true); |
3056 } | 3040 } |
3057 mock_server_->AddUpdateDirectory(2, 1, "fred", 1, 10); | 3041 mock_server_->AddUpdateDirectory(2, 1, "fred", 1, 10); |
3058 SyncShareNudge(); | 3042 SyncShareAsDelegate(); |
3059 SyncShareNudge(); | 3043 SyncShareAsDelegate(); |
3060 } | 3044 } |
3061 | 3045 |
3062 TEST_F(SyncerTest, ConflictResolverMergesLocalDeleteAndServerUpdate) { | 3046 TEST_F(SyncerTest, ConflictResolverMergesLocalDeleteAndServerUpdate) { |
3063 { | 3047 { |
3064 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3048 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3065 | 3049 |
3066 MutableEntry local_deleted(&trans, CREATE, trans.root_id(), "name"); | 3050 MutableEntry local_deleted(&trans, CREATE, trans.root_id(), "name"); |
3067 local_deleted.Put(ID, ids_.FromNumber(1)); | 3051 local_deleted.Put(ID, ids_.FromNumber(1)); |
3068 local_deleted.Put(BASE_VERSION, 1); | 3052 local_deleted.Put(BASE_VERSION, 1); |
3069 local_deleted.Put(IS_DEL, true); | 3053 local_deleted.Put(IS_DEL, true); |
3070 local_deleted.Put(IS_DIR, false); | 3054 local_deleted.Put(IS_DIR, false); |
3071 local_deleted.Put(IS_UNSYNCED, true); | 3055 local_deleted.Put(IS_UNSYNCED, true); |
3072 local_deleted.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 3056 local_deleted.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
3073 } | 3057 } |
3074 | 3058 |
3075 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); | 3059 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); |
3076 | 3060 |
3077 // We don't care about actually committing, just the resolution. | 3061 // We don't care about actually committing, just the resolution. |
3078 mock_server_->set_conflict_all_commits(true); | 3062 mock_server_->set_conflict_all_commits(true); |
3079 SyncShareNudge(); | 3063 SyncShareAsDelegate(); |
3080 | 3064 |
3081 { | 3065 { |
3082 ReadTransaction trans(FROM_HERE, directory()); | 3066 ReadTransaction trans(FROM_HERE, directory()); |
3083 Entry local_deleted(&trans, GET_BY_ID, ids_.FromNumber(1)); | 3067 Entry local_deleted(&trans, GET_BY_ID, ids_.FromNumber(1)); |
3084 EXPECT_TRUE(local_deleted.Get(BASE_VERSION) == 10); | 3068 EXPECT_TRUE(local_deleted.Get(BASE_VERSION) == 10); |
3085 EXPECT_TRUE(local_deleted.Get(IS_UNAPPLIED_UPDATE) == false); | 3069 EXPECT_TRUE(local_deleted.Get(IS_UNAPPLIED_UPDATE) == false); |
3086 EXPECT_TRUE(local_deleted.Get(IS_UNSYNCED) == true); | 3070 EXPECT_TRUE(local_deleted.Get(IS_UNSYNCED) == true); |
3087 EXPECT_TRUE(local_deleted.Get(IS_DEL) == true); | 3071 EXPECT_TRUE(local_deleted.Get(IS_DEL) == true); |
3088 EXPECT_TRUE(local_deleted.Get(IS_DIR) == false); | 3072 EXPECT_TRUE(local_deleted.Get(IS_DIR) == false); |
3089 } | 3073 } |
(...skipping 15 matching lines...) Expand all Loading... |
3105 local_deleted.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 3089 local_deleted.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
3106 } | 3090 } |
3107 | 3091 |
3108 // Server update: entry-type object (not a container), revision 10. | 3092 // Server update: entry-type object (not a container), revision 10. |
3109 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); | 3093 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); |
3110 | 3094 |
3111 // Don't attempt to commit. | 3095 // Don't attempt to commit. |
3112 mock_server_->set_conflict_all_commits(true); | 3096 mock_server_->set_conflict_all_commits(true); |
3113 | 3097 |
3114 // The syncer should not attempt to apply the invalid update. | 3098 // The syncer should not attempt to apply the invalid update. |
3115 SyncShareNudge(); | 3099 SyncShareAsDelegate(); |
3116 | 3100 |
3117 { | 3101 { |
3118 ReadTransaction trans(FROM_HERE, directory()); | 3102 ReadTransaction trans(FROM_HERE, directory()); |
3119 Entry local_deleted(&trans, GET_BY_ID, ids_.FromNumber(1)); | 3103 Entry local_deleted(&trans, GET_BY_ID, ids_.FromNumber(1)); |
3120 EXPECT_TRUE(local_deleted.Get(BASE_VERSION) == 1); | 3104 EXPECT_TRUE(local_deleted.Get(BASE_VERSION) == 1); |
3121 EXPECT_TRUE(local_deleted.Get(IS_UNAPPLIED_UPDATE) == false); | 3105 EXPECT_TRUE(local_deleted.Get(IS_UNAPPLIED_UPDATE) == false); |
3122 EXPECT_TRUE(local_deleted.Get(IS_UNSYNCED) == true); | 3106 EXPECT_TRUE(local_deleted.Get(IS_UNSYNCED) == true); |
3123 EXPECT_TRUE(local_deleted.Get(IS_DEL) == true); | 3107 EXPECT_TRUE(local_deleted.Get(IS_DEL) == true); |
3124 EXPECT_TRUE(local_deleted.Get(IS_DIR) == true); | 3108 EXPECT_TRUE(local_deleted.Get(IS_DIR) == true); |
3125 } | 3109 } |
3126 } | 3110 } |
3127 | 3111 |
3128 // Bug Synopsis: | 3112 // Bug Synopsis: |
3129 // Merge conflict resolution will merge a new local entry with another entry | 3113 // Merge conflict resolution will merge a new local entry with another entry |
3130 // that needs updates, resulting in CHECK. | 3114 // that needs updates, resulting in CHECK. |
3131 TEST_F(SyncerTest, MergingExistingItems) { | 3115 TEST_F(SyncerTest, MergingExistingItems) { |
3132 mock_server_->set_conflict_all_commits(true); | 3116 mock_server_->set_conflict_all_commits(true); |
3133 mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10); | 3117 mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10); |
3134 SyncShareNudge(); | 3118 SyncShareAsDelegate(); |
3135 { | 3119 { |
3136 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3120 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3137 MutableEntry entry(&trans, CREATE, trans.root_id(), "Copy of base"); | 3121 MutableEntry entry(&trans, CREATE, trans.root_id(), "Copy of base"); |
3138 WriteTestDataToEntry(&trans, &entry); | 3122 WriteTestDataToEntry(&trans, &entry); |
3139 } | 3123 } |
3140 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); | 3124 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); |
3141 SyncRepeatedlyToTriggerConflictResolution(session_.get()); | 3125 SyncRepeatedlyToTriggerConflictResolution(session_.get()); |
3142 } | 3126 } |
3143 | 3127 |
3144 // In this test a long changelog contains a child at the start of the changelog | 3128 // In this test a long changelog contains a child at the start of the changelog |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3192 EXPECT_EQ(entry.Get(ID), child.Get(PARENT_ID)); | 3176 EXPECT_EQ(entry.Get(ID), child.Get(PARENT_ID)); |
3193 EXPECT_EQ("stuck", child.Get(NON_UNIQUE_NAME)); | 3177 EXPECT_EQ("stuck", child.Get(NON_UNIQUE_NAME)); |
3194 EXPECT_TRUE(child.good()); | 3178 EXPECT_TRUE(child.good()); |
3195 } | 3179 } |
3196 } | 3180 } |
3197 | 3181 |
3198 TEST_F(SyncerTest, DontMergeTwoExistingItems) { | 3182 TEST_F(SyncerTest, DontMergeTwoExistingItems) { |
3199 mock_server_->set_conflict_all_commits(true); | 3183 mock_server_->set_conflict_all_commits(true); |
3200 mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10); | 3184 mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10); |
3201 mock_server_->AddUpdateBookmark(2, 0, "base2", 10, 10); | 3185 mock_server_->AddUpdateBookmark(2, 0, "base2", 10, 10); |
3202 SyncShareNudge(); | 3186 SyncShareAsDelegate(); |
3203 { | 3187 { |
3204 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3188 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3205 MutableEntry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3189 MutableEntry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); |
3206 ASSERT_TRUE(entry.good()); | 3190 ASSERT_TRUE(entry.good()); |
3207 EXPECT_TRUE(entry.Put(NON_UNIQUE_NAME, "Copy of base")); | 3191 EXPECT_TRUE(entry.Put(NON_UNIQUE_NAME, "Copy of base")); |
3208 entry.Put(IS_UNSYNCED, true); | 3192 entry.Put(IS_UNSYNCED, true); |
3209 } | 3193 } |
3210 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); | 3194 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); |
3211 SyncRepeatedlyToTriggerConflictResolution(session_.get()); | 3195 SyncRepeatedlyToTriggerConflictResolution(session_.get()); |
3212 { | 3196 { |
3213 ReadTransaction trans(FROM_HERE, directory()); | 3197 ReadTransaction trans(FROM_HERE, directory()); |
3214 Entry entry1(&trans, GET_BY_ID, ids_.FromNumber(1)); | 3198 Entry entry1(&trans, GET_BY_ID, ids_.FromNumber(1)); |
3215 EXPECT_FALSE(entry1.Get(IS_UNAPPLIED_UPDATE)); | 3199 EXPECT_FALSE(entry1.Get(IS_UNAPPLIED_UPDATE)); |
3216 EXPECT_FALSE(entry1.Get(IS_UNSYNCED)); | 3200 EXPECT_FALSE(entry1.Get(IS_UNSYNCED)); |
3217 EXPECT_FALSE(entry1.Get(IS_DEL)); | 3201 EXPECT_FALSE(entry1.Get(IS_DEL)); |
3218 Entry entry2(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3202 Entry entry2(&trans, GET_BY_ID, ids_.FromNumber(2)); |
3219 EXPECT_FALSE(entry2.Get(IS_UNAPPLIED_UPDATE)); | 3203 EXPECT_FALSE(entry2.Get(IS_UNAPPLIED_UPDATE)); |
3220 EXPECT_TRUE(entry2.Get(IS_UNSYNCED)); | 3204 EXPECT_TRUE(entry2.Get(IS_UNSYNCED)); |
3221 EXPECT_FALSE(entry2.Get(IS_DEL)); | 3205 EXPECT_FALSE(entry2.Get(IS_DEL)); |
3222 EXPECT_EQ(entry1.Get(NON_UNIQUE_NAME), entry2.Get(NON_UNIQUE_NAME)); | 3206 EXPECT_EQ(entry1.Get(NON_UNIQUE_NAME), entry2.Get(NON_UNIQUE_NAME)); |
3223 } | 3207 } |
3224 } | 3208 } |
3225 | 3209 |
3226 TEST_F(SyncerTest, TestUndeleteUpdate) { | 3210 TEST_F(SyncerTest, TestUndeleteUpdate) { |
3227 mock_server_->set_conflict_all_commits(true); | 3211 mock_server_->set_conflict_all_commits(true); |
3228 mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1); | 3212 mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1); |
3229 mock_server_->AddUpdateDirectory(2, 1, "bar", 1, 2); | 3213 mock_server_->AddUpdateDirectory(2, 1, "bar", 1, 2); |
3230 SyncShareNudge(); | 3214 SyncShareAsDelegate(); |
3231 mock_server_->AddUpdateDirectory(2, 1, "bar", 2, 3); | 3215 mock_server_->AddUpdateDirectory(2, 1, "bar", 2, 3); |
3232 mock_server_->SetLastUpdateDeleted(); | 3216 mock_server_->SetLastUpdateDeleted(); |
3233 SyncShareNudge(); | 3217 SyncShareAsDelegate(); |
3234 | 3218 |
3235 int64 metahandle; | 3219 int64 metahandle; |
3236 { | 3220 { |
3237 ReadTransaction trans(FROM_HERE, directory()); | 3221 ReadTransaction trans(FROM_HERE, directory()); |
3238 Entry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3222 Entry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); |
3239 ASSERT_TRUE(entry.good()); | 3223 ASSERT_TRUE(entry.good()); |
3240 EXPECT_TRUE(entry.Get(IS_DEL)); | 3224 EXPECT_TRUE(entry.Get(IS_DEL)); |
3241 metahandle = entry.Get(META_HANDLE); | 3225 metahandle = entry.Get(META_HANDLE); |
3242 } | 3226 } |
3243 mock_server_->AddUpdateDirectory(1, 0, "foo", 2, 4); | 3227 mock_server_->AddUpdateDirectory(1, 0, "foo", 2, 4); |
3244 mock_server_->SetLastUpdateDeleted(); | 3228 mock_server_->SetLastUpdateDeleted(); |
3245 SyncShareNudge(); | 3229 SyncShareAsDelegate(); |
3246 // This used to be rejected as it's an undeletion. Now, it results in moving | 3230 // This used to be rejected as it's an undeletion. Now, it results in moving |
3247 // the delete path aside. | 3231 // the delete path aside. |
3248 mock_server_->AddUpdateDirectory(2, 1, "bar", 3, 5); | 3232 mock_server_->AddUpdateDirectory(2, 1, "bar", 3, 5); |
3249 SyncShareNudge(); | 3233 SyncShareAsDelegate(); |
3250 { | 3234 { |
3251 ReadTransaction trans(FROM_HERE, directory()); | 3235 ReadTransaction trans(FROM_HERE, directory()); |
3252 Entry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3236 Entry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); |
3253 ASSERT_TRUE(entry.good()); | 3237 ASSERT_TRUE(entry.good()); |
3254 EXPECT_TRUE(entry.Get(IS_DEL)); | 3238 EXPECT_TRUE(entry.Get(IS_DEL)); |
3255 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); | 3239 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); |
3256 EXPECT_TRUE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3240 EXPECT_TRUE(entry.Get(IS_UNAPPLIED_UPDATE)); |
3257 EXPECT_NE(entry.Get(META_HANDLE), metahandle); | 3241 EXPECT_NE(entry.Get(META_HANDLE), metahandle); |
3258 } | 3242 } |
3259 } | 3243 } |
3260 | 3244 |
3261 TEST_F(SyncerTest, TestMoveSanitizedNamedFolder) { | 3245 TEST_F(SyncerTest, TestMoveSanitizedNamedFolder) { |
3262 mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1); | 3246 mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1); |
3263 mock_server_->AddUpdateDirectory(2, 0, ":::", 1, 2); | 3247 mock_server_->AddUpdateDirectory(2, 0, ":::", 1, 2); |
3264 SyncShareNudge(); | 3248 SyncShareAsDelegate(); |
3265 { | 3249 { |
3266 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3250 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3267 MutableEntry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3251 MutableEntry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); |
3268 ASSERT_TRUE(entry.good()); | 3252 ASSERT_TRUE(entry.good()); |
3269 EXPECT_TRUE(entry.Put(PARENT_ID, ids_.FromNumber(1))); | 3253 EXPECT_TRUE(entry.Put(PARENT_ID, ids_.FromNumber(1))); |
3270 EXPECT_TRUE(entry.Put(IS_UNSYNCED, true)); | 3254 EXPECT_TRUE(entry.Put(IS_UNSYNCED, true)); |
3271 } | 3255 } |
3272 SyncShareNudge(); | 3256 SyncShareAsDelegate(); |
3273 // We use the same sync ts as before so our times match up. | 3257 // We use the same sync ts as before so our times match up. |
3274 mock_server_->AddUpdateDirectory(2, 1, ":::", 2, 2); | 3258 mock_server_->AddUpdateDirectory(2, 1, ":::", 2, 2); |
3275 SyncShareNudge(); | 3259 SyncShareAsDelegate(); |
3276 } | 3260 } |
3277 | 3261 |
3278 // Don't crash when this occurs. | 3262 // Don't crash when this occurs. |
3279 TEST_F(SyncerTest, UpdateWhereParentIsNotAFolder) { | 3263 TEST_F(SyncerTest, UpdateWhereParentIsNotAFolder) { |
3280 mock_server_->AddUpdateBookmark(1, 0, "B", 10, 10); | 3264 mock_server_->AddUpdateBookmark(1, 0, "B", 10, 10); |
3281 mock_server_->AddUpdateDirectory(2, 1, "BookmarkParent", 10, 10); | 3265 mock_server_->AddUpdateDirectory(2, 1, "BookmarkParent", 10, 10); |
3282 // Used to cause a CHECK | 3266 // Used to cause a CHECK |
3283 SyncShareNudge(); | 3267 SyncShareAsDelegate(); |
3284 { | 3268 { |
3285 ReadTransaction rtrans(FROM_HERE, directory()); | 3269 ReadTransaction rtrans(FROM_HERE, directory()); |
3286 Entry good_entry(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 3270 Entry good_entry(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
3287 ASSERT_TRUE(good_entry.good()); | 3271 ASSERT_TRUE(good_entry.good()); |
3288 EXPECT_FALSE(good_entry.Get(IS_UNAPPLIED_UPDATE)); | 3272 EXPECT_FALSE(good_entry.Get(IS_UNAPPLIED_UPDATE)); |
3289 Entry bad_parent(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2)); | 3273 Entry bad_parent(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2)); |
3290 ASSERT_TRUE(bad_parent.good()); | 3274 ASSERT_TRUE(bad_parent.good()); |
3291 EXPECT_TRUE(bad_parent.Get(IS_UNAPPLIED_UPDATE)); | 3275 EXPECT_TRUE(bad_parent.Get(IS_UNAPPLIED_UPDATE)); |
3292 } | 3276 } |
3293 } | 3277 } |
3294 | 3278 |
3295 const char kRootId[] = "0"; | 3279 const char kRootId[] = "0"; |
3296 | 3280 |
3297 TEST_F(SyncerTest, DirectoryUpdateTest) { | 3281 TEST_F(SyncerTest, DirectoryUpdateTest) { |
3298 Id in_root_id = ids_.NewServerId(); | 3282 Id in_root_id = ids_.NewServerId(); |
3299 Id in_in_root_id = ids_.NewServerId(); | 3283 Id in_in_root_id = ids_.NewServerId(); |
3300 | 3284 |
3301 mock_server_->AddUpdateDirectory(in_root_id, TestIdFactory::root(), | 3285 mock_server_->AddUpdateDirectory(in_root_id, TestIdFactory::root(), |
3302 "in_root_name", 2, 2); | 3286 "in_root_name", 2, 2); |
3303 mock_server_->AddUpdateDirectory(in_in_root_id, in_root_id, | 3287 mock_server_->AddUpdateDirectory(in_in_root_id, in_root_id, |
3304 "in_in_root_name", 3, 3); | 3288 "in_in_root_name", 3, 3); |
3305 SyncShareNudge(); | 3289 SyncShareAsDelegate(); |
3306 { | 3290 { |
3307 ReadTransaction trans(FROM_HERE, directory()); | 3291 ReadTransaction trans(FROM_HERE, directory()); |
3308 Entry in_root(&trans, GET_BY_ID, in_root_id); | 3292 Entry in_root(&trans, GET_BY_ID, in_root_id); |
3309 ASSERT_TRUE(in_root.good()); | 3293 ASSERT_TRUE(in_root.good()); |
3310 EXPECT_EQ("in_root_name", in_root.Get(NON_UNIQUE_NAME)); | 3294 EXPECT_EQ("in_root_name", in_root.Get(NON_UNIQUE_NAME)); |
3311 EXPECT_EQ(TestIdFactory::root(), in_root.Get(PARENT_ID)); | 3295 EXPECT_EQ(TestIdFactory::root(), in_root.Get(PARENT_ID)); |
3312 | 3296 |
3313 Entry in_in_root(&trans, GET_BY_ID, in_in_root_id); | 3297 Entry in_in_root(&trans, GET_BY_ID, in_in_root_id); |
3314 ASSERT_TRUE(in_in_root.good()); | 3298 ASSERT_TRUE(in_in_root.good()); |
3315 EXPECT_EQ("in_in_root_name", in_in_root.Get(NON_UNIQUE_NAME)); | 3299 EXPECT_EQ("in_in_root_name", in_in_root.Get(NON_UNIQUE_NAME)); |
(...skipping 17 matching lines...) Expand all Loading... |
3333 foo_metahandle = parent.Get(META_HANDLE); | 3317 foo_metahandle = parent.Get(META_HANDLE); |
3334 | 3318 |
3335 MutableEntry child(&wtrans, syncable::CREATE, parent.Get(ID), "bar"); | 3319 MutableEntry child(&wtrans, syncable::CREATE, parent.Get(ID), "bar"); |
3336 ASSERT_TRUE(child.good()); | 3320 ASSERT_TRUE(child.good()); |
3337 child.Put(syncable::IS_UNSYNCED, true); | 3321 child.Put(syncable::IS_UNSYNCED, true); |
3338 child.Put(syncable::IS_DIR, true); | 3322 child.Put(syncable::IS_DIR, true); |
3339 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 3323 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
3340 bar_metahandle = child.Get(META_HANDLE); | 3324 bar_metahandle = child.Get(META_HANDLE); |
3341 in_dir_id = parent.Get(syncable::ID); | 3325 in_dir_id = parent.Get(syncable::ID); |
3342 } | 3326 } |
3343 SyncShareNudge(); | 3327 SyncShareAsDelegate(); |
3344 { | 3328 { |
3345 ReadTransaction trans(FROM_HERE, directory()); | 3329 ReadTransaction trans(FROM_HERE, directory()); |
3346 Entry fail_by_old_id_entry(&trans, GET_BY_ID, in_root_id); | 3330 Entry fail_by_old_id_entry(&trans, GET_BY_ID, in_root_id); |
3347 ASSERT_FALSE(fail_by_old_id_entry.good()); | 3331 ASSERT_FALSE(fail_by_old_id_entry.good()); |
3348 | 3332 |
3349 Entry foo_entry(&trans, GET_BY_HANDLE, foo_metahandle); | 3333 Entry foo_entry(&trans, GET_BY_HANDLE, foo_metahandle); |
3350 ASSERT_TRUE(foo_entry.good()); | 3334 ASSERT_TRUE(foo_entry.good()); |
3351 EXPECT_EQ("foo", foo_entry.Get(NON_UNIQUE_NAME)); | 3335 EXPECT_EQ("foo", foo_entry.Get(NON_UNIQUE_NAME)); |
3352 EXPECT_NE(foo_entry.Get(syncable::ID), in_root_id); | 3336 EXPECT_NE(foo_entry.Get(syncable::ID), in_root_id); |
3353 | 3337 |
3354 Entry bar_entry(&trans, GET_BY_HANDLE, bar_metahandle); | 3338 Entry bar_entry(&trans, GET_BY_HANDLE, bar_metahandle); |
3355 ASSERT_TRUE(bar_entry.good()); | 3339 ASSERT_TRUE(bar_entry.good()); |
3356 EXPECT_EQ("bar", bar_entry.Get(NON_UNIQUE_NAME)); | 3340 EXPECT_EQ("bar", bar_entry.Get(NON_UNIQUE_NAME)); |
3357 EXPECT_NE(bar_entry.Get(syncable::ID), in_dir_id); | 3341 EXPECT_NE(bar_entry.Get(syncable::ID), in_dir_id); |
3358 EXPECT_EQ(foo_entry.Get(syncable::ID), bar_entry.Get(PARENT_ID)); | 3342 EXPECT_EQ(foo_entry.Get(syncable::ID), bar_entry.Get(PARENT_ID)); |
3359 } | 3343 } |
3360 } | 3344 } |
3361 | 3345 |
3362 TEST_F(SyncerTest, TestClientCommand) { | 3346 TEST_F(SyncerTest, TestClientCommand) { |
3363 using sync_pb::ClientCommand; | 3347 using sync_pb::ClientCommand; |
3364 | 3348 |
3365 ClientCommand* command = mock_server_->GetNextClientCommand(); | 3349 ClientCommand* command = mock_server_->GetNextClientCommand(); |
3366 command->set_set_sync_poll_interval(8); | 3350 command->set_set_sync_poll_interval(8); |
3367 command->set_set_sync_long_poll_interval(800); | 3351 command->set_set_sync_long_poll_interval(800); |
3368 command->set_sessions_commit_delay_seconds(3141); | 3352 command->set_sessions_commit_delay_seconds(3141); |
3369 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1); | 3353 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1); |
3370 SyncShareNudge(); | 3354 SyncShareAsDelegate(); |
3371 | 3355 |
3372 EXPECT_TRUE(TimeDelta::FromSeconds(8) == | 3356 EXPECT_TRUE(TimeDelta::FromSeconds(8) == |
3373 last_short_poll_interval_received_); | 3357 last_short_poll_interval_received_); |
3374 EXPECT_TRUE(TimeDelta::FromSeconds(800) == | 3358 EXPECT_TRUE(TimeDelta::FromSeconds(800) == |
3375 last_long_poll_interval_received_); | 3359 last_long_poll_interval_received_); |
3376 EXPECT_TRUE(TimeDelta::FromSeconds(3141) == | 3360 EXPECT_TRUE(TimeDelta::FromSeconds(3141) == |
3377 last_sessions_commit_delay_seconds_); | 3361 last_sessions_commit_delay_seconds_); |
3378 | 3362 |
3379 command = mock_server_->GetNextClientCommand(); | 3363 command = mock_server_->GetNextClientCommand(); |
3380 command->set_set_sync_poll_interval(180); | 3364 command->set_set_sync_poll_interval(180); |
3381 command->set_set_sync_long_poll_interval(190); | 3365 command->set_set_sync_long_poll_interval(190); |
3382 command->set_sessions_commit_delay_seconds(2718); | 3366 command->set_sessions_commit_delay_seconds(2718); |
3383 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1); | 3367 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1); |
3384 SyncShareNudge(); | 3368 SyncShareAsDelegate(); |
3385 | 3369 |
3386 EXPECT_TRUE(TimeDelta::FromSeconds(180) == | 3370 EXPECT_TRUE(TimeDelta::FromSeconds(180) == |
3387 last_short_poll_interval_received_); | 3371 last_short_poll_interval_received_); |
3388 EXPECT_TRUE(TimeDelta::FromSeconds(190) == | 3372 EXPECT_TRUE(TimeDelta::FromSeconds(190) == |
3389 last_long_poll_interval_received_); | 3373 last_long_poll_interval_received_); |
3390 EXPECT_TRUE(TimeDelta::FromSeconds(2718) == | 3374 EXPECT_TRUE(TimeDelta::FromSeconds(2718) == |
3391 last_sessions_commit_delay_seconds_); | 3375 last_sessions_commit_delay_seconds_); |
3392 } | 3376 } |
3393 | 3377 |
3394 TEST_F(SyncerTest, EnsureWeSendUpOldParent) { | 3378 TEST_F(SyncerTest, EnsureWeSendUpOldParent) { |
3395 syncable::Id folder_one_id = ids_.FromNumber(1); | 3379 syncable::Id folder_one_id = ids_.FromNumber(1); |
3396 syncable::Id folder_two_id = ids_.FromNumber(2); | 3380 syncable::Id folder_two_id = ids_.FromNumber(2); |
3397 | 3381 |
3398 mock_server_->AddUpdateDirectory(folder_one_id, TestIdFactory::root(), | 3382 mock_server_->AddUpdateDirectory(folder_one_id, TestIdFactory::root(), |
3399 "folder_one", 1, 1); | 3383 "folder_one", 1, 1); |
3400 mock_server_->AddUpdateDirectory(folder_two_id, TestIdFactory::root(), | 3384 mock_server_->AddUpdateDirectory(folder_two_id, TestIdFactory::root(), |
3401 "folder_two", 1, 1); | 3385 "folder_two", 1, 1); |
3402 SyncShareNudge(); | 3386 SyncShareAsDelegate(); |
3403 { | 3387 { |
3404 // A moved entry should send an "old parent." | 3388 // A moved entry should send an "old parent." |
3405 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3389 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3406 MutableEntry entry(&trans, GET_BY_ID, folder_one_id); | 3390 MutableEntry entry(&trans, GET_BY_ID, folder_one_id); |
3407 ASSERT_TRUE(entry.good()); | 3391 ASSERT_TRUE(entry.good()); |
3408 entry.Put(PARENT_ID, folder_two_id); | 3392 entry.Put(PARENT_ID, folder_two_id); |
3409 entry.Put(IS_UNSYNCED, true); | 3393 entry.Put(IS_UNSYNCED, true); |
3410 // A new entry should send no "old parent." | 3394 // A new entry should send no "old parent." |
3411 MutableEntry create(&trans, CREATE, trans.root_id(), "new_folder"); | 3395 MutableEntry create(&trans, CREATE, trans.root_id(), "new_folder"); |
3412 create.Put(IS_UNSYNCED, true); | 3396 create.Put(IS_UNSYNCED, true); |
3413 create.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 3397 create.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
3414 } | 3398 } |
3415 SyncShareNudge(); | 3399 SyncShareAsDelegate(); |
3416 const sync_pb::CommitMessage& commit = mock_server_->last_sent_commit(); | 3400 const sync_pb::CommitMessage& commit = mock_server_->last_sent_commit(); |
3417 ASSERT_EQ(2, commit.entries_size()); | 3401 ASSERT_EQ(2, commit.entries_size()); |
3418 EXPECT_TRUE(commit.entries(0).parent_id_string() == "2"); | 3402 EXPECT_TRUE(commit.entries(0).parent_id_string() == "2"); |
3419 EXPECT_TRUE(commit.entries(0).old_parent_id() == "0"); | 3403 EXPECT_TRUE(commit.entries(0).old_parent_id() == "0"); |
3420 EXPECT_FALSE(commit.entries(1).has_old_parent_id()); | 3404 EXPECT_FALSE(commit.entries(1).has_old_parent_id()); |
3421 } | 3405 } |
3422 | 3406 |
3423 TEST_F(SyncerTest, Test64BitVersionSupport) { | 3407 TEST_F(SyncerTest, Test64BitVersionSupport) { |
3424 int64 really_big_int = std::numeric_limits<int64>::max() - 12; | 3408 int64 really_big_int = std::numeric_limits<int64>::max() - 12; |
3425 const string name("ringo's dang orang ran rings around my o-ring"); | 3409 const string name("ringo's dang orang ran rings around my o-ring"); |
(...skipping 14 matching lines...) Expand all Loading... |
3440 Entry entry(&rtrans, syncable::GET_BY_HANDLE, item_metahandle); | 3424 Entry entry(&rtrans, syncable::GET_BY_HANDLE, item_metahandle); |
3441 ASSERT_TRUE(entry.good()); | 3425 ASSERT_TRUE(entry.good()); |
3442 EXPECT_TRUE(really_big_int == entry.Get(syncable::BASE_VERSION)); | 3426 EXPECT_TRUE(really_big_int == entry.Get(syncable::BASE_VERSION)); |
3443 } | 3427 } |
3444 | 3428 |
3445 TEST_F(SyncerTest, TestSimpleUndelete) { | 3429 TEST_F(SyncerTest, TestSimpleUndelete) { |
3446 Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root(); | 3430 Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root(); |
3447 mock_server_->set_conflict_all_commits(true); | 3431 mock_server_->set_conflict_all_commits(true); |
3448 // Let there be an entry from the server. | 3432 // Let there be an entry from the server. |
3449 mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10); | 3433 mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10); |
3450 SyncShareNudge(); | 3434 SyncShareAsDelegate(); |
3451 // Check it out and delete it. | 3435 // Check it out and delete it. |
3452 { | 3436 { |
3453 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 3437 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
3454 MutableEntry entry(&wtrans, GET_BY_ID, id); | 3438 MutableEntry entry(&wtrans, GET_BY_ID, id); |
3455 ASSERT_TRUE(entry.good()); | 3439 ASSERT_TRUE(entry.good()); |
3456 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3440 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
3457 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3441 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
3458 EXPECT_FALSE(entry.Get(IS_DEL)); | 3442 EXPECT_FALSE(entry.Get(IS_DEL)); |
3459 // Delete it locally. | 3443 // Delete it locally. |
3460 entry.Put(IS_DEL, true); | 3444 entry.Put(IS_DEL, true); |
3461 } | 3445 } |
3462 SyncShareNudge(); | 3446 SyncShareAsDelegate(); |
3463 // Confirm we see IS_DEL and not SERVER_IS_DEL. | 3447 // Confirm we see IS_DEL and not SERVER_IS_DEL. |
3464 { | 3448 { |
3465 ReadTransaction trans(FROM_HERE, directory()); | 3449 ReadTransaction trans(FROM_HERE, directory()); |
3466 Entry entry(&trans, GET_BY_ID, id); | 3450 Entry entry(&trans, GET_BY_ID, id); |
3467 ASSERT_TRUE(entry.good()); | 3451 ASSERT_TRUE(entry.good()); |
3468 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3452 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
3469 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3453 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
3470 EXPECT_TRUE(entry.Get(IS_DEL)); | 3454 EXPECT_TRUE(entry.Get(IS_DEL)); |
3471 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); | 3455 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); |
3472 } | 3456 } |
3473 SyncShareNudge(); | 3457 SyncShareAsDelegate(); |
3474 // Update from server confirming deletion. | 3458 // Update from server confirming deletion. |
3475 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 11); | 3459 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 11); |
3476 mock_server_->SetLastUpdateDeleted(); | 3460 mock_server_->SetLastUpdateDeleted(); |
3477 SyncShareNudge(); | 3461 SyncShareAsDelegate(); |
3478 // IS_DEL AND SERVER_IS_DEL now both true. | 3462 // IS_DEL AND SERVER_IS_DEL now both true. |
3479 { | 3463 { |
3480 ReadTransaction trans(FROM_HERE, directory()); | 3464 ReadTransaction trans(FROM_HERE, directory()); |
3481 Entry entry(&trans, GET_BY_ID, id); | 3465 Entry entry(&trans, GET_BY_ID, id); |
3482 ASSERT_TRUE(entry.good()); | 3466 ASSERT_TRUE(entry.good()); |
3483 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3467 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
3484 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3468 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
3485 EXPECT_TRUE(entry.Get(IS_DEL)); | 3469 EXPECT_TRUE(entry.Get(IS_DEL)); |
3486 EXPECT_TRUE(entry.Get(SERVER_IS_DEL)); | 3470 EXPECT_TRUE(entry.Get(SERVER_IS_DEL)); |
3487 } | 3471 } |
3488 // Undelete from server. | 3472 // Undelete from server. |
3489 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12); | 3473 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12); |
3490 SyncShareNudge(); | 3474 SyncShareAsDelegate(); |
3491 // IS_DEL and SERVER_IS_DEL now both false. | 3475 // IS_DEL and SERVER_IS_DEL now both false. |
3492 { | 3476 { |
3493 ReadTransaction trans(FROM_HERE, directory()); | 3477 ReadTransaction trans(FROM_HERE, directory()); |
3494 Entry entry(&trans, GET_BY_ID, id); | 3478 Entry entry(&trans, GET_BY_ID, id); |
3495 ASSERT_TRUE(entry.good()); | 3479 ASSERT_TRUE(entry.good()); |
3496 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3480 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
3497 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3481 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
3498 EXPECT_FALSE(entry.Get(IS_DEL)); | 3482 EXPECT_FALSE(entry.Get(IS_DEL)); |
3499 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); | 3483 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); |
3500 } | 3484 } |
3501 } | 3485 } |
3502 | 3486 |
3503 TEST_F(SyncerTest, TestUndeleteWithMissingDeleteUpdate) { | 3487 TEST_F(SyncerTest, TestUndeleteWithMissingDeleteUpdate) { |
3504 Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root(); | 3488 Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root(); |
3505 // Let there be a entry, from the server. | 3489 // Let there be a entry, from the server. |
3506 mock_server_->set_conflict_all_commits(true); | 3490 mock_server_->set_conflict_all_commits(true); |
3507 mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10); | 3491 mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10); |
3508 SyncShareNudge(); | 3492 SyncShareAsDelegate(); |
3509 // Check it out and delete it. | 3493 // Check it out and delete it. |
3510 { | 3494 { |
3511 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 3495 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
3512 MutableEntry entry(&wtrans, GET_BY_ID, id); | 3496 MutableEntry entry(&wtrans, GET_BY_ID, id); |
3513 ASSERT_TRUE(entry.good()); | 3497 ASSERT_TRUE(entry.good()); |
3514 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3498 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
3515 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3499 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
3516 EXPECT_FALSE(entry.Get(IS_DEL)); | 3500 EXPECT_FALSE(entry.Get(IS_DEL)); |
3517 // Delete it locally. | 3501 // Delete it locally. |
3518 entry.Put(IS_DEL, true); | 3502 entry.Put(IS_DEL, true); |
3519 } | 3503 } |
3520 SyncShareNudge(); | 3504 SyncShareAsDelegate(); |
3521 // Confirm we see IS_DEL and not SERVER_IS_DEL. | 3505 // Confirm we see IS_DEL and not SERVER_IS_DEL. |
3522 { | 3506 { |
3523 ReadTransaction trans(FROM_HERE, directory()); | 3507 ReadTransaction trans(FROM_HERE, directory()); |
3524 Entry entry(&trans, GET_BY_ID, id); | 3508 Entry entry(&trans, GET_BY_ID, id); |
3525 ASSERT_TRUE(entry.good()); | 3509 ASSERT_TRUE(entry.good()); |
3526 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3510 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
3527 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3511 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
3528 EXPECT_TRUE(entry.Get(IS_DEL)); | 3512 EXPECT_TRUE(entry.Get(IS_DEL)); |
3529 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); | 3513 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); |
3530 } | 3514 } |
3531 SyncShareNudge(); | 3515 SyncShareAsDelegate(); |
3532 // Say we do not get an update from server confirming deletion. Undelete | 3516 // Say we do not get an update from server confirming deletion. Undelete |
3533 // from server | 3517 // from server |
3534 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12); | 3518 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12); |
3535 SyncShareNudge(); | 3519 SyncShareAsDelegate(); |
3536 // IS_DEL and SERVER_IS_DEL now both false. | 3520 // IS_DEL and SERVER_IS_DEL now both false. |
3537 { | 3521 { |
3538 ReadTransaction trans(FROM_HERE, directory()); | 3522 ReadTransaction trans(FROM_HERE, directory()); |
3539 Entry entry(&trans, GET_BY_ID, id); | 3523 Entry entry(&trans, GET_BY_ID, id); |
3540 ASSERT_TRUE(entry.good()); | 3524 ASSERT_TRUE(entry.good()); |
3541 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3525 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
3542 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3526 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
3543 EXPECT_FALSE(entry.Get(IS_DEL)); | 3527 EXPECT_FALSE(entry.Get(IS_DEL)); |
3544 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); | 3528 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); |
3545 } | 3529 } |
3546 } | 3530 } |
3547 | 3531 |
3548 TEST_F(SyncerTest, TestUndeleteIgnoreCorrectlyUnappliedUpdate) { | 3532 TEST_F(SyncerTest, TestUndeleteIgnoreCorrectlyUnappliedUpdate) { |
3549 Id id1 = ids_.MakeServer("first"), id2 = ids_.MakeServer("second"); | 3533 Id id1 = ids_.MakeServer("first"), id2 = ids_.MakeServer("second"); |
3550 Id root = TestIdFactory::root(); | 3534 Id root = TestIdFactory::root(); |
3551 // Duplicate! expect path clashing! | 3535 // Duplicate! expect path clashing! |
3552 mock_server_->set_conflict_all_commits(true); | 3536 mock_server_->set_conflict_all_commits(true); |
3553 mock_server_->AddUpdateBookmark(id1, root, "foo", 1, 10); | 3537 mock_server_->AddUpdateBookmark(id1, root, "foo", 1, 10); |
3554 mock_server_->AddUpdateBookmark(id2, root, "foo", 1, 10); | 3538 mock_server_->AddUpdateBookmark(id2, root, "foo", 1, 10); |
3555 SyncShareNudge(); | 3539 SyncShareAsDelegate(); |
3556 mock_server_->AddUpdateBookmark(id2, root, "foo2", 2, 20); | 3540 mock_server_->AddUpdateBookmark(id2, root, "foo2", 2, 20); |
3557 SyncShareNudge(); // Now just don't explode. | 3541 SyncShareAsDelegate(); // Now just don't explode. |
3558 } | 3542 } |
3559 | 3543 |
3560 TEST_F(SyncerTest, ClientTagServerCreatedUpdatesWork) { | 3544 TEST_F(SyncerTest, ClientTagServerCreatedUpdatesWork) { |
3561 mock_server_->AddUpdateDirectory(1, 0, "permitem1", 1, 10); | 3545 mock_server_->AddUpdateDirectory(1, 0, "permitem1", 1, 10); |
3562 mock_server_->SetLastUpdateClientTag("permfolder"); | 3546 mock_server_->SetLastUpdateClientTag("permfolder"); |
3563 | 3547 |
3564 SyncShareNudge(); | 3548 SyncShareAsDelegate(); |
3565 | 3549 |
3566 { | 3550 { |
3567 ReadTransaction trans(FROM_HERE, directory()); | 3551 ReadTransaction trans(FROM_HERE, directory()); |
3568 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "permfolder"); | 3552 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "permfolder"); |
3569 ASSERT_TRUE(perm_folder.good()); | 3553 ASSERT_TRUE(perm_folder.good()); |
3570 EXPECT_FALSE(perm_folder.Get(IS_DEL)); | 3554 EXPECT_FALSE(perm_folder.Get(IS_DEL)); |
3571 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); | 3555 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); |
3572 EXPECT_FALSE(perm_folder.Get(IS_UNSYNCED)); | 3556 EXPECT_FALSE(perm_folder.Get(IS_UNSYNCED)); |
3573 EXPECT_EQ(perm_folder.Get(UNIQUE_CLIENT_TAG), "permfolder"); | 3557 EXPECT_EQ(perm_folder.Get(UNIQUE_CLIENT_TAG), "permfolder"); |
3574 EXPECT_EQ(perm_folder.Get(NON_UNIQUE_NAME), "permitem1"); | 3558 EXPECT_EQ(perm_folder.Get(NON_UNIQUE_NAME), "permitem1"); |
3575 } | 3559 } |
3576 | 3560 |
3577 mock_server_->AddUpdateDirectory(1, 0, "permitem_renamed", 10, 100); | 3561 mock_server_->AddUpdateDirectory(1, 0, "permitem_renamed", 10, 100); |
3578 mock_server_->SetLastUpdateClientTag("permfolder"); | 3562 mock_server_->SetLastUpdateClientTag("permfolder"); |
3579 SyncShareNudge(); | 3563 SyncShareAsDelegate(); |
3580 | 3564 |
3581 { | 3565 { |
3582 ReadTransaction trans(FROM_HERE, directory()); | 3566 ReadTransaction trans(FROM_HERE, directory()); |
3583 | 3567 |
3584 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "permfolder"); | 3568 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "permfolder"); |
3585 ASSERT_TRUE(perm_folder.good()); | 3569 ASSERT_TRUE(perm_folder.good()); |
3586 EXPECT_FALSE(perm_folder.Get(IS_DEL)); | 3570 EXPECT_FALSE(perm_folder.Get(IS_DEL)); |
3587 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); | 3571 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); |
3588 EXPECT_FALSE(perm_folder.Get(IS_UNSYNCED)); | 3572 EXPECT_FALSE(perm_folder.Get(IS_UNSYNCED)); |
3589 EXPECT_EQ(perm_folder.Get(UNIQUE_CLIENT_TAG), "permfolder"); | 3573 EXPECT_EQ(perm_folder.Get(UNIQUE_CLIENT_TAG), "permfolder"); |
3590 EXPECT_EQ(perm_folder.Get(NON_UNIQUE_NAME), "permitem_renamed"); | 3574 EXPECT_EQ(perm_folder.Get(NON_UNIQUE_NAME), "permitem_renamed"); |
3591 } | 3575 } |
3592 } | 3576 } |
3593 | 3577 |
3594 TEST_F(SyncerTest, ClientTagIllegalUpdateIgnored) { | 3578 TEST_F(SyncerTest, ClientTagIllegalUpdateIgnored) { |
3595 mock_server_->AddUpdateDirectory(1, 0, "permitem1", 1, 10); | 3579 mock_server_->AddUpdateDirectory(1, 0, "permitem1", 1, 10); |
3596 mock_server_->SetLastUpdateClientTag("permfolder"); | 3580 mock_server_->SetLastUpdateClientTag("permfolder"); |
3597 | 3581 |
3598 SyncShareNudge(); | 3582 SyncShareAsDelegate(); |
3599 | 3583 |
3600 { | 3584 { |
3601 ReadTransaction trans(FROM_HERE, directory()); | 3585 ReadTransaction trans(FROM_HERE, directory()); |
3602 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "permfolder"); | 3586 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "permfolder"); |
3603 ASSERT_TRUE(perm_folder.good()); | 3587 ASSERT_TRUE(perm_folder.good()); |
3604 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); | 3588 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); |
3605 EXPECT_FALSE(perm_folder.Get(IS_UNSYNCED)); | 3589 EXPECT_FALSE(perm_folder.Get(IS_UNSYNCED)); |
3606 EXPECT_EQ(perm_folder.Get(UNIQUE_CLIENT_TAG), "permfolder"); | 3590 EXPECT_EQ(perm_folder.Get(UNIQUE_CLIENT_TAG), "permfolder"); |
3607 EXPECT_TRUE(perm_folder.Get(NON_UNIQUE_NAME) == "permitem1"); | 3591 EXPECT_TRUE(perm_folder.Get(NON_UNIQUE_NAME) == "permitem1"); |
3608 EXPECT_TRUE(perm_folder.Get(ID).ServerKnows()); | 3592 EXPECT_TRUE(perm_folder.Get(ID).ServerKnows()); |
3609 } | 3593 } |
3610 | 3594 |
3611 mock_server_->AddUpdateDirectory(1, 0, "permitem_renamed", 10, 100); | 3595 mock_server_->AddUpdateDirectory(1, 0, "permitem_renamed", 10, 100); |
3612 mock_server_->SetLastUpdateClientTag("wrongtag"); | 3596 mock_server_->SetLastUpdateClientTag("wrongtag"); |
3613 SyncShareNudge(); | 3597 SyncShareAsDelegate(); |
3614 | 3598 |
3615 { | 3599 { |
3616 ReadTransaction trans(FROM_HERE, directory()); | 3600 ReadTransaction trans(FROM_HERE, directory()); |
3617 | 3601 |
3618 // This update is rejected because it has the same ID, but a | 3602 // This update is rejected because it has the same ID, but a |
3619 // different tag than one that is already on the client. | 3603 // different tag than one that is already on the client. |
3620 // The client has a ServerKnows ID, which cannot be overwritten. | 3604 // The client has a ServerKnows ID, which cannot be overwritten. |
3621 Entry rejected_update(&trans, GET_BY_CLIENT_TAG, "wrongtag"); | 3605 Entry rejected_update(&trans, GET_BY_CLIENT_TAG, "wrongtag"); |
3622 EXPECT_FALSE(rejected_update.good()); | 3606 EXPECT_FALSE(rejected_update.good()); |
3623 | 3607 |
(...skipping 24 matching lines...) Expand all Loading... |
3648 EXPECT_FALSE(perm_folder.Get(ID).ServerKnows()); | 3632 EXPECT_FALSE(perm_folder.Get(ID).ServerKnows()); |
3649 original_metahandle = perm_folder.Get(META_HANDLE); | 3633 original_metahandle = perm_folder.Get(META_HANDLE); |
3650 } | 3634 } |
3651 | 3635 |
3652 mock_server_->AddUpdateBookmark(1, 0, "permitem_renamed", 10, 100); | 3636 mock_server_->AddUpdateBookmark(1, 0, "permitem_renamed", 10, 100); |
3653 mock_server_->SetLastUpdateClientTag("clientperm"); | 3637 mock_server_->SetLastUpdateClientTag("clientperm"); |
3654 mock_server_->GetMutableLastUpdate()->mutable_specifics()-> | 3638 mock_server_->GetMutableLastUpdate()->mutable_specifics()-> |
3655 CopyFrom(server_bookmark); | 3639 CopyFrom(server_bookmark); |
3656 mock_server_->set_conflict_all_commits(true); | 3640 mock_server_->set_conflict_all_commits(true); |
3657 | 3641 |
3658 SyncShareNudge(); | 3642 SyncShareAsDelegate(); |
3659 // This should cause client tag reunion, preserving the metahandle. | 3643 // This should cause client tag reunion, preserving the metahandle. |
3660 { | 3644 { |
3661 ReadTransaction trans(FROM_HERE, directory()); | 3645 ReadTransaction trans(FROM_HERE, directory()); |
3662 | 3646 |
3663 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "clientperm"); | 3647 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "clientperm"); |
3664 ASSERT_TRUE(perm_folder.good()); | 3648 ASSERT_TRUE(perm_folder.good()); |
3665 EXPECT_FALSE(perm_folder.Get(IS_DEL)); | 3649 EXPECT_FALSE(perm_folder.Get(IS_DEL)); |
3666 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); | 3650 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); |
3667 EXPECT_TRUE(perm_folder.Get(IS_UNSYNCED)); | 3651 EXPECT_TRUE(perm_folder.Get(IS_UNSYNCED)); |
3668 EXPECT_EQ(10, perm_folder.Get(BASE_VERSION)); | 3652 EXPECT_EQ(10, perm_folder.Get(BASE_VERSION)); |
3669 // Entry should have been given the new ID while preserving the | 3653 // Entry should have been given the new ID while preserving the |
3670 // metahandle; client should have won the conflict resolution. | 3654 // metahandle; client should have won the conflict resolution. |
3671 EXPECT_EQ(original_metahandle, perm_folder.Get(META_HANDLE)); | 3655 EXPECT_EQ(original_metahandle, perm_folder.Get(META_HANDLE)); |
3672 EXPECT_EQ("clientperm", perm_folder.Get(UNIQUE_CLIENT_TAG)); | 3656 EXPECT_EQ("clientperm", perm_folder.Get(UNIQUE_CLIENT_TAG)); |
3673 EXPECT_EQ("clientname", perm_folder.Get(NON_UNIQUE_NAME)); | 3657 EXPECT_EQ("clientname", perm_folder.Get(NON_UNIQUE_NAME)); |
3674 EXPECT_EQ(local_bookmark.SerializeAsString(), | 3658 EXPECT_EQ(local_bookmark.SerializeAsString(), |
3675 perm_folder.Get(SPECIFICS).SerializeAsString()); | 3659 perm_folder.Get(SPECIFICS).SerializeAsString()); |
3676 EXPECT_TRUE(perm_folder.Get(ID).ServerKnows()); | 3660 EXPECT_TRUE(perm_folder.Get(ID).ServerKnows()); |
3677 } | 3661 } |
3678 | 3662 |
3679 mock_server_->set_conflict_all_commits(false); | 3663 mock_server_->set_conflict_all_commits(false); |
3680 SyncShareNudge(); | 3664 SyncShareAsDelegate(); |
3681 | 3665 |
3682 // The resolved entry ought to commit cleanly. | 3666 // The resolved entry ought to commit cleanly. |
3683 { | 3667 { |
3684 ReadTransaction trans(FROM_HERE, directory()); | 3668 ReadTransaction trans(FROM_HERE, directory()); |
3685 | 3669 |
3686 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "clientperm"); | 3670 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "clientperm"); |
3687 ASSERT_TRUE(perm_folder.good()); | 3671 ASSERT_TRUE(perm_folder.good()); |
3688 EXPECT_FALSE(perm_folder.Get(IS_DEL)); | 3672 EXPECT_FALSE(perm_folder.Get(IS_DEL)); |
3689 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); | 3673 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); |
3690 EXPECT_FALSE(perm_folder.Get(IS_UNSYNCED)); | 3674 EXPECT_FALSE(perm_folder.Get(IS_UNSYNCED)); |
(...skipping 18 matching lines...) Expand all Loading... |
3709 perm_folder.Put(UNIQUE_CLIENT_TAG, "clientperm"); | 3693 perm_folder.Put(UNIQUE_CLIENT_TAG, "clientperm"); |
3710 perm_folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 3694 perm_folder.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
3711 perm_folder.Put(IS_UNSYNCED, true); | 3695 perm_folder.Put(IS_UNSYNCED, true); |
3712 perm_folder.Put(IS_DEL, true); | 3696 perm_folder.Put(IS_DEL, true); |
3713 } | 3697 } |
3714 | 3698 |
3715 mock_server_->AddUpdateDirectory(1, 0, "permitem_renamed", 10, 100); | 3699 mock_server_->AddUpdateDirectory(1, 0, "permitem_renamed", 10, 100); |
3716 mock_server_->SetLastUpdateClientTag("clientperm"); | 3700 mock_server_->SetLastUpdateClientTag("clientperm"); |
3717 mock_server_->set_conflict_all_commits(true); | 3701 mock_server_->set_conflict_all_commits(true); |
3718 | 3702 |
3719 SyncShareNudge(); | 3703 SyncShareAsDelegate(); |
3720 // This should cause client tag overwrite. | 3704 // This should cause client tag overwrite. |
3721 { | 3705 { |
3722 ReadTransaction trans(FROM_HERE, directory()); | 3706 ReadTransaction trans(FROM_HERE, directory()); |
3723 | 3707 |
3724 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "clientperm"); | 3708 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "clientperm"); |
3725 ASSERT_TRUE(perm_folder.good()); | 3709 ASSERT_TRUE(perm_folder.good()); |
3726 ASSERT_TRUE(perm_folder.Get(ID).ServerKnows()); | 3710 ASSERT_TRUE(perm_folder.Get(ID).ServerKnows()); |
3727 EXPECT_TRUE(perm_folder.Get(IS_DEL)); | 3711 EXPECT_TRUE(perm_folder.Get(IS_DEL)); |
3728 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); | 3712 EXPECT_FALSE(perm_folder.Get(IS_UNAPPLIED_UPDATE)); |
3729 EXPECT_TRUE(perm_folder.Get(IS_UNSYNCED)); | 3713 EXPECT_TRUE(perm_folder.Get(IS_UNSYNCED)); |
3730 EXPECT_EQ(perm_folder.Get(BASE_VERSION), 10); | 3714 EXPECT_EQ(perm_folder.Get(BASE_VERSION), 10); |
3731 EXPECT_EQ(perm_folder.Get(UNIQUE_CLIENT_TAG), "clientperm"); | 3715 EXPECT_EQ(perm_folder.Get(UNIQUE_CLIENT_TAG), "clientperm"); |
3732 } | 3716 } |
3733 } | 3717 } |
3734 | 3718 |
3735 TEST_F(SyncerTest, ClientTagUpdateClashesWithLocalEntry) { | 3719 TEST_F(SyncerTest, ClientTagUpdateClashesWithLocalEntry) { |
3736 // This test is written assuming that ID comparison | 3720 // This test is written assuming that ID comparison |
3737 // will work out in a particular way. | 3721 // will work out in a particular way. |
3738 EXPECT_TRUE(ids_.FromNumber(1) < ids_.FromNumber(2)); | 3722 EXPECT_TRUE(ids_.FromNumber(1) < ids_.FromNumber(2)); |
3739 EXPECT_TRUE(ids_.FromNumber(3) < ids_.FromNumber(4)); | 3723 EXPECT_TRUE(ids_.FromNumber(3) < ids_.FromNumber(4)); |
3740 | 3724 |
3741 mock_server_->AddUpdateBookmark(1, 0, "One", 10, 100); | 3725 mock_server_->AddUpdateBookmark(1, 0, "One", 10, 100); |
3742 mock_server_->SetLastUpdateClientTag("tag1"); | 3726 mock_server_->SetLastUpdateClientTag("tag1"); |
3743 mock_server_->AddUpdateBookmark(4, 0, "Four", 11, 110); | 3727 mock_server_->AddUpdateBookmark(4, 0, "Four", 11, 110); |
3744 mock_server_->SetLastUpdateClientTag("tag2"); | 3728 mock_server_->SetLastUpdateClientTag("tag2"); |
3745 | 3729 |
3746 mock_server_->set_conflict_all_commits(true); | 3730 mock_server_->set_conflict_all_commits(true); |
3747 | 3731 |
3748 SyncShareNudge(); | 3732 SyncShareAsDelegate(); |
3749 int64 tag1_metahandle = syncable::kInvalidMetaHandle; | 3733 int64 tag1_metahandle = syncable::kInvalidMetaHandle; |
3750 int64 tag2_metahandle = syncable::kInvalidMetaHandle; | 3734 int64 tag2_metahandle = syncable::kInvalidMetaHandle; |
3751 // This should cause client tag overwrite. | 3735 // This should cause client tag overwrite. |
3752 { | 3736 { |
3753 ReadTransaction trans(FROM_HERE, directory()); | 3737 ReadTransaction trans(FROM_HERE, directory()); |
3754 | 3738 |
3755 Entry tag1(&trans, GET_BY_CLIENT_TAG, "tag1"); | 3739 Entry tag1(&trans, GET_BY_CLIENT_TAG, "tag1"); |
3756 ASSERT_TRUE(tag1.good()); | 3740 ASSERT_TRUE(tag1.good()); |
3757 ASSERT_TRUE(tag1.Get(ID).ServerKnows()); | 3741 ASSERT_TRUE(tag1.Get(ID).ServerKnows()); |
3758 ASSERT_TRUE(ids_.FromNumber(1) == tag1.Get(ID)); | 3742 ASSERT_TRUE(ids_.FromNumber(1) == tag1.Get(ID)); |
(...skipping 19 matching lines...) Expand all Loading... |
3778 | 3762 |
3779 syncable::Directory::ChildHandles children; | 3763 syncable::Directory::ChildHandles children; |
3780 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); | 3764 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); |
3781 ASSERT_EQ(2U, children.size()); | 3765 ASSERT_EQ(2U, children.size()); |
3782 } | 3766 } |
3783 | 3767 |
3784 mock_server_->AddUpdateBookmark(2, 0, "Two", 12, 120); | 3768 mock_server_->AddUpdateBookmark(2, 0, "Two", 12, 120); |
3785 mock_server_->SetLastUpdateClientTag("tag1"); | 3769 mock_server_->SetLastUpdateClientTag("tag1"); |
3786 mock_server_->AddUpdateBookmark(3, 0, "Three", 13, 130); | 3770 mock_server_->AddUpdateBookmark(3, 0, "Three", 13, 130); |
3787 mock_server_->SetLastUpdateClientTag("tag2"); | 3771 mock_server_->SetLastUpdateClientTag("tag2"); |
3788 SyncShareNudge(); | 3772 SyncShareAsDelegate(); |
3789 | 3773 |
3790 { | 3774 { |
3791 ReadTransaction trans(FROM_HERE, directory()); | 3775 ReadTransaction trans(FROM_HERE, directory()); |
3792 | 3776 |
3793 Entry tag1(&trans, GET_BY_CLIENT_TAG, "tag1"); | 3777 Entry tag1(&trans, GET_BY_CLIENT_TAG, "tag1"); |
3794 ASSERT_TRUE(tag1.good()); | 3778 ASSERT_TRUE(tag1.good()); |
3795 ASSERT_TRUE(tag1.Get(ID).ServerKnows()); | 3779 ASSERT_TRUE(tag1.Get(ID).ServerKnows()); |
3796 ASSERT_TRUE(ids_.FromNumber(1) == tag1.Get(ID)) | 3780 ASSERT_TRUE(ids_.FromNumber(1) == tag1.Get(ID)) |
3797 << "ID 1 should be kept, since it was less than ID 2."; | 3781 << "ID 1 should be kept, since it was less than ID 2."; |
3798 EXPECT_FALSE(tag1.Get(IS_DEL)); | 3782 EXPECT_FALSE(tag1.Get(IS_DEL)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3850 mock_server_->SetLastUpdateClientTag("tag c"); | 3834 mock_server_->SetLastUpdateClientTag("tag c"); |
3851 mock_server_->AddUpdateBookmark(202, 0, "Two C", 19, 190); | 3835 mock_server_->AddUpdateBookmark(202, 0, "Two C", 19, 190); |
3852 mock_server_->SetLastUpdateClientTag("tag c"); | 3836 mock_server_->SetLastUpdateClientTag("tag c"); |
3853 mock_server_->AddUpdateBookmark(204, 0, "Three C", 20, 200); | 3837 mock_server_->AddUpdateBookmark(204, 0, "Three C", 20, 200); |
3854 mock_server_->SetLastUpdateClientTag("tag c"); | 3838 mock_server_->SetLastUpdateClientTag("tag c"); |
3855 mock_server_->AddUpdateBookmark(201, 0, "Four C", 21, 210); | 3839 mock_server_->AddUpdateBookmark(201, 0, "Four C", 21, 210); |
3856 mock_server_->SetLastUpdateClientTag("tag c"); // Least ID: winner. | 3840 mock_server_->SetLastUpdateClientTag("tag c"); // Least ID: winner. |
3857 | 3841 |
3858 mock_server_->set_conflict_all_commits(true); | 3842 mock_server_->set_conflict_all_commits(true); |
3859 | 3843 |
3860 SyncShareNudge(); | 3844 SyncShareAsDelegate(); |
3861 // This should cause client tag overwrite. | 3845 // This should cause client tag overwrite. |
3862 { | 3846 { |
3863 ReadTransaction trans(FROM_HERE, directory()); | 3847 ReadTransaction trans(FROM_HERE, directory()); |
3864 | 3848 |
3865 Entry tag_a(&trans, GET_BY_CLIENT_TAG, "tag a"); | 3849 Entry tag_a(&trans, GET_BY_CLIENT_TAG, "tag a"); |
3866 ASSERT_TRUE(tag_a.good()); | 3850 ASSERT_TRUE(tag_a.good()); |
3867 EXPECT_TRUE(tag_a.Get(ID).ServerKnows()); | 3851 EXPECT_TRUE(tag_a.Get(ID).ServerKnows()); |
3868 EXPECT_EQ(ids_.FromNumber(1), tag_a.Get(ID)); | 3852 EXPECT_EQ(ids_.FromNumber(1), tag_a.Get(ID)); |
3869 EXPECT_FALSE(tag_a.Get(IS_DEL)); | 3853 EXPECT_FALSE(tag_a.Get(IS_DEL)); |
3870 EXPECT_FALSE(tag_a.Get(IS_UNAPPLIED_UPDATE)); | 3854 EXPECT_FALSE(tag_a.Get(IS_UNAPPLIED_UPDATE)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3918 EXPECT_FALSE(tag_alpha.good()); | 3902 EXPECT_FALSE(tag_alpha.good()); |
3919 Entry tag_bob(&trans, GET_BY_SERVER_TAG, "bob"); | 3903 Entry tag_bob(&trans, GET_BY_SERVER_TAG, "bob"); |
3920 EXPECT_FALSE(tag_bob.good()); | 3904 EXPECT_FALSE(tag_bob.good()); |
3921 } | 3905 } |
3922 | 3906 |
3923 // Now download some tagged items as updates. | 3907 // Now download some tagged items as updates. |
3924 mock_server_->AddUpdateDirectory(1, 0, "update1", 1, 10); | 3908 mock_server_->AddUpdateDirectory(1, 0, "update1", 1, 10); |
3925 mock_server_->SetLastUpdateServerTag("alpha"); | 3909 mock_server_->SetLastUpdateServerTag("alpha"); |
3926 mock_server_->AddUpdateDirectory(2, 0, "update2", 2, 20); | 3910 mock_server_->AddUpdateDirectory(2, 0, "update2", 2, 20); |
3927 mock_server_->SetLastUpdateServerTag("bob"); | 3911 mock_server_->SetLastUpdateServerTag("bob"); |
3928 SyncShareNudge(); | 3912 SyncShareAsDelegate(); |
3929 | 3913 |
3930 { | 3914 { |
3931 ReadTransaction trans(FROM_HERE, directory()); | 3915 ReadTransaction trans(FROM_HERE, directory()); |
3932 | 3916 |
3933 // The new items should be applied as new entries, and we should be able | 3917 // The new items should be applied as new entries, and we should be able |
3934 // to look them up by their tag values. | 3918 // to look them up by their tag values. |
3935 Entry tag_alpha(&trans, GET_BY_SERVER_TAG, "alpha"); | 3919 Entry tag_alpha(&trans, GET_BY_SERVER_TAG, "alpha"); |
3936 ASSERT_TRUE(tag_alpha.good()); | 3920 ASSERT_TRUE(tag_alpha.good()); |
3937 ASSERT_TRUE(!tag_alpha.Get(IS_DEL)); | 3921 ASSERT_TRUE(!tag_alpha.Get(IS_DEL)); |
3938 ASSERT_TRUE(tag_alpha.Get(UNIQUE_SERVER_TAG) == "alpha"); | 3922 ASSERT_TRUE(tag_alpha.Get(UNIQUE_SERVER_TAG) == "alpha"); |
(...skipping 10 matching lines...) Expand all Loading... |
3949 ASSERT_TRUE(hurdle.Get(UNIQUE_SERVER_TAG).empty()); | 3933 ASSERT_TRUE(hurdle.Get(UNIQUE_SERVER_TAG).empty()); |
3950 ASSERT_TRUE(hurdle.Get(NON_UNIQUE_NAME) == "bob"); | 3934 ASSERT_TRUE(hurdle.Get(NON_UNIQUE_NAME) == "bob"); |
3951 } | 3935 } |
3952 } | 3936 } |
3953 | 3937 |
3954 TEST_F(SyncerTest, GetUpdatesSetsRequestedTypes) { | 3938 TEST_F(SyncerTest, GetUpdatesSetsRequestedTypes) { |
3955 // The expectations of this test happen in the MockConnectionManager's | 3939 // The expectations of this test happen in the MockConnectionManager's |
3956 // GetUpdates handler. EnableDatatype sets the expectation value from our | 3940 // GetUpdates handler. EnableDatatype sets the expectation value from our |
3957 // set of enabled/disabled datatypes. | 3941 // set of enabled/disabled datatypes. |
3958 EnableDatatype(syncable::BOOKMARKS); | 3942 EnableDatatype(syncable::BOOKMARKS); |
3959 SyncShareNudge(); | 3943 SyncShareAsDelegate(); |
3960 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 3944 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
3961 | 3945 |
3962 EnableDatatype(syncable::AUTOFILL); | 3946 EnableDatatype(syncable::AUTOFILL); |
3963 SyncShareNudge(); | 3947 SyncShareAsDelegate(); |
3964 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 3948 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
3965 | 3949 |
3966 EnableDatatype(syncable::PREFERENCES); | 3950 EnableDatatype(syncable::PREFERENCES); |
3967 SyncShareNudge(); | 3951 SyncShareAsDelegate(); |
3968 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 3952 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
3969 | 3953 |
3970 DisableDatatype(syncable::BOOKMARKS); | 3954 DisableDatatype(syncable::BOOKMARKS); |
3971 SyncShareNudge(); | 3955 SyncShareAsDelegate(); |
3972 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 3956 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
3973 | 3957 |
3974 DisableDatatype(syncable::AUTOFILL); | 3958 DisableDatatype(syncable::AUTOFILL); |
3975 SyncShareNudge(); | 3959 SyncShareAsDelegate(); |
3976 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 3960 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
3977 | 3961 |
3978 DisableDatatype(syncable::PREFERENCES); | 3962 DisableDatatype(syncable::PREFERENCES); |
3979 EnableDatatype(syncable::AUTOFILL); | 3963 EnableDatatype(syncable::AUTOFILL); |
3980 SyncShareNudge(); | 3964 SyncShareAsDelegate(); |
3981 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 3965 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
3982 } | 3966 } |
3983 | 3967 |
3984 // A typical scenario: server and client each have one update for the other. | |
3985 // It is the "happy path" alternative to the test below. | |
3986 TEST_F(SyncerTest, UpdateThenCommit) { | |
3987 syncable::Id to_receive = ids_.NewServerId(); | |
3988 syncable::Id to_commit = ids_.NewLocalId(); | |
3989 | |
3990 mock_server_->AddUpdateDirectory(to_receive, ids_.root(), "x", 1, 10); | |
3991 int64 commit_handle = CreateUnsyncedDirectory("y", to_commit); | |
3992 SyncShareNudge(); | |
3993 | |
3994 ReadTransaction trans(FROM_HERE, directory()); | |
3995 | |
3996 Entry received(&trans, GET_BY_ID, to_receive); | |
3997 ASSERT_TRUE(received.good()); | |
3998 EXPECT_FALSE(received.Get(IS_UNSYNCED)); | |
3999 EXPECT_FALSE(received.Get(IS_UNAPPLIED_UPDATE)); | |
4000 | |
4001 Entry committed(&trans, GET_BY_HANDLE, commit_handle); | |
4002 ASSERT_TRUE(committed.good()); | |
4003 EXPECT_FALSE(committed.Get(IS_UNSYNCED)); | |
4004 EXPECT_FALSE(committed.Get(IS_UNAPPLIED_UPDATE)); | |
4005 } | |
4006 | |
4007 // Same as above, but this time we fail to download updates. | |
4008 // We should not attempt to commit anything unless we successfully downloaded | |
4009 // updates, otherwise we risk causing a server-side conflict. | |
4010 TEST_F(SyncerTest, UpdateFailsThenDontCommit) { | |
4011 syncable::Id to_receive = ids_.NewServerId(); | |
4012 syncable::Id to_commit = ids_.NewLocalId(); | |
4013 | |
4014 mock_server_->AddUpdateDirectory(to_receive, ids_.root(), "x", 1, 10); | |
4015 int64 commit_handle = CreateUnsyncedDirectory("y", to_commit); | |
4016 mock_server_->FailNextPostBufferToPathCall(); | |
4017 SyncShareNudge(); | |
4018 | |
4019 ReadTransaction trans(FROM_HERE, directory()); | |
4020 | |
4021 // We did not receive this update. | |
4022 Entry received(&trans, GET_BY_ID, to_receive); | |
4023 ASSERT_FALSE(received.good()); | |
4024 | |
4025 // And our local update remains unapplied. | |
4026 Entry committed(&trans, GET_BY_HANDLE, commit_handle); | |
4027 ASSERT_TRUE(committed.good()); | |
4028 EXPECT_TRUE(committed.Get(IS_UNSYNCED)); | |
4029 EXPECT_FALSE(committed.Get(IS_UNAPPLIED_UPDATE)); | |
4030 | |
4031 // Inform the Mock we won't be fetching all updates. | |
4032 mock_server_->ClearUpdatesQueue(); | |
4033 } | |
4034 | |
4035 // Downloads two updates and applies them successfully. | |
4036 // This is the "happy path" alternative to the test below. | |
4037 TEST_F(SyncerTest, ConfigureDownloadsTwoBatchesSuccess) { | |
4038 syncable::Id node1 = ids_.NewServerId(); | |
4039 syncable::Id node2 = ids_.NewServerId(); | |
4040 | |
4041 // Construct the first GetUpdates response. | |
4042 mock_server_->AddUpdateDirectory(node1, ids_.root(), "one", 1, 10); | |
4043 mock_server_->SetChangesRemaining(1); | |
4044 mock_server_->NextUpdateBatch(); | |
4045 | |
4046 // Construct the second GetUpdates response. | |
4047 mock_server_->AddUpdateDirectory(node2, ids_.root(), "two", 1, 20); | |
4048 | |
4049 SyncShareConfigure(); | |
4050 | |
4051 ReadTransaction trans(FROM_HERE, directory()); | |
4052 // Both nodes should be downloaded and applied. | |
4053 | |
4054 Entry n1(&trans, GET_BY_ID, node1); | |
4055 ASSERT_TRUE(n1.good()); | |
4056 EXPECT_FALSE(n1.Get(IS_UNAPPLIED_UPDATE)); | |
4057 | |
4058 Entry n2(&trans, GET_BY_ID, node2); | |
4059 ASSERT_TRUE(n2.good()); | |
4060 EXPECT_FALSE(n2.Get(IS_UNAPPLIED_UPDATE)); | |
4061 } | |
4062 | |
4063 // Same as the above case, but this time the second batch fails to download. | |
4064 TEST_F(SyncerTest, ConfigureFailsDontApplyUpdates) { | |
4065 syncable::Id node1 = ids_.NewServerId(); | |
4066 syncable::Id node2 = ids_.NewServerId(); | |
4067 | |
4068 // The scenario: we have two batches of updates with one update each. A | |
4069 // normal confgure step would download all the updates one batch at a time and | |
4070 // apply them. This configure will succeed in downloading the first batch | |
4071 // then fail when downloading the second. | |
4072 mock_server_->FailNthPostBufferToPathCall(2); | |
4073 | |
4074 // Construct the first GetUpdates response. | |
4075 mock_server_->AddUpdateDirectory(node1, ids_.root(), "one", 1, 10); | |
4076 mock_server_->SetChangesRemaining(1); | |
4077 mock_server_->NextUpdateBatch(); | |
4078 | |
4079 // Consutrct the second GetUpdates response. | |
4080 mock_server_->AddUpdateDirectory(node2, ids_.root(), "two", 1, 20); | |
4081 | |
4082 SyncShareConfigure(); | |
4083 | |
4084 ReadTransaction trans(FROM_HERE, directory()); | |
4085 | |
4086 // The first node was downloaded, but not applied. | |
4087 Entry n1(&trans, GET_BY_ID, node1); | |
4088 ASSERT_TRUE(n1.good()); | |
4089 EXPECT_TRUE(n1.Get(IS_UNAPPLIED_UPDATE)); | |
4090 | |
4091 // The second node was not downloaded. | |
4092 Entry n2(&trans, GET_BY_ID, node2); | |
4093 EXPECT_FALSE(n2.good()); | |
4094 | |
4095 // One update remains undownloaded. | |
4096 mock_server_->ClearUpdatesQueue(); | |
4097 } | |
4098 | |
4099 // Test what happens if a client deletes, then recreates, an object very | 3968 // Test what happens if a client deletes, then recreates, an object very |
4100 // quickly. It is possible that the deletion gets sent as a commit, and | 3969 // quickly. It is possible that the deletion gets sent as a commit, and |
4101 // the undelete happens during the commit request. The principle here | 3970 // the undelete happens during the commit request. The principle here |
4102 // is that with a single committing client, conflicts should never | 3971 // is that with a single committing client, conflicts should never |
4103 // be encountered, and a client encountering its past actions during | 3972 // be encountered, and a client encountering its past actions during |
4104 // getupdates should never feed back to override later actions. | 3973 // getupdates should never feed back to override later actions. |
4105 // | 3974 // |
4106 // In cases of ordering A-F below, the outcome should be the same. | 3975 // In cases of ordering A-F below, the outcome should be the same. |
4107 // Exercised by UndeleteDuringCommit: | 3976 // Exercised by UndeleteDuringCommit: |
4108 // A. Delete - commit - undelete - commitresponse. | 3977 // A. Delete - commit - undelete - commitresponse. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4226 } | 4095 } |
4227 | 4096 |
4228 protected: | 4097 protected: |
4229 const std::string client_tag_; | 4098 const std::string client_tag_; |
4230 int64 metahandle_; | 4099 int64 metahandle_; |
4231 }; | 4100 }; |
4232 | 4101 |
4233 TEST_F(SyncerUndeletionTest, UndeleteDuringCommit) { | 4102 TEST_F(SyncerUndeletionTest, UndeleteDuringCommit) { |
4234 Create(); | 4103 Create(); |
4235 ExpectUnsyncedCreation(); | 4104 ExpectUnsyncedCreation(); |
4236 SyncShareNudge(); | 4105 SyncShareAsDelegate(); |
4237 | 4106 |
4238 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4107 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4239 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4108 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4240 ExpectSyncedAndCreated(); | 4109 ExpectSyncedAndCreated(); |
4241 | 4110 |
4242 // Delete, begin committing the delete, then undelete while committing. | 4111 // Delete, begin committing the delete, then undelete while committing. |
4243 Delete(); | 4112 Delete(); |
4244 ExpectUnsyncedDeletion(); | 4113 ExpectUnsyncedDeletion(); |
4245 mock_server_->SetMidCommitCallback( | 4114 mock_server_->SetMidCommitCallback( |
4246 base::Bind(&SyncerUndeletionTest::Undelete, base::Unretained(this))); | 4115 base::Bind(&SyncerUndeletionTest::Undelete, base::Unretained(this))); |
4247 SyncShareNudge(); | 4116 SyncShareAsDelegate(); |
4248 | 4117 |
4249 // The item ought to exist as an unsynced undeletion (meaning, | 4118 // The item ought to exist as an unsynced undeletion (meaning, |
4250 // we think that the next commit ought to be a recreation commit). | 4119 // we think that the next commit ought to be a recreation commit). |
4251 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4120 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4252 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4121 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4253 ExpectUnsyncedUndeletion(); | 4122 ExpectUnsyncedUndeletion(); |
4254 | 4123 |
4255 // Now, encounter a GetUpdates corresponding to the deletion from | 4124 // Now, encounter a GetUpdates corresponding to the deletion from |
4256 // the server. The undeletion should prevail again and be committed. | 4125 // the server. The undeletion should prevail again and be committed. |
4257 // None of this should trigger any conflict detection -- it is perfectly | 4126 // None of this should trigger any conflict detection -- it is perfectly |
4258 // normal to recieve updates from our own commits. | 4127 // normal to recieve updates from our own commits. |
4259 mock_server_->SetMidCommitCallback(base::Closure()); | 4128 mock_server_->SetMidCommitCallback(base::Closure()); |
4260 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); | 4129 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); |
4261 SyncShareNudge(); | 4130 SyncShareAsDelegate(); |
4262 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4131 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4263 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4132 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4264 ExpectSyncedAndCreated(); | 4133 ExpectSyncedAndCreated(); |
4265 } | 4134 } |
4266 | 4135 |
4267 TEST_F(SyncerUndeletionTest, UndeleteBeforeCommit) { | 4136 TEST_F(SyncerUndeletionTest, UndeleteBeforeCommit) { |
4268 Create(); | 4137 Create(); |
4269 ExpectUnsyncedCreation(); | 4138 ExpectUnsyncedCreation(); |
4270 SyncShareNudge(); | 4139 SyncShareAsDelegate(); |
4271 | 4140 |
4272 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4141 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4273 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4142 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4274 ExpectSyncedAndCreated(); | 4143 ExpectSyncedAndCreated(); |
4275 | 4144 |
4276 // Delete and undelete, then sync to pick up the result. | 4145 // Delete and undelete, then sync to pick up the result. |
4277 Delete(); | 4146 Delete(); |
4278 ExpectUnsyncedDeletion(); | 4147 ExpectUnsyncedDeletion(); |
4279 Undelete(); | 4148 Undelete(); |
4280 ExpectUnsyncedEdit(); // Edit, not undelete: server thinks it exists. | 4149 ExpectUnsyncedEdit(); // Edit, not undelete: server thinks it exists. |
4281 SyncShareNudge(); | 4150 SyncShareAsDelegate(); |
4282 | 4151 |
4283 // The item ought to have committed successfully. | 4152 // The item ought to have committed successfully. |
4284 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4153 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4285 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4154 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4286 ExpectSyncedAndCreated(); | 4155 ExpectSyncedAndCreated(); |
4287 EXPECT_EQ(2, Get(metahandle_, BASE_VERSION)); | 4156 EXPECT_EQ(2, Get(metahandle_, BASE_VERSION)); |
4288 | 4157 |
4289 // Now, encounter a GetUpdates corresponding to the just-committed | 4158 // Now, encounter a GetUpdates corresponding to the just-committed |
4290 // update. | 4159 // update. |
4291 mock_server_->AddUpdateFromLastCommit(); | 4160 mock_server_->AddUpdateFromLastCommit(); |
4292 SyncShareNudge(); | 4161 SyncShareAsDelegate(); |
4293 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4162 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4294 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4163 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4295 ExpectSyncedAndCreated(); | 4164 ExpectSyncedAndCreated(); |
4296 } | 4165 } |
4297 | 4166 |
4298 TEST_F(SyncerUndeletionTest, UndeleteAfterCommitButBeforeGetUpdates) { | 4167 TEST_F(SyncerUndeletionTest, UndeleteAfterCommitButBeforeGetUpdates) { |
4299 Create(); | 4168 Create(); |
4300 ExpectUnsyncedCreation(); | 4169 ExpectUnsyncedCreation(); |
4301 SyncShareNudge(); | 4170 SyncShareAsDelegate(); |
4302 | 4171 |
4303 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4172 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4304 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4173 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4305 ExpectSyncedAndCreated(); | 4174 ExpectSyncedAndCreated(); |
4306 | 4175 |
4307 // Delete and commit. | 4176 // Delete and commit. |
4308 Delete(); | 4177 Delete(); |
4309 ExpectUnsyncedDeletion(); | 4178 ExpectUnsyncedDeletion(); |
4310 SyncShareNudge(); | 4179 SyncShareAsDelegate(); |
4311 | 4180 |
4312 // The item ought to have committed successfully. | 4181 // The item ought to have committed successfully. |
4313 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4182 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4314 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4183 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4315 ExpectSyncedAndDeleted(); | 4184 ExpectSyncedAndDeleted(); |
4316 | 4185 |
4317 // Before the GetUpdates, the item is locally undeleted. | 4186 // Before the GetUpdates, the item is locally undeleted. |
4318 Undelete(); | 4187 Undelete(); |
4319 ExpectUnsyncedUndeletion(); | 4188 ExpectUnsyncedUndeletion(); |
4320 | 4189 |
4321 // Now, encounter a GetUpdates corresponding to the just-committed | 4190 // Now, encounter a GetUpdates corresponding to the just-committed |
4322 // deletion update. The undeletion should prevail. | 4191 // deletion update. The undeletion should prevail. |
4323 mock_server_->AddUpdateFromLastCommit(); | 4192 mock_server_->AddUpdateFromLastCommit(); |
4324 SyncShareNudge(); | 4193 SyncShareAsDelegate(); |
4325 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4194 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4326 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4195 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4327 ExpectSyncedAndCreated(); | 4196 ExpectSyncedAndCreated(); |
4328 } | 4197 } |
4329 | 4198 |
4330 TEST_F(SyncerUndeletionTest, UndeleteAfterDeleteAndGetUpdates) { | 4199 TEST_F(SyncerUndeletionTest, UndeleteAfterDeleteAndGetUpdates) { |
4331 Create(); | 4200 Create(); |
4332 ExpectUnsyncedCreation(); | 4201 ExpectUnsyncedCreation(); |
4333 SyncShareNudge(); | 4202 SyncShareAsDelegate(); |
4334 | 4203 |
4335 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4204 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4336 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4205 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4337 ExpectSyncedAndCreated(); | 4206 ExpectSyncedAndCreated(); |
4338 | 4207 |
4339 mock_server_->AddUpdateFromLastCommit(); | 4208 mock_server_->AddUpdateFromLastCommit(); |
4340 SyncShareNudge(); | 4209 SyncShareAsDelegate(); |
4341 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4210 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4342 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4211 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4343 ExpectSyncedAndCreated(); | 4212 ExpectSyncedAndCreated(); |
4344 | 4213 |
4345 // Delete and commit. | 4214 // Delete and commit. |
4346 Delete(); | 4215 Delete(); |
4347 ExpectUnsyncedDeletion(); | 4216 ExpectUnsyncedDeletion(); |
4348 SyncShareNudge(); | 4217 SyncShareAsDelegate(); |
4349 | 4218 |
4350 // The item ought to have committed successfully. | 4219 // The item ought to have committed successfully. |
4351 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4220 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4352 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4221 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4353 ExpectSyncedAndDeleted(); | 4222 ExpectSyncedAndDeleted(); |
4354 | 4223 |
4355 // Now, encounter a GetUpdates corresponding to the just-committed | 4224 // Now, encounter a GetUpdates corresponding to the just-committed |
4356 // deletion update. Should be consistent. | 4225 // deletion update. Should be consistent. |
4357 mock_server_->AddUpdateFromLastCommit(); | 4226 mock_server_->AddUpdateFromLastCommit(); |
4358 SyncShareNudge(); | 4227 SyncShareAsDelegate(); |
4359 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4228 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4360 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4229 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4361 ExpectSyncedAndDeleted(); | 4230 ExpectSyncedAndDeleted(); |
4362 | 4231 |
4363 // After the GetUpdates, the item is locally undeleted. | 4232 // After the GetUpdates, the item is locally undeleted. |
4364 Undelete(); | 4233 Undelete(); |
4365 ExpectUnsyncedUndeletion(); | 4234 ExpectUnsyncedUndeletion(); |
4366 | 4235 |
4367 // Now, encounter a GetUpdates corresponding to the just-committed | 4236 // Now, encounter a GetUpdates corresponding to the just-committed |
4368 // deletion update. The undeletion should prevail. | 4237 // deletion update. The undeletion should prevail. |
4369 SyncShareNudge(); | 4238 SyncShareAsDelegate(); |
4370 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4239 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4371 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4240 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4372 ExpectSyncedAndCreated(); | 4241 ExpectSyncedAndCreated(); |
4373 } | 4242 } |
4374 | 4243 |
4375 // Test processing of undeletion GetUpdateses. | 4244 // Test processing of undeletion GetUpdateses. |
4376 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletes) { | 4245 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletes) { |
4377 Create(); | 4246 Create(); |
4378 ExpectUnsyncedCreation(); | 4247 ExpectUnsyncedCreation(); |
4379 SyncShareNudge(); | 4248 SyncShareAsDelegate(); |
4380 | 4249 |
4381 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4250 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4382 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4251 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4383 ExpectSyncedAndCreated(); | 4252 ExpectSyncedAndCreated(); |
4384 | 4253 |
4385 // Add a delete from the server. | 4254 // Add a delete from the server. |
4386 mock_server_->AddUpdateFromLastCommit(); | 4255 mock_server_->AddUpdateFromLastCommit(); |
4387 SyncShareNudge(); | 4256 SyncShareAsDelegate(); |
4388 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4257 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4389 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4258 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4390 ExpectSyncedAndCreated(); | 4259 ExpectSyncedAndCreated(); |
4391 | 4260 |
4392 // Some other client deletes the item. | 4261 // Some other client deletes the item. |
4393 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); | 4262 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); |
4394 SyncShareNudge(); | 4263 SyncShareAsDelegate(); |
4395 | 4264 |
4396 // The update ought to have applied successfully. | 4265 // The update ought to have applied successfully. |
4397 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4266 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4398 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4267 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4399 ExpectSyncedAndDeleted(); | 4268 ExpectSyncedAndDeleted(); |
4400 | 4269 |
4401 // Undelete it locally. | 4270 // Undelete it locally. |
4402 Undelete(); | 4271 Undelete(); |
4403 ExpectUnsyncedUndeletion(); | 4272 ExpectUnsyncedUndeletion(); |
4404 SyncShareNudge(); | 4273 SyncShareAsDelegate(); |
4405 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4274 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4406 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4275 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4407 ExpectSyncedAndCreated(); | 4276 ExpectSyncedAndCreated(); |
4408 | 4277 |
4409 // Now, encounter a GetUpdates corresponding to the just-committed | 4278 // Now, encounter a GetUpdates corresponding to the just-committed |
4410 // deletion update. The undeletion should prevail. | 4279 // deletion update. The undeletion should prevail. |
4411 mock_server_->AddUpdateFromLastCommit(); | 4280 mock_server_->AddUpdateFromLastCommit(); |
4412 SyncShareNudge(); | 4281 SyncShareAsDelegate(); |
4413 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4282 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4414 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4283 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4415 ExpectSyncedAndCreated(); | 4284 ExpectSyncedAndCreated(); |
4416 } | 4285 } |
4417 | 4286 |
4418 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletesImmediately) { | 4287 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletesImmediately) { |
4419 Create(); | 4288 Create(); |
4420 ExpectUnsyncedCreation(); | 4289 ExpectUnsyncedCreation(); |
4421 SyncShareNudge(); | 4290 SyncShareAsDelegate(); |
4422 | 4291 |
4423 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4292 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4424 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4293 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4425 ExpectSyncedAndCreated(); | 4294 ExpectSyncedAndCreated(); |
4426 | 4295 |
4427 // Some other client deletes the item before we get a chance | 4296 // Some other client deletes the item before we get a chance |
4428 // to GetUpdates our original request. | 4297 // to GetUpdates our original request. |
4429 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); | 4298 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); |
4430 SyncShareNudge(); | 4299 SyncShareAsDelegate(); |
4431 | 4300 |
4432 // The update ought to have applied successfully. | 4301 // The update ought to have applied successfully. |
4433 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4302 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4434 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4303 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4435 ExpectSyncedAndDeleted(); | 4304 ExpectSyncedAndDeleted(); |
4436 | 4305 |
4437 // Undelete it locally. | 4306 // Undelete it locally. |
4438 Undelete(); | 4307 Undelete(); |
4439 ExpectUnsyncedUndeletion(); | 4308 ExpectUnsyncedUndeletion(); |
4440 SyncShareNudge(); | 4309 SyncShareAsDelegate(); |
4441 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4310 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4442 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4311 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4443 ExpectSyncedAndCreated(); | 4312 ExpectSyncedAndCreated(); |
4444 | 4313 |
4445 // Now, encounter a GetUpdates corresponding to the just-committed | 4314 // Now, encounter a GetUpdates corresponding to the just-committed |
4446 // deletion update. The undeletion should prevail. | 4315 // deletion update. The undeletion should prevail. |
4447 mock_server_->AddUpdateFromLastCommit(); | 4316 mock_server_->AddUpdateFromLastCommit(); |
4448 SyncShareNudge(); | 4317 SyncShareAsDelegate(); |
4449 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4318 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4450 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4319 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4451 ExpectSyncedAndCreated(); | 4320 ExpectSyncedAndCreated(); |
4452 } | 4321 } |
4453 | 4322 |
4454 TEST_F(SyncerUndeletionTest, OtherClientUndeletes) { | 4323 TEST_F(SyncerUndeletionTest, OtherClientUndeletes) { |
4455 Create(); | 4324 Create(); |
4456 ExpectUnsyncedCreation(); | 4325 ExpectUnsyncedCreation(); |
4457 SyncShareNudge(); | 4326 SyncShareAsDelegate(); |
4458 | 4327 |
4459 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4328 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4460 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4329 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4461 ExpectSyncedAndCreated(); | 4330 ExpectSyncedAndCreated(); |
4462 | 4331 |
4463 // Get the updates of our just-committed entry. | 4332 // Get the updates of our just-committed entry. |
4464 mock_server_->AddUpdateFromLastCommit(); | 4333 mock_server_->AddUpdateFromLastCommit(); |
4465 SyncShareNudge(); | 4334 SyncShareAsDelegate(); |
4466 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4335 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4467 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4336 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4468 ExpectSyncedAndCreated(); | 4337 ExpectSyncedAndCreated(); |
4469 | 4338 |
4470 // We delete the item. | 4339 // We delete the item. |
4471 Delete(); | 4340 Delete(); |
4472 ExpectUnsyncedDeletion(); | 4341 ExpectUnsyncedDeletion(); |
4473 SyncShareNudge(); | 4342 SyncShareAsDelegate(); |
4474 | 4343 |
4475 // The update ought to have applied successfully. | 4344 // The update ought to have applied successfully. |
4476 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4345 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4477 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4346 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4478 ExpectSyncedAndDeleted(); | 4347 ExpectSyncedAndDeleted(); |
4479 | 4348 |
4480 // Now, encounter a GetUpdates corresponding to the just-committed | 4349 // Now, encounter a GetUpdates corresponding to the just-committed |
4481 // deletion update. | 4350 // deletion update. |
4482 mock_server_->AddUpdateFromLastCommit(); | 4351 mock_server_->AddUpdateFromLastCommit(); |
4483 SyncShareNudge(); | 4352 SyncShareAsDelegate(); |
4484 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4353 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4485 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4354 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4486 ExpectSyncedAndDeleted(); | 4355 ExpectSyncedAndDeleted(); |
4487 | 4356 |
4488 // Some other client undeletes the item. | 4357 // Some other client undeletes the item. |
4489 mock_server_->AddUpdateBookmark(Get(metahandle_, ID), | 4358 mock_server_->AddUpdateBookmark(Get(metahandle_, ID), |
4490 Get(metahandle_, PARENT_ID), | 4359 Get(metahandle_, PARENT_ID), |
4491 "Thadeusz", 100, 1000); | 4360 "Thadeusz", 100, 1000); |
4492 mock_server_->SetLastUpdateClientTag(client_tag_); | 4361 mock_server_->SetLastUpdateClientTag(client_tag_); |
4493 SyncShareNudge(); | 4362 SyncShareAsDelegate(); |
4494 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4363 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4495 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4364 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4496 ExpectSyncedAndCreated(); | 4365 ExpectSyncedAndCreated(); |
4497 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME)); | 4366 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME)); |
4498 } | 4367 } |
4499 | 4368 |
4500 TEST_F(SyncerUndeletionTest, OtherClientUndeletesImmediately) { | 4369 TEST_F(SyncerUndeletionTest, OtherClientUndeletesImmediately) { |
4501 Create(); | 4370 Create(); |
4502 ExpectUnsyncedCreation(); | 4371 ExpectUnsyncedCreation(); |
4503 SyncShareNudge(); | 4372 SyncShareAsDelegate(); |
4504 | 4373 |
4505 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4374 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4506 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4375 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4507 ExpectSyncedAndCreated(); | 4376 ExpectSyncedAndCreated(); |
4508 | 4377 |
4509 // Get the updates of our just-committed entry. | 4378 // Get the updates of our just-committed entry. |
4510 mock_server_->AddUpdateFromLastCommit(); | 4379 mock_server_->AddUpdateFromLastCommit(); |
4511 SyncShareNudge(); | 4380 SyncShareAsDelegate(); |
4512 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4381 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4513 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4382 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4514 ExpectSyncedAndCreated(); | 4383 ExpectSyncedAndCreated(); |
4515 | 4384 |
4516 // We delete the item. | 4385 // We delete the item. |
4517 Delete(); | 4386 Delete(); |
4518 ExpectUnsyncedDeletion(); | 4387 ExpectUnsyncedDeletion(); |
4519 SyncShareNudge(); | 4388 SyncShareAsDelegate(); |
4520 | 4389 |
4521 // The update ought to have applied successfully. | 4390 // The update ought to have applied successfully. |
4522 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4391 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4523 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4392 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4524 ExpectSyncedAndDeleted(); | 4393 ExpectSyncedAndDeleted(); |
4525 | 4394 |
4526 // Some other client undeletes before we see the update from our | 4395 // Some other client undeletes before we see the update from our |
4527 // commit. | 4396 // commit. |
4528 mock_server_->AddUpdateBookmark(Get(metahandle_, ID), | 4397 mock_server_->AddUpdateBookmark(Get(metahandle_, ID), |
4529 Get(metahandle_, PARENT_ID), | 4398 Get(metahandle_, PARENT_ID), |
4530 "Thadeusz", 100, 1000); | 4399 "Thadeusz", 100, 1000); |
4531 mock_server_->SetLastUpdateClientTag(client_tag_); | 4400 mock_server_->SetLastUpdateClientTag(client_tag_); |
4532 SyncShareNudge(); | 4401 SyncShareAsDelegate(); |
4533 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4402 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
4534 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4403 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
4535 ExpectSyncedAndCreated(); | 4404 ExpectSyncedAndCreated(); |
4536 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME)); | 4405 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME)); |
4537 } | 4406 } |
4538 | 4407 |
4539 // A group of tests exercising the syncer's handling of sibling ordering, as | 4408 // A group of tests exercising the syncer's handling of sibling ordering, as |
4540 // represented in the sync protocol. | 4409 // represented in the sync protocol. |
4541 class SyncerPositionUpdateTest : public SyncerTest { | 4410 class SyncerPositionUpdateTest : public SyncerTest { |
4542 public: | 4411 public: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4587 | 4456 |
4588 TEST_F(SyncerPositionUpdateTest, InOrderPositive) { | 4457 TEST_F(SyncerPositionUpdateTest, InOrderPositive) { |
4589 // Add a bunch of items in increasing order, starting with just positive | 4458 // Add a bunch of items in increasing order, starting with just positive |
4590 // position values. | 4459 // position values. |
4591 AddRootItemWithPosition(100); | 4460 AddRootItemWithPosition(100); |
4592 AddRootItemWithPosition(199); | 4461 AddRootItemWithPosition(199); |
4593 AddRootItemWithPosition(200); | 4462 AddRootItemWithPosition(200); |
4594 AddRootItemWithPosition(201); | 4463 AddRootItemWithPosition(201); |
4595 AddRootItemWithPosition(400); | 4464 AddRootItemWithPosition(400); |
4596 | 4465 |
4597 SyncShareNudge(); | 4466 SyncShareAsDelegate(); |
4598 ExpectLocalItemsInServerOrder(); | 4467 ExpectLocalItemsInServerOrder(); |
4599 } | 4468 } |
4600 | 4469 |
4601 TEST_F(SyncerPositionUpdateTest, InOrderNegative) { | 4470 TEST_F(SyncerPositionUpdateTest, InOrderNegative) { |
4602 // Test negative position values, but in increasing order. | 4471 // Test negative position values, but in increasing order. |
4603 AddRootItemWithPosition(-400); | 4472 AddRootItemWithPosition(-400); |
4604 AddRootItemWithPosition(-201); | 4473 AddRootItemWithPosition(-201); |
4605 AddRootItemWithPosition(-200); | 4474 AddRootItemWithPosition(-200); |
4606 AddRootItemWithPosition(-150); | 4475 AddRootItemWithPosition(-150); |
4607 AddRootItemWithPosition(100); | 4476 AddRootItemWithPosition(100); |
4608 | 4477 |
4609 SyncShareNudge(); | 4478 SyncShareAsDelegate(); |
4610 ExpectLocalItemsInServerOrder(); | 4479 ExpectLocalItemsInServerOrder(); |
4611 } | 4480 } |
4612 | 4481 |
4613 TEST_F(SyncerPositionUpdateTest, ReverseOrder) { | 4482 TEST_F(SyncerPositionUpdateTest, ReverseOrder) { |
4614 // Test when items are sent in the reverse order. | 4483 // Test when items are sent in the reverse order. |
4615 AddRootItemWithPosition(400); | 4484 AddRootItemWithPosition(400); |
4616 AddRootItemWithPosition(201); | 4485 AddRootItemWithPosition(201); |
4617 AddRootItemWithPosition(200); | 4486 AddRootItemWithPosition(200); |
4618 AddRootItemWithPosition(100); | 4487 AddRootItemWithPosition(100); |
4619 AddRootItemWithPosition(-150); | 4488 AddRootItemWithPosition(-150); |
4620 AddRootItemWithPosition(-201); | 4489 AddRootItemWithPosition(-201); |
4621 AddRootItemWithPosition(-200); | 4490 AddRootItemWithPosition(-200); |
4622 AddRootItemWithPosition(-400); | 4491 AddRootItemWithPosition(-400); |
4623 | 4492 |
4624 SyncShareNudge(); | 4493 SyncShareAsDelegate(); |
4625 ExpectLocalItemsInServerOrder(); | 4494 ExpectLocalItemsInServerOrder(); |
4626 } | 4495 } |
4627 | 4496 |
4628 TEST_F(SyncerPositionUpdateTest, RandomOrderInBatches) { | 4497 TEST_F(SyncerPositionUpdateTest, RandomOrderInBatches) { |
4629 // Mix it all up, interleaving position values, and try multiple batches of | 4498 // Mix it all up, interleaving position values, and try multiple batches of |
4630 // updates. | 4499 // updates. |
4631 AddRootItemWithPosition(400); | 4500 AddRootItemWithPosition(400); |
4632 AddRootItemWithPosition(201); | 4501 AddRootItemWithPosition(201); |
4633 AddRootItemWithPosition(-400); | 4502 AddRootItemWithPosition(-400); |
4634 AddRootItemWithPosition(100); | 4503 AddRootItemWithPosition(100); |
4635 | 4504 |
4636 SyncShareNudge(); | 4505 SyncShareAsDelegate(); |
4637 ExpectLocalItemsInServerOrder(); | 4506 ExpectLocalItemsInServerOrder(); |
4638 | 4507 |
4639 AddRootItemWithPosition(-150); | 4508 AddRootItemWithPosition(-150); |
4640 AddRootItemWithPosition(-200); | 4509 AddRootItemWithPosition(-200); |
4641 AddRootItemWithPosition(200); | 4510 AddRootItemWithPosition(200); |
4642 AddRootItemWithPosition(-201); | 4511 AddRootItemWithPosition(-201); |
4643 | 4512 |
4644 SyncShareNudge(); | 4513 SyncShareAsDelegate(); |
4645 ExpectLocalItemsInServerOrder(); | 4514 ExpectLocalItemsInServerOrder(); |
4646 | 4515 |
4647 AddRootItemWithPosition(-144); | 4516 AddRootItemWithPosition(-144); |
4648 | 4517 |
4649 SyncShareNudge(); | 4518 SyncShareAsDelegate(); |
4650 ExpectLocalItemsInServerOrder(); | 4519 ExpectLocalItemsInServerOrder(); |
4651 } | 4520 } |
4652 | 4521 |
4653 class SyncerPositionTiebreakingTest : public SyncerTest { | 4522 class SyncerPositionTiebreakingTest : public SyncerTest { |
4654 public: | 4523 public: |
4655 SyncerPositionTiebreakingTest() | 4524 SyncerPositionTiebreakingTest() |
4656 : low_id_(Id::CreateFromServerId("A")), | 4525 : low_id_(Id::CreateFromServerId("A")), |
4657 mid_id_(Id::CreateFromServerId("M")), | 4526 mid_id_(Id::CreateFromServerId("M")), |
4658 high_id_(Id::CreateFromServerId("Z")), | 4527 high_id_(Id::CreateFromServerId("Z")), |
4659 next_revision_(1) { | 4528 next_revision_(1) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4699 | 4568 |
4700 private: | 4569 private: |
4701 int next_revision_; | 4570 int next_revision_; |
4702 DISALLOW_COPY_AND_ASSIGN(SyncerPositionTiebreakingTest); | 4571 DISALLOW_COPY_AND_ASSIGN(SyncerPositionTiebreakingTest); |
4703 }; | 4572 }; |
4704 | 4573 |
4705 TEST_F(SyncerPositionTiebreakingTest, LowMidHigh) { | 4574 TEST_F(SyncerPositionTiebreakingTest, LowMidHigh) { |
4706 Add(low_id_); | 4575 Add(low_id_); |
4707 Add(mid_id_); | 4576 Add(mid_id_); |
4708 Add(high_id_); | 4577 Add(high_id_); |
4709 SyncShareNudge(); | 4578 SyncShareAsDelegate(); |
4710 ExpectLocalOrderIsByServerId(); | 4579 ExpectLocalOrderIsByServerId(); |
4711 } | 4580 } |
4712 | 4581 |
4713 TEST_F(SyncerPositionTiebreakingTest, LowHighMid) { | 4582 TEST_F(SyncerPositionTiebreakingTest, LowHighMid) { |
4714 Add(low_id_); | 4583 Add(low_id_); |
4715 Add(high_id_); | 4584 Add(high_id_); |
4716 Add(mid_id_); | 4585 Add(mid_id_); |
4717 SyncShareNudge(); | 4586 SyncShareAsDelegate(); |
4718 ExpectLocalOrderIsByServerId(); | 4587 ExpectLocalOrderIsByServerId(); |
4719 } | 4588 } |
4720 | 4589 |
4721 TEST_F(SyncerPositionTiebreakingTest, HighMidLow) { | 4590 TEST_F(SyncerPositionTiebreakingTest, HighMidLow) { |
4722 Add(high_id_); | 4591 Add(high_id_); |
4723 Add(mid_id_); | 4592 Add(mid_id_); |
4724 Add(low_id_); | 4593 Add(low_id_); |
4725 SyncShareNudge(); | 4594 SyncShareAsDelegate(); |
4726 ExpectLocalOrderIsByServerId(); | 4595 ExpectLocalOrderIsByServerId(); |
4727 } | 4596 } |
4728 | 4597 |
4729 TEST_F(SyncerPositionTiebreakingTest, HighLowMid) { | 4598 TEST_F(SyncerPositionTiebreakingTest, HighLowMid) { |
4730 Add(high_id_); | 4599 Add(high_id_); |
4731 Add(low_id_); | 4600 Add(low_id_); |
4732 Add(mid_id_); | 4601 Add(mid_id_); |
4733 SyncShareNudge(); | 4602 SyncShareAsDelegate(); |
4734 ExpectLocalOrderIsByServerId(); | 4603 ExpectLocalOrderIsByServerId(); |
4735 } | 4604 } |
4736 | 4605 |
4737 TEST_F(SyncerPositionTiebreakingTest, MidHighLow) { | 4606 TEST_F(SyncerPositionTiebreakingTest, MidHighLow) { |
4738 Add(mid_id_); | 4607 Add(mid_id_); |
4739 Add(high_id_); | 4608 Add(high_id_); |
4740 Add(low_id_); | 4609 Add(low_id_); |
4741 SyncShareNudge(); | 4610 SyncShareAsDelegate(); |
4742 ExpectLocalOrderIsByServerId(); | 4611 ExpectLocalOrderIsByServerId(); |
4743 } | 4612 } |
4744 | 4613 |
4745 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { | 4614 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { |
4746 Add(mid_id_); | 4615 Add(mid_id_); |
4747 Add(low_id_); | 4616 Add(low_id_); |
4748 Add(high_id_); | 4617 Add(high_id_); |
4749 SyncShareNudge(); | 4618 SyncShareAsDelegate(); |
4750 ExpectLocalOrderIsByServerId(); | 4619 ExpectLocalOrderIsByServerId(); |
4751 } | 4620 } |
4752 | 4621 |
4753 } // namespace browser_sync | 4622 } // namespace browser_sync |
OLD | NEW |