| 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 // If this test starts failing, be aware other sort orders could be valid. | 384 // If this test starts failing, be aware other sort orders could be valid. |
| 385 for (size_t i = 0; i < expected_positions.size(); ++i) { | 385 for (size_t i = 0; i < expected_positions.size(); ++i) { |
| 386 EXPECT_EQ(1u, expected_positions.count(i)); | 386 EXPECT_EQ(1u, expected_positions.count(i)); |
| 387 EXPECT_TRUE(expected_positions[i] == mock_server_->committed_ids()[i]); | 387 EXPECT_TRUE(expected_positions[i] == mock_server_->committed_ids()[i]); |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 | 390 |
| 391 void DoTruncationTest(const vector<int64>& unsynced_handle_view, | 391 void DoTruncationTest(const vector<int64>& unsynced_handle_view, |
| 392 const vector<syncable::Id>& expected_id_order) { | 392 const vector<syncable::Id>& expected_id_order) { |
| 393 for (size_t limit = expected_id_order.size() + 2; limit > 0; --limit) { | 393 for (size_t limit = expected_id_order.size() + 2; limit > 0; --limit) { |
| 394 StatusController* status = session_->mutable_status_controller(); | |
| 395 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 394 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
| 396 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); | 395 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); |
| 397 | 396 |
| 398 ModelSafeRoutingInfo routes; | 397 ModelSafeRoutingInfo routes; |
| 399 GetModelSafeRoutingInfo(&routes); | 398 GetModelSafeRoutingInfo(&routes); |
| 400 GetCommitIdsCommand command(limit); | 399 sessions::OrderedCommitSet output_set(routes); |
| 400 GetCommitIdsCommand command(limit, &output_set); |
| 401 std::set<int64> ready_unsynced_set; | 401 std::set<int64> ready_unsynced_set; |
| 402 command.FilterUnreadyEntries(&wtrans, syncable::ModelTypeSet(), | 402 command.FilterUnreadyEntries(&wtrans, syncable::ModelTypeSet(), |
| 403 syncable::ModelTypeSet(), false, | 403 syncable::ModelTypeSet(), false, |
| 404 unsynced_handle_view, &ready_unsynced_set); | 404 unsynced_handle_view, &ready_unsynced_set); |
| 405 command.BuildCommitIds(session_->write_transaction(), routes, | 405 command.BuildCommitIds(session_->write_transaction(), routes, |
| 406 ready_unsynced_set); | 406 ready_unsynced_set); |
| 407 syncable::Directory::UnsyncedMetaHandles ready_unsynced_vector( | 407 syncable::Directory::UnsyncedMetaHandles ready_unsynced_vector( |
| 408 ready_unsynced_set.begin(), ready_unsynced_set.end()); | 408 ready_unsynced_set.begin(), ready_unsynced_set.end()); |
| 409 status->set_unsynced_handles(ready_unsynced_vector); | |
| 410 vector<syncable::Id> output = | |
| 411 command.ordered_commit_set_->GetAllCommitIds(); | |
| 412 size_t truncated_size = std::min(limit, expected_id_order.size()); | 409 size_t truncated_size = std::min(limit, expected_id_order.size()); |
| 413 ASSERT_EQ(truncated_size, output.size()); | 410 ASSERT_EQ(truncated_size, output_set.Size()); |
| 414 for (size_t i = 0; i < truncated_size; ++i) { | 411 for (size_t i = 0; i < truncated_size; ++i) { |
| 415 ASSERT_EQ(expected_id_order[i], output[i]) | 412 ASSERT_EQ(expected_id_order[i], output_set.GetCommitIdAt(i)) |
| 416 << "At index " << i << " with batch size limited to " << limit; | 413 << "At index " << i << " with batch size limited to " << limit; |
| 417 } | 414 } |
| 418 sessions::OrderedCommitSet::Projection proj; | 415 sessions::OrderedCommitSet::Projection proj; |
| 419 proj = command.ordered_commit_set_->GetCommitIdProjection(GROUP_PASSIVE); | 416 proj = output_set.GetCommitIdProjection(GROUP_PASSIVE); |
| 420 ASSERT_EQ(truncated_size, proj.size()); | 417 ASSERT_EQ(truncated_size, proj.size()); |
| 421 for (size_t i = 0; i < truncated_size; ++i) { | 418 for (size_t i = 0; i < truncated_size; ++i) { |
| 422 SCOPED_TRACE(::testing::Message("Projection mismatch with i = ") << i); | 419 SCOPED_TRACE(::testing::Message("Projection mismatch with i = ") << i); |
| 423 syncable::Id projected = | 420 syncable::Id projected = output_set.GetCommitIdAt(proj[i]); |
| 424 command.ordered_commit_set_->GetCommitIdAt(proj[i]); | |
| 425 ASSERT_EQ(expected_id_order[proj[i]], projected); | 421 ASSERT_EQ(expected_id_order[proj[i]], projected); |
| 426 // Since this projection is the identity, the following holds. | 422 // Since this projection is the identity, the following holds. |
| 427 ASSERT_EQ(expected_id_order[i], projected); | 423 ASSERT_EQ(expected_id_order[i], projected); |
| 428 } | 424 } |
| 429 } | 425 } |
| 430 } | 426 } |
| 431 | 427 |
| 432 const StatusController& status() { | 428 const StatusController& status() { |
| 433 return session_->status_controller(); | 429 return session_->status_controller(); |
| 434 } | 430 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 C.Put(NON_UNIQUE_NAME, kEncryptedString); | 723 C.Put(NON_UNIQUE_NAME, kEncryptedString); |
| 728 // Unencrypted non_unique_name. | 724 // Unencrypted non_unique_name. |
| 729 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); | 725 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); |
| 730 ASSERT_TRUE(D.good()); | 726 ASSERT_TRUE(D.good()); |
| 731 D.Put(IS_UNSYNCED, true); | 727 D.Put(IS_UNSYNCED, true); |
| 732 D.Put(SPECIFICS, encrypted_bookmark); | 728 D.Put(SPECIFICS, encrypted_bookmark); |
| 733 D.Put(NON_UNIQUE_NAME, "not encrypted"); | 729 D.Put(NON_UNIQUE_NAME, "not encrypted"); |
| 734 } | 730 } |
| 735 SyncShareNudge(); | 731 SyncShareNudge(); |
| 736 { | 732 { |
| 737 // We remove any unready entries from the status controller's unsynced | |
| 738 // handles, so this should remain 0 even though the entries didn't commit. | |
| 739 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | |
| 740 // Nothing should have commited due to bookmarks being encrypted and | 733 // Nothing should have commited due to bookmarks being encrypted and |
| 741 // the cryptographer having pending keys. A would have been resolved | 734 // the cryptographer having pending keys. A would have been resolved |
| 742 // as a simple conflict, but still be unsynced until the next sync cycle. | 735 // as a simple conflict, but still be unsynced until the next sync cycle. |
| 743 ReadTransaction rtrans(FROM_HERE, directory()); | 736 ReadTransaction rtrans(FROM_HERE, directory()); |
| 744 VERIFY_ENTRY(1, false, true, false, 0, 20, 20, ids_, &rtrans); | 737 VERIFY_ENTRY(1, false, true, false, 0, 20, 20, ids_, &rtrans); |
| 745 VERIFY_ENTRY(2, false, true, false, 0, 10, 10, ids_, &rtrans); | 738 VERIFY_ENTRY(2, false, true, false, 0, 10, 10, ids_, &rtrans); |
| 746 VERIFY_ENTRY(3, false, true, false, 0, 10, 10, ids_, &rtrans); | 739 VERIFY_ENTRY(3, false, true, false, 0, 10, 10, ids_, &rtrans); |
| 747 VERIFY_ENTRY(4, false, true, false, 0, 10, 10, ids_, &rtrans); | 740 VERIFY_ENTRY(4, false, true, false, 0, 10, 10, ids_, &rtrans); |
| 748 | 741 |
| 749 // Resolve the pending keys. | 742 // Resolve the pending keys. |
| 750 cryptographer(&rtrans)->DecryptPendingKeys(other_params); | 743 cryptographer(&rtrans)->DecryptPendingKeys(other_params); |
| 751 } | 744 } |
| 752 SyncShareNudge(); | 745 SyncShareNudge(); |
| 753 { | 746 { |
| 754 // 2 unsynced handles to reflect the items that committed succesfully. | |
| 755 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size()); | |
| 756 // All properly encrypted and non-conflicting items should commit. "A" was | 747 // All properly encrypted and non-conflicting items should commit. "A" was |
| 757 // conflicting, but last sync cycle resolved it as simple conflict, so on | 748 // conflicting, but last sync cycle resolved it as simple conflict, so on |
| 758 // this sync cycle it committed succesfullly. | 749 // this sync cycle it committed succesfullly. |
| 759 ReadTransaction rtrans(FROM_HERE, directory()); | 750 ReadTransaction rtrans(FROM_HERE, directory()); |
| 760 // Committed successfully. | 751 // Committed successfully. |
| 761 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans); | 752 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans); |
| 762 // Committed successfully. | 753 // Committed successfully. |
| 763 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans); | 754 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans); |
| 764 // Was not properly encrypted. | 755 // Was not properly encrypted. |
| 765 VERIFY_ENTRY(3, false, true, false, 0, 10, 10, ids_, &rtrans); | 756 VERIFY_ENTRY(3, false, true, false, 0, 10, 10, ids_, &rtrans); |
| 766 // Was not properly encrypted. | 757 // Was not properly encrypted. |
| 767 VERIFY_ENTRY(4, false, true, false, 0, 10, 10, ids_, &rtrans); | 758 VERIFY_ENTRY(4, false, true, false, 0, 10, 10, ids_, &rtrans); |
| 768 } | 759 } |
| 769 { | 760 { |
| 770 // Fix the remaining items. | 761 // Fix the remaining items. |
| 771 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 762 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
| 772 MutableEntry C(&wtrans, GET_BY_ID, ids_.FromNumber(3)); | 763 MutableEntry C(&wtrans, GET_BY_ID, ids_.FromNumber(3)); |
| 773 ASSERT_TRUE(C.good()); | 764 ASSERT_TRUE(C.good()); |
| 774 C.Put(SPECIFICS, encrypted_bookmark); | 765 C.Put(SPECIFICS, encrypted_bookmark); |
| 775 C.Put(NON_UNIQUE_NAME, kEncryptedString); | 766 C.Put(NON_UNIQUE_NAME, kEncryptedString); |
| 776 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); | 767 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); |
| 777 ASSERT_TRUE(D.good()); | 768 ASSERT_TRUE(D.good()); |
| 778 D.Put(SPECIFICS, encrypted_bookmark); | 769 D.Put(SPECIFICS, encrypted_bookmark); |
| 779 D.Put(NON_UNIQUE_NAME, kEncryptedString); | 770 D.Put(NON_UNIQUE_NAME, kEncryptedString); |
| 780 } | 771 } |
| 781 SyncShareNudge(); | 772 SyncShareNudge(); |
| 782 { | 773 { |
| 783 // We attempted to commit two items. | 774 const StatusController& status_controller = session_->status_controller(); |
| 784 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size()); | 775 // Expect success. |
| 785 EXPECT_TRUE(session_->status_controller().did_commit_items()); | 776 EXPECT_EQ(status_controller.last_post_commit_result(), SYNCER_OK); |
| 786 // None should be unsynced anymore. | 777 // None should be unsynced anymore. |
| 787 ReadTransaction rtrans(FROM_HERE, directory()); | 778 ReadTransaction rtrans(FROM_HERE, directory()); |
| 788 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans); | 779 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans); |
| 789 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans); | 780 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans); |
| 790 VERIFY_ENTRY(3, false, false, false, 0, 11, 11, ids_, &rtrans); | 781 VERIFY_ENTRY(3, false, false, false, 0, 11, 11, ids_, &rtrans); |
| 791 VERIFY_ENTRY(4, false, false, false, 0, 11, 11, ids_, &rtrans); | 782 VERIFY_ENTRY(4, false, false, false, 0, 11, 11, ids_, &rtrans); |
| 792 } | 783 } |
| 793 } | 784 } |
| 794 | 785 |
| 795 TEST_F(SyncerTest, EncryptionAwareConflicts) { | 786 TEST_F(SyncerTest, EncryptionAwareConflicts) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 824 cryptographer(&wtrans)->Update(*nigori); | 815 cryptographer(&wtrans)->Update(*nigori); |
| 825 EXPECT_TRUE(cryptographer(&wtrans)->has_pending_keys()); | 816 EXPECT_TRUE(cryptographer(&wtrans)->has_pending_keys()); |
| 826 } | 817 } |
| 827 | 818 |
| 828 mock_server_->AddUpdateSpecifics(1, 0, "A", 10, 10, true, 0, bookmark); | 819 mock_server_->AddUpdateSpecifics(1, 0, "A", 10, 10, true, 0, bookmark); |
| 829 mock_server_->AddUpdateSpecifics(2, 1, "B", 10, 10, false, 2, bookmark); | 820 mock_server_->AddUpdateSpecifics(2, 1, "B", 10, 10, false, 2, bookmark); |
| 830 mock_server_->AddUpdateSpecifics(3, 1, "C", 10, 10, false, 1, bookmark); | 821 mock_server_->AddUpdateSpecifics(3, 1, "C", 10, 10, false, 1, bookmark); |
| 831 mock_server_->AddUpdateSpecifics(4, 0, "D", 10, 10, false, 0, pref); | 822 mock_server_->AddUpdateSpecifics(4, 0, "D", 10, 10, false, 0, pref); |
| 832 SyncShareNudge(); | 823 SyncShareNudge(); |
| 833 { | 824 { |
| 834 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | |
| 835 // Initial state. Everything is normal. | 825 // Initial state. Everything is normal. |
| 836 ReadTransaction rtrans(FROM_HERE, directory()); | 826 ReadTransaction rtrans(FROM_HERE, directory()); |
| 837 VERIFY_ENTRY(1, false, false, false, 0, 10, 10, ids_, &rtrans); | 827 VERIFY_ENTRY(1, false, false, false, 0, 10, 10, ids_, &rtrans); |
| 838 VERIFY_ENTRY(2, false, false, false, 1, 10, 10, ids_, &rtrans); | 828 VERIFY_ENTRY(2, false, false, false, 1, 10, 10, ids_, &rtrans); |
| 839 VERIFY_ENTRY(3, false, false, false, 1, 10, 10, ids_, &rtrans); | 829 VERIFY_ENTRY(3, false, false, false, 1, 10, 10, ids_, &rtrans); |
| 840 VERIFY_ENTRY(4, false, false, false, 0, 10, 10, ids_, &rtrans); | 830 VERIFY_ENTRY(4, false, false, false, 0, 10, 10, ids_, &rtrans); |
| 841 } | 831 } |
| 842 | 832 |
| 843 // Server side encryption will not be applied due to undecryptable data. | 833 // Server side encryption will not be applied due to undecryptable data. |
| 844 // At this point, BASE_SERVER_SPECIFICS should be filled for all four items. | 834 // At this point, BASE_SERVER_SPECIFICS should be filled for all four items. |
| 845 mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 20, 20, true, 0, | 835 mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 20, 20, true, 0, |
| 846 encrypted_bookmark); | 836 encrypted_bookmark); |
| 847 mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 20, 20, false, 2, | 837 mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 20, 20, false, 2, |
| 848 encrypted_bookmark); | 838 encrypted_bookmark); |
| 849 mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 20, 20, false, 1, | 839 mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 20, 20, false, 1, |
| 850 encrypted_bookmark); | 840 encrypted_bookmark); |
| 851 mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 20, 20, false, 0, | 841 mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 20, 20, false, 0, |
| 852 encrypted_pref); | 842 encrypted_pref); |
| 853 SyncShareNudge(); | 843 SyncShareNudge(); |
| 854 { | 844 { |
| 855 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | |
| 856 // All should be unapplied due to being undecryptable and have a valid | 845 // All should be unapplied due to being undecryptable and have a valid |
| 857 // BASE_SERVER_SPECIFICS. | 846 // BASE_SERVER_SPECIFICS. |
| 858 ReadTransaction rtrans(FROM_HERE, directory()); | 847 ReadTransaction rtrans(FROM_HERE, directory()); |
| 859 VERIFY_ENTRY(1, true, false, true, 0, 10, 20, ids_, &rtrans); | 848 VERIFY_ENTRY(1, true, false, true, 0, 10, 20, ids_, &rtrans); |
| 860 VERIFY_ENTRY(2, true, false, true, 1, 10, 20, ids_, &rtrans); | 849 VERIFY_ENTRY(2, true, false, true, 1, 10, 20, ids_, &rtrans); |
| 861 VERIFY_ENTRY(3, true, false, true, 1, 10, 20, ids_, &rtrans); | 850 VERIFY_ENTRY(3, true, false, true, 1, 10, 20, ids_, &rtrans); |
| 862 VERIFY_ENTRY(4, true, false, true, 0, 10, 20, ids_, &rtrans); | 851 VERIFY_ENTRY(4, true, false, true, 0, 10, 20, ids_, &rtrans); |
| 863 } | 852 } |
| 864 | 853 |
| 865 // Server side change that don't modify anything should not affect | 854 // Server side change that don't modify anything should not affect |
| 866 // BASE_SERVER_SPECIFICS (such as name changes and mtime changes). | 855 // BASE_SERVER_SPECIFICS (such as name changes and mtime changes). |
| 867 mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 30, 30, true, 0, | 856 mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 30, 30, true, 0, |
| 868 encrypted_bookmark); | 857 encrypted_bookmark); |
| 869 mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 30, 30, false, 2, | 858 mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 30, 30, false, 2, |
| 870 encrypted_bookmark); | 859 encrypted_bookmark); |
| 871 // Item 3 doesn't change. | 860 // Item 3 doesn't change. |
| 872 mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 30, 30, false, 0, | 861 mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 30, 30, false, 0, |
| 873 encrypted_pref); | 862 encrypted_pref); |
| 874 SyncShareNudge(); | 863 SyncShareNudge(); |
| 875 { | 864 { |
| 876 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | |
| 877 // Items 1, 2, and 4 should have newer server versions, 3 remains the same. | 865 // Items 1, 2, and 4 should have newer server versions, 3 remains the same. |
| 878 // All should remain unapplied due to be undecryptable. | 866 // All should remain unapplied due to be undecryptable. |
| 879 ReadTransaction rtrans(FROM_HERE, directory()); | 867 ReadTransaction rtrans(FROM_HERE, directory()); |
| 880 VERIFY_ENTRY(1, true, false, true, 0, 10, 30, ids_, &rtrans); | 868 VERIFY_ENTRY(1, true, false, true, 0, 10, 30, ids_, &rtrans); |
| 881 VERIFY_ENTRY(2, true, false, true, 1, 10, 30, ids_, &rtrans); | 869 VERIFY_ENTRY(2, true, false, true, 1, 10, 30, ids_, &rtrans); |
| 882 VERIFY_ENTRY(3, true, false, true, 1, 10, 20, ids_, &rtrans); | 870 VERIFY_ENTRY(3, true, false, true, 1, 10, 20, ids_, &rtrans); |
| 883 VERIFY_ENTRY(4, true, false, true, 0, 10, 30, ids_, &rtrans); | 871 VERIFY_ENTRY(4, true, false, true, 0, 10, 30, ids_, &rtrans); |
| 884 } | 872 } |
| 885 | 873 |
| 886 // Positional changes, parent changes, and specifics changes should reset | 874 // Positional changes, parent changes, and specifics changes should reset |
| 887 // BASE_SERVER_SPECIFICS. | 875 // BASE_SERVER_SPECIFICS. |
| 888 // Became unencrypted. | 876 // Became unencrypted. |
| 889 mock_server_->AddUpdateSpecifics(1, 0, "A", 40, 40, true, 0, bookmark); | 877 mock_server_->AddUpdateSpecifics(1, 0, "A", 40, 40, true, 0, bookmark); |
| 890 // Reordered to after item 2. | 878 // Reordered to after item 2. |
| 891 mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 30, 30, false, 3, | 879 mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 30, 30, false, 3, |
| 892 encrypted_bookmark); | 880 encrypted_bookmark); |
| 893 SyncShareNudge(); | 881 SyncShareNudge(); |
| 894 { | 882 { |
| 895 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | |
| 896 // Items 2 and 4 should be the only ones with BASE_SERVER_SPECIFICS set. | 883 // Items 2 and 4 should be the only ones with BASE_SERVER_SPECIFICS set. |
| 897 // Items 1 is now unencrypted, so should have applied normally. | 884 // Items 1 is now unencrypted, so should have applied normally. |
| 898 ReadTransaction rtrans(FROM_HERE, directory()); | 885 ReadTransaction rtrans(FROM_HERE, directory()); |
| 899 VERIFY_ENTRY(1, false, false, false, 0, 40, 40, ids_, &rtrans); | 886 VERIFY_ENTRY(1, false, false, false, 0, 40, 40, ids_, &rtrans); |
| 900 VERIFY_ENTRY(2, true, false, true, 1, 10, 30, ids_, &rtrans); | 887 VERIFY_ENTRY(2, true, false, true, 1, 10, 30, ids_, &rtrans); |
| 901 VERIFY_ENTRY(3, true, false, false, 1, 10, 30, ids_, &rtrans); | 888 VERIFY_ENTRY(3, true, false, false, 1, 10, 30, ids_, &rtrans); |
| 902 VERIFY_ENTRY(4, true, false, true, 0, 10, 30, ids_, &rtrans); | 889 VERIFY_ENTRY(4, true, false, true, 0, 10, 30, ids_, &rtrans); |
| 903 } | 890 } |
| 904 | 891 |
| 905 // Make local changes, which should remain unsynced for items 2, 3, 4. | 892 // Make local changes, which should remain unsynced for items 2, 3, 4. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 921 C.Put(NON_UNIQUE_NAME, kEncryptedString); | 908 C.Put(NON_UNIQUE_NAME, kEncryptedString); |
| 922 C.Put(IS_UNSYNCED, true); | 909 C.Put(IS_UNSYNCED, true); |
| 923 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); | 910 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); |
| 924 ASSERT_TRUE(D.good()); | 911 ASSERT_TRUE(D.good()); |
| 925 D.Put(SPECIFICS, modified_pref); | 912 D.Put(SPECIFICS, modified_pref); |
| 926 D.Put(NON_UNIQUE_NAME, kEncryptedString); | 913 D.Put(NON_UNIQUE_NAME, kEncryptedString); |
| 927 D.Put(IS_UNSYNCED, true); | 914 D.Put(IS_UNSYNCED, true); |
| 928 } | 915 } |
| 929 SyncShareNudge(); | 916 SyncShareNudge(); |
| 930 { | 917 { |
| 931 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size()); | |
| 932 // Item 1 remains unsynced due to there being pending keys. | 918 // Item 1 remains unsynced due to there being pending keys. |
| 933 // Items 2, 3, 4 should remain unsynced since they were not up to date. | 919 // Items 2, 3, 4 should remain unsynced since they were not up to date. |
| 934 ReadTransaction rtrans(FROM_HERE, directory()); | 920 ReadTransaction rtrans(FROM_HERE, directory()); |
| 935 VERIFY_ENTRY(1, false, true, false, 0, 40, 40, ids_, &rtrans); | 921 VERIFY_ENTRY(1, false, true, false, 0, 40, 40, ids_, &rtrans); |
| 936 VERIFY_ENTRY(2, true, true, true, 1, 10, 30, ids_, &rtrans); | 922 VERIFY_ENTRY(2, true, true, true, 1, 10, 30, ids_, &rtrans); |
| 937 VERIFY_ENTRY(3, true, true, false, 1, 10, 30, ids_, &rtrans); | 923 VERIFY_ENTRY(3, true, true, false, 1, 10, 30, ids_, &rtrans); |
| 938 VERIFY_ENTRY(4, true, true, true, 0, 10, 30, ids_, &rtrans); | 924 VERIFY_ENTRY(4, true, true, true, 0, 10, 30, ids_, &rtrans); |
| 939 } | 925 } |
| 940 | 926 |
| 941 { | 927 { |
| 942 ReadTransaction rtrans(FROM_HERE, directory()); | 928 ReadTransaction rtrans(FROM_HERE, directory()); |
| 943 // Resolve the pending keys. | 929 // Resolve the pending keys. |
| 944 cryptographer(&rtrans)->DecryptPendingKeys(key_params); | 930 cryptographer(&rtrans)->DecryptPendingKeys(key_params); |
| 945 } | 931 } |
| 946 // First cycle resolves conflicts, second cycle commits changes. | 932 // First cycle resolves conflicts, second cycle commits changes. |
| 947 SyncShareNudge(); | 933 SyncShareNudge(); |
| 948 EXPECT_EQ(2, session_->status_controller().syncer_status(). | 934 EXPECT_EQ(2, status().syncer_status().num_server_overwrites); |
| 949 num_server_overwrites); | 935 EXPECT_EQ(1, status().syncer_status().num_local_overwrites); |
| 950 EXPECT_EQ(1, session_->status_controller().syncer_status(). | 936 // We successfully commited item(s). |
| 951 num_local_overwrites); | 937 EXPECT_EQ(status().last_post_commit_result(), SYNCER_OK); |
| 952 // We attempted to commit item 1. | |
| 953 EXPECT_EQ(1U, session_->status_controller().unsynced_handles().size()); | |
| 954 EXPECT_TRUE(session_->status_controller().did_commit_items()); | |
| 955 SyncShareNudge(); | 938 SyncShareNudge(); |
| 956 { | 939 |
| 957 // Everything should be resolved now. The local changes should have | 940 // Everything should be resolved now. The local changes should have |
| 958 // overwritten the server changes for 2 and 4, while the server changes | 941 // overwritten the server changes for 2 and 4, while the server changes |
| 959 // overwrote the local for entry 3. | 942 // overwrote the local for entry 3. |
| 960 // We attempted to commit two handles. | 943 EXPECT_EQ(0, status().syncer_status().num_server_overwrites); |
| 961 EXPECT_EQ(0, session_->status_controller().syncer_status(). | 944 EXPECT_EQ(0, status().syncer_status().num_local_overwrites); |
| 962 num_server_overwrites); | 945 EXPECT_EQ(status().last_post_commit_result(), SYNCER_OK); |
| 963 EXPECT_EQ(0, session_->status_controller().syncer_status(). | 946 ReadTransaction rtrans(FROM_HERE, directory()); |
| 964 num_local_overwrites); | 947 VERIFY_ENTRY(1, false, false, false, 0, 41, 41, ids_, &rtrans); |
| 965 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size()); | 948 VERIFY_ENTRY(2, false, false, false, 1, 31, 31, ids_, &rtrans); |
| 966 EXPECT_TRUE(session_->status_controller().did_commit_items()); | 949 VERIFY_ENTRY(3, false, false, false, 1, 30, 30, ids_, &rtrans); |
| 967 ReadTransaction rtrans(FROM_HERE, directory()); | 950 VERIFY_ENTRY(4, false, false, false, 0, 31, 31, ids_, &rtrans); |
| 968 VERIFY_ENTRY(1, false, false, false, 0, 41, 41, ids_, &rtrans); | |
| 969 VERIFY_ENTRY(2, false, false, false, 1, 31, 31, ids_, &rtrans); | |
| 970 VERIFY_ENTRY(3, false, false, false, 1, 30, 30, ids_, &rtrans); | |
| 971 VERIFY_ENTRY(4, false, false, false, 0, 31, 31, ids_, &rtrans); | |
| 972 } | |
| 973 } | 951 } |
| 974 | 952 |
| 975 #undef VERIFY_ENTRY | 953 #undef VERIFY_ENTRY |
| 976 | 954 |
| 977 // Receive an old nigori with old encryption keys and encrypted types. We should | 955 // Receive an old nigori with old encryption keys and encrypted types. We should |
| 978 // not revert our default key or encrypted types. | 956 // not revert our default key or encrypted types. |
| 979 TEST_F(SyncerTest, ReceiveOldNigori) { | 957 TEST_F(SyncerTest, ReceiveOldNigori) { |
| 980 KeyParams old_key = {"localhost", "dummy", "old"}; | 958 KeyParams old_key = {"localhost", "dummy", "old"}; |
| 981 KeyParams current_key = {"localhost", "dummy", "cur"}; | 959 KeyParams current_key = {"localhost", "dummy", "cur"}; |
| 982 | 960 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 parent.Put(syncable::BASE_VERSION, 1); | 1169 parent.Put(syncable::BASE_VERSION, 1); |
| 1192 parent.Put(syncable::ID, parent_id_); | 1170 parent.Put(syncable::ID, parent_id_); |
| 1193 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete"); | 1171 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete"); |
| 1194 ASSERT_TRUE(child.good()); | 1172 ASSERT_TRUE(child.good()); |
| 1195 child.Put(syncable::ID, child_id_); | 1173 child.Put(syncable::ID, child_id_); |
| 1196 child.Put(syncable::BASE_VERSION, 1); | 1174 child.Put(syncable::BASE_VERSION, 1); |
| 1197 WriteTestDataToEntry(&wtrans, &child); | 1175 WriteTestDataToEntry(&wtrans, &child); |
| 1198 } | 1176 } |
| 1199 | 1177 |
| 1200 SyncShareNudge(); | 1178 SyncShareNudge(); |
| 1201 EXPECT_EQ(2u, status().unsynced_handles().size()); | |
| 1202 ASSERT_EQ(2u, mock_server_->committed_ids().size()); | 1179 ASSERT_EQ(2u, mock_server_->committed_ids().size()); |
| 1203 // If this test starts failing, be aware other sort orders could be valid. | 1180 // If this test starts failing, be aware other sort orders could be valid. |
| 1204 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1181 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 1205 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 1182 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
| 1206 { | 1183 { |
| 1207 ReadTransaction rt(FROM_HERE, directory()); | 1184 ReadTransaction rt(FROM_HERE, directory()); |
| 1208 Entry entry(&rt, syncable::GET_BY_ID, child_id_); | 1185 Entry entry(&rt, syncable::GET_BY_ID, child_id_); |
| 1209 ASSERT_TRUE(entry.good()); | 1186 ASSERT_TRUE(entry.good()); |
| 1210 VerifyTestDataInEntry(&rt, &entry); | 1187 VerifyTestDataInEntry(&rt, &entry); |
| 1211 } | 1188 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1235 parent2.Put(syncable::IS_DIR, true); | 1212 parent2.Put(syncable::IS_DIR, true); |
| 1236 parent2.Put(syncable::SPECIFICS, DefaultPreferencesSpecifics()); | 1213 parent2.Put(syncable::SPECIFICS, DefaultPreferencesSpecifics()); |
| 1237 parent2.Put(syncable::BASE_VERSION, 1); | 1214 parent2.Put(syncable::BASE_VERSION, 1); |
| 1238 parent2.Put(syncable::ID, pref_node_id); | 1215 parent2.Put(syncable::ID, pref_node_id); |
| 1239 } | 1216 } |
| 1240 | 1217 |
| 1241 directory()->PurgeEntriesWithTypeIn( | 1218 directory()->PurgeEntriesWithTypeIn( |
| 1242 syncable::ModelTypeSet(syncable::PREFERENCES)); | 1219 syncable::ModelTypeSet(syncable::PREFERENCES)); |
| 1243 | 1220 |
| 1244 SyncShareNudge(); | 1221 SyncShareNudge(); |
| 1245 EXPECT_EQ(2U, status().unsynced_handles().size()); | |
| 1246 ASSERT_EQ(2U, mock_server_->committed_ids().size()); | 1222 ASSERT_EQ(2U, mock_server_->committed_ids().size()); |
| 1247 // If this test starts failing, be aware other sort orders could be valid. | 1223 // If this test starts failing, be aware other sort orders could be valid. |
| 1248 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1224 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 1249 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 1225 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
| 1250 { | 1226 { |
| 1251 ReadTransaction rt(FROM_HERE, directory()); | 1227 ReadTransaction rt(FROM_HERE, directory()); |
| 1252 Entry entry(&rt, syncable::GET_BY_ID, child_id_); | 1228 Entry entry(&rt, syncable::GET_BY_ID, child_id_); |
| 1253 ASSERT_TRUE(entry.good()); | 1229 ASSERT_TRUE(entry.good()); |
| 1254 VerifyTestDataInEntry(&rt, &entry); | 1230 VerifyTestDataInEntry(&rt, &entry); |
| 1255 } | 1231 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 grandchild.Put(syncable::ID, ids_.FromNumber(105)); | 1450 grandchild.Put(syncable::ID, ids_.FromNumber(105)); |
| 1475 grandchild.Put(syncable::IS_DEL, true); | 1451 grandchild.Put(syncable::IS_DEL, true); |
| 1476 grandchild.Put(syncable::IS_DIR, false); | 1452 grandchild.Put(syncable::IS_DIR, false); |
| 1477 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1453 grandchild.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
| 1478 grandchild.Put(syncable::BASE_VERSION, 1); | 1454 grandchild.Put(syncable::BASE_VERSION, 1); |
| 1479 grandchild.Put(syncable::MTIME, now_minus_2h); | 1455 grandchild.Put(syncable::MTIME, now_minus_2h); |
| 1480 } | 1456 } |
| 1481 } | 1457 } |
| 1482 | 1458 |
| 1483 SyncShareNudge(); | 1459 SyncShareNudge(); |
| 1484 EXPECT_EQ(6u, session_->status_controller().unsynced_handles().size()); | |
| 1485 ASSERT_EQ(6u, mock_server_->committed_ids().size()); | 1460 ASSERT_EQ(6u, mock_server_->committed_ids().size()); |
| 1486 // This test will NOT unroll deletes because SERVER_PARENT_ID is not set. | 1461 // This test will NOT unroll deletes because SERVER_PARENT_ID is not set. |
| 1487 // It will treat these like moves. | 1462 // It will treat these like moves. |
| 1488 vector<syncable::Id> commit_ids(mock_server_->committed_ids()); | 1463 vector<syncable::Id> commit_ids(mock_server_->committed_ids()); |
| 1489 EXPECT_TRUE(ids_.FromNumber(100) == commit_ids[0]); | 1464 EXPECT_TRUE(ids_.FromNumber(100) == commit_ids[0]); |
| 1490 EXPECT_TRUE(ids_.FromNumber(101) == commit_ids[1]); | 1465 EXPECT_TRUE(ids_.FromNumber(101) == commit_ids[1]); |
| 1491 EXPECT_TRUE(ids_.FromNumber(102) == commit_ids[2]); | 1466 EXPECT_TRUE(ids_.FromNumber(102) == commit_ids[2]); |
| 1492 // We don't guarantee the delete orders in this test, only that they occur | 1467 // We don't guarantee the delete orders in this test, only that they occur |
| 1493 // at the end. | 1468 // at the end. |
| 1494 std::sort(commit_ids.begin() + 3, commit_ids.end()); | 1469 std::sort(commit_ids.begin() + 3, commit_ids.end()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 MutableEntry child(&wtrans, syncable::CREATE, child_id_, "B"); | 1517 MutableEntry child(&wtrans, syncable::CREATE, child_id_, "B"); |
| 1543 ASSERT_TRUE(child.good()); | 1518 ASSERT_TRUE(child.good()); |
| 1544 child.Put(syncable::IS_UNSYNCED, true); | 1519 child.Put(syncable::IS_UNSYNCED, true); |
| 1545 child.Put(syncable::IS_DIR, true); | 1520 child.Put(syncable::IS_DIR, true); |
| 1546 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1521 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
| 1547 child.Put(syncable::ID, ids_.FromNumber(105)); | 1522 child.Put(syncable::ID, ids_.FromNumber(105)); |
| 1548 child.Put(syncable::BASE_VERSION, 1); | 1523 child.Put(syncable::BASE_VERSION, 1); |
| 1549 } | 1524 } |
| 1550 | 1525 |
| 1551 SyncShareNudge(); | 1526 SyncShareNudge(); |
| 1552 EXPECT_EQ(6u, session_->status_controller().unsynced_handles().size()); | |
| 1553 ASSERT_EQ(6u, mock_server_->committed_ids().size()); | 1527 ASSERT_EQ(6u, mock_server_->committed_ids().size()); |
| 1554 // If this test starts failing, be aware other sort orders could be valid. | 1528 // If this test starts failing, be aware other sort orders could be valid. |
| 1555 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1529 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 1556 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 1530 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
| 1557 EXPECT_TRUE(ids_.FromNumber(102) == mock_server_->committed_ids()[2]); | 1531 EXPECT_TRUE(ids_.FromNumber(102) == mock_server_->committed_ids()[2]); |
| 1558 EXPECT_TRUE(ids_.FromNumber(-103) == mock_server_->committed_ids()[3]); | 1532 EXPECT_TRUE(ids_.FromNumber(-103) == mock_server_->committed_ids()[3]); |
| 1559 EXPECT_TRUE(ids_.FromNumber(-104) == mock_server_->committed_ids()[4]); | 1533 EXPECT_TRUE(ids_.FromNumber(-104) == mock_server_->committed_ids()[4]); |
| 1560 EXPECT_TRUE(ids_.FromNumber(105) == mock_server_->committed_ids()[5]); | 1534 EXPECT_TRUE(ids_.FromNumber(105) == mock_server_->committed_ids()[5]); |
| 1561 } | 1535 } |
| 1562 | 1536 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1581 child2.Put(syncable::IS_UNSYNCED, true); | 1555 child2.Put(syncable::IS_UNSYNCED, true); |
| 1582 child2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1556 child2.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
| 1583 child2.Put(syncable::ID, child2_id); | 1557 child2.Put(syncable::ID, child2_id); |
| 1584 | 1558 |
| 1585 parent.Put(syncable::BASE_VERSION, 1); | 1559 parent.Put(syncable::BASE_VERSION, 1); |
| 1586 child1.Put(syncable::BASE_VERSION, 1); | 1560 child1.Put(syncable::BASE_VERSION, 1); |
| 1587 child2.Put(syncable::BASE_VERSION, 1); | 1561 child2.Put(syncable::BASE_VERSION, 1); |
| 1588 } | 1562 } |
| 1589 | 1563 |
| 1590 SyncShareNudge(); | 1564 SyncShareNudge(); |
| 1591 EXPECT_EQ(3u, session_->status_controller().unsynced_handles().size()); | |
| 1592 ASSERT_EQ(3u, mock_server_->committed_ids().size()); | 1565 ASSERT_EQ(3u, mock_server_->committed_ids().size()); |
| 1593 // If this test starts failing, be aware other sort orders could be valid. | 1566 // If this test starts failing, be aware other sort orders could be valid. |
| 1594 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1567 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 1595 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 1568 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
| 1596 EXPECT_TRUE(child2_id == mock_server_->committed_ids()[2]); | 1569 EXPECT_TRUE(child2_id == mock_server_->committed_ids()[2]); |
| 1597 } | 1570 } |
| 1598 | 1571 |
| 1599 TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) { | 1572 TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) { |
| 1600 string parent1_name = "1"; | 1573 string parent1_name = "1"; |
| 1601 string parent2_name = "A"; | 1574 string parent2_name = "A"; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1627 MutableEntry child(&wtrans, syncable::CREATE, parent2_id, child_name); | 1600 MutableEntry child(&wtrans, syncable::CREATE, parent2_id, child_name); |
| 1628 ASSERT_TRUE(child.good()); | 1601 ASSERT_TRUE(child.good()); |
| 1629 child.Put(syncable::IS_UNSYNCED, true); | 1602 child.Put(syncable::IS_UNSYNCED, true); |
| 1630 child.Put(syncable::IS_DIR, true); | 1603 child.Put(syncable::IS_DIR, true); |
| 1631 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1604 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
| 1632 child.Put(syncable::ID, child_id); | 1605 child.Put(syncable::ID, child_id); |
| 1633 child.Put(syncable::BASE_VERSION, 1); | 1606 child.Put(syncable::BASE_VERSION, 1); |
| 1634 } | 1607 } |
| 1635 | 1608 |
| 1636 SyncShareNudge(); | 1609 SyncShareNudge(); |
| 1637 EXPECT_EQ(3u, session_->status_controller().unsynced_handles().size()); | |
| 1638 ASSERT_EQ(3u, mock_server_->committed_ids().size()); | 1610 ASSERT_EQ(3u, mock_server_->committed_ids().size()); |
| 1639 // If this test starts failing, be aware other sort orders could be valid. | 1611 // If this test starts failing, be aware other sort orders could be valid. |
| 1640 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1612 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 1641 EXPECT_TRUE(parent2_id == mock_server_->committed_ids()[1]); | 1613 EXPECT_TRUE(parent2_id == mock_server_->committed_ids()[1]); |
| 1642 EXPECT_TRUE(child_id == mock_server_->committed_ids()[2]); | 1614 EXPECT_TRUE(child_id == mock_server_->committed_ids()[2]); |
| 1643 { | 1615 { |
| 1644 ReadTransaction rtrans(FROM_HERE, directory()); | 1616 ReadTransaction rtrans(FROM_HERE, directory()); |
| 1645 // Check that things committed correctly. | 1617 // Check that things committed correctly. |
| 1646 Entry entry_1(&rtrans, syncable::GET_BY_ID, parent_id_); | 1618 Entry entry_1(&rtrans, syncable::GET_BY_ID, parent_id_); |
| 1647 EXPECT_EQ(entry_1.Get(NON_UNIQUE_NAME), parent1_name); | 1619 EXPECT_EQ(entry_1.Get(NON_UNIQUE_NAME), parent1_name); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 MutableEntry child(&wtrans, syncable::CREATE, parent2_local_id, child_name); | 1670 MutableEntry child(&wtrans, syncable::CREATE, parent2_local_id, child_name); |
| 1699 ASSERT_TRUE(child.good()); | 1671 ASSERT_TRUE(child.good()); |
| 1700 child.Put(syncable::IS_UNSYNCED, true); | 1672 child.Put(syncable::IS_UNSYNCED, true); |
| 1701 child.Put(syncable::IS_DIR, true); | 1673 child.Put(syncable::IS_DIR, true); |
| 1702 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 1674 child.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
| 1703 child.Put(syncable::ID, child_local_id); | 1675 child.Put(syncable::ID, child_local_id); |
| 1704 meta_handle_b = child.Get(syncable::META_HANDLE); | 1676 meta_handle_b = child.Get(syncable::META_HANDLE); |
| 1705 } | 1677 } |
| 1706 | 1678 |
| 1707 SyncShareNudge(); | 1679 SyncShareNudge(); |
| 1708 EXPECT_EQ(3u, session_->status_controller().unsynced_handles().size()); | |
| 1709 ASSERT_EQ(3u, mock_server_->committed_ids().size()); | 1680 ASSERT_EQ(3u, mock_server_->committed_ids().size()); |
| 1710 // If this test starts failing, be aware other sort orders could be valid. | 1681 // If this test starts failing, be aware other sort orders could be valid. |
| 1711 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 1682 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 1712 EXPECT_TRUE(parent2_local_id == mock_server_->committed_ids()[1]); | 1683 EXPECT_TRUE(parent2_local_id == mock_server_->committed_ids()[1]); |
| 1713 EXPECT_TRUE(child_local_id == mock_server_->committed_ids()[2]); | 1684 EXPECT_TRUE(child_local_id == mock_server_->committed_ids()[2]); |
| 1714 { | 1685 { |
| 1715 ReadTransaction rtrans(FROM_HERE, directory()); | 1686 ReadTransaction rtrans(FROM_HERE, directory()); |
| 1716 | 1687 |
| 1717 Entry parent(&rtrans, syncable::GET_BY_ID, | 1688 Entry parent(&rtrans, syncable::GET_BY_ID, |
| 1718 GetOnlyEntryWithName(&rtrans, rtrans.root_id(), parent_name)); | 1689 GetOnlyEntryWithName(&rtrans, rtrans.root_id(), parent_name)); |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2325 "bob"); | 2296 "bob"); |
| 2326 ASSERT_TRUE(entry.good()); | 2297 ASSERT_TRUE(entry.good()); |
| 2327 entry.Put(syncable::IS_DIR, true); | 2298 entry.Put(syncable::IS_DIR, true); |
| 2328 entry.Put(syncable::IS_UNSYNCED, true); | 2299 entry.Put(syncable::IS_UNSYNCED, true); |
| 2329 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); | 2300 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); |
| 2330 } | 2301 } |
| 2331 | 2302 |
| 2332 mock_server_->SetMidCommitCallback( | 2303 mock_server_->SetMidCommitCallback( |
| 2333 base::Bind(&EntryCreatedInNewFolderTest::CreateFolderInBob, | 2304 base::Bind(&EntryCreatedInNewFolderTest::CreateFolderInBob, |
| 2334 base::Unretained(this))); | 2305 base::Unretained(this))); |
| 2335 syncer_->SyncShare(session_.get(), BUILD_COMMIT_REQUEST, SYNCER_END); | 2306 syncer_->SyncShare(session_.get(), COMMIT, SYNCER_END); |
| 2336 EXPECT_EQ(1u, mock_server_->committed_ids().size()); | 2307 // We loop until no unsynced handles remain, so we will commit both ids. |
| 2308 EXPECT_EQ(2u, mock_server_->committed_ids().size()); |
| 2337 { | 2309 { |
| 2338 ReadTransaction trans(FROM_HERE, directory()); | 2310 ReadTransaction trans(FROM_HERE, directory()); |
| 2339 Entry parent_entry(&trans, syncable::GET_BY_ID, | 2311 Entry parent_entry(&trans, syncable::GET_BY_ID, |
| 2340 GetOnlyEntryWithName(&trans, TestIdFactory::root(), "bob")); | 2312 GetOnlyEntryWithName(&trans, TestIdFactory::root(), "bob")); |
| 2341 ASSERT_TRUE(parent_entry.good()); | 2313 ASSERT_TRUE(parent_entry.good()); |
| 2342 | 2314 |
| 2343 Id child_id = | 2315 Id child_id = |
| 2344 GetOnlyEntryWithName(&trans, parent_entry.Get(ID), "bob"); | 2316 GetOnlyEntryWithName(&trans, parent_entry.Get(ID), "bob"); |
| 2345 Entry child(&trans, syncable::GET_BY_ID, child_id); | 2317 Entry child(&trans, syncable::GET_BY_ID, child_id); |
| 2346 ASSERT_TRUE(child.good()); | 2318 ASSERT_TRUE(child.good()); |
| 2347 EXPECT_EQ(parent_entry.Get(ID), child.Get(PARENT_ID)); | 2319 EXPECT_EQ(parent_entry.Get(ID), child.Get(PARENT_ID)); |
| 2348 } | 2320 } |
| 2349 } | 2321 } |
| 2350 | 2322 |
| 2351 TEST_F(SyncerTest, NegativeIDInUpdate) { | 2323 TEST_F(SyncerTest, NegativeIDInUpdate) { |
| 2352 mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40); | 2324 mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40); |
| 2353 SyncShareNudge(); | 2325 SyncShareNudge(); |
| 2354 // The negative id would make us CHECK! | 2326 // The negative id would make us CHECK! |
| 2355 } | 2327 } |
| 2356 | 2328 |
| 2357 TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { | 2329 TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { |
| 2358 int64 metahandle_fred; | 2330 int64 metahandle_fred; |
| (...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4254 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4226 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
| 4255 ExpectSyncedAndCreated(); | 4227 ExpectSyncedAndCreated(); |
| 4256 | 4228 |
| 4257 // Delete, begin committing the delete, then undelete while committing. | 4229 // Delete, begin committing the delete, then undelete while committing. |
| 4258 Delete(); | 4230 Delete(); |
| 4259 ExpectUnsyncedDeletion(); | 4231 ExpectUnsyncedDeletion(); |
| 4260 mock_server_->SetMidCommitCallback( | 4232 mock_server_->SetMidCommitCallback( |
| 4261 base::Bind(&SyncerUndeletionTest::Undelete, base::Unretained(this))); | 4233 base::Bind(&SyncerUndeletionTest::Undelete, base::Unretained(this))); |
| 4262 SyncShareNudge(); | 4234 SyncShareNudge(); |
| 4263 | 4235 |
| 4264 // The item ought to exist as an unsynced undeletion (meaning, | 4236 // We will continue to commit until all nodes are synced, so we expect |
| 4265 // we think that the next commit ought to be a recreation commit). | 4237 // that both the delete and following undelete were committed. We haven't |
| 4238 // downloaded any updates, though, so the SERVER fields will be the same |
| 4239 // as they were at the start of the cycle. |
| 4266 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4240 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
| 4267 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4241 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
| 4268 ExpectUnsyncedUndeletion(); | 4242 |
| 4243 // Server fields lag behind. |
| 4244 EXPECT_FALSE(Get(metahandle_, SERVER_IS_DEL)); |
| 4245 |
| 4246 // We have committed the second (undelete) update. |
| 4247 EXPECT_FALSE(Get(metahandle_, IS_DEL)); |
| 4248 EXPECT_FALSE(Get(metahandle_, IS_UNSYNCED)); |
| 4249 EXPECT_FALSE(Get(metahandle_, IS_UNAPPLIED_UPDATE)); |
| 4269 | 4250 |
| 4270 // Now, encounter a GetUpdates corresponding to the deletion from | 4251 // Now, encounter a GetUpdates corresponding to the deletion from |
| 4271 // the server. The undeletion should prevail again and be committed. | 4252 // the server. The undeletion should prevail again and be committed. |
| 4272 // None of this should trigger any conflict detection -- it is perfectly | 4253 // None of this should trigger any conflict detection -- it is perfectly |
| 4273 // normal to recieve updates from our own commits. | 4254 // normal to recieve updates from our own commits. |
| 4274 mock_server_->SetMidCommitCallback(base::Closure()); | 4255 mock_server_->SetMidCommitCallback(base::Closure()); |
| 4275 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); | 4256 mock_server_->AddUpdateFromLastCommit(); |
| 4276 SyncShareNudge(); | 4257 SyncShareNudge(); |
| 4277 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 4258 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
| 4278 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4259 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
| 4279 ExpectSyncedAndCreated(); | 4260 ExpectSyncedAndCreated(); |
| 4280 } | 4261 } |
| 4281 | 4262 |
| 4282 TEST_F(SyncerUndeletionTest, UndeleteBeforeCommit) { | 4263 TEST_F(SyncerUndeletionTest, UndeleteBeforeCommit) { |
| 4283 Create(); | 4264 Create(); |
| 4284 ExpectUnsyncedCreation(); | 4265 ExpectUnsyncedCreation(); |
| 4285 SyncShareNudge(); | 4266 SyncShareNudge(); |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4759 | 4740 |
| 4760 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { | 4741 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { |
| 4761 Add(mid_id_); | 4742 Add(mid_id_); |
| 4762 Add(low_id_); | 4743 Add(low_id_); |
| 4763 Add(high_id_); | 4744 Add(high_id_); |
| 4764 SyncShareNudge(); | 4745 SyncShareNudge(); |
| 4765 ExpectLocalOrderIsByServerId(); | 4746 ExpectLocalOrderIsByServerId(); |
| 4766 } | 4747 } |
| 4767 | 4748 |
| 4768 } // namespace browser_sync | 4749 } // namespace browser_sync |
| OLD | NEW |