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