Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chrome/browser/sync/engine/syncer_unittest.cc

Issue 8770032: [Sync] Implement encryption-aware conflict resolution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Syncer unit tests. Unfortunately a lot of these tests 5 // Syncer unit tests. Unfortunately a lot of these tests
6 // are outdated and need to be reworked and updated. 6 // are outdated and need to be reworked and updated.
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <limits> 9 #include <limits>
10 #include <list> 10 #include <list>
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/sync/engine/net/server_connection_manager.h" 26 #include "chrome/browser/sync/engine/net/server_connection_manager.h"
27 #include "chrome/browser/sync/engine/process_updates_command.h" 27 #include "chrome/browser/sync/engine/process_updates_command.h"
28 #include "chrome/browser/sync/engine/nigori_util.h" 28 #include "chrome/browser/sync/engine/nigori_util.h"
29 #include "chrome/browser/sync/engine/syncer.h" 29 #include "chrome/browser/sync/engine/syncer.h"
30 #include "chrome/browser/sync/engine/syncer_proto_util.h" 30 #include "chrome/browser/sync/engine/syncer_proto_util.h"
31 #include "chrome/browser/sync/engine/syncer_util.h" 31 #include "chrome/browser/sync/engine/syncer_util.h"
32 #include "chrome/browser/sync/engine/syncproto.h" 32 #include "chrome/browser/sync/engine/syncproto.h"
33 #include "chrome/browser/sync/protocol/sync.pb.h" 33 #include "chrome/browser/sync/protocol/sync.pb.h"
34 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 34 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
35 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" 35 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h"
36 #include "chrome/browser/sync/protocol/preference_specifics.pb.h"
36 #include "chrome/browser/sync/sessions/sync_session_context.h" 37 #include "chrome/browser/sync/sessions/sync_session_context.h"
37 #include "chrome/browser/sync/syncable/directory_manager.h" 38 #include "chrome/browser/sync/syncable/directory_manager.h"
38 #include "chrome/browser/sync/syncable/model_type.h" 39 #include "chrome/browser/sync/syncable/model_type.h"
39 #include "chrome/browser/sync/syncable/syncable.h" 40 #include "chrome/browser/sync/syncable/syncable.h"
40 #include "chrome/browser/sync/test/engine/fake_model_worker.h" 41 #include "chrome/browser/sync/test/engine/fake_model_worker.h"
41 #include "chrome/browser/sync/test/engine/mock_connection_manager.h" 42 #include "chrome/browser/sync/test/engine/mock_connection_manager.h"
42 #include "chrome/browser/sync/test/engine/test_directory_setter_upper.h" 43 #include "chrome/browser/sync/test/engine/test_directory_setter_upper.h"
43 #include "chrome/browser/sync/test/engine/test_id_factory.h" 44 #include "chrome/browser/sync/test/engine/test_id_factory.h"
44 #include "chrome/browser/sync/test/engine/test_syncable_utils.h" 45 #include "chrome/browser/sync/test/engine/test_syncable_utils.h"
45 #include "chrome/browser/sync/util/cryptographer.h" 46 #include "chrome/browser/sync/util/cryptographer.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 using syncable::IS_DEL; 81 using syncable::IS_DEL;
81 using syncable::IS_DIR; 82 using syncable::IS_DIR;
82 using syncable::IS_UNAPPLIED_UPDATE; 83 using syncable::IS_UNAPPLIED_UPDATE;
83 using syncable::IS_UNSYNCED; 84 using syncable::IS_UNSYNCED;
84 using syncable::META_HANDLE; 85 using syncable::META_HANDLE;
85 using syncable::MTIME; 86 using syncable::MTIME;
86 using syncable::NEXT_ID; 87 using syncable::NEXT_ID;
87 using syncable::NON_UNIQUE_NAME; 88 using syncable::NON_UNIQUE_NAME;
88 using syncable::PARENT_ID; 89 using syncable::PARENT_ID;
89 using syncable::PREV_ID; 90 using syncable::PREV_ID;
91 using syncable::BASE_SERVER_SPECIFICS;
90 using syncable::SERVER_IS_DEL; 92 using syncable::SERVER_IS_DEL;
91 using syncable::SERVER_NON_UNIQUE_NAME; 93 using syncable::SERVER_NON_UNIQUE_NAME;
92 using syncable::SERVER_PARENT_ID; 94 using syncable::SERVER_PARENT_ID;
93 using syncable::SERVER_POSITION_IN_PARENT; 95 using syncable::SERVER_POSITION_IN_PARENT;
94 using syncable::SERVER_SPECIFICS; 96 using syncable::SERVER_SPECIFICS;
95 using syncable::SERVER_VERSION; 97 using syncable::SERVER_VERSION;
96 using syncable::UNIQUE_CLIENT_TAG; 98 using syncable::UNIQUE_CLIENT_TAG;
97 using syncable::UNIQUE_SERVER_TAG; 99 using syncable::UNIQUE_SERVER_TAG;
98 using syncable::SPECIFICS; 100 using syncable::SPECIFICS;
99 using syncable::SYNCING; 101 using syncable::SYNCING;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 GetModelSafeRoutingInfo(&info); 173 GetModelSafeRoutingInfo(&info);
172 GetWorkers(&workers); 174 GetWorkers(&workers);
173 syncable::ModelTypePayloadMap types = 175 syncable::ModelTypePayloadMap types =
174 syncable::ModelTypePayloadMapFromRoutingInfo(info, std::string()); 176 syncable::ModelTypePayloadMapFromRoutingInfo(info, std::string());
175 return new SyncSession(context_.get(), this, 177 return new SyncSession(context_.get(), this,
176 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, types), 178 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, types),
177 info, workers); 179 info, workers);
178 } 180 }
179 181
180 bool SyncShareAsDelegate() { 182 bool SyncShareAsDelegate() {
181 scoped_ptr<SyncSession> session(MakeSession()); 183 session_.reset(MakeSession());
182 syncer_->SyncShare(session.get(), SYNCER_BEGIN, SYNCER_END); 184 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END);
183 return session->HasMoreToSync(); 185 return session_->HasMoreToSync();
184 } 186 }
185 187
186 void LoopSyncShare() { 188 void LoopSyncShare() {
187 bool should_loop = false; 189 bool should_loop = false;
188 int loop_iterations = 0; 190 int loop_iterations = 0;
189 do { 191 do {
190 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; 192 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix";
191 should_loop = SyncShareAsDelegate(); 193 should_loop = SyncShareAsDelegate();
192 } while (should_loop); 194 } while (should_loop);
193 } 195 }
194 196
195 virtual void SetUp() { 197 virtual void SetUp() {
196 syncdb_.SetUp(); 198 syncdb_.SetUp();
197 199
198 mock_server_.reset( 200 mock_server_.reset(
199 new MockConnectionManager(syncdb_.manager(), syncdb_.name())); 201 new MockConnectionManager(syncdb_.manager(), syncdb_.name()));
200 EnableDatatype(syncable::BOOKMARKS); 202 EnableDatatype(syncable::BOOKMARKS);
201 EnableDatatype(syncable::NIGORI); 203 EnableDatatype(syncable::NIGORI);
204 EnableDatatype(syncable::PREFERENCES);
205 EnableDatatype(syncable::NIGORI);
202 worker_ = new FakeModelWorker(GROUP_PASSIVE); 206 worker_ = new FakeModelWorker(GROUP_PASSIVE);
203 std::vector<SyncEngineEventListener*> listeners; 207 std::vector<SyncEngineEventListener*> listeners;
204 listeners.push_back(this); 208 listeners.push_back(this);
205 context_.reset(new SyncSessionContext(mock_server_.get(), 209 context_.reset(new SyncSessionContext(mock_server_.get(),
206 syncdb_.manager(), this, listeners, NULL)); 210 syncdb_.manager(), this, listeners, NULL));
207 context_->set_account_name(syncdb_.name()); 211 context_->set_account_name(syncdb_.name());
208 ASSERT_FALSE(context_->resolver()); 212 ASSERT_FALSE(context_->resolver());
209 syncer_ = new Syncer(); 213 syncer_ = new Syncer();
210 session_.reset(MakeSession()); 214 session_.reset(MakeSession());
211 215
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 expected_order.push_back(ids_.MakeLocal("b")); 558 expected_order.push_back(ids_.MakeLocal("b"));
555 expected_order.push_back(ids_.MakeLocal("c")); 559 expected_order.push_back(ids_.MakeLocal("c"));
556 expected_order.push_back(ids_.MakeLocal("e")); 560 expected_order.push_back(ids_.MakeLocal("e"));
557 DoTruncationTest(dir, unsynced_handle_view, expected_order); 561 DoTruncationTest(dir, unsynced_handle_view, expected_order);
558 } 562 }
559 563
560 TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) { 564 TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) {
561 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); 565 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
562 ASSERT_TRUE(dir.good()); 566 ASSERT_TRUE(dir.good());
563 const syncable::ModelTypeSet throttled_types(syncable::BOOKMARKS); 567 const syncable::ModelTypeSet throttled_types(syncable::BOOKMARKS);
564 KeyParams key_params = {"localhost", "dummy", "foobar"};
565 sync_pb::EntitySpecifics bookmark_data; 568 sync_pb::EntitySpecifics bookmark_data;
566 AddDefaultExtensionValue(syncable::BOOKMARKS, &bookmark_data); 569 AddDefaultExtensionValue(syncable::BOOKMARKS, &bookmark_data);
567 570
568 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); 571 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10);
569 SyncShareAsDelegate(); 572 SyncShareAsDelegate();
570 573
571 { 574 {
572 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); 575 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
573 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); 576 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1));
574 ASSERT_TRUE(A.good()); 577 ASSERT_TRUE(A.good());
(...skipping 23 matching lines...) Expand all
598 SyncShareAsDelegate(); 601 SyncShareAsDelegate();
599 { 602 {
600 // It should have been committed. 603 // It should have been committed.
601 ReadTransaction rtrans(FROM_HERE, dir); 604 ReadTransaction rtrans(FROM_HERE, dir);
602 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); 605 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1));
603 ASSERT_TRUE(entryA.good()); 606 ASSERT_TRUE(entryA.good());
604 EXPECT_FALSE(entryA.Get(IS_UNSYNCED)); 607 EXPECT_FALSE(entryA.Get(IS_UNSYNCED));
605 } 608 }
606 } 609 }
607 610
611 // We use a macro so we can preserve the error location.
612 #define VERIFY_ENTRY(id, is_unapplied, is_unsynced, prev_initialized, \
613 parent_id, version, server_version, id_fac, rtrans) \
614 do { \
615 Entry entryA(rtrans, syncable::GET_BY_ID, id_fac.FromNumber(id)); \
616 ASSERT_TRUE(entryA.good()); \
617 EXPECT_EQ(is_unsynced, entryA.Get(IS_UNSYNCED)); \
618 EXPECT_EQ(is_unapplied, entryA.Get(IS_UNAPPLIED_UPDATE)); \
619 EXPECT_EQ(prev_initialized, \
620 syncable::IsRealDataType(syncable::GetModelTypeFromSpecifics( \
621 entryA.Get(BASE_SERVER_SPECIFICS)))); \
622 EXPECT_TRUE(parent_id == -1 || \
623 entryA.Get(PARENT_ID) == id_fac.FromNumber(parent_id)); \
624 EXPECT_EQ(version, entryA.Get(BASE_VERSION)); \
625 EXPECT_EQ(server_version, entryA.Get(SERVER_VERSION)); \
626 } while (0)
627
608 TEST_F(SyncerTest, GetCommitIdsFiltersUnreadyEntries) { 628 TEST_F(SyncerTest, GetCommitIdsFiltersUnreadyEntries) {
609 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); 629 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
610 ASSERT_TRUE(dir.good()); 630 ASSERT_TRUE(dir.good());
611 KeyParams key_params = {"localhost", "dummy", "foobar"}; 631 KeyParams key_params = {"localhost", "dummy", "foobar"};
612 sync_pb::EncryptedData encrypted; 632 KeyParams other_params = {"localhost", "dummy", "foobar2"};
613 sync_pb::EntitySpecifics encrypted_bookmark; 633 sync_pb::EntitySpecifics bookmark, encrypted_bookmark;
614 encrypted_bookmark.mutable_encrypted(); 634 bookmark.MutableExtension(sync_pb::bookmark)->set_url("url");
635 bookmark.MutableExtension(sync_pb::bookmark)->set_title("title");
615 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); 636 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark);
616 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); 637 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10);
617 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); 638 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10);
618 mock_server_->AddUpdateDirectory(3, 0, "C", 10, 10); 639 mock_server_->AddUpdateDirectory(3, 0, "C", 10, 10);
619 mock_server_->AddUpdateDirectory(4, 0, "D", 10, 10); 640 mock_server_->AddUpdateDirectory(4, 0, "D", 10, 10);
620 SyncShareAsDelegate(); 641 SyncShareAsDelegate();
621 // Server side change will put A in conflict. 642 // Server side change will put A in conflict.
622 mock_server_->AddUpdateDirectory(1, 0, "A", 20, 20); 643 mock_server_->AddUpdateDirectory(1, 0, "A", 20, 20);
623 { 644 {
624 // Mark bookmarks as encrypted and set the cryptographer to have pending 645 // Mark bookmarks as encrypted and set the cryptographer to have pending
625 // keys. 646 // keys.
626 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); 647 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
627 browser_sync::Cryptographer other_cryptographer; 648 browser_sync::Cryptographer other_cryptographer;
628 other_cryptographer.AddKey(key_params); 649 other_cryptographer.AddKey(other_params);
629 sync_pb::EntitySpecifics specifics; 650 sync_pb::EntitySpecifics specifics;
630 sync_pb::NigoriSpecifics* nigori = 651 sync_pb::NigoriSpecifics* nigori =
631 specifics.MutableExtension(sync_pb::nigori); 652 specifics.MutableExtension(sync_pb::nigori);
632 other_cryptographer.GetKeys(nigori->mutable_encrypted()); 653 other_cryptographer.GetKeys(nigori->mutable_encrypted());
633 nigori->set_encrypt_bookmarks(true); 654 nigori->set_encrypt_bookmarks(true);
655 // Set up with an old passphrase, but have pending keys
656 syncdb_.manager()->GetCryptographer(&wtrans)->AddKey(key_params);
657 syncdb_.manager()->GetCryptographer(&wtrans)->Encrypt(
658 bookmark,
659 encrypted_bookmark.mutable_encrypted());
634 syncdb_.manager()->GetCryptographer(&wtrans)->Update(*nigori); 660 syncdb_.manager()->GetCryptographer(&wtrans)->Update(*nigori);
635 661
636 // In conflict but properly encrypted. 662 // In conflict but properly encrypted.
637 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); 663 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1));
638 ASSERT_TRUE(A.good()); 664 ASSERT_TRUE(A.good());
639 A.Put(IS_UNSYNCED, true); 665 A.Put(IS_UNSYNCED, true);
640 A.Put(SPECIFICS, encrypted_bookmark); 666 A.Put(SPECIFICS, encrypted_bookmark);
641 A.Put(NON_UNIQUE_NAME, kEncryptedString); 667 A.Put(NON_UNIQUE_NAME, kEncryptedString);
642 // Not in conflict and properly encrypted. 668 // Not in conflict and properly encrypted.
643 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); 669 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2));
(...skipping 10 matching lines...) Expand all
654 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); 680 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4));
655 ASSERT_TRUE(D.good()); 681 ASSERT_TRUE(D.good());
656 D.Put(IS_UNSYNCED, true); 682 D.Put(IS_UNSYNCED, true);
657 D.Put(SPECIFICS, encrypted_bookmark); 683 D.Put(SPECIFICS, encrypted_bookmark);
658 D.Put(NON_UNIQUE_NAME, "not encrypted"); 684 D.Put(NON_UNIQUE_NAME, "not encrypted");
659 } 685 }
660 SyncShareAsDelegate(); 686 SyncShareAsDelegate();
661 { 687 {
662 // We remove any unready entries from the status controller's unsynced 688 // We remove any unready entries from the status controller's unsynced
663 // handles, so this should remain 0 even though the entries didn't commit. 689 // handles, so this should remain 0 even though the entries didn't commit.
664 ASSERT_EQ(0U, session_->status_controller().unsynced_handles().size()); 690 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size());
665 // Nothing should have commited due to bookmarks being encrypted and 691 // Nothing should have commited due to bookmarks being encrypted and
666 // the cryptographer having pending keys. A would have been resolved 692 // the cryptographer having pending keys. A would have been resolved
667 // as a simple conflict, but still be unsynced until the next sync cycle. 693 // as a simple conflict, but still be unsynced until the next sync cycle.
668 ReadTransaction rtrans(FROM_HERE, dir); 694 ReadTransaction rtrans(FROM_HERE, dir);
669 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); 695 VERIFY_ENTRY(1, false, true, false, 0, 20, 20, ids_, &rtrans);
670 ASSERT_TRUE(entryA.good()); 696 VERIFY_ENTRY(2, false, true, false, 0, 10, 10, ids_, &rtrans);
671 EXPECT_TRUE(entryA.Get(IS_UNSYNCED)); 697 VERIFY_ENTRY(3, false, true, false, 0, 10, 10, ids_, &rtrans);
672 Entry entryB(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2)); 698 VERIFY_ENTRY(4, false, true, false, 0, 10, 10, ids_, &rtrans);
673 ASSERT_TRUE(entryB.good());
674 EXPECT_TRUE(entryB.Get(IS_UNSYNCED));
675 Entry entryC(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(3));
676 ASSERT_TRUE(entryC.good());
677 EXPECT_TRUE(entryC.Get(IS_UNSYNCED));
678 Entry entryD(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(4));
679 ASSERT_TRUE(entryD.good());
680 EXPECT_TRUE(entryD.Get(IS_UNSYNCED));
681 699
682 // Resolve the pending keys. 700 // Resolve the pending keys.
683 syncdb_.manager()->GetCryptographer(&rtrans)->DecryptPendingKeys( 701 syncdb_.manager()->GetCryptographer(&rtrans)->DecryptPendingKeys(
684 key_params); 702 other_params);
685 } 703 }
686 SyncShareAsDelegate(); 704 SyncShareAsDelegate();
687 { 705 {
688 ASSERT_EQ(0U, session_->status_controller().unsynced_handles().size()); 706 // 2 unsynced handles to reflect the items that committed succesfully.
707 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size());
689 // All properly encrypted and non-conflicting items should commit. "A" was 708 // All properly encrypted and non-conflicting items should commit. "A" was
690 // conflicting, but last sync cycle resolved it as simple conflict, so on 709 // conflicting, but last sync cycle resolved it as simple conflict, so on
691 // this sync cycle it committed succesfullly. 710 // this sync cycle it committed succesfullly.
692 ReadTransaction rtrans(FROM_HERE, dir); 711 ReadTransaction rtrans(FROM_HERE, dir);
693 // Committed successfully. 712 // Committed successfully.
694 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); 713 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans);
695 ASSERT_TRUE(entryA.good());
696 EXPECT_FALSE(entryA.Get(IS_UNSYNCED));
697 EXPECT_FALSE(entryA.Get(IS_UNAPPLIED_UPDATE));
698 // Committed successfully. 714 // Committed successfully.
699 Entry entryB(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2)); 715 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans);
700 ASSERT_TRUE(entryB.good());
701 EXPECT_FALSE(entryB.Get(IS_UNSYNCED));
702 EXPECT_FALSE(entryB.Get(IS_UNAPPLIED_UPDATE));
703 // Was not properly encrypted. 716 // Was not properly encrypted.
704 Entry entryC(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(3)); 717 VERIFY_ENTRY(3, false, true, false, 0, 10, 10, ids_, &rtrans);
705 ASSERT_TRUE(entryC.good());
706 EXPECT_TRUE(entryC.Get(IS_UNSYNCED));
707 EXPECT_FALSE(entryC.Get(IS_UNAPPLIED_UPDATE));
708 // Was not properly encrypted. 718 // Was not properly encrypted.
709 Entry entryD(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(4)); 719 VERIFY_ENTRY(4, false, true, false, 0, 10, 10, ids_, &rtrans);
710 ASSERT_TRUE(entryD.good());
711 EXPECT_TRUE(entryD.Get(IS_UNSYNCED));
712 EXPECT_FALSE(entryD.Get(IS_UNAPPLIED_UPDATE));
713 } 720 }
714 { 721 {
715 // Fix the remaining items. 722 // Fix the remaining items.
716 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); 723 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
717 MutableEntry C(&wtrans, GET_BY_ID, ids_.FromNumber(3)); 724 MutableEntry C(&wtrans, GET_BY_ID, ids_.FromNumber(3));
718 ASSERT_TRUE(C.good()); 725 ASSERT_TRUE(C.good());
719 C.Put(SPECIFICS, encrypted_bookmark); 726 C.Put(SPECIFICS, encrypted_bookmark);
720 C.Put(NON_UNIQUE_NAME, kEncryptedString); 727 C.Put(NON_UNIQUE_NAME, kEncryptedString);
721 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4)); 728 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4));
722 ASSERT_TRUE(D.good()); 729 ASSERT_TRUE(D.good());
723 D.Put(SPECIFICS, encrypted_bookmark); 730 D.Put(SPECIFICS, encrypted_bookmark);
724 D.Put(NON_UNIQUE_NAME, kEncryptedString); 731 D.Put(NON_UNIQUE_NAME, kEncryptedString);
725 } 732 }
726 SyncShareAsDelegate(); 733 SyncShareAsDelegate();
727 { 734 {
728 ASSERT_EQ(0U, session_->status_controller().unsynced_handles().size()); 735 // We attempted to commit two items.
736 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size());
737 EXPECT_TRUE(session_->status_controller().did_commit_items());
729 // None should be unsynced anymore. 738 // None should be unsynced anymore.
730 ReadTransaction rtrans(FROM_HERE, dir); 739 ReadTransaction rtrans(FROM_HERE, dir);
731 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); 740 VERIFY_ENTRY(1, false, false, false, 0, 21, 21, ids_, &rtrans);
732 ASSERT_TRUE(entryA.good()); 741 VERIFY_ENTRY(2, false, false, false, 0, 11, 11, ids_, &rtrans);
733 EXPECT_FALSE(entryA.Get(IS_UNSYNCED)); 742 VERIFY_ENTRY(3, false, false, false, 0, 11, 11, ids_, &rtrans);
734 EXPECT_FALSE(entryA.Get(IS_UNAPPLIED_UPDATE)); 743 VERIFY_ENTRY(4, false, false, false, 0, 11, 11, ids_, &rtrans);
735 Entry entryB(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2));
736 ASSERT_TRUE(entryB.good());
737 EXPECT_FALSE(entryB.Get(IS_UNSYNCED));
738 EXPECT_FALSE(entryB.Get(IS_UNAPPLIED_UPDATE));
739 Entry entryC(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(3));
740 ASSERT_TRUE(entryC.good());
741 EXPECT_FALSE(entryC.Get(IS_UNSYNCED));
742 EXPECT_FALSE(entryC.Get(IS_UNAPPLIED_UPDATE));
743 Entry entryD(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(4));
744 ASSERT_TRUE(entryD.good());
745 EXPECT_FALSE(entryD.Get(IS_UNSYNCED));
746 EXPECT_FALSE(entryD.Get(IS_UNAPPLIED_UPDATE));
747 } 744 }
748 } 745 }
749 746
747 TEST_F(SyncerTest, EncryptionAwareConflicts) {
748 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
749 ASSERT_TRUE(dir.good());
750 KeyParams key_params = {"localhost", "dummy", "foobar"};
751 browser_sync::Cryptographer other_cryptographer;
752 other_cryptographer.AddKey(key_params);
753 sync_pb::EntitySpecifics bookmark, encrypted_bookmark, modified_bookmark;
754 bookmark.MutableExtension(sync_pb::bookmark)->set_title("title");
755 other_cryptographer.Encrypt(bookmark,
756 encrypted_bookmark.mutable_encrypted());
757 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark);
758 modified_bookmark.MutableExtension(sync_pb::bookmark)->set_title("title2");
759 other_cryptographer.Encrypt(modified_bookmark,
760 modified_bookmark.mutable_encrypted());
761 sync_pb::EntitySpecifics pref, encrypted_pref, modified_pref;
762 pref.MutableExtension(sync_pb::preference)->set_name("name");
763 AddDefaultExtensionValue(syncable::PREFERENCES, &encrypted_pref);
764 other_cryptographer.Encrypt(pref,
765 encrypted_pref.mutable_encrypted());
766 modified_pref.MutableExtension(sync_pb::preference)->set_name("name2");
767 other_cryptographer.Encrypt(modified_pref,
768 modified_pref.mutable_encrypted());
769 {
770 // Mark bookmarks and preferences as encrypted and set the cryptographer to
771 // have pending keys.
772 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
773 sync_pb::EntitySpecifics specifics;
774 sync_pb::NigoriSpecifics* nigori =
775 specifics.MutableExtension(sync_pb::nigori);
776 other_cryptographer.GetKeys(nigori->mutable_encrypted());
777 nigori->set_encrypt_bookmarks(true);
778 nigori->set_encrypt_preferences(true);
779 syncdb_.manager()->GetCryptographer(&wtrans)->Update(*nigori);
780 EXPECT_TRUE(syncdb_.manager()->GetCryptographer(&wtrans)->
781 has_pending_keys());
782 }
783
784 mock_server_->AddUpdateSpecifics(1, 0, "A", 10, 10, true, 0, bookmark);
785 mock_server_->AddUpdateSpecifics(2, 1, "B", 10, 10, false, 2, bookmark);
786 mock_server_->AddUpdateSpecifics(3, 1, "C", 10, 10, false, 1, bookmark);
787 mock_server_->AddUpdateSpecifics(4, 0, "D", 10, 10, false, 0, pref);
788 SyncShareAsDelegate();
789 {
790 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size());
791 // Initial state. Everything is normal.
792 ReadTransaction rtrans(FROM_HERE, dir);
793 VERIFY_ENTRY(1, false, false, false, 0, 10, 10, ids_, &rtrans);
794 VERIFY_ENTRY(2, false, false, false, 1, 10, 10, ids_, &rtrans);
795 VERIFY_ENTRY(3, false, false, false, 1, 10, 10, ids_, &rtrans);
796 VERIFY_ENTRY(4, false, false, false, 0, 10, 10, ids_, &rtrans);
797 }
798
799 // Server side encryption will not be applied due to undecryptable data.
800 // At this point, BASE_SERVER_SPECIFICS should be filled for all four items.
801 mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 20, 20, true, 0,
802 encrypted_bookmark);
803 mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 20, 20, false, 2,
804 encrypted_bookmark);
805 mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 20, 20, false, 1,
806 encrypted_bookmark);
807 mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 20, 20, false, 0,
808 encrypted_pref);
809 SyncShareAsDelegate();
810 {
811 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size());
812 // All should be unapplied due to being undecryptable and have a valid
813 // BASE_SERVER_SPECIFICS.
814 ReadTransaction rtrans(FROM_HERE, dir);
815 VERIFY_ENTRY(1, true, false, true, 0, 10, 20, ids_, &rtrans);
816 VERIFY_ENTRY(2, true, false, true, 1, 10, 20, ids_, &rtrans);
817 VERIFY_ENTRY(3, true, false, true, 1, 10, 20, ids_, &rtrans);
818 VERIFY_ENTRY(4, true, false, true, 0, 10, 20, ids_, &rtrans);
819 }
820
821 // Server side change that don't modify anything should not affect
822 // BASE_SERVER_SPECIFICS (such as name changes and mtime changes).
823 mock_server_->AddUpdateSpecifics(1, 0, kEncryptedString, 30, 30, true, 0,
824 encrypted_bookmark);
825 mock_server_->AddUpdateSpecifics(2, 1, kEncryptedString, 30, 30, false, 2,
826 encrypted_bookmark);
827 // Item 3 doesn't change.
828 mock_server_->AddUpdateSpecifics(4, 0, kEncryptedString, 30, 30, false, 0,
829 encrypted_pref);
830 SyncShareAsDelegate();
831 {
832 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size());
833 // Items 1, 2, and 4 should have newer server versions, 3 remains the same.
834 // All should remain unapplied due to be undecryptable.
835 ReadTransaction rtrans(FROM_HERE, dir);
836 VERIFY_ENTRY(1, true, false, true, 0, 10, 30, ids_, &rtrans);
837 VERIFY_ENTRY(2, true, false, true, 1, 10, 30, ids_, &rtrans);
838 VERIFY_ENTRY(3, true, false, true, 1, 10, 20, ids_, &rtrans);
839 VERIFY_ENTRY(4, true, false, true, 0, 10, 30, ids_, &rtrans);
840 }
841
842 // Positional changes, parent changes, and specifics changes should reset
843 // BASE_SERVER_SPECIFICS.
844 // Became unencrypted.
845 mock_server_->AddUpdateSpecifics(1, 0, "A", 40, 40, true, 0, bookmark);
846 // Reordered to after item 2.
847 mock_server_->AddUpdateSpecifics(3, 1, kEncryptedString, 30, 30, false, 3,
848 encrypted_bookmark);
849 SyncShareAsDelegate();
850 {
851 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size());
852 // Items 2 and 4 should be the only ones with BASE_SERVER_SPECIFICS set.
853 // Items 1 is now unencrypted, so should have applied normally.
854 ReadTransaction rtrans(FROM_HERE, dir);
855 VERIFY_ENTRY(1, false, false, false, 0, 40, 40, ids_, &rtrans);
856 VERIFY_ENTRY(2, true, false, true, 1, 10, 30, ids_, &rtrans);
857 VERIFY_ENTRY(3, true, false, false, 1, 10, 30, ids_, &rtrans);
858 VERIFY_ENTRY(4, true, false, true, 0, 10, 30, ids_, &rtrans);
859 }
860
861 // Make local changes, which should remain unsynced for items 2, 3, 4.
862 {
863 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
864 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1));
865 ASSERT_TRUE(A.good());
866 A.Put(SPECIFICS, modified_bookmark);
867 A.Put(NON_UNIQUE_NAME, kEncryptedString);
868 A.Put(IS_UNSYNCED, true);
869 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2));
870 ASSERT_TRUE(B.good());
871 B.Put(SPECIFICS, modified_bookmark);
872 B.Put(NON_UNIQUE_NAME, kEncryptedString);
873 B.Put(IS_UNSYNCED, true);
874 MutableEntry C(&wtrans, GET_BY_ID, ids_.FromNumber(3));
875 ASSERT_TRUE(C.good());
876 C.Put(SPECIFICS, modified_bookmark);
877 C.Put(NON_UNIQUE_NAME, kEncryptedString);
878 C.Put(IS_UNSYNCED, true);
879 MutableEntry D(&wtrans, GET_BY_ID, ids_.FromNumber(4));
880 ASSERT_TRUE(D.good());
881 D.Put(SPECIFICS, modified_pref);
882 D.Put(NON_UNIQUE_NAME, kEncryptedString);
883 D.Put(IS_UNSYNCED, true);
884 }
885 SyncShareAsDelegate();
886 {
887 EXPECT_EQ(0U, session_->status_controller().unsynced_handles().size());
888 // Item 1 remains unsynced due to there being pending keys.
889 // Items 2, 3, 4 should remain unsynced since they were not up to date.
890 ReadTransaction rtrans(FROM_HERE, dir);
891 VERIFY_ENTRY(1, false, true, false, 0, 40, 40, ids_, &rtrans);
892 VERIFY_ENTRY(2, true, true, true, 1, 10, 30, ids_, &rtrans);
893 VERIFY_ENTRY(3, true, true, false, 1, 10, 30, ids_, &rtrans);
894 VERIFY_ENTRY(4, true, true, true, 0, 10, 30, ids_, &rtrans);
895 }
896
897 {
898 ReadTransaction rtrans(FROM_HERE, dir);
899 // Resolve the pending keys.
900 syncdb_.manager()->GetCryptographer(&rtrans)->DecryptPendingKeys(
901 key_params);
902 }
903 // First cycle resolves conflicts, second cycle commits changes.
904 SyncShareAsDelegate();
905 EXPECT_EQ(2, session_->status_controller().syncer_status().
906 num_server_overwrites);
907 EXPECT_EQ(1, session_->status_controller().syncer_status().
908 num_local_overwrites);
909 // We attempted to commit item 1.
910 EXPECT_EQ(1U, session_->status_controller().unsynced_handles().size());
911 EXPECT_TRUE(session_->status_controller().did_commit_items());
912 SyncShareAsDelegate();
913 {
914 // Everything should be resolved now. The local changes should have
915 // overwritten the server changes for 2 and 4, while the server changes
916 // overwrote the local for entry 3.
917 // We attempted to commit two handles.
918 EXPECT_EQ(0, session_->status_controller().syncer_status().
919 num_server_overwrites);
920 EXPECT_EQ(0, session_->status_controller().syncer_status().
921 num_local_overwrites);
922 EXPECT_EQ(2U, session_->status_controller().unsynced_handles().size());
923 EXPECT_TRUE(session_->status_controller().did_commit_items());
924 ReadTransaction rtrans(FROM_HERE, dir);
925 VERIFY_ENTRY(1, false, false, false, 0, 41, 41, ids_, &rtrans);
926 VERIFY_ENTRY(2, false, false, false, 1, 31, 31, ids_, &rtrans);
927 VERIFY_ENTRY(3, false, false, false, 1, 30, 30, ids_, &rtrans);
928 VERIFY_ENTRY(4, false, false, false, 0, 31, 31, ids_, &rtrans);
929 }
930 }
931
932 #undef VERIFY_ENTRY
933
750 TEST_F(SyncerTest, NigoriConflicts) { 934 TEST_F(SyncerTest, NigoriConflicts) {
751 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); 935 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
752 ASSERT_TRUE(dir.good()); 936 ASSERT_TRUE(dir.good());
753 KeyParams local_key_params = {"localhost", "dummy", "blargle"}; 937 KeyParams local_key_params = {"localhost", "dummy", "blargle"};
754 KeyParams other_key_params = {"localhost", "dummy", "foobar"}; 938 KeyParams other_key_params = {"localhost", "dummy", "foobar"};
755 browser_sync::Cryptographer other_cryptographer; 939 browser_sync::Cryptographer other_cryptographer;
756 other_cryptographer.AddKey(other_key_params); 940 other_cryptographer.AddKey(other_key_params);
757 syncable::ModelTypeSet encrypted_types(syncable::PASSWORDS, syncable::NIGORI); 941 syncable::ModelTypeSet encrypted_types(syncable::PASSWORDS, syncable::NIGORI);
758 sync_pb::EntitySpecifics initial_nigori_specifics; 942 sync_pb::EntitySpecifics initial_nigori_specifics;
759 initial_nigori_specifics.MutableExtension(sync_pb::nigori); 943 initial_nigori_specifics.MutableExtension(sync_pb::nigori);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 CanDecryptUsingDefaultKey(our_encrypted_specifics.encrypted())); 1053 CanDecryptUsingDefaultKey(our_encrypted_specifics.encrypted()));
870 EXPECT_TRUE(syncdb_.manager()->GetCryptographer(&wtrans)->CanDecrypt( 1054 EXPECT_TRUE(syncdb_.manager()->GetCryptographer(&wtrans)->CanDecrypt(
871 other_encrypted_specifics.encrypted())); 1055 other_encrypted_specifics.encrypted()));
872 EXPECT_TRUE(syncdb_.manager()->GetCryptographer(&wtrans)-> 1056 EXPECT_TRUE(syncdb_.manager()->GetCryptographer(&wtrans)->
873 CanDecryptUsingDefaultKey(other_encrypted_specifics.encrypted())); 1057 CanDecryptUsingDefaultKey(other_encrypted_specifics.encrypted()));
874 EXPECT_TRUE(nigori_entry.Get(SPECIFICS).GetExtension(sync_pb::nigori) 1058 EXPECT_TRUE(nigori_entry.Get(SPECIFICS).GetExtension(sync_pb::nigori)
875 .sync_tabs()); 1059 .sync_tabs());
876 } 1060 }
877 } 1061 }
878 1062
879
880 // TODO(chron): More corner case unit tests around validation. 1063 // TODO(chron): More corner case unit tests around validation.
881 TEST_F(SyncerTest, TestCommitMetahandleIterator) { 1064 TEST_F(SyncerTest, TestCommitMetahandleIterator) {
882 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); 1065 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
883 ASSERT_TRUE(dir.good()); 1066 ASSERT_TRUE(dir.good());
884 StatusController* status = session_->mutable_status_controller(); 1067 StatusController* status = session_->mutable_status_controller();
885 const vector<int64>& unsynced(status->unsynced_handles()); 1068 const vector<int64>& unsynced(status->unsynced_handles());
886 1069
887 { 1070 {
888 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); 1071 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
889 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); 1072 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans);
(...skipping 3248 matching lines...) Expand 10 before | Expand all | Expand 10 after
4138 EXPECT_GE(0, Get(metahandle_, BASE_VERSION)); 4321 EXPECT_GE(0, Get(metahandle_, BASE_VERSION));
4139 EXPECT_GE(0, Get(metahandle_, SERVER_VERSION)); 4322 EXPECT_GE(0, Get(metahandle_, SERVER_VERSION));
4140 } 4323 }
4141 4324
4142 protected: 4325 protected:
4143 const std::string client_tag_; 4326 const std::string client_tag_;
4144 int64 metahandle_; 4327 int64 metahandle_;
4145 }; 4328 };
4146 4329
4147 TEST_F(SyncerUndeletionTest, UndeleteDuringCommit) { 4330 TEST_F(SyncerUndeletionTest, UndeleteDuringCommit) {
4148 const StatusController& status = session_->status_controller();
4149
4150 Create(); 4331 Create();
4151 ExpectUnsyncedCreation(); 4332 ExpectUnsyncedCreation();
4152 SyncShareAsDelegate(); 4333 SyncShareAsDelegate();
4153 4334
4154 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4335 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4155 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4336 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4156 ExpectSyncedAndCreated(); 4337 ExpectSyncedAndCreated();
4157 4338
4158 // Delete, begin committing the delete, then undelete while committing. 4339 // Delete, begin committing the delete, then undelete while committing.
4159 Delete(); 4340 Delete();
4160 ExpectUnsyncedDeletion(); 4341 ExpectUnsyncedDeletion();
4161 mock_server_->SetMidCommitCallback( 4342 mock_server_->SetMidCommitCallback(
4162 NewCallback<SyncerUndeletionTest>(this, 4343 NewCallback<SyncerUndeletionTest>(this,
4163 &SyncerUndeletionTest::Undelete)); 4344 &SyncerUndeletionTest::Undelete));
4164 SyncShareAsDelegate(); 4345 SyncShareAsDelegate();
4165 4346
4166 // The item ought to exist as an unsynced undeletion (meaning, 4347 // The item ought to exist as an unsynced undeletion (meaning,
4167 // we think that the next commit ought to be a recreation commit). 4348 // we think that the next commit ought to be a recreation commit).
4168 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4349 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4169 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4350 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4170 ExpectUnsyncedUndeletion(); 4351 ExpectUnsyncedUndeletion();
4171 4352
4172 // Now, encounter a GetUpdates corresponding to the deletion from 4353 // Now, encounter a GetUpdates corresponding to the deletion from
4173 // the server. The undeletion should prevail again and be committed. 4354 // the server. The undeletion should prevail again and be committed.
4174 // None of this should trigger any conflict detection -- it is perfectly 4355 // None of this should trigger any conflict detection -- it is perfectly
4175 // normal to recieve updates from our own commits. 4356 // normal to recieve updates from our own commits.
4176 mock_server_->SetMidCommitCallback(NULL); 4357 mock_server_->SetMidCommitCallback(NULL);
4177 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); 4358 mock_server_->AddUpdateTombstone(Get(metahandle_, ID));
4178 SyncShareAsDelegate(); 4359 SyncShareAsDelegate();
4179 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4360 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4180 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4361 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4181 ExpectSyncedAndCreated(); 4362 ExpectSyncedAndCreated();
4182 } 4363 }
4183 4364
4184 TEST_F(SyncerUndeletionTest, UndeleteBeforeCommit) { 4365 TEST_F(SyncerUndeletionTest, UndeleteBeforeCommit) {
4185 const StatusController& status = session_->status_controller();
4186
4187 Create(); 4366 Create();
4188 ExpectUnsyncedCreation(); 4367 ExpectUnsyncedCreation();
4189 SyncShareAsDelegate(); 4368 SyncShareAsDelegate();
4190 4369
4191 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4370 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4192 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4371 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4193 ExpectSyncedAndCreated(); 4372 ExpectSyncedAndCreated();
4194 4373
4195 // Delete and undelete, then sync to pick up the result. 4374 // Delete and undelete, then sync to pick up the result.
4196 Delete(); 4375 Delete();
4197 ExpectUnsyncedDeletion(); 4376 ExpectUnsyncedDeletion();
4198 Undelete(); 4377 Undelete();
4199 ExpectUnsyncedEdit(); // Edit, not undelete: server thinks it exists. 4378 ExpectUnsyncedEdit(); // Edit, not undelete: server thinks it exists.
4200 SyncShareAsDelegate(); 4379 SyncShareAsDelegate();
4201 4380
4202 // The item ought to have committed successfully. 4381 // The item ought to have committed successfully.
4203 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4382 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4204 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4383 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4205 ExpectSyncedAndCreated(); 4384 ExpectSyncedAndCreated();
4206 EXPECT_EQ(2, Get(metahandle_, BASE_VERSION)); 4385 EXPECT_EQ(2, Get(metahandle_, BASE_VERSION));
4207 4386
4208 // Now, encounter a GetUpdates corresponding to the just-committed 4387 // Now, encounter a GetUpdates corresponding to the just-committed
4209 // update. 4388 // update.
4210 mock_server_->AddUpdateFromLastCommit(); 4389 mock_server_->AddUpdateFromLastCommit();
4211 SyncShareAsDelegate(); 4390 SyncShareAsDelegate();
4212 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4391 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4213 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4392 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4214 ExpectSyncedAndCreated(); 4393 ExpectSyncedAndCreated();
4215 } 4394 }
4216 4395
4217 TEST_F(SyncerUndeletionTest, UndeleteAfterCommitButBeforeGetUpdates) { 4396 TEST_F(SyncerUndeletionTest, UndeleteAfterCommitButBeforeGetUpdates) {
4218 const StatusController& status = session_->status_controller();
4219
4220 Create(); 4397 Create();
4221 ExpectUnsyncedCreation(); 4398 ExpectUnsyncedCreation();
4222 SyncShareAsDelegate(); 4399 SyncShareAsDelegate();
4223 4400
4224 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4401 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4225 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4402 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4226 ExpectSyncedAndCreated(); 4403 ExpectSyncedAndCreated();
4227 4404
4228 // Delete and commit. 4405 // Delete and commit.
4229 Delete(); 4406 Delete();
4230 ExpectUnsyncedDeletion(); 4407 ExpectUnsyncedDeletion();
4231 SyncShareAsDelegate(); 4408 SyncShareAsDelegate();
4232 4409
4233 // The item ought to have committed successfully. 4410 // The item ought to have committed successfully.
4234 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4411 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4235 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4412 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4236 ExpectSyncedAndDeleted(); 4413 ExpectSyncedAndDeleted();
4237 4414
4238 // Before the GetUpdates, the item is locally undeleted. 4415 // Before the GetUpdates, the item is locally undeleted.
4239 Undelete(); 4416 Undelete();
4240 ExpectUnsyncedUndeletion(); 4417 ExpectUnsyncedUndeletion();
4241 4418
4242 // Now, encounter a GetUpdates corresponding to the just-committed 4419 // Now, encounter a GetUpdates corresponding to the just-committed
4243 // deletion update. The undeletion should prevail. 4420 // deletion update. The undeletion should prevail.
4244 mock_server_->AddUpdateFromLastCommit(); 4421 mock_server_->AddUpdateFromLastCommit();
4245 SyncShareAsDelegate(); 4422 SyncShareAsDelegate();
4246 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4423 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4247 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4424 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4248 ExpectSyncedAndCreated(); 4425 ExpectSyncedAndCreated();
4249 } 4426 }
4250 4427
4251 TEST_F(SyncerUndeletionTest, UndeleteAfterDeleteAndGetUpdates) { 4428 TEST_F(SyncerUndeletionTest, UndeleteAfterDeleteAndGetUpdates) {
4252 const StatusController& status = session_->status_controller();
4253
4254 Create(); 4429 Create();
4255 ExpectUnsyncedCreation(); 4430 ExpectUnsyncedCreation();
4256 SyncShareAsDelegate(); 4431 SyncShareAsDelegate();
4257 4432
4258 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4433 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4259 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4434 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4260 ExpectSyncedAndCreated(); 4435 ExpectSyncedAndCreated();
4261 4436
4262 mock_server_->AddUpdateFromLastCommit(); 4437 mock_server_->AddUpdateFromLastCommit();
4263 SyncShareAsDelegate(); 4438 SyncShareAsDelegate();
4264 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4439 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4265 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4440 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4266 ExpectSyncedAndCreated(); 4441 ExpectSyncedAndCreated();
4267 4442
4268 // Delete and commit. 4443 // Delete and commit.
4269 Delete(); 4444 Delete();
4270 ExpectUnsyncedDeletion(); 4445 ExpectUnsyncedDeletion();
4271 SyncShareAsDelegate(); 4446 SyncShareAsDelegate();
4272 4447
4273 // The item ought to have committed successfully. 4448 // The item ought to have committed successfully.
4274 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4449 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4275 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4450 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4276 ExpectSyncedAndDeleted(); 4451 ExpectSyncedAndDeleted();
4277 4452
4278 // Now, encounter a GetUpdates corresponding to the just-committed 4453 // Now, encounter a GetUpdates corresponding to the just-committed
4279 // deletion update. Should be consistent. 4454 // deletion update. Should be consistent.
4280 mock_server_->AddUpdateFromLastCommit(); 4455 mock_server_->AddUpdateFromLastCommit();
4281 SyncShareAsDelegate(); 4456 SyncShareAsDelegate();
4282 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4457 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4283 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4458 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4284 ExpectSyncedAndDeleted(); 4459 ExpectSyncedAndDeleted();
4285 4460
4286 // After the GetUpdates, the item is locally undeleted. 4461 // After the GetUpdates, the item is locally undeleted.
4287 Undelete(); 4462 Undelete();
4288 ExpectUnsyncedUndeletion(); 4463 ExpectUnsyncedUndeletion();
4289 4464
4290 // Now, encounter a GetUpdates corresponding to the just-committed 4465 // Now, encounter a GetUpdates corresponding to the just-committed
4291 // deletion update. The undeletion should prevail. 4466 // deletion update. The undeletion should prevail.
4292 SyncShareAsDelegate(); 4467 SyncShareAsDelegate();
4293 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4468 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4294 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4469 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4295 ExpectSyncedAndCreated(); 4470 ExpectSyncedAndCreated();
4296 } 4471 }
4297 4472
4298 // Test processing of undeletion GetUpdateses. 4473 // Test processing of undeletion GetUpdateses.
4299 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletes) { 4474 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletes) {
4300 const StatusController& status = session_->status_controller();
4301
4302 Create(); 4475 Create();
4303 ExpectUnsyncedCreation(); 4476 ExpectUnsyncedCreation();
4304 SyncShareAsDelegate(); 4477 SyncShareAsDelegate();
4305 4478
4306 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4479 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4307 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4480 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4308 ExpectSyncedAndCreated(); 4481 ExpectSyncedAndCreated();
4309 4482
4310 // Add a delete from the server. 4483 // Add a delete from the server.
4311 mock_server_->AddUpdateFromLastCommit(); 4484 mock_server_->AddUpdateFromLastCommit();
4312 SyncShareAsDelegate(); 4485 SyncShareAsDelegate();
4313 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4486 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4314 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4487 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4315 ExpectSyncedAndCreated(); 4488 ExpectSyncedAndCreated();
4316 4489
4317 // Some other client deletes the item. 4490 // Some other client deletes the item.
4318 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); 4491 mock_server_->AddUpdateTombstone(Get(metahandle_, ID));
4319 SyncShareAsDelegate(); 4492 SyncShareAsDelegate();
4320 4493
4321 // The update ought to have applied successfully. 4494 // The update ought to have applied successfully.
4322 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4495 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4323 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4496 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4324 ExpectSyncedAndDeleted(); 4497 ExpectSyncedAndDeleted();
4325 4498
4326 // Undelete it locally. 4499 // Undelete it locally.
4327 Undelete(); 4500 Undelete();
4328 ExpectUnsyncedUndeletion(); 4501 ExpectUnsyncedUndeletion();
4329 SyncShareAsDelegate(); 4502 SyncShareAsDelegate();
4330 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4503 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4331 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4504 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4332 ExpectSyncedAndCreated(); 4505 ExpectSyncedAndCreated();
4333 4506
4334 // Now, encounter a GetUpdates corresponding to the just-committed 4507 // Now, encounter a GetUpdates corresponding to the just-committed
4335 // deletion update. The undeletion should prevail. 4508 // deletion update. The undeletion should prevail.
4336 mock_server_->AddUpdateFromLastCommit(); 4509 mock_server_->AddUpdateFromLastCommit();
4337 SyncShareAsDelegate(); 4510 SyncShareAsDelegate();
4338 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4511 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4339 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4512 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4340 ExpectSyncedAndCreated(); 4513 ExpectSyncedAndCreated();
4341 } 4514 }
4342 4515
4343 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletesImmediately) { 4516 TEST_F(SyncerUndeletionTest, UndeleteAfterOtherClientDeletesImmediately) {
4344 const StatusController& status = session_->status_controller();
4345
4346 Create(); 4517 Create();
4347 ExpectUnsyncedCreation(); 4518 ExpectUnsyncedCreation();
4348 SyncShareAsDelegate(); 4519 SyncShareAsDelegate();
4349 4520
4350 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4521 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4351 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4522 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4352 ExpectSyncedAndCreated(); 4523 ExpectSyncedAndCreated();
4353 4524
4354 // Some other client deletes the item before we get a chance 4525 // Some other client deletes the item before we get a chance
4355 // to GetUpdates our original request. 4526 // to GetUpdates our original request.
4356 mock_server_->AddUpdateTombstone(Get(metahandle_, ID)); 4527 mock_server_->AddUpdateTombstone(Get(metahandle_, ID));
4357 SyncShareAsDelegate(); 4528 SyncShareAsDelegate();
4358 4529
4359 // The update ought to have applied successfully. 4530 // The update ought to have applied successfully.
4360 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4531 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4361 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4532 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4362 ExpectSyncedAndDeleted(); 4533 ExpectSyncedAndDeleted();
4363 4534
4364 // Undelete it locally. 4535 // Undelete it locally.
4365 Undelete(); 4536 Undelete();
4366 ExpectUnsyncedUndeletion(); 4537 ExpectUnsyncedUndeletion();
4367 SyncShareAsDelegate(); 4538 SyncShareAsDelegate();
4368 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4539 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4369 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4540 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4370 ExpectSyncedAndCreated(); 4541 ExpectSyncedAndCreated();
4371 4542
4372 // Now, encounter a GetUpdates corresponding to the just-committed 4543 // Now, encounter a GetUpdates corresponding to the just-committed
4373 // deletion update. The undeletion should prevail. 4544 // deletion update. The undeletion should prevail.
4374 mock_server_->AddUpdateFromLastCommit(); 4545 mock_server_->AddUpdateFromLastCommit();
4375 SyncShareAsDelegate(); 4546 SyncShareAsDelegate();
4376 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4547 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4377 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4548 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4378 ExpectSyncedAndCreated(); 4549 ExpectSyncedAndCreated();
4379 } 4550 }
4380 4551
4381 TEST_F(SyncerUndeletionTest, OtherClientUndeletes) { 4552 TEST_F(SyncerUndeletionTest, OtherClientUndeletes) {
4382 const StatusController& status = session_->status_controller();
4383
4384 Create(); 4553 Create();
4385 ExpectUnsyncedCreation(); 4554 ExpectUnsyncedCreation();
4386 SyncShareAsDelegate(); 4555 SyncShareAsDelegate();
4387 4556
4388 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4557 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4389 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4558 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4390 ExpectSyncedAndCreated(); 4559 ExpectSyncedAndCreated();
4391 4560
4392 // Get the updates of our just-committed entry. 4561 // Get the updates of our just-committed entry.
4393 mock_server_->AddUpdateFromLastCommit(); 4562 mock_server_->AddUpdateFromLastCommit();
4394 SyncShareAsDelegate(); 4563 SyncShareAsDelegate();
4395 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4564 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4396 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4565 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4397 ExpectSyncedAndCreated(); 4566 ExpectSyncedAndCreated();
4398 4567
4399 // We delete the item. 4568 // We delete the item.
4400 Delete(); 4569 Delete();
4401 ExpectUnsyncedDeletion(); 4570 ExpectUnsyncedDeletion();
4402 SyncShareAsDelegate(); 4571 SyncShareAsDelegate();
4403 4572
4404 // The update ought to have applied successfully. 4573 // The update ought to have applied successfully.
4405 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4574 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4406 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4575 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4407 ExpectSyncedAndDeleted(); 4576 ExpectSyncedAndDeleted();
4408 4577
4409 // Now, encounter a GetUpdates corresponding to the just-committed 4578 // Now, encounter a GetUpdates corresponding to the just-committed
4410 // deletion update. 4579 // deletion update.
4411 mock_server_->AddUpdateFromLastCommit(); 4580 mock_server_->AddUpdateFromLastCommit();
4412 SyncShareAsDelegate(); 4581 SyncShareAsDelegate();
4413 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4582 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4414 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4583 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4415 ExpectSyncedAndDeleted(); 4584 ExpectSyncedAndDeleted();
4416 4585
4417 // Some other client undeletes the item. 4586 // Some other client undeletes the item.
4418 mock_server_->AddUpdateBookmark(Get(metahandle_, ID), 4587 mock_server_->AddUpdateBookmark(Get(metahandle_, ID),
4419 Get(metahandle_, PARENT_ID), 4588 Get(metahandle_, PARENT_ID),
4420 "Thadeusz", 100, 1000); 4589 "Thadeusz", 100, 1000);
4421 mock_server_->SetLastUpdateClientTag(client_tag_); 4590 mock_server_->SetLastUpdateClientTag(client_tag_);
4422 SyncShareAsDelegate(); 4591 SyncShareAsDelegate();
4423 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4592 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4424 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4593 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4425 ExpectSyncedAndCreated(); 4594 ExpectSyncedAndCreated();
4426 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME)); 4595 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME));
4427 } 4596 }
4428 4597
4429 TEST_F(SyncerUndeletionTest, OtherClientUndeletesImmediately) { 4598 TEST_F(SyncerUndeletionTest, OtherClientUndeletesImmediately) {
4430 const StatusController& status = session_->status_controller();
4431
4432 Create(); 4599 Create();
4433 ExpectUnsyncedCreation(); 4600 ExpectUnsyncedCreation();
4434 SyncShareAsDelegate(); 4601 SyncShareAsDelegate();
4435 4602
4436 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4603 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4437 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4604 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4438 ExpectSyncedAndCreated(); 4605 ExpectSyncedAndCreated();
4439 4606
4440 // Get the updates of our just-committed entry. 4607 // Get the updates of our just-committed entry.
4441 mock_server_->AddUpdateFromLastCommit(); 4608 mock_server_->AddUpdateFromLastCommit();
4442 SyncShareAsDelegate(); 4609 SyncShareAsDelegate();
4443 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4610 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4444 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4611 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4445 ExpectSyncedAndCreated(); 4612 ExpectSyncedAndCreated();
4446 4613
4447 // We delete the item. 4614 // We delete the item.
4448 Delete(); 4615 Delete();
4449 ExpectUnsyncedDeletion(); 4616 ExpectUnsyncedDeletion();
4450 SyncShareAsDelegate(); 4617 SyncShareAsDelegate();
4451 4618
4452 // The update ought to have applied successfully. 4619 // The update ought to have applied successfully.
4453 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4620 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4454 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4621 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4455 ExpectSyncedAndDeleted(); 4622 ExpectSyncedAndDeleted();
4456 4623
4457 // Some other client undeletes before we see the update from our 4624 // Some other client undeletes before we see the update from our
4458 // commit. 4625 // commit.
4459 mock_server_->AddUpdateBookmark(Get(metahandle_, ID), 4626 mock_server_->AddUpdateBookmark(Get(metahandle_, ID),
4460 Get(metahandle_, PARENT_ID), 4627 Get(metahandle_, PARENT_ID),
4461 "Thadeusz", 100, 1000); 4628 "Thadeusz", 100, 1000);
4462 mock_server_->SetLastUpdateClientTag(client_tag_); 4629 mock_server_->SetLastUpdateClientTag(client_tag_);
4463 SyncShareAsDelegate(); 4630 SyncShareAsDelegate();
4464 EXPECT_EQ(0, status.TotalNumConflictingItems()); 4631 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems());
4465 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); 4632 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests());
4466 ExpectSyncedAndCreated(); 4633 ExpectSyncedAndCreated();
4467 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME)); 4634 EXPECT_EQ("Thadeusz", Get(metahandle_, NON_UNIQUE_NAME));
4468 } 4635 }
4469 4636
4470 // A group of tests exercising the syncer's handling of sibling ordering, as 4637 // A group of tests exercising the syncer's handling of sibling ordering, as
4471 // represented in the sync protocol. 4638 // represented in the sync protocol.
4472 class SyncerPositionUpdateTest : public SyncerTest { 4639 class SyncerPositionUpdateTest : public SyncerTest {
4473 public: 4640 public:
4474 SyncerPositionUpdateTest() : next_update_id_(1), next_revision_(1) {} 4641 SyncerPositionUpdateTest() : next_update_id_(1), next_revision_(1) {}
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
4682 Add(low_id_); 4849 Add(low_id_);
4683 Add(high_id_); 4850 Add(high_id_);
4684 SyncShareAsDelegate(); 4851 SyncShareAsDelegate();
4685 ExpectLocalOrderIsByServerId(); 4852 ExpectLocalOrderIsByServerId();
4686 } 4853 }
4687 4854
4688 const SyncerTest::CommitOrderingTest 4855 const SyncerTest::CommitOrderingTest
4689 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; 4856 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()};
4690 4857
4691 } // namespace browser_sync 4858 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/process_updates_command.cc ('k') | chrome/browser/sync/engine/syncer_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698