| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 entry. | 3 // found in the LICENSE entry. |
| 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 <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/at_exit.h" | 12 #include "base/at_exit.h" |
| 13 | 13 |
| 14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/sync/engine/client_command_channel.h" | |
| 17 #include "chrome/browser/sync/engine/conflict_resolution_view.h" | |
| 18 #include "chrome/browser/sync/engine/conflict_resolver.h" | 16 #include "chrome/browser/sync/engine/conflict_resolver.h" |
| 19 #include "chrome/browser/sync/engine/get_commit_ids_command.h" | 17 #include "chrome/browser/sync/engine/get_commit_ids_command.h" |
| 20 #include "chrome/browser/sync/engine/model_safe_worker.h" | 18 #include "chrome/browser/sync/engine/model_safe_worker.h" |
| 21 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 19 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| 22 #include "chrome/browser/sync/engine/process_updates_command.h" | 20 #include "chrome/browser/sync/engine/process_updates_command.h" |
| 23 #include "chrome/browser/sync/engine/syncer.h" | 21 #include "chrome/browser/sync/engine/syncer.h" |
| 24 #include "chrome/browser/sync/engine/syncer_util.h" | 22 #include "chrome/browser/sync/engine/syncer_util.h" |
| 25 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 23 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
| 26 #include "chrome/browser/sync/engine/syncer_session.h" | |
| 27 #include "chrome/browser/sync/protocol/sync.pb.h" | 24 #include "chrome/browser/sync/protocol/sync.pb.h" |
| 28 #include "chrome/browser/sync/syncable/directory_manager.h" | 25 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 29 #include "chrome/browser/sync/syncable/syncable.h" | 26 #include "chrome/browser/sync/syncable/syncable.h" |
| 30 #include "chrome/browser/sync/util/closure.h" | 27 #include "chrome/browser/sync/util/closure.h" |
| 31 #include "chrome/browser/sync/util/event_sys-inl.h" | 28 #include "chrome/browser/sync/util/event_sys-inl.h" |
| 32 #include "chrome/test/sync/engine/mock_server_connection.h" | 29 #include "chrome/test/sync/engine/mock_server_connection.h" |
| 33 #include "chrome/test/sync/engine/test_directory_setter_upper.h" | 30 #include "chrome/test/sync/engine/test_directory_setter_upper.h" |
| 34 #include "chrome/test/sync/engine/test_id_factory.h" | 31 #include "chrome/test/sync/engine/test_id_factory.h" |
| 35 #include "chrome/test/sync/engine/test_syncable_utils.h" | 32 #include "chrome/test/sync/engine/test_syncable_utils.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 37 | 34 |
| 35 using base::TimeDelta; |
| 36 |
| 38 using std::map; | 37 using std::map; |
| 39 using std::multimap; | 38 using std::multimap; |
| 40 using std::set; | 39 using std::set; |
| 41 using std::string; | 40 using std::string; |
| 42 | 41 |
| 43 namespace browser_sync { | 42 namespace browser_sync { |
| 44 | 43 |
| 45 using syncable::BaseTransaction; | 44 using syncable::BaseTransaction; |
| 46 using syncable::Blob; | 45 using syncable::Blob; |
| 47 using syncable::CountEntriesWithName; | 46 using syncable::CountEntriesWithName; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 77 using syncable::PARENT_ID; | 76 using syncable::PARENT_ID; |
| 78 using syncable::PREV_ID; | 77 using syncable::PREV_ID; |
| 79 using syncable::SERVER_IS_DEL; | 78 using syncable::SERVER_IS_DEL; |
| 80 using syncable::SERVER_NON_UNIQUE_NAME; | 79 using syncable::SERVER_NON_UNIQUE_NAME; |
| 81 using syncable::SERVER_PARENT_ID; | 80 using syncable::SERVER_PARENT_ID; |
| 82 using syncable::SERVER_POSITION_IN_PARENT; | 81 using syncable::SERVER_POSITION_IN_PARENT; |
| 83 using syncable::SERVER_VERSION; | 82 using syncable::SERVER_VERSION; |
| 84 using syncable::SINGLETON_TAG; | 83 using syncable::SINGLETON_TAG; |
| 85 using syncable::UNITTEST; | 84 using syncable::UNITTEST; |
| 86 | 85 |
| 86 using sessions::ConflictProgress; |
| 87 using sessions::ScopedSetSessionWriteTransaction; |
| 88 using sessions::StatusController; |
| 89 using sessions::SyncSessionContext; |
| 90 using sessions::SyncSession; |
| 91 |
| 87 namespace { | 92 namespace { |
| 88 const char* kTestData = "Hello World!"; | 93 const char* kTestData = "Hello World!"; |
| 89 const int kTestDataLen = 12; | 94 const int kTestDataLen = 12; |
| 90 const int64 kTestLogRequestTimestamp = 123456; | 95 const int64 kTestLogRequestTimestamp = 123456; |
| 91 } // namespace | 96 } // namespace |
| 92 | 97 |
| 93 class SyncerTest : public testing::Test { | 98 class SyncerTest : public testing::Test, public SyncSession::Delegate { |
| 94 protected: | 99 protected: |
| 95 SyncerTest() : client_command_channel_(0) { | 100 SyncerTest() : syncer_(NULL) {} |
| 101 |
| 102 // SyncSession::Delegate implementation. |
| 103 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) { |
| 104 FAIL() << "Should not get silenced."; |
| 96 } | 105 } |
| 97 | 106 virtual bool IsSyncingCurrentlySilenced() { |
| 98 void HandleClientCommand(const sync_pb::ClientCommand* event) { | 107 return false; |
| 99 last_client_command_ = *event; | 108 } |
| 109 virtual void OnReceivedLongPollIntervalUpdate( |
| 110 const base::TimeDelta& new_interval) { |
| 111 last_long_poll_interval_received_ = new_interval; |
| 112 } |
| 113 virtual void OnReceivedShortPollIntervalUpdate( |
| 114 const base::TimeDelta& new_interval) { |
| 115 last_short_poll_interval_received_ = new_interval; |
| 100 } | 116 } |
| 101 | 117 |
| 102 void HandleSyncerEvent(SyncerEvent event) { | 118 void HandleSyncerEvent(SyncerEvent event) { |
| 103 LOG(INFO) << "HandleSyncerEvent in unittest " << event.what_happened; | 119 LOG(INFO) << "HandleSyncerEvent in unittest " << event.what_happened; |
| 104 // we only test for entry-specific events, not status changed ones. | 120 // we only test for entry-specific events, not status changed ones. |
| 105 switch (event.what_happened) { | 121 switch (event.what_happened) { |
| 106 case SyncerEvent::STATUS_CHANGED: | 122 case SyncerEvent::STATUS_CHANGED: |
| 107 // fall through | 123 // fall through |
| 108 case SyncerEvent::SYNC_CYCLE_ENDED: | 124 case SyncerEvent::SYNC_CYCLE_ENDED: |
| 109 // fall through | 125 // fall through |
| 110 case SyncerEvent::COMMITS_SUCCEEDED: | 126 case SyncerEvent::COMMITS_SUCCEEDED: |
| 111 return; | 127 return; |
| 112 case SyncerEvent::SHUTDOWN_USE_WITH_CARE: | 128 case SyncerEvent::SHUTDOWN_USE_WITH_CARE: |
| 113 case SyncerEvent::OVER_QUOTA: | 129 case SyncerEvent::OVER_QUOTA: |
| 114 case SyncerEvent::REQUEST_SYNC_NUDGE: | 130 case SyncerEvent::REQUEST_SYNC_NUDGE: |
| 115 LOG(INFO) << "Handling event type " << event.what_happened; | 131 LOG(INFO) << "Handling event type " << event.what_happened; |
| 116 break; | 132 break; |
| 117 default: | 133 default: |
| 118 CHECK(false) << "Handling unknown error type in unit tests!!"; | 134 CHECK(false) << "Handling unknown error type in unit tests!!"; |
| 119 } | 135 } |
| 120 syncer_events_.insert(event); | 136 syncer_events_.insert(event); |
| 121 } | 137 } |
| 122 | 138 |
| 123 void LoopSyncShare(Syncer* syncer) { | 139 void LoopSyncShare(Syncer* syncer) { |
| 124 SyncProcessState state(syncdb_.manager(), syncdb_.name(), | |
| 125 mock_server_.get(), | |
| 126 syncer->conflict_resolver(), | |
| 127 syncer->channel(), | |
| 128 syncer->model_safe_worker()); | |
| 129 bool should_loop = false; | 140 bool should_loop = false; |
| 130 int loop_iterations = 0; | 141 int loop_iterations = 0; |
| 131 do { | 142 do { |
| 132 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; | 143 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; |
| 133 should_loop = syncer->SyncShare(&state); | 144 should_loop = syncer->SyncShare(this); |
| 134 } while (should_loop); | 145 } while (should_loop); |
| 135 } | 146 } |
| 136 | 147 |
| 137 virtual void SetUp() { | 148 virtual void SetUp() { |
| 138 syncdb_.SetUp(); | 149 syncdb_.SetUp(); |
| 139 | 150 |
| 140 mock_server_.reset( | 151 mock_server_.reset( |
| 141 new MockConnectionManager(syncdb_.manager(), syncdb_.name())); | 152 new MockConnectionManager(syncdb_.manager(), syncdb_.name())); |
| 142 model_safe_worker_.reset(new ModelSafeWorker()); | |
| 143 // Safe to pass NULL as Authwatcher for now since the code path that | |
| 144 // uses it is not unittested yet. | |
| 145 syncer_ = new Syncer(syncdb_.manager(), syncdb_.name(), | |
| 146 mock_server_.get(), | |
| 147 model_safe_worker_.get()); | |
| 148 CHECK(syncer_->channel()); | |
| 149 | 153 |
| 150 hookup_.reset(NewEventListenerHookup(syncer_->channel(), this, | 154 context_.reset(new SyncSessionContext(mock_server_.get(), syncdb_.manager(), |
| 155 new ModelSafeWorker())); |
| 156 context_->set_account_name(syncdb_.name()); |
| 157 ASSERT_FALSE(context_->syncer_event_channel()); |
| 158 ASSERT_FALSE(context_->resolver()); |
| 159 syncer_ = new Syncer(context_.get()); |
| 160 // The Syncer installs some components on the context. |
| 161 ASSERT_TRUE(context_->syncer_event_channel()); |
| 162 ASSERT_TRUE(context_->resolver()); |
| 163 |
| 164 hookup_.reset(NewEventListenerHookup(context_->syncer_event_channel(), this, |
| 151 &SyncerTest::HandleSyncerEvent)); | 165 &SyncerTest::HandleSyncerEvent)); |
| 152 | 166 session_.reset(new SyncSession(context_.get(), this)); |
| 153 command_channel_hookup_.reset(NewEventListenerHookup( | |
| 154 &client_command_channel_, this, &SyncerTest::HandleClientCommand)); | |
| 155 syncer_->set_command_channel(&client_command_channel_); | |
| 156 | |
| 157 state_.reset(new SyncProcessState(syncdb_.manager(), syncdb_.name(), | |
| 158 mock_server_.get(), | |
| 159 syncer_->conflict_resolver(), | |
| 160 syncer_->channel(), | |
| 161 syncer_->model_safe_worker())); | |
| 162 | 167 |
| 163 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 168 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 164 CHECK(dir.good()); | 169 CHECK(dir.good()); |
| 165 ReadTransaction trans(dir, __FILE__, __LINE__); | 170 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 166 syncable::Directory::ChildHandles children; | 171 syncable::Directory::ChildHandles children; |
| 167 dir->GetChildHandles(&trans, trans.root_id(), &children); | 172 dir->GetChildHandles(&trans, trans.root_id(), &children); |
| 168 ASSERT_TRUE(0 == children.size()); | 173 ASSERT_TRUE(0 == children.size()); |
| 169 syncer_events_.clear(); | 174 syncer_events_.clear(); |
| 170 root_id_ = TestIdFactory::root(); | 175 root_id_ = TestIdFactory::root(); |
| 171 parent_id_ = ids_.MakeServer("parent id"); | 176 parent_id_ = ids_.MakeServer("parent id"); |
| 172 child_id_ = ids_.MakeServer("child id"); | 177 child_id_ = ids_.MakeServer("child id"); |
| 173 } | 178 } |
| 174 | 179 |
| 175 virtual void TearDown() { | 180 virtual void TearDown() { |
| 176 mock_server_.reset(); | 181 mock_server_.reset(); |
| 177 hookup_.reset(); | 182 hookup_.reset(); |
| 178 command_channel_hookup_.reset(); | |
| 179 delete syncer_; | 183 delete syncer_; |
| 184 syncer_ = NULL; |
| 180 syncdb_.TearDown(); | 185 syncdb_.TearDown(); |
| 181 } | 186 } |
| 182 void WriteTestDataToEntry(WriteTransaction* trans, MutableEntry* entry) { | 187 void WriteTestDataToEntry(WriteTransaction* trans, MutableEntry* entry) { |
| 183 EXPECT_FALSE(entry->Get(IS_DIR)); | 188 EXPECT_FALSE(entry->Get(IS_DIR)); |
| 184 EXPECT_FALSE(entry->Get(IS_DEL)); | 189 EXPECT_FALSE(entry->Get(IS_DEL)); |
| 185 Blob test_value(kTestData, kTestData + kTestDataLen); | 190 Blob test_value(kTestData, kTestData + kTestDataLen); |
| 186 ExtendedAttributeKey key(entry->Get(META_HANDLE), PSTR("DATA")); | 191 ExtendedAttributeKey key(entry->Get(META_HANDLE), PSTR("DATA")); |
| 187 MutableExtendedAttribute attr(trans, CREATE, key); | 192 MutableExtendedAttribute attr(trans, CREATE, key); |
| 188 attr.mutable_value()->swap(test_value); | 193 attr.mutable_value()->swap(test_value); |
| 189 entry->Put(syncable::IS_UNSYNCED, true); | 194 entry->Put(syncable::IS_UNSYNCED, true); |
| 190 } | 195 } |
| 191 void VerifyTestDataInEntry(BaseTransaction* trans, Entry* entry) { | 196 void VerifyTestDataInEntry(BaseTransaction* trans, Entry* entry) { |
| 192 EXPECT_FALSE(entry->Get(IS_DIR)); | 197 EXPECT_FALSE(entry->Get(IS_DIR)); |
| 193 EXPECT_FALSE(entry->Get(IS_DEL)); | 198 EXPECT_FALSE(entry->Get(IS_DEL)); |
| 194 Blob test_value(kTestData, kTestData + kTestDataLen); | 199 Blob test_value(kTestData, kTestData + kTestDataLen); |
| 195 ExtendedAttributeKey key(entry->Get(META_HANDLE), PSTR("DATA")); | 200 ExtendedAttributeKey key(entry->Get(META_HANDLE), PSTR("DATA")); |
| 196 ExtendedAttribute attr(trans, GET_BY_HANDLE, key); | 201 ExtendedAttribute attr(trans, GET_BY_HANDLE, key); |
| 197 EXPECT_FALSE(attr.is_deleted()); | 202 EXPECT_FALSE(attr.is_deleted()); |
| 198 EXPECT_TRUE(test_value == attr.value()); | 203 EXPECT_TRUE(test_value == attr.value()); |
| 199 } | 204 } |
| 200 bool SyncerStuck(SyncProcessState* state) { | 205 void SyncRepeatedlyToTriggerConflictResolution(SyncSession* session) { |
| 201 SyncerStatus status(NULL, state); | 206 // We should trigger after less than 6 syncs, but extra does no harm. |
| 202 return status.syncer_stuck(); | 207 for (int i = 0 ; i < 6 ; ++i) |
| 208 syncer_->SyncShare(session); |
| 203 } | 209 } |
| 204 void SyncRepeatedlyToTriggerConflictResolution(SyncProcessState* state) { | 210 void SyncRepeatedlyToTriggerStuckSignal(SyncSession* session) { |
| 205 // We should trigger after less than 6 syncs, but we want to avoid brittle | |
| 206 // tests. | |
| 207 for (int i = 0 ; i < 6 ; ++i) | |
| 208 syncer_->SyncShare(state); | |
| 209 } | |
| 210 void SyncRepeatedlyToTriggerStuckSignal(SyncProcessState* state) { | |
| 211 // We should trigger after less than 10 syncs, but we want to avoid brittle | 211 // We should trigger after less than 10 syncs, but we want to avoid brittle |
| 212 // tests. | 212 // tests. |
| 213 for (int i = 0 ; i < 12 ; ++i) | 213 for (int i = 0 ; i < 12 ; ++i) |
| 214 syncer_->SyncShare(state); | 214 syncer_->SyncShare(session); |
| 215 } | 215 } |
| 216 | 216 |
| 217 // Enumeration of alterations to entries for commit ordering tests. | 217 // Enumeration of alterations to entries for commit ordering tests. |
| 218 enum EntryFeature { | 218 enum EntryFeature { |
| 219 LIST_END = 0, // Denotes the end of the list of features from below. | 219 LIST_END = 0, // Denotes the end of the list of features from below. |
| 220 SYNCED, // Items are unsynced by default | 220 SYNCED, // Items are unsynced by default |
| 221 DELETED, | 221 DELETED, |
| 222 OLD_MTIME, | 222 OLD_MTIME, |
| 223 MOVED_FROM_ROOT, | 223 MOVED_FROM_ROOT, |
| 224 }; | 224 }; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 EXPECT_TRUE(1 == expected_positions.count(i)); | 295 EXPECT_TRUE(1 == expected_positions.count(i)); |
| 296 EXPECT_TRUE(expected_positions[i] == mock_server_->committed_ids()[i]); | 296 EXPECT_TRUE(expected_positions[i] == mock_server_->committed_ids()[i]); |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 void DoTruncationTest(const ScopedDirLookup& dir, | 300 void DoTruncationTest(const ScopedDirLookup& dir, |
| 301 const vector<int64>& unsynced_handle_view, | 301 const vector<int64>& unsynced_handle_view, |
| 302 const vector<syncable::Id>& expected_id_order) { | 302 const vector<syncable::Id>& expected_id_order) { |
| 303 // The expected order is "x", "b", "c", "e", truncated appropriately. | 303 // The expected order is "x", "b", "c", "e", truncated appropriately. |
| 304 for (size_t limit = expected_id_order.size() + 2; limit > 0; --limit) { | 304 for (size_t limit = expected_id_order.size() + 2; limit > 0; --limit) { |
| 305 SyncCycleState cycle_state; | 305 StatusController* status = session_->status_controller(); |
| 306 SyncerSession session(&cycle_state, state_.get()); | 306 status->ResetTransientState(); |
| 307 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 307 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 308 SyncerSession::ScopedSetWriteTransaction set_trans(&session, &wtrans); | 308 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); |
| 309 session.set_unsynced_handles(unsynced_handle_view); | 309 status->set_unsynced_handles(unsynced_handle_view); |
| 310 | 310 |
| 311 GetCommitIdsCommand command(limit); | 311 GetCommitIdsCommand command(limit); |
| 312 command.BuildCommitIds(&session); | 312 command.BuildCommitIds(session_->status_controller()->unsynced_handles(), |
| 313 session_->write_transaction()); |
| 313 vector<syncable::Id> output = command.ordered_commit_set_.GetCommitIds(); | 314 vector<syncable::Id> output = command.ordered_commit_set_.GetCommitIds(); |
| 314 size_t truncated_size = std::min(limit, expected_id_order.size()); | 315 size_t truncated_size = std::min(limit, expected_id_order.size()); |
| 315 ASSERT_TRUE(truncated_size == output.size()); | 316 ASSERT_TRUE(truncated_size == output.size()); |
| 316 for (size_t i = 0; i < truncated_size; ++i) { | 317 for (size_t i = 0; i < truncated_size; ++i) { |
| 317 ASSERT_TRUE(expected_id_order[i] == output[i]) | 318 ASSERT_TRUE(expected_id_order[i] == output[i]) |
| 318 << "At index " << i << " with batch size limited to " << limit; | 319 << "At index " << i << " with batch size limited to " << limit; |
| 319 } | 320 } |
| 320 } | 321 } |
| 321 } | 322 } |
| 322 | 323 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 347 // more confusing. | 348 // more confusing. |
| 348 syncable::Id root_id_; | 349 syncable::Id root_id_; |
| 349 syncable::Id parent_id_; | 350 syncable::Id parent_id_; |
| 350 syncable::Id child_id_; | 351 syncable::Id child_id_; |
| 351 | 352 |
| 352 TestIdFactory ids_; | 353 TestIdFactory ids_; |
| 353 | 354 |
| 354 TestDirectorySetterUpper syncdb_; | 355 TestDirectorySetterUpper syncdb_; |
| 355 scoped_ptr<MockConnectionManager> mock_server_; | 356 scoped_ptr<MockConnectionManager> mock_server_; |
| 356 scoped_ptr<EventListenerHookup> hookup_; | 357 scoped_ptr<EventListenerHookup> hookup_; |
| 357 scoped_ptr<EventListenerHookup> command_channel_hookup_; | |
| 358 ClientCommandChannel client_command_channel_; | |
| 359 | 358 |
| 360 Syncer* syncer_; | 359 Syncer* syncer_; |
| 361 scoped_ptr<SyncProcessState> state_; | 360 |
| 362 scoped_ptr<ModelSafeWorker> model_safe_worker_; | 361 scoped_ptr<SyncSession> session_; |
| 362 scoped_ptr<SyncSessionContext> context_; |
| 363 std::set<SyncerEvent> syncer_events_; | 363 std::set<SyncerEvent> syncer_events_; |
| 364 sync_pb::ClientCommand last_client_command_; | 364 base::TimeDelta last_short_poll_interval_received_; |
| 365 base::TimeDelta last_long_poll_interval_received_; |
| 365 | 366 |
| 366 DISALLOW_COPY_AND_ASSIGN(SyncerTest); | 367 DISALLOW_COPY_AND_ASSIGN(SyncerTest); |
| 367 }; | 368 }; |
| 368 | 369 |
| 369 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { | 370 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { |
| 370 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 371 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 371 ASSERT_TRUE(dir.good()); | 372 ASSERT_TRUE(dir.good()); |
| 372 { | 373 { |
| 373 Syncer::UnsyncedMetaHandles handles; | 374 Syncer::UnsyncedMetaHandles handles; |
| 374 { | 375 { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 unsynced_handle_view.push_back(handle_e); | 417 unsynced_handle_view.push_back(handle_e); |
| 417 expected_order.push_back(ids_.MakeLocal("x")); | 418 expected_order.push_back(ids_.MakeLocal("x")); |
| 418 expected_order.push_back(ids_.MakeLocal("b")); | 419 expected_order.push_back(ids_.MakeLocal("b")); |
| 419 expected_order.push_back(ids_.MakeLocal("c")); | 420 expected_order.push_back(ids_.MakeLocal("c")); |
| 420 expected_order.push_back(ids_.MakeLocal("e")); | 421 expected_order.push_back(ids_.MakeLocal("e")); |
| 421 DoTruncationTest(dir, unsynced_handle_view, expected_order); | 422 DoTruncationTest(dir, unsynced_handle_view, expected_order); |
| 422 } | 423 } |
| 423 | 424 |
| 424 // TODO(chron): More corner case unit tests around validation. | 425 // TODO(chron): More corner case unit tests around validation. |
| 425 TEST_F(SyncerTest, TestCommitMetahandleIterator) { | 426 TEST_F(SyncerTest, TestCommitMetahandleIterator) { |
| 426 SyncCycleState cycle_state; | |
| 427 SyncerSession session(&cycle_state, state_.get()); | |
| 428 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 427 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 429 ASSERT_TRUE(dir.good()); | 428 ASSERT_TRUE(dir.good()); |
| 429 StatusController* status = session_->status_controller(); |
| 430 const vector<int64>& unsynced(status->unsynced_handles()); |
| 430 | 431 |
| 431 { | 432 { |
| 432 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 433 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 433 SyncerSession::ScopedSetWriteTransaction set_trans(&session, &wtrans); | 434 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); |
| 434 | 435 |
| 435 GetCommitIdsCommand::OrderedCommitSet commit_set; | 436 GetCommitIdsCommand::OrderedCommitSet commit_set; |
| 436 GetCommitIdsCommand::CommitMetahandleIterator iterator(&session, | 437 GetCommitIdsCommand::CommitMetahandleIterator iterator(unsynced, &wtrans, |
| 437 &commit_set); | 438 &commit_set); |
| 438 EXPECT_FALSE(iterator.Valid()); | 439 EXPECT_FALSE(iterator.Valid()); |
| 439 EXPECT_FALSE(iterator.Increment()); | 440 EXPECT_FALSE(iterator.Increment()); |
| 440 } | 441 } |
| 441 | 442 |
| 442 { | 443 { |
| 443 vector<int64> session_metahandles; | 444 vector<int64> session_metahandles; |
| 444 session_metahandles.push_back( | 445 session_metahandles.push_back( |
| 445 CreateUnsyncedDirectory(PSTR("test1"), "testid1")); | 446 CreateUnsyncedDirectory(PSTR("test1"), "testid1")); |
| 446 session_metahandles.push_back( | 447 session_metahandles.push_back( |
| 447 CreateUnsyncedDirectory(PSTR("test2"), "testid2")); | 448 CreateUnsyncedDirectory(PSTR("test2"), "testid2")); |
| 448 session_metahandles.push_back( | 449 session_metahandles.push_back( |
| 449 CreateUnsyncedDirectory(PSTR("test3"), "testid3")); | 450 CreateUnsyncedDirectory(PSTR("test3"), "testid3")); |
| 450 session.set_unsynced_handles(session_metahandles); | 451 status->set_unsynced_handles(session_metahandles); |
| 451 | 452 |
| 452 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 453 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 453 SyncerSession::ScopedSetWriteTransaction set_trans(&session, &wtrans); | 454 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); |
| 454 GetCommitIdsCommand::OrderedCommitSet commit_set; | 455 GetCommitIdsCommand::OrderedCommitSet commit_set; |
| 455 GetCommitIdsCommand::CommitMetahandleIterator iterator(&session, | 456 GetCommitIdsCommand::CommitMetahandleIterator iterator(unsynced, &wtrans, |
| 456 &commit_set); | 457 &commit_set); |
| 457 | 458 |
| 458 EXPECT_TRUE(iterator.Valid()); | 459 EXPECT_TRUE(iterator.Valid()); |
| 459 EXPECT_TRUE(iterator.Current() == session_metahandles[0]); | 460 EXPECT_TRUE(iterator.Current() == session_metahandles[0]); |
| 460 EXPECT_TRUE(iterator.Increment()); | 461 EXPECT_TRUE(iterator.Increment()); |
| 461 | 462 |
| 462 EXPECT_TRUE(iterator.Valid()); | 463 EXPECT_TRUE(iterator.Valid()); |
| 463 EXPECT_TRUE(iterator.Current() == session_metahandles[1]); | 464 EXPECT_TRUE(iterator.Current() == session_metahandles[1]); |
| 464 EXPECT_TRUE(iterator.Increment()); | 465 EXPECT_TRUE(iterator.Increment()); |
| 465 | 466 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 484 parent.Put(syncable::IS_DIR, true); | 485 parent.Put(syncable::IS_DIR, true); |
| 485 parent.Put(syncable::BASE_VERSION, 1); | 486 parent.Put(syncable::BASE_VERSION, 1); |
| 486 parent.Put(syncable::ID, parent_id_); | 487 parent.Put(syncable::ID, parent_id_); |
| 487 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, PSTR("Pete")); | 488 MutableEntry child(&wtrans, syncable::CREATE, parent_id_, PSTR("Pete")); |
| 488 ASSERT_TRUE(child.good()); | 489 ASSERT_TRUE(child.good()); |
| 489 child.Put(syncable::ID, child_id_); | 490 child.Put(syncable::ID, child_id_); |
| 490 child.Put(syncable::BASE_VERSION, 1); | 491 child.Put(syncable::BASE_VERSION, 1); |
| 491 WriteTestDataToEntry(&wtrans, &child); | 492 WriteTestDataToEntry(&wtrans, &child); |
| 492 } | 493 } |
| 493 | 494 |
| 494 SyncCycleState cycle_state; | 495 StatusController* status = session_->status_controller(); |
| 495 SyncerSession session(&cycle_state, state_.get()); | 496 syncer_->SyncShare(session_.get()); |
| 496 | 497 EXPECT_TRUE(2 == status->unsynced_handles().size()); |
| 497 syncer_->SyncShare(&session); | |
| 498 EXPECT_TRUE(2 == session.unsynced_count()); | |
| 499 ASSERT_TRUE(2 == mock_server_->committed_ids().size()); | 498 ASSERT_TRUE(2 == mock_server_->committed_ids().size()); |
| 500 // If this test starts failing, be aware other sort orders could be valid. | 499 // If this test starts failing, be aware other sort orders could be valid. |
| 501 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 500 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 502 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 501 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
| 503 { | 502 { |
| 504 ReadTransaction rt(dir, __FILE__, __LINE__); | 503 ReadTransaction rt(dir, __FILE__, __LINE__); |
| 505 Entry entry(&rt, syncable::GET_BY_ID, child_id_); | 504 Entry entry(&rt, syncable::GET_BY_ID, child_id_); |
| 506 ASSERT_TRUE(entry.good()); | 505 ASSERT_TRUE(entry.good()); |
| 507 VerifyTestDataInEntry(&rt, &entry); | 506 VerifyTestDataInEntry(&rt, &entry); |
| 508 } | 507 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 ASSERT_TRUE(grandchild.good()); | 691 ASSERT_TRUE(grandchild.good()); |
| 693 grandchild.Put(syncable::IS_UNSYNCED, true); | 692 grandchild.Put(syncable::IS_UNSYNCED, true); |
| 694 grandchild.Put(syncable::ID, ids_.FromNumber(105)); | 693 grandchild.Put(syncable::ID, ids_.FromNumber(105)); |
| 695 grandchild.Put(syncable::IS_DEL, true); | 694 grandchild.Put(syncable::IS_DEL, true); |
| 696 grandchild.Put(syncable::IS_DIR, false); | 695 grandchild.Put(syncable::IS_DIR, false); |
| 697 grandchild.Put(syncable::BASE_VERSION, 1); | 696 grandchild.Put(syncable::BASE_VERSION, 1); |
| 698 grandchild.Put(syncable::MTIME, now_minus_2h); | 697 grandchild.Put(syncable::MTIME, now_minus_2h); |
| 699 } | 698 } |
| 700 } | 699 } |
| 701 | 700 |
| 702 SyncCycleState cycle_state; | 701 syncer_->SyncShare(session_.get()); |
| 703 SyncerSession session(&cycle_state, state_.get()); | 702 EXPECT_TRUE(6 == session_->status_controller()->unsynced_handles().size()); |
| 704 syncer_->SyncShare(&session); | |
| 705 EXPECT_TRUE(6 == session.unsynced_count()); | |
| 706 ASSERT_TRUE(6 == mock_server_->committed_ids().size()); | 703 ASSERT_TRUE(6 == mock_server_->committed_ids().size()); |
| 707 // This test will NOT unroll deletes because SERVER_PARENT_ID is not set. | 704 // This test will NOT unroll deletes because SERVER_PARENT_ID is not set. |
| 708 // It will treat these like moves. | 705 // It will treat these like moves. |
| 709 vector<syncable::Id> commit_ids(mock_server_->committed_ids()); | 706 vector<syncable::Id> commit_ids(mock_server_->committed_ids()); |
| 710 EXPECT_TRUE(ids_.FromNumber(100) == commit_ids[0]); | 707 EXPECT_TRUE(ids_.FromNumber(100) == commit_ids[0]); |
| 711 EXPECT_TRUE(ids_.FromNumber(101) == commit_ids[1]); | 708 EXPECT_TRUE(ids_.FromNumber(101) == commit_ids[1]); |
| 712 EXPECT_TRUE(ids_.FromNumber(102) == commit_ids[2]); | 709 EXPECT_TRUE(ids_.FromNumber(102) == commit_ids[2]); |
| 713 // We don't guarantee the delete orders in this test, only that they occur | 710 // We don't guarantee the delete orders in this test, only that they occur |
| 714 // at the end. | 711 // at the end. |
| 715 std::sort(commit_ids.begin() + 3, commit_ids.end()); | 712 std::sort(commit_ids.begin() + 3, commit_ids.end()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 parent.Put(syncable::IS_DIR, true); | 755 parent.Put(syncable::IS_DIR, true); |
| 759 parent.Put(syncable::ID, ids_.FromNumber(-104)); | 756 parent.Put(syncable::ID, ids_.FromNumber(-104)); |
| 760 MutableEntry child(&wtrans, syncable::CREATE, child_id_, PSTR("B")); | 757 MutableEntry child(&wtrans, syncable::CREATE, child_id_, PSTR("B")); |
| 761 ASSERT_TRUE(child.good()); | 758 ASSERT_TRUE(child.good()); |
| 762 child.Put(syncable::IS_UNSYNCED, true); | 759 child.Put(syncable::IS_UNSYNCED, true); |
| 763 child.Put(syncable::IS_DIR, true); | 760 child.Put(syncable::IS_DIR, true); |
| 764 child.Put(syncable::ID, ids_.FromNumber(105)); | 761 child.Put(syncable::ID, ids_.FromNumber(105)); |
| 765 child.Put(syncable::BASE_VERSION, 1); | 762 child.Put(syncable::BASE_VERSION, 1); |
| 766 } | 763 } |
| 767 | 764 |
| 768 SyncCycleState cycle_state; | 765 syncer_->SyncShare(session_.get()); |
| 769 SyncerSession session(&cycle_state, state_.get()); | 766 EXPECT_TRUE(6 == session_->status_controller()->unsynced_handles().size()); |
| 770 syncer_->SyncShare(&session); | |
| 771 EXPECT_TRUE(6 == session.unsynced_count()); | |
| 772 ASSERT_TRUE(6 == mock_server_->committed_ids().size()); | 767 ASSERT_TRUE(6 == mock_server_->committed_ids().size()); |
| 773 // If this test starts failing, be aware other sort orders could be valid. | 768 // If this test starts failing, be aware other sort orders could be valid. |
| 774 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 769 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 775 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 770 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
| 776 EXPECT_TRUE(ids_.FromNumber(102) == mock_server_->committed_ids()[2]); | 771 EXPECT_TRUE(ids_.FromNumber(102) == mock_server_->committed_ids()[2]); |
| 777 EXPECT_TRUE(ids_.FromNumber(-103) == mock_server_->committed_ids()[3]); | 772 EXPECT_TRUE(ids_.FromNumber(-103) == mock_server_->committed_ids()[3]); |
| 778 EXPECT_TRUE(ids_.FromNumber(-104) == mock_server_->committed_ids()[4]); | 773 EXPECT_TRUE(ids_.FromNumber(-104) == mock_server_->committed_ids()[4]); |
| 779 EXPECT_TRUE(ids_.FromNumber(105) == mock_server_->committed_ids()[5]); | 774 EXPECT_TRUE(ids_.FromNumber(105) == mock_server_->committed_ids()[5]); |
| 780 } | 775 } |
| 781 | 776 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 798 child1.Put(syncable::ID, child_id_); | 793 child1.Put(syncable::ID, child_id_); |
| 799 MutableEntry child2(&wtrans, syncable::CREATE, parent_id_, PSTR("2")); | 794 MutableEntry child2(&wtrans, syncable::CREATE, parent_id_, PSTR("2")); |
| 800 ASSERT_TRUE(child2.good()); | 795 ASSERT_TRUE(child2.good()); |
| 801 child2.Put(syncable::IS_UNSYNCED, true); | 796 child2.Put(syncable::IS_UNSYNCED, true); |
| 802 child2.Put(syncable::ID, child2_id); | 797 child2.Put(syncable::ID, child2_id); |
| 803 parent.Put(syncable::BASE_VERSION, 1); | 798 parent.Put(syncable::BASE_VERSION, 1); |
| 804 child1.Put(syncable::BASE_VERSION, 1); | 799 child1.Put(syncable::BASE_VERSION, 1); |
| 805 child2.Put(syncable::BASE_VERSION, 1); | 800 child2.Put(syncable::BASE_VERSION, 1); |
| 806 } | 801 } |
| 807 | 802 |
| 808 SyncCycleState cycle_state; | 803 syncer_->SyncShare(session_.get()); |
| 809 SyncerSession session(&cycle_state, state_.get()); | 804 EXPECT_TRUE(3 == session_->status_controller()->unsynced_handles().size()); |
| 810 syncer_->SyncShare(&session); | |
| 811 EXPECT_TRUE(3 == session.unsynced_count()); | |
| 812 ASSERT_TRUE(3 == mock_server_->committed_ids().size()); | 805 ASSERT_TRUE(3 == mock_server_->committed_ids().size()); |
| 813 // If this test starts failing, be aware other sort orders could be valid. | 806 // If this test starts failing, be aware other sort orders could be valid. |
| 814 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 807 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 815 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); | 808 EXPECT_TRUE(child_id_ == mock_server_->committed_ids()[1]); |
| 816 EXPECT_TRUE(child2_id == mock_server_->committed_ids()[2]); | 809 EXPECT_TRUE(child2_id == mock_server_->committed_ids()[2]); |
| 817 } | 810 } |
| 818 | 811 |
| 819 TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) { | 812 TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) { |
| 820 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 813 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 821 ASSERT_TRUE(dir.good()); | 814 ASSERT_TRUE(dir.good()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 845 parent2.Put(syncable::ID, parent2_id); | 838 parent2.Put(syncable::ID, parent2_id); |
| 846 | 839 |
| 847 MutableEntry child(&wtrans, syncable::CREATE, parent2_id, child_name); | 840 MutableEntry child(&wtrans, syncable::CREATE, parent2_id, child_name); |
| 848 ASSERT_TRUE(child.good()); | 841 ASSERT_TRUE(child.good()); |
| 849 child.Put(syncable::IS_UNSYNCED, true); | 842 child.Put(syncable::IS_UNSYNCED, true); |
| 850 child.Put(syncable::IS_DIR, true); | 843 child.Put(syncable::IS_DIR, true); |
| 851 child.Put(syncable::ID, child_id); | 844 child.Put(syncable::ID, child_id); |
| 852 child.Put(syncable::BASE_VERSION, 1); | 845 child.Put(syncable::BASE_VERSION, 1); |
| 853 } | 846 } |
| 854 | 847 |
| 855 SyncCycleState cycle_state; | 848 syncer_->SyncShare(session_.get()); |
| 856 SyncerSession session(&cycle_state, state_.get()); | 849 EXPECT_TRUE(3 == session_->status_controller()->unsynced_handles().size()); |
| 857 | |
| 858 syncer_->SyncShare(&session); | |
| 859 EXPECT_TRUE(3 == session.unsynced_count()); | |
| 860 ASSERT_TRUE(3 == mock_server_->committed_ids().size()); | 850 ASSERT_TRUE(3 == mock_server_->committed_ids().size()); |
| 861 // If this test starts failing, be aware other sort orders could be valid. | 851 // If this test starts failing, be aware other sort orders could be valid. |
| 862 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 852 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 863 EXPECT_TRUE(parent2_id == mock_server_->committed_ids()[1]); | 853 EXPECT_TRUE(parent2_id == mock_server_->committed_ids()[1]); |
| 864 EXPECT_TRUE(child_id == mock_server_->committed_ids()[2]); | 854 EXPECT_TRUE(child_id == mock_server_->committed_ids()[2]); |
| 865 { | 855 { |
| 866 ReadTransaction rtrans(dir, __FILE__, __LINE__); | 856 ReadTransaction rtrans(dir, __FILE__, __LINE__); |
| 867 // Check that things committed correctly. | 857 // Check that things committed correctly. |
| 868 Entry entry_1(&rtrans, syncable::GET_BY_ID, parent_id_); | 858 Entry entry_1(&rtrans, syncable::GET_BY_ID, parent_id_); |
| 869 EXPECT_EQ(entry_1.Get(NON_UNIQUE_NAME), parent1_name); | 859 EXPECT_EQ(entry_1.Get(NON_UNIQUE_NAME), parent1_name); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 parent2.Put(syncable::ID, parent2_local_id); | 910 parent2.Put(syncable::ID, parent2_local_id); |
| 921 meta_handle_a = parent2.Get(syncable::META_HANDLE); | 911 meta_handle_a = parent2.Get(syncable::META_HANDLE); |
| 922 MutableEntry child(&wtrans, syncable::CREATE, parent2_local_id, child_name); | 912 MutableEntry child(&wtrans, syncable::CREATE, parent2_local_id, child_name); |
| 923 ASSERT_TRUE(child.good()); | 913 ASSERT_TRUE(child.good()); |
| 924 child.Put(syncable::IS_UNSYNCED, true); | 914 child.Put(syncable::IS_UNSYNCED, true); |
| 925 child.Put(syncable::IS_DIR, true); | 915 child.Put(syncable::IS_DIR, true); |
| 926 child.Put(syncable::ID, child_local_id); | 916 child.Put(syncable::ID, child_local_id); |
| 927 meta_handle_b = child.Get(syncable::META_HANDLE); | 917 meta_handle_b = child.Get(syncable::META_HANDLE); |
| 928 } | 918 } |
| 929 | 919 |
| 930 SyncCycleState cycle_state; | 920 syncer_->SyncShare(session_.get()); |
| 931 SyncerSession session(&cycle_state, state_.get()); | 921 EXPECT_TRUE(3 == session_->status_controller()->unsynced_handles().size()); |
| 932 | |
| 933 syncer_->SyncShare(&session); | |
| 934 EXPECT_TRUE(3 == session.unsynced_count()); | |
| 935 ASSERT_TRUE(3 == mock_server_->committed_ids().size()); | 922 ASSERT_TRUE(3 == mock_server_->committed_ids().size()); |
| 936 // If this test starts failing, be aware other sort orders could be valid. | 923 // If this test starts failing, be aware other sort orders could be valid. |
| 937 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); | 924 EXPECT_TRUE(parent_id_ == mock_server_->committed_ids()[0]); |
| 938 EXPECT_TRUE(parent2_local_id == mock_server_->committed_ids()[1]); | 925 EXPECT_TRUE(parent2_local_id == mock_server_->committed_ids()[1]); |
| 939 EXPECT_TRUE(child_local_id == mock_server_->committed_ids()[2]); | 926 EXPECT_TRUE(child_local_id == mock_server_->committed_ids()[2]); |
| 940 { | 927 { |
| 941 ReadTransaction rtrans(dir, __FILE__, __LINE__); | 928 ReadTransaction rtrans(dir, __FILE__, __LINE__); |
| 942 | 929 |
| 943 Entry parent(&rtrans, syncable::GET_BY_ID, | 930 Entry parent(&rtrans, syncable::GET_BY_ID, |
| 944 GetOnlyEntryWithName(&rtrans, rtrans.root_id(), parent_name)); | 931 GetOnlyEntryWithName(&rtrans, rtrans.root_id(), parent_name)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 962 } | 949 } |
| 963 } | 950 } |
| 964 | 951 |
| 965 TEST_F(SyncerTest, UpdateWithZeroLengthName) { | 952 TEST_F(SyncerTest, UpdateWithZeroLengthName) { |
| 966 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 953 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 967 ASSERT_TRUE(dir.good()); | 954 ASSERT_TRUE(dir.good()); |
| 968 // One illegal update | 955 // One illegal update |
| 969 mock_server_->AddUpdateDirectory(1, 0, "", 1, 10); | 956 mock_server_->AddUpdateDirectory(1, 0, "", 1, 10); |
| 970 // And one legal one that we're going to delete. | 957 // And one legal one that we're going to delete. |
| 971 mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10); | 958 mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10); |
| 972 syncer_->SyncShare(); | 959 syncer_->SyncShare(this); |
| 973 // Delete the legal one. The new update has a null name. | 960 // Delete the legal one. The new update has a null name. |
| 974 mock_server_->AddUpdateDirectory(2, 0, "", 2, 20); | 961 mock_server_->AddUpdateDirectory(2, 0, "", 2, 20); |
| 975 mock_server_->SetLastUpdateDeleted(); | 962 mock_server_->SetLastUpdateDeleted(); |
| 976 syncer_->SyncShare(); | 963 syncer_->SyncShare(this); |
| 977 } | 964 } |
| 978 | 965 |
| 979 TEST_F(SyncerTest, DontGetStuckWithTwoSameNames) { | 966 TEST_F(SyncerTest, DontGetStuckWithTwoSameNames) { |
| 980 // We should not get stuck here because we get | 967 // We should not get stuck here because we get |
| 981 // two server updates with exactly the same name. | 968 // two server updates with exactly the same name. |
| 982 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 969 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 983 ASSERT_TRUE(dir.good()); | 970 ASSERT_TRUE(dir.good()); |
| 984 mock_server_->AddUpdateDirectory(1, 0, "foo:", 1, 10); | 971 mock_server_->AddUpdateDirectory(1, 0, "foo:", 1, 10); |
| 985 syncer_->SyncShare(); | 972 syncer_->SyncShare(this); |
| 986 mock_server_->AddUpdateDirectory(2, 0, "foo:", 1, 20); | 973 mock_server_->AddUpdateDirectory(2, 0, "foo:", 1, 20); |
| 987 SyncRepeatedlyToTriggerStuckSignal(state_.get()); | 974 SyncRepeatedlyToTriggerStuckSignal(session_.get()); |
| 988 EXPECT_FALSE(SyncerStuck(state_.get())); | 975 EXPECT_FALSE(session_->status_controller()->syncer_status().syncer_stuck); |
| 989 syncer_events_.clear(); | 976 syncer_events_.clear(); |
| 990 } | 977 } |
| 991 | 978 |
| 992 TEST_F(SyncerTest, ExtendedAttributeWithNullCharacter) { | 979 TEST_F(SyncerTest, ExtendedAttributeWithNullCharacter) { |
| 993 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 980 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 994 ASSERT_TRUE(dir.good()); | 981 ASSERT_TRUE(dir.good()); |
| 995 size_t xattr_count = 2; | 982 size_t xattr_count = 2; |
| 996 PathString xattr_keys[] = { PSTR("key"), PSTR("key2") }; | 983 PathString xattr_keys[] = { PSTR("key"), PSTR("key2") }; |
| 997 syncable::Blob xattr_values[2]; | 984 syncable::Blob xattr_values[2]; |
| 998 const char* value[] = { "value", "val\0ue" }; | 985 const char* value[] = { "value", "val\0ue" }; |
| 999 int value_length[] = { 5, 6 }; | 986 int value_length[] = { 5, 6 }; |
| 1000 for (size_t i = 0; i < xattr_count; i++) { | 987 for (size_t i = 0; i < xattr_count; i++) { |
| 1001 for (int j = 0; j < value_length[i]; j++) | 988 for (int j = 0; j < value_length[i]; j++) |
| 1002 xattr_values[i].push_back(value[i][j]); | 989 xattr_values[i].push_back(value[i][j]); |
| 1003 } | 990 } |
| 1004 sync_pb::SyncEntity* ent = | 991 sync_pb::SyncEntity* ent = |
| 1005 mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10); | 992 mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10); |
| 1006 mock_server_->AddUpdateExtendedAttributes( | 993 mock_server_->AddUpdateExtendedAttributes( |
| 1007 ent, xattr_keys, xattr_values, xattr_count); | 994 ent, xattr_keys, xattr_values, xattr_count); |
| 1008 | 995 |
| 1009 // Add some other items. | 996 // Add some other items. |
| 1010 mock_server_->AddUpdateBookmark(2, 0, "fred", 2, 10); | 997 mock_server_->AddUpdateBookmark(2, 0, "fred", 2, 10); |
| 1011 mock_server_->AddUpdateBookmark(3, 0, "sue", 15, 10); | 998 mock_server_->AddUpdateBookmark(3, 0, "sue", 15, 10); |
| 1012 | 999 |
| 1013 syncer_->SyncShare(); | 1000 syncer_->SyncShare(this); |
| 1014 ReadTransaction trans(dir, __FILE__, __LINE__); | 1001 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1015 Entry entry1(&trans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 1002 Entry entry1(&trans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
| 1016 ASSERT_TRUE(entry1.good()); | 1003 ASSERT_TRUE(entry1.good()); |
| 1017 EXPECT_TRUE(1 == entry1.Get(syncable::BASE_VERSION)); | 1004 EXPECT_TRUE(1 == entry1.Get(syncable::BASE_VERSION)); |
| 1018 EXPECT_TRUE(1 == entry1.Get(syncable::SERVER_VERSION)); | 1005 EXPECT_TRUE(1 == entry1.Get(syncable::SERVER_VERSION)); |
| 1019 set<ExtendedAttribute> client_extended_attributes; | 1006 set<ExtendedAttribute> client_extended_attributes; |
| 1020 entry1.GetAllExtendedAttributes(&trans, &client_extended_attributes); | 1007 entry1.GetAllExtendedAttributes(&trans, &client_extended_attributes); |
| 1021 EXPECT_TRUE(xattr_count == client_extended_attributes.size()); | 1008 EXPECT_TRUE(xattr_count == client_extended_attributes.size()); |
| 1022 for (size_t i = 0; i < xattr_count; i++) { | 1009 for (size_t i = 0; i < xattr_count; i++) { |
| 1023 ExtendedAttributeKey key(entry1.Get(syncable::META_HANDLE), xattr_keys[i]); | 1010 ExtendedAttributeKey key(entry1.Get(syncable::META_HANDLE), xattr_keys[i]); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1037 TEST_F(SyncerTest, TestBasicUpdate) { | 1024 TEST_F(SyncerTest, TestBasicUpdate) { |
| 1038 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1025 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1039 ASSERT_TRUE(dir.good()); | 1026 ASSERT_TRUE(dir.good()); |
| 1040 string id = "some_id"; | 1027 string id = "some_id"; |
| 1041 string parent_id = "0"; | 1028 string parent_id = "0"; |
| 1042 string name = "in_root"; | 1029 string name = "in_root"; |
| 1043 int64 version = 10; | 1030 int64 version = 10; |
| 1044 int64 timestamp = 10; | 1031 int64 timestamp = 10; |
| 1045 mock_server_->AddUpdateDirectory(id, parent_id, name, version, timestamp); | 1032 mock_server_->AddUpdateDirectory(id, parent_id, name, version, timestamp); |
| 1046 | 1033 |
| 1047 syncer_->SyncShare(state_.get()); | 1034 syncer_->SyncShare(this); |
| 1048 SyncerStatus status(NULL, state_.get()); | |
| 1049 { | 1035 { |
| 1050 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1036 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1051 Entry entry(&trans, GET_BY_ID, | 1037 Entry entry(&trans, GET_BY_ID, |
| 1052 syncable::Id::CreateFromServerId("some_id")); | 1038 syncable::Id::CreateFromServerId("some_id")); |
| 1053 ASSERT_TRUE(entry.good()); | 1039 ASSERT_TRUE(entry.good()); |
| 1054 EXPECT_TRUE(entry.Get(IS_DIR)); | 1040 EXPECT_TRUE(entry.Get(IS_DIR)); |
| 1055 EXPECT_TRUE(entry.Get(SERVER_VERSION) == version); | 1041 EXPECT_TRUE(entry.Get(SERVER_VERSION) == version); |
| 1056 EXPECT_TRUE(entry.Get(BASE_VERSION) == version); | 1042 EXPECT_TRUE(entry.Get(BASE_VERSION) == version); |
| 1057 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 1043 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
| 1058 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 1044 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1071 // Same name. But this SHOULD work. | 1057 // Same name. But this SHOULD work. |
| 1072 mock_server_->AddUpdateDirectory(2, 0, "in_root", 10, 10); | 1058 mock_server_->AddUpdateDirectory(2, 0, "in_root", 10, 10); |
| 1073 | 1059 |
| 1074 // Unknown parent: should never be applied. "-80" is a legal server ID, | 1060 // Unknown parent: should never be applied. "-80" is a legal server ID, |
| 1075 // because any string sent by the server is a legal server ID in the sync | 1061 // because any string sent by the server is a legal server ID in the sync |
| 1076 // protocol, but it's not the ID of any item known to the client. This | 1062 // protocol, but it's not the ID of any item known to the client. This |
| 1077 // update should succeed validation, but be stuck in the unapplied state | 1063 // update should succeed validation, but be stuck in the unapplied state |
| 1078 // until an item with the server ID "-80" arrives. | 1064 // until an item with the server ID "-80" arrives. |
| 1079 mock_server_->AddUpdateDirectory(3, -80, "bad_parent", 10, 10); | 1065 mock_server_->AddUpdateDirectory(3, -80, "bad_parent", 10, 10); |
| 1080 | 1066 |
| 1081 syncer_->SyncShare(state_.get()); | 1067 syncer_->SyncShare(session_.get()); |
| 1068 StatusController* status = session_->status_controller(); |
| 1082 | 1069 |
| 1083 ConflictResolutionView conflict_view(state_.get()); | |
| 1084 SyncerStatus status(NULL, state_.get()); | |
| 1085 // Id 3 should be in conflict now. | 1070 // Id 3 should be in conflict now. |
| 1086 EXPECT_TRUE(1 == conflict_view.conflicting_updates()); | 1071 EXPECT_TRUE(1 == status->conflict_progress()->ConflictingItemsSize()); |
| 1087 | 1072 |
| 1088 // These entries will be used in the second set of updates. | 1073 // These entries will be used in the second set of updates. |
| 1089 mock_server_->AddUpdateDirectory(4, 0, "newer_version", 20, 10); | 1074 mock_server_->AddUpdateDirectory(4, 0, "newer_version", 20, 10); |
| 1090 mock_server_->AddUpdateDirectory(5, 0, "circular1", 10, 10); | 1075 mock_server_->AddUpdateDirectory(5, 0, "circular1", 10, 10); |
| 1091 mock_server_->AddUpdateDirectory(6, 5, "circular2", 10, 10); | 1076 mock_server_->AddUpdateDirectory(6, 5, "circular2", 10, 10); |
| 1092 mock_server_->AddUpdateDirectory(9, 3, "bad_parent_child", 10, 10); | 1077 mock_server_->AddUpdateDirectory(9, 3, "bad_parent_child", 10, 10); |
| 1093 mock_server_->AddUpdateDirectory(100, 9, "bad_parent_child2", 10, 10); | 1078 mock_server_->AddUpdateDirectory(100, 9, "bad_parent_child2", 10, 10); |
| 1094 mock_server_->AddUpdateDirectory(10, 0, "dir_to_bookmark", 10, 10); | 1079 mock_server_->AddUpdateDirectory(10, 0, "dir_to_bookmark", 10, 10); |
| 1095 | 1080 |
| 1096 syncer_->SyncShare(state_.get()); | 1081 syncer_->SyncShare(session_.get()); |
| 1097 // The three items with an unresolved parent should be unapplied (3, 9, 100). | 1082 // The three items with an unresolved parent should be unapplied (3, 9, 100). |
| 1098 EXPECT_TRUE(3 == conflict_view.conflicting_updates()); | 1083 // The name clash should also still be in conflict. |
| 1084 EXPECT_TRUE(3 == status->conflict_progress()->ConflictingItemsSize()); |
| 1099 { | 1085 { |
| 1100 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1086 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1101 // Even though it has the same name, it should work. | 1087 // Even though it has the same name, it should work. |
| 1102 Entry name_clash(&trans, GET_BY_ID, ids_.FromNumber(2)); | 1088 Entry name_clash(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 1103 ASSERT_TRUE(name_clash.good()); | 1089 ASSERT_TRUE(name_clash.good()); |
| 1104 EXPECT_FALSE(name_clash.Get(IS_UNAPPLIED_UPDATE)) | 1090 EXPECT_FALSE(name_clash.Get(IS_UNAPPLIED_UPDATE)) |
| 1105 << "Duplicate name SHOULD be OK."; | 1091 << "Duplicate name SHOULD be OK."; |
| 1106 | 1092 |
| 1107 Entry bad_parent(&trans, GET_BY_ID, ids_.FromNumber(3)); | 1093 Entry bad_parent(&trans, GET_BY_ID, ids_.FromNumber(3)); |
| 1108 ASSERT_TRUE(bad_parent.good()); | 1094 ASSERT_TRUE(bad_parent.good()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1121 } | 1107 } |
| 1122 | 1108 |
| 1123 // Updating 1 should not affect item 2 of the same name. | 1109 // Updating 1 should not affect item 2 of the same name. |
| 1124 mock_server_->AddUpdateDirectory(1, 0, "new_name", 20, 20); | 1110 mock_server_->AddUpdateDirectory(1, 0, "new_name", 20, 20); |
| 1125 | 1111 |
| 1126 // Moving 5 under 6 will create a cycle: a conflict. | 1112 // Moving 5 under 6 will create a cycle: a conflict. |
| 1127 mock_server_->AddUpdateDirectory(5, 6, "circular3", 20, 20); | 1113 mock_server_->AddUpdateDirectory(5, 6, "circular3", 20, 20); |
| 1128 | 1114 |
| 1129 // Flip the is_dir bit: should fail verify & be dropped. | 1115 // Flip the is_dir bit: should fail verify & be dropped. |
| 1130 mock_server_->AddUpdateBookmark(10, 0, "dir_to_bookmark", 20, 20); | 1116 mock_server_->AddUpdateBookmark(10, 0, "dir_to_bookmark", 20, 20); |
| 1131 syncer_->SyncShare(state_.get()); | 1117 syncer_->SyncShare(session_.get()); |
| 1132 | 1118 |
| 1133 // Version number older than last known: should fail verify & be dropped. | 1119 // Version number older than last known: should fail verify & be dropped. |
| 1134 mock_server_->AddUpdateDirectory(4, 0, "old_version", 10, 10); | 1120 mock_server_->AddUpdateDirectory(4, 0, "old_version", 10, 10); |
| 1135 syncer_->SyncShare(state_.get()); | 1121 syncer_->SyncShare(session_.get()); |
| 1136 { | 1122 { |
| 1137 ReadTransaction trans(dir, __FILE__, __LINE__); | 1123 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1138 | 1124 |
| 1139 Entry still_a_dir(&trans, GET_BY_ID, ids_.FromNumber(10)); | 1125 Entry still_a_dir(&trans, GET_BY_ID, ids_.FromNumber(10)); |
| 1140 ASSERT_TRUE(still_a_dir.good()); | 1126 ASSERT_TRUE(still_a_dir.good()); |
| 1141 EXPECT_FALSE(still_a_dir.Get(IS_UNAPPLIED_UPDATE)); | 1127 EXPECT_FALSE(still_a_dir.Get(IS_UNAPPLIED_UPDATE)); |
| 1142 EXPECT_TRUE(10 == still_a_dir.Get(BASE_VERSION)); | 1128 EXPECT_TRUE(10 == still_a_dir.Get(BASE_VERSION)); |
| 1143 EXPECT_TRUE(10 == still_a_dir.Get(SERVER_VERSION)); | 1129 EXPECT_TRUE(10 == still_a_dir.Get(SERVER_VERSION)); |
| 1144 EXPECT_TRUE(still_a_dir.Get(IS_DIR)); | 1130 EXPECT_TRUE(still_a_dir.Get(IS_DIR)); |
| 1145 | 1131 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1176 | 1162 |
| 1177 Entry circular_parent_target(&trans, GET_BY_ID, ids_.FromNumber(6)); | 1163 Entry circular_parent_target(&trans, GET_BY_ID, ids_.FromNumber(6)); |
| 1178 ASSERT_TRUE(circular_parent_target.good()); | 1164 ASSERT_TRUE(circular_parent_target.good()); |
| 1179 EXPECT_FALSE(circular_parent_target.Get(IS_UNAPPLIED_UPDATE)); | 1165 EXPECT_FALSE(circular_parent_target.Get(IS_UNAPPLIED_UPDATE)); |
| 1180 EXPECT_TRUE(circular_parent_issue.Get(ID) == | 1166 EXPECT_TRUE(circular_parent_issue.Get(ID) == |
| 1181 circular_parent_target.Get(PARENT_ID)); | 1167 circular_parent_target.Get(PARENT_ID)); |
| 1182 EXPECT_TRUE(10 == circular_parent_target.Get(BASE_VERSION)); | 1168 EXPECT_TRUE(10 == circular_parent_target.Get(BASE_VERSION)); |
| 1183 } | 1169 } |
| 1184 | 1170 |
| 1185 EXPECT_TRUE(0 == syncer_events_.size()); | 1171 EXPECT_TRUE(0 == syncer_events_.size()); |
| 1186 EXPECT_TRUE(4 == conflict_view.conflicting_updates()); | 1172 EXPECT_TRUE(4 == status->conflict_progress()->ConflictingItemsSize()); |
| 1187 } | 1173 } |
| 1188 | 1174 |
| 1189 TEST_F(SyncerTest, CommitTimeRename) { | 1175 TEST_F(SyncerTest, CommitTimeRename) { |
| 1190 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1176 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1191 ASSERT_TRUE(dir.good()); | 1177 ASSERT_TRUE(dir.good()); |
| 1192 int64 metahandle_folder; | 1178 int64 metahandle_folder; |
| 1193 int64 metahandle_new_entry; | 1179 int64 metahandle_new_entry; |
| 1194 | 1180 |
| 1195 // Create a folder and an entry. | 1181 // Create a folder and an entry. |
| 1196 { | 1182 { |
| 1197 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1183 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1198 MutableEntry parent(&trans, CREATE, root_id_, PSTR("Folder")); | 1184 MutableEntry parent(&trans, CREATE, root_id_, PSTR("Folder")); |
| 1199 ASSERT_TRUE(parent.good()); | 1185 ASSERT_TRUE(parent.good()); |
| 1200 parent.Put(IS_DIR, true); | 1186 parent.Put(IS_DIR, true); |
| 1201 parent.Put(IS_UNSYNCED, true); | 1187 parent.Put(IS_UNSYNCED, true); |
| 1202 metahandle_folder = parent.Get(META_HANDLE); | 1188 metahandle_folder = parent.Get(META_HANDLE); |
| 1203 | 1189 |
| 1204 MutableEntry entry(&trans, CREATE, parent.Get(ID), PSTR("new_entry")); | 1190 MutableEntry entry(&trans, CREATE, parent.Get(ID), PSTR("new_entry")); |
| 1205 ASSERT_TRUE(entry.good()); | 1191 ASSERT_TRUE(entry.good()); |
| 1206 metahandle_new_entry = entry.Get(META_HANDLE); | 1192 metahandle_new_entry = entry.Get(META_HANDLE); |
| 1207 WriteTestDataToEntry(&trans, &entry); | 1193 WriteTestDataToEntry(&trans, &entry); |
| 1208 } | 1194 } |
| 1209 | 1195 |
| 1210 // Mix in a directory creation too for later. | 1196 // Mix in a directory creation too for later. |
| 1211 mock_server_->AddUpdateDirectory(2, 0, "dir_in_root", 10, 10); | 1197 mock_server_->AddUpdateDirectory(2, 0, "dir_in_root", 10, 10); |
| 1212 mock_server_->SetCommitTimeRename("renamed_"); | 1198 mock_server_->SetCommitTimeRename("renamed_"); |
| 1213 syncer_->SyncShare(); | 1199 syncer_->SyncShare(this); |
| 1214 | 1200 |
| 1215 // Verify it was correctly renamed. | 1201 // Verify it was correctly renamed. |
| 1216 { | 1202 { |
| 1217 ReadTransaction trans(dir, __FILE__, __LINE__); | 1203 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1218 Entry entry_folder(&trans, GET_BY_HANDLE, metahandle_folder); | 1204 Entry entry_folder(&trans, GET_BY_HANDLE, metahandle_folder); |
| 1219 ASSERT_TRUE(entry_folder.good()); | 1205 ASSERT_TRUE(entry_folder.good()); |
| 1220 EXPECT_EQ(PSTR("renamed_Folder"), entry_folder.Get(NON_UNIQUE_NAME)); | 1206 EXPECT_EQ(PSTR("renamed_Folder"), entry_folder.Get(NON_UNIQUE_NAME)); |
| 1221 | 1207 |
| 1222 Entry entry_new(&trans, GET_BY_HANDLE, metahandle_new_entry); | 1208 Entry entry_new(&trans, GET_BY_HANDLE, metahandle_new_entry); |
| 1223 ASSERT_TRUE(entry_new.good()); | 1209 ASSERT_TRUE(entry_new.good()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1245 { | 1231 { |
| 1246 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1232 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1247 MutableEntry parent(&trans, CREATE, root_id_, PSTR("Folder")); | 1233 MutableEntry parent(&trans, CREATE, root_id_, PSTR("Folder")); |
| 1248 ASSERT_TRUE(parent.good()); | 1234 ASSERT_TRUE(parent.good()); |
| 1249 parent.Put(IS_DIR, true); | 1235 parent.Put(IS_DIR, true); |
| 1250 parent.Put(IS_UNSYNCED, true); | 1236 parent.Put(IS_UNSYNCED, true); |
| 1251 metahandle = parent.Get(META_HANDLE); | 1237 metahandle = parent.Get(META_HANDLE); |
| 1252 } | 1238 } |
| 1253 | 1239 |
| 1254 mock_server_->SetCommitTimeRename(i18nString); | 1240 mock_server_->SetCommitTimeRename(i18nString); |
| 1255 syncer_->SyncShare(); | 1241 syncer_->SyncShare(this); |
| 1256 | 1242 |
| 1257 // Verify it was correctly renamed. | 1243 // Verify it was correctly renamed. |
| 1258 { | 1244 { |
| 1259 ReadTransaction trans(dir, __FILE__, __LINE__); | 1245 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1260 PathString expected_folder_name(i18nString); | 1246 PathString expected_folder_name(i18nString); |
| 1261 expected_folder_name.append("Folder"); | 1247 expected_folder_name.append("Folder"); |
| 1262 | 1248 |
| 1263 | 1249 |
| 1264 Entry entry_folder(&trans, GET_BY_HANDLE, metahandle); | 1250 Entry entry_folder(&trans, GET_BY_HANDLE, metahandle); |
| 1265 ASSERT_TRUE(entry_folder.good()); | 1251 ASSERT_TRUE(entry_folder.good()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 // well as reassociate the id. | 1313 // well as reassociate the id. |
| 1328 mock_server_->AddUpdateDirectory(new_folder_id, root_id_, | 1314 mock_server_->AddUpdateDirectory(new_folder_id, root_id_, |
| 1329 "new_folder", new_version, timestamp); | 1315 "new_folder", new_version, timestamp); |
| 1330 mock_server_->SetLastUpdateOriginatorFields( | 1316 mock_server_->SetLastUpdateOriginatorFields( |
| 1331 dir->cache_guid(), folder_id.GetServerId()); | 1317 dir->cache_guid(), folder_id.GetServerId()); |
| 1332 | 1318 |
| 1333 // We don't want it accidentally committed, just the update applied. | 1319 // We don't want it accidentally committed, just the update applied. |
| 1334 mock_server_->set_conflict_all_commits(true); | 1320 mock_server_->set_conflict_all_commits(true); |
| 1335 | 1321 |
| 1336 // Alright! Apply that update! | 1322 // Alright! Apply that update! |
| 1337 syncer_->SyncShare(); | 1323 syncer_->SyncShare(this); |
| 1338 { | 1324 { |
| 1339 // The folder's ID should have been updated. | 1325 // The folder's ID should have been updated. |
| 1340 ReadTransaction trans(dir, __FILE__, __LINE__); | 1326 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1341 Entry folder(&trans, GET_BY_HANDLE, metahandle_folder); | 1327 Entry folder(&trans, GET_BY_HANDLE, metahandle_folder); |
| 1342 ASSERT_TRUE(folder.good()); | 1328 ASSERT_TRUE(folder.good()); |
| 1343 EXPECT_EQ(PSTR("new_folder"), folder.Get(NON_UNIQUE_NAME)); | 1329 EXPECT_EQ(PSTR("new_folder"), folder.Get(NON_UNIQUE_NAME)); |
| 1344 EXPECT_TRUE(new_version == folder.Get(BASE_VERSION)); | 1330 EXPECT_TRUE(new_version == folder.Get(BASE_VERSION)); |
| 1345 EXPECT_TRUE(new_folder_id == folder.Get(ID)); | 1331 EXPECT_TRUE(new_folder_id == folder.Get(ID)); |
| 1346 EXPECT_TRUE(folder.Get(ID).ServerKnows()); | 1332 EXPECT_TRUE(folder.Get(ID).ServerKnows()); |
| 1347 EXPECT_EQ(trans.root_id(), folder.Get(PARENT_ID)); | 1333 EXPECT_EQ(trans.root_id(), folder.Get(PARENT_ID)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 // Generate an update from the server with a relevant ID reassignment. | 1382 // Generate an update from the server with a relevant ID reassignment. |
| 1397 mock_server_->AddUpdateBookmark(new_entry_id, root_id_, | 1383 mock_server_->AddUpdateBookmark(new_entry_id, root_id_, |
| 1398 "new_entry", new_version, timestamp); | 1384 "new_entry", new_version, timestamp); |
| 1399 mock_server_->SetLastUpdateOriginatorFields( | 1385 mock_server_->SetLastUpdateOriginatorFields( |
| 1400 dir->cache_guid(), entry_id.GetServerId()); | 1386 dir->cache_guid(), entry_id.GetServerId()); |
| 1401 | 1387 |
| 1402 // We don't want it accidentally committed, just the update applied. | 1388 // We don't want it accidentally committed, just the update applied. |
| 1403 mock_server_->set_conflict_all_commits(true); | 1389 mock_server_->set_conflict_all_commits(true); |
| 1404 | 1390 |
| 1405 // Alright! Apply that update! | 1391 // Alright! Apply that update! |
| 1406 syncer_->SyncShare(); | 1392 syncer_->SyncShare(this); |
| 1407 { | 1393 { |
| 1408 ReadTransaction trans(dir, __FILE__, __LINE__); | 1394 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1409 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); | 1395 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); |
| 1410 ASSERT_TRUE(entry.good()); | 1396 ASSERT_TRUE(entry.good()); |
| 1411 EXPECT_TRUE(new_version == entry.Get(BASE_VERSION)); | 1397 EXPECT_TRUE(new_version == entry.Get(BASE_VERSION)); |
| 1412 EXPECT_TRUE(new_entry_id == entry.Get(ID)); | 1398 EXPECT_TRUE(new_entry_id == entry.Get(ID)); |
| 1413 EXPECT_EQ(PSTR("new_entry"), entry.Get(NON_UNIQUE_NAME)); | 1399 EXPECT_EQ(PSTR("new_entry"), entry.Get(NON_UNIQUE_NAME)); |
| 1414 } | 1400 } |
| 1415 } | 1401 } |
| 1416 | 1402 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 { | 1448 { |
| 1463 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1449 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1464 Id new_entry_id = GetOnlyEntryWithName( | 1450 Id new_entry_id = GetOnlyEntryWithName( |
| 1465 &trans, trans.root_id(), PSTR("new_entry")); | 1451 &trans, trans.root_id(), PSTR("new_entry")); |
| 1466 MutableEntry entry(&trans, GET_BY_ID, new_entry_id); | 1452 MutableEntry entry(&trans, GET_BY_ID, new_entry_id); |
| 1467 ASSERT_TRUE(entry.good()); | 1453 ASSERT_TRUE(entry.good()); |
| 1468 entry.Put(syncable::IS_DEL, true); | 1454 entry.Put(syncable::IS_DEL, true); |
| 1469 } | 1455 } |
| 1470 | 1456 |
| 1471 // Just don't CHECK fail in sync, have the update split. | 1457 // Just don't CHECK fail in sync, have the update split. |
| 1472 syncer_->SyncShare(); | 1458 syncer_->SyncShare(this); |
| 1473 { | 1459 { |
| 1474 ReadTransaction trans(dir, __FILE__, __LINE__); | 1460 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1475 Id new_entry_id = GetOnlyEntryWithName( | 1461 Id new_entry_id = GetOnlyEntryWithName( |
| 1476 &trans, trans.root_id(), PSTR("new_entry")); | 1462 &trans, trans.root_id(), PSTR("new_entry")); |
| 1477 Entry entry(&trans, GET_BY_ID, new_entry_id); | 1463 Entry entry(&trans, GET_BY_ID, new_entry_id); |
| 1478 ASSERT_TRUE(entry.good()); | 1464 ASSERT_TRUE(entry.good()); |
| 1479 EXPECT_FALSE(entry.Get(IS_DEL)); | 1465 EXPECT_FALSE(entry.Get(IS_DEL)); |
| 1480 | 1466 |
| 1481 Entry old_entry(&trans, GET_BY_ID, entry_id); | 1467 Entry old_entry(&trans, GET_BY_ID, entry_id); |
| 1482 ASSERT_TRUE(old_entry.good()); | 1468 ASSERT_TRUE(old_entry.good()); |
| 1483 EXPECT_TRUE(old_entry.Get(IS_DEL)); | 1469 EXPECT_TRUE(old_entry.Get(IS_DEL)); |
| 1484 } | 1470 } |
| 1485 } | 1471 } |
| 1486 | 1472 |
| 1487 // TODO(chron): Add more unsanitized name tests. | 1473 // TODO(chron): Add more unsanitized name tests. |
| 1488 TEST_F(SyncerTest, ConflictMatchingEntryHandlesUnsanitizedNames) { | 1474 TEST_F(SyncerTest, ConflictMatchingEntryHandlesUnsanitizedNames) { |
| 1489 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1475 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1490 CHECK(dir.good()); | 1476 CHECK(dir.good()); |
| 1491 mock_server_->AddUpdateDirectory(1, 0, "A/A", 10, 10); | 1477 mock_server_->AddUpdateDirectory(1, 0, "A/A", 10, 10); |
| 1492 mock_server_->AddUpdateDirectory(2, 0, "B/B", 10, 10); | 1478 mock_server_->AddUpdateDirectory(2, 0, "B/B", 10, 10); |
| 1493 mock_server_->set_conflict_all_commits(true); | 1479 mock_server_->set_conflict_all_commits(true); |
| 1494 syncer_->SyncShare(); | 1480 syncer_->SyncShare(this); |
| 1495 { | 1481 { |
| 1496 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 1482 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 1497 | 1483 |
| 1498 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 1484 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
| 1499 ASSERT_TRUE(A.good()); | 1485 ASSERT_TRUE(A.good()); |
| 1500 A.Put(IS_UNSYNCED, true); | 1486 A.Put(IS_UNSYNCED, true); |
| 1501 A.Put(IS_UNAPPLIED_UPDATE, true); | 1487 A.Put(IS_UNAPPLIED_UPDATE, true); |
| 1502 A.Put(SERVER_VERSION, 20); | 1488 A.Put(SERVER_VERSION, 20); |
| 1503 | 1489 |
| 1504 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 1490 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1526 EXPECT_TRUE(B.Get(SERVER_VERSION) == 20); | 1512 EXPECT_TRUE(B.Get(SERVER_VERSION) == 20); |
| 1527 } | 1513 } |
| 1528 } | 1514 } |
| 1529 | 1515 |
| 1530 TEST_F(SyncerTest, ConflictMatchingEntryHandlesNormalNames) { | 1516 TEST_F(SyncerTest, ConflictMatchingEntryHandlesNormalNames) { |
| 1531 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1517 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1532 CHECK(dir.good()); | 1518 CHECK(dir.good()); |
| 1533 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 1519 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
| 1534 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); | 1520 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); |
| 1535 mock_server_->set_conflict_all_commits(true); | 1521 mock_server_->set_conflict_all_commits(true); |
| 1536 syncer_->SyncShare(); | 1522 syncer_->SyncShare(this); |
| 1537 { | 1523 { |
| 1538 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 1524 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 1539 | 1525 |
| 1540 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 1526 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
| 1541 ASSERT_TRUE(A.good()); | 1527 ASSERT_TRUE(A.good()); |
| 1542 A.Put(IS_UNSYNCED, true); | 1528 A.Put(IS_UNSYNCED, true); |
| 1543 A.Put(IS_UNAPPLIED_UPDATE, true); | 1529 A.Put(IS_UNAPPLIED_UPDATE, true); |
| 1544 A.Put(SERVER_VERSION, 20); | 1530 A.Put(SERVER_VERSION, 20); |
| 1545 | 1531 |
| 1546 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 1532 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1585 Entry child(&trans, GET_BY_ID, child_id); | 1571 Entry child(&trans, GET_BY_ID, child_id); |
| 1586 ASSERT_TRUE(child.good()); | 1572 ASSERT_TRUE(child.good()); |
| 1587 } | 1573 } |
| 1588 | 1574 |
| 1589 class EntryCreatedInNewFolderTest : public SyncerTest { | 1575 class EntryCreatedInNewFolderTest : public SyncerTest { |
| 1590 public: | 1576 public: |
| 1591 void CreateFolderInBob() { | 1577 void CreateFolderInBob() { |
| 1592 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1578 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1593 CHECK(dir.good()); | 1579 CHECK(dir.good()); |
| 1594 | 1580 |
| 1595 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1581 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1596 MutableEntry bob(&trans, | 1582 MutableEntry bob(&trans, |
| 1597 syncable::GET_BY_ID, | 1583 syncable::GET_BY_ID, |
| 1598 GetOnlyEntryWithName(&trans, | 1584 GetOnlyEntryWithName(&trans, |
| 1599 TestIdFactory::root(), | 1585 TestIdFactory::root(), |
| 1600 PSTR("bob"))); | 1586 PSTR("bob"))); |
| 1601 CHECK(bob.good()); | 1587 CHECK(bob.good()); |
| 1602 | 1588 |
| 1603 MutableEntry entry2(&trans, syncable::CREATE, bob.Get(syncable::ID), | 1589 MutableEntry entry2(&trans, syncable::CREATE, bob.Get(syncable::ID), |
| 1604 PSTR("bob")); | 1590 PSTR("bob")); |
| 1605 CHECK(entry2.good()); | 1591 CHECK(entry2.good()); |
| 1606 entry2.Put(syncable::IS_DIR, true); | 1592 entry2.Put(syncable::IS_DIR, true); |
| 1607 entry2.Put(syncable::IS_UNSYNCED, true); | 1593 entry2.Put(syncable::IS_UNSYNCED, true); |
| 1608 } | 1594 } |
| 1609 }; | 1595 }; |
| 1610 | 1596 |
| 1611 TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) { | 1597 TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) { |
| 1612 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1598 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1613 CHECK(dir.good()); | 1599 CHECK(dir.good()); |
| 1614 { | 1600 { |
| 1615 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1601 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1616 MutableEntry entry(&trans, syncable::CREATE, trans.root_id(), | 1602 MutableEntry entry(&trans, syncable::CREATE, trans.root_id(), |
| 1617 PSTR("bob")); | 1603 PSTR("bob")); |
| 1618 ASSERT_TRUE(entry.good()); | 1604 ASSERT_TRUE(entry.good()); |
| 1619 entry.Put(syncable::IS_DIR, true); | 1605 entry.Put(syncable::IS_DIR, true); |
| 1620 entry.Put(syncable::IS_UNSYNCED, true); | 1606 entry.Put(syncable::IS_UNSYNCED, true); |
| 1621 } | 1607 } |
| 1622 | 1608 |
| 1623 mock_server_->SetMidCommitCallback( | 1609 mock_server_->SetMidCommitCallback( |
| 1624 NewCallback<EntryCreatedInNewFolderTest>(this, | 1610 NewCallback<EntryCreatedInNewFolderTest>(this, |
| 1625 &EntryCreatedInNewFolderTest::CreateFolderInBob)); | 1611 &EntryCreatedInNewFolderTest::CreateFolderInBob)); |
| 1626 syncer_->SyncShare(BUILD_COMMIT_REQUEST, SYNCER_END); | 1612 syncer_->SyncShare(BUILD_COMMIT_REQUEST, SYNCER_END, this); |
| 1627 EXPECT_TRUE(1 == mock_server_->committed_ids().size()); | 1613 EXPECT_TRUE(1 == mock_server_->committed_ids().size()); |
| 1628 { | 1614 { |
| 1629 ReadTransaction trans(dir, __FILE__, __LINE__); | 1615 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1630 Entry parent_entry(&trans, syncable::GET_BY_ID, | 1616 Entry parent_entry(&trans, syncable::GET_BY_ID, |
| 1631 GetOnlyEntryWithName(&trans, TestIdFactory::root(), PSTR("bob"))); | 1617 GetOnlyEntryWithName(&trans, TestIdFactory::root(), PSTR("bob"))); |
| 1632 ASSERT_TRUE(parent_entry.good()); | 1618 ASSERT_TRUE(parent_entry.good()); |
| 1633 | 1619 |
| 1634 Id child_id = | 1620 Id child_id = |
| 1635 GetOnlyEntryWithName(&trans, parent_entry.Get(ID), PSTR("bob")); | 1621 GetOnlyEntryWithName(&trans, parent_entry.Get(ID), PSTR("bob")); |
| 1636 Entry child(&trans, syncable::GET_BY_ID, child_id); | 1622 Entry child(&trans, syncable::GET_BY_ID, child_id); |
| 1637 ASSERT_TRUE(child.good()); | 1623 ASSERT_TRUE(child.good()); |
| 1638 EXPECT_EQ(parent_entry.Get(ID), child.Get(PARENT_ID)); | 1624 EXPECT_EQ(parent_entry.Get(ID), child.Get(PARENT_ID)); |
| 1639 } | 1625 } |
| 1640 } | 1626 } |
| 1641 | 1627 |
| 1642 TEST_F(SyncerTest, NegativeIDInUpdate) { | 1628 TEST_F(SyncerTest, NegativeIDInUpdate) { |
| 1643 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1629 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1644 CHECK(dir.good()); | 1630 CHECK(dir.good()); |
| 1645 mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40); | 1631 mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40); |
| 1646 syncer_->SyncShare(); | 1632 syncer_->SyncShare(this); |
| 1647 // The negative id would make us CHECK! | 1633 // The negative id would make us CHECK! |
| 1648 } | 1634 } |
| 1649 | 1635 |
| 1650 TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { | 1636 TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { |
| 1651 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1637 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1652 CHECK(dir.good()); | 1638 CHECK(dir.good()); |
| 1653 | 1639 |
| 1654 int64 metahandle_fred; | 1640 int64 metahandle_fred; |
| 1655 { | 1641 { |
| 1656 // Create an item. | 1642 // Create an item. |
| 1657 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1643 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1658 MutableEntry fred_match(&trans, CREATE, trans.root_id(), | 1644 MutableEntry fred_match(&trans, CREATE, trans.root_id(), |
| 1659 PSTR("fred_match")); | 1645 PSTR("fred_match")); |
| 1660 ASSERT_TRUE(fred_match.good()); | 1646 ASSERT_TRUE(fred_match.good()); |
| 1661 metahandle_fred = fred_match.Get(META_HANDLE); | 1647 metahandle_fred = fred_match.Get(META_HANDLE); |
| 1662 WriteTestDataToEntry(&trans, &fred_match); | 1648 WriteTestDataToEntry(&trans, &fred_match); |
| 1663 } | 1649 } |
| 1664 // Commit it. | 1650 // Commit it. |
| 1665 syncer_->SyncShare(); | 1651 syncer_->SyncShare(this); |
| 1666 EXPECT_TRUE(1 == mock_server_->committed_ids().size()); | 1652 EXPECT_TRUE(1 == mock_server_->committed_ids().size()); |
| 1667 mock_server_->set_conflict_all_commits(true); | 1653 mock_server_->set_conflict_all_commits(true); |
| 1668 syncable::Id fred_match_id; | 1654 syncable::Id fred_match_id; |
| 1669 { | 1655 { |
| 1670 // Now receive a change from outside. | 1656 // Now receive a change from outside. |
| 1671 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1657 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1672 MutableEntry fred_match(&trans, GET_BY_HANDLE, metahandle_fred); | 1658 MutableEntry fred_match(&trans, GET_BY_HANDLE, metahandle_fred); |
| 1673 ASSERT_TRUE(fred_match.good()); | 1659 ASSERT_TRUE(fred_match.good()); |
| 1674 EXPECT_TRUE(fred_match.Get(ID).ServerKnows()); | 1660 EXPECT_TRUE(fred_match.Get(ID).ServerKnows()); |
| 1675 fred_match_id = fred_match.Get(ID); | 1661 fred_match_id = fred_match.Get(ID); |
| 1676 mock_server_->AddUpdateBookmark(fred_match_id, trans.root_id(), | 1662 mock_server_->AddUpdateBookmark(fred_match_id, trans.root_id(), |
| 1677 "fred_match", 40, 40); | 1663 "fred_match", 40, 40); |
| 1678 } | 1664 } |
| 1679 // Run the syncer. | 1665 // Run the syncer. |
| 1680 for (int i = 0 ; i < 30 ; ++i) { | 1666 for (int i = 0 ; i < 30 ; ++i) { |
| 1681 syncer_->SyncShare(); | 1667 syncer_->SyncShare(this); |
| 1682 } | 1668 } |
| 1683 } | 1669 } |
| 1684 | 1670 |
| 1685 /** | 1671 /** |
| 1686 * In the event that we have a double changed entry, that is changed on both | 1672 * In the event that we have a double changed entry, that is changed on both |
| 1687 * the client and the server, the conflict resolver should just drop one of | 1673 * the client and the server, the conflict resolver should just drop one of |
| 1688 * them and accept the other. | 1674 * them and accept the other. |
| 1689 */ | 1675 */ |
| 1676 |
| 1690 TEST_F(SyncerTest, DoublyChangedWithResolver) { | 1677 TEST_F(SyncerTest, DoublyChangedWithResolver) { |
| 1691 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1678 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1692 CHECK(dir.good()); | 1679 CHECK(dir.good()); |
| 1693 { | 1680 { |
| 1694 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 1681 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 1695 MutableEntry parent(&wtrans, syncable::CREATE, root_id_, PSTR("Folder")); | 1682 MutableEntry parent(&wtrans, syncable::CREATE, root_id_, PSTR("Folder")); |
| 1696 ASSERT_TRUE(parent.good()); | 1683 ASSERT_TRUE(parent.good()); |
| 1697 parent.Put(syncable::IS_DIR, true); | 1684 parent.Put(syncable::IS_DIR, true); |
| 1698 parent.Put(syncable::ID, parent_id_); | 1685 parent.Put(syncable::ID, parent_id_); |
| 1699 parent.Put(syncable::BASE_VERSION, 5); | 1686 parent.Put(syncable::BASE_VERSION, 5); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 { | 1719 { |
| 1733 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 1720 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 1734 MutableEntry entry(&wtrans, syncable::CREATE, root_id_, PSTR("Pete")); | 1721 MutableEntry entry(&wtrans, syncable::CREATE, root_id_, PSTR("Pete")); |
| 1735 ASSERT_TRUE(entry.good()); | 1722 ASSERT_TRUE(entry.good()); |
| 1736 EXPECT_FALSE(entry.Get(ID).ServerKnows()); | 1723 EXPECT_FALSE(entry.Get(ID).ServerKnows()); |
| 1737 entry.Put(syncable::IS_DIR, true); | 1724 entry.Put(syncable::IS_DIR, true); |
| 1738 entry.Put(syncable::IS_UNSYNCED, true); | 1725 entry.Put(syncable::IS_UNSYNCED, true); |
| 1739 entry.Put(syncable::MTIME, test_time); | 1726 entry.Put(syncable::MTIME, test_time); |
| 1740 entry_metahandle = entry.Get(META_HANDLE); | 1727 entry_metahandle = entry.Get(META_HANDLE); |
| 1741 } | 1728 } |
| 1742 syncer_->SyncShare(); | 1729 syncer_->SyncShare(this); |
| 1743 syncable::Id id; | 1730 syncable::Id id; |
| 1744 int64 version; | 1731 int64 version; |
| 1745 int64 server_position_in_parent; | 1732 int64 server_position_in_parent; |
| 1746 { | 1733 { |
| 1747 ReadTransaction trans(dir, __FILE__, __LINE__); | 1734 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1748 Entry entry(&trans, syncable::GET_BY_HANDLE, entry_metahandle); | 1735 Entry entry(&trans, syncable::GET_BY_HANDLE, entry_metahandle); |
| 1749 ASSERT_TRUE(entry.good()); | 1736 ASSERT_TRUE(entry.good()); |
| 1750 id = entry.Get(ID); | 1737 id = entry.Get(ID); |
| 1751 EXPECT_TRUE(id.ServerKnows()); | 1738 EXPECT_TRUE(id.ServerKnows()); |
| 1752 version = entry.Get(BASE_VERSION); | 1739 version = entry.Get(BASE_VERSION); |
| 1753 server_position_in_parent = entry.Get(SERVER_POSITION_IN_PARENT); | 1740 server_position_in_parent = entry.Get(SERVER_POSITION_IN_PARENT); |
| 1754 } | 1741 } |
| 1755 mock_server_->AddUpdateDirectory(id, root_id_, "Pete", version, 10); | 1742 mock_server_->AddUpdateDirectory(id, root_id_, "Pete", version, 10); |
| 1756 mock_server_->SetLastUpdatePosition(server_position_in_parent); | 1743 mock_server_->SetLastUpdatePosition(server_position_in_parent); |
| 1757 syncer_->SyncShare(); | 1744 syncer_->SyncShare(this); |
| 1758 { | 1745 { |
| 1759 ReadTransaction trans(dir, __FILE__, __LINE__); | 1746 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1760 Entry entry(&trans, syncable::GET_BY_ID, id); | 1747 Entry entry(&trans, syncable::GET_BY_ID, id); |
| 1761 ASSERT_TRUE(entry.good()); | 1748 ASSERT_TRUE(entry.good()); |
| 1762 EXPECT_TRUE(entry.Get(MTIME) == test_time); | 1749 EXPECT_TRUE(entry.Get(MTIME) == test_time); |
| 1763 } | 1750 } |
| 1764 } | 1751 } |
| 1765 | 1752 |
| 1766 TEST_F(SyncerTest, ParentAndChildBothMatch) { | 1753 TEST_F(SyncerTest, ParentAndChildBothMatch) { |
| 1767 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1754 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1782 MutableEntry child(&wtrans, CREATE, parent.Get(ID), PSTR("test.htm")); | 1769 MutableEntry child(&wtrans, CREATE, parent.Get(ID), PSTR("test.htm")); |
| 1783 ASSERT_TRUE(child.good()); | 1770 ASSERT_TRUE(child.good()); |
| 1784 child.Put(ID, child_id); | 1771 child.Put(ID, child_id); |
| 1785 child.Put(BASE_VERSION, 1); | 1772 child.Put(BASE_VERSION, 1); |
| 1786 child.Put(IS_BOOKMARK_OBJECT, true); | 1773 child.Put(IS_BOOKMARK_OBJECT, true); |
| 1787 WriteTestDataToEntry(&wtrans, &child); | 1774 WriteTestDataToEntry(&wtrans, &child); |
| 1788 } | 1775 } |
| 1789 mock_server_->AddUpdateDirectory(parent_id, root_id_, "Folder", 10, 10); | 1776 mock_server_->AddUpdateDirectory(parent_id, root_id_, "Folder", 10, 10); |
| 1790 mock_server_->AddUpdateBookmark(child_id, parent_id, "test.htm", 10, 10); | 1777 mock_server_->AddUpdateBookmark(child_id, parent_id, "test.htm", 10, 10); |
| 1791 mock_server_->set_conflict_all_commits(true); | 1778 mock_server_->set_conflict_all_commits(true); |
| 1792 syncer_->SyncShare(); | 1779 syncer_->SyncShare(this); |
| 1793 syncer_->SyncShare(); | 1780 syncer_->SyncShare(this); |
| 1794 syncer_->SyncShare(); | 1781 syncer_->SyncShare(this); |
| 1795 { | 1782 { |
| 1796 ReadTransaction trans(dir, __FILE__, __LINE__); | 1783 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1797 Directory::ChildHandles children; | 1784 Directory::ChildHandles children; |
| 1798 dir->GetChildHandles(&trans, root_id_, &children); | 1785 dir->GetChildHandles(&trans, root_id_, &children); |
| 1799 EXPECT_TRUE(1 == children.size()); | 1786 EXPECT_TRUE(1 == children.size()); |
| 1800 dir->GetChildHandles(&trans, parent_id, &children); | 1787 dir->GetChildHandles(&trans, parent_id, &children); |
| 1801 EXPECT_TRUE(1 == children.size()); | 1788 EXPECT_TRUE(1 == children.size()); |
| 1802 Directory::UnappliedUpdateMetaHandles unapplied; | 1789 Directory::UnappliedUpdateMetaHandles unapplied; |
| 1803 dir->GetUnappliedUpdateMetaHandles(&trans, &unapplied); | 1790 dir->GetUnappliedUpdateMetaHandles(&trans, &unapplied); |
| 1804 EXPECT_TRUE(0 == unapplied.size()); | 1791 EXPECT_TRUE(0 == unapplied.size()); |
| 1805 syncable::Directory::UnsyncedMetaHandles unsynced; | 1792 syncable::Directory::UnsyncedMetaHandles unsynced; |
| 1806 dir->GetUnsyncedMetaHandles(&trans, &unsynced); | 1793 dir->GetUnsyncedMetaHandles(&trans, &unsynced); |
| 1807 EXPECT_TRUE(0 == unsynced.size()); | 1794 EXPECT_TRUE(0 == unsynced.size()); |
| 1808 syncer_events_.clear(); | 1795 syncer_events_.clear(); |
| 1809 } | 1796 } |
| 1810 } | 1797 } |
| 1811 | 1798 |
| 1812 TEST_F(SyncerTest, CommittingNewDeleted) { | 1799 TEST_F(SyncerTest, CommittingNewDeleted) { |
| 1813 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1800 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1814 CHECK(dir.good()); | 1801 CHECK(dir.good()); |
| 1815 { | 1802 { |
| 1816 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1803 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1817 MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("bob")); | 1804 MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("bob")); |
| 1818 entry.Put(IS_UNSYNCED, true); | 1805 entry.Put(IS_UNSYNCED, true); |
| 1819 entry.Put(IS_DEL, true); | 1806 entry.Put(IS_DEL, true); |
| 1820 } | 1807 } |
| 1821 syncer_->SyncShare(); | 1808 syncer_->SyncShare(this); |
| 1822 EXPECT_TRUE(0 == mock_server_->committed_ids().size()); | 1809 EXPECT_TRUE(0 == mock_server_->committed_ids().size()); |
| 1823 } | 1810 } |
| 1824 | 1811 |
| 1825 // Original problem synopsis: | 1812 // Original problem synopsis: |
| 1826 // Check failed: entry->Get(BASE_VERSION) <= entry->Get(SERVER_VERSION) | 1813 // Check failed: entry->Get(BASE_VERSION) <= entry->Get(SERVER_VERSION) |
| 1827 // Client creates entry, client finishes committing entry. Between | 1814 // Client creates entry, client finishes committing entry. Between |
| 1828 // commit and getting update back, we delete the entry. | 1815 // commit and getting update back, we delete the entry. |
| 1829 // We get the update for the entry, but the local one was modified | 1816 // We get the update for the entry, but the local one was modified |
| 1830 // so we store the entry but don't apply it. IS_UNAPPLIED_UPDATE is set. | 1817 // so we store the entry but don't apply it. IS_UNAPPLIED_UPDATE is set. |
| 1831 // We commit deletion and get a new version number. | 1818 // We commit deletion and get a new version number. |
| 1832 // We apply unapplied updates again before we get the update about the deletion. | 1819 // We apply unapplied updates again before we get the update about the deletion. |
| 1833 // This means we have an unapplied update where server_version < base_version. | 1820 // This means we have an unapplied update where server_version < base_version. |
| 1834 TEST_F(SyncerTest, UnappliedUpdateDuringCommit) { | 1821 TEST_F(SyncerTest, UnappliedUpdateDuringCommit) { |
| 1835 // This test is a little fake. | 1822 // This test is a little fake. |
| 1836 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1823 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1837 CHECK(dir.good()); | 1824 CHECK(dir.good()); |
| 1838 { | 1825 { |
| 1839 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1826 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1840 MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("bob")); | 1827 MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("bob")); |
| 1841 entry.Put(ID, ids_.FromNumber(20)); | 1828 entry.Put(ID, ids_.FromNumber(20)); |
| 1842 entry.Put(BASE_VERSION, 1); | 1829 entry.Put(BASE_VERSION, 1); |
| 1843 entry.Put(SERVER_VERSION, 1); | 1830 entry.Put(SERVER_VERSION, 1); |
| 1844 entry.Put(SERVER_PARENT_ID, ids_.FromNumber(9999)); // Bad parent. | 1831 entry.Put(SERVER_PARENT_ID, ids_.FromNumber(9999)); // Bad parent. |
| 1845 entry.Put(IS_UNSYNCED, true); | 1832 entry.Put(IS_UNSYNCED, true); |
| 1846 entry.Put(IS_UNAPPLIED_UPDATE, true); | 1833 entry.Put(IS_UNAPPLIED_UPDATE, true); |
| 1847 entry.Put(IS_DEL, false); | 1834 entry.Put(IS_DEL, false); |
| 1848 } | 1835 } |
| 1849 syncer_->SyncShare(state_.get()); | 1836 syncer_->SyncShare(session_.get()); |
| 1850 syncer_->SyncShare(state_.get()); | 1837 syncer_->SyncShare(session_.get()); |
| 1851 SyncerStatus status(NULL, state_.get()); | 1838 const ConflictProgress* progress = |
| 1852 EXPECT_TRUE(0 == status.conflicting_updates()); | 1839 session_->status_controller()->conflict_progress(); |
| 1840 EXPECT_TRUE(0 == progress->ConflictingItemsSize()); |
| 1853 syncer_events_.clear(); | 1841 syncer_events_.clear(); |
| 1854 } | 1842 } |
| 1855 | 1843 |
| 1856 // Original problem synopsis: | 1844 // Original problem synopsis: |
| 1857 // Illegal parent | 1845 // Illegal parent |
| 1858 // Unexpected error during sync if we: | 1846 // Unexpected error during sync if we: |
| 1859 // make a new folder bob | 1847 // make a new folder bob |
| 1860 // wait for sync | 1848 // wait for sync |
| 1861 // make a new folder fred | 1849 // make a new folder fred |
| 1862 // move bob into fred | 1850 // move bob into fred |
| 1863 // remove bob | 1851 // remove bob |
| 1864 // remove fred | 1852 // remove fred |
| 1865 // if no syncing occured midway, bob will have an illegal parent | 1853 // if no syncing occured midway, bob will have an illegal parent |
| 1866 TEST_F(SyncerTest, DeletingEntryInFolder) { | 1854 TEST_F(SyncerTest, DeletingEntryInFolder) { |
| 1867 // This test is a little fake. | 1855 // This test is a little fake. |
| 1868 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1856 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1869 CHECK(dir.good()); | 1857 CHECK(dir.good()); |
| 1870 | 1858 |
| 1871 int64 existing_metahandle; | 1859 int64 existing_metahandle; |
| 1872 { | 1860 { |
| 1873 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1861 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1874 MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("existing")); | 1862 MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("existing")); |
| 1875 ASSERT_TRUE(entry.good()); | 1863 ASSERT_TRUE(entry.good()); |
| 1876 entry.Put(IS_DIR, true); | 1864 entry.Put(IS_DIR, true); |
| 1877 entry.Put(IS_UNSYNCED, true); | 1865 entry.Put(IS_UNSYNCED, true); |
| 1878 existing_metahandle = entry.Get(META_HANDLE); | 1866 existing_metahandle = entry.Get(META_HANDLE); |
| 1879 } | 1867 } |
| 1880 syncer_->SyncShare(state_.get()); | 1868 syncer_->SyncShare(session_.get()); |
| 1881 { | 1869 { |
| 1882 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1870 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1883 MutableEntry newfolder(&trans, CREATE, trans.root_id(), PSTR("new")); | 1871 MutableEntry newfolder(&trans, CREATE, trans.root_id(), PSTR("new")); |
| 1884 ASSERT_TRUE(newfolder.good()); | 1872 ASSERT_TRUE(newfolder.good()); |
| 1885 newfolder.Put(IS_DIR, true); | 1873 newfolder.Put(IS_DIR, true); |
| 1886 newfolder.Put(IS_UNSYNCED, true); | 1874 newfolder.Put(IS_UNSYNCED, true); |
| 1887 | 1875 |
| 1888 MutableEntry existing(&trans, GET_BY_HANDLE, existing_metahandle); | 1876 MutableEntry existing(&trans, GET_BY_HANDLE, existing_metahandle); |
| 1889 ASSERT_TRUE(existing.good()); | 1877 ASSERT_TRUE(existing.good()); |
| 1890 existing.Put(PARENT_ID, newfolder.Get(ID)); | 1878 existing.Put(PARENT_ID, newfolder.Get(ID)); |
| 1891 existing.Put(IS_UNSYNCED, true); | 1879 existing.Put(IS_UNSYNCED, true); |
| 1892 EXPECT_TRUE(existing.Get(ID).ServerKnows()); | 1880 EXPECT_TRUE(existing.Get(ID).ServerKnows()); |
| 1893 | 1881 |
| 1894 newfolder.Put(IS_DEL, true); | 1882 newfolder.Put(IS_DEL, true); |
| 1895 existing.Put(IS_DEL, true); | 1883 existing.Put(IS_DEL, true); |
| 1896 } | 1884 } |
| 1897 syncer_->SyncShare(state_.get()); | 1885 syncer_->SyncShare(session_.get()); |
| 1898 SyncerStatus status(NULL, state_.get()); | 1886 StatusController* status(session_->status_controller()); |
| 1899 EXPECT_TRUE(0 == status.conflicting_commits()); | 1887 EXPECT_TRUE(0 == status->error_counters().num_conflicting_commits); |
| 1900 } | 1888 } |
| 1901 | 1889 |
| 1902 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { | 1890 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { |
| 1903 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1891 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1904 CHECK(dir.good()); | 1892 CHECK(dir.good()); |
| 1905 int64 newfolder_metahandle; | 1893 int64 newfolder_metahandle; |
| 1906 | 1894 |
| 1907 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 1895 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
| 1908 syncer_->SyncShare(); | 1896 syncer_->SyncShare(this); |
| 1909 { | 1897 { |
| 1910 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1898 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 1911 MutableEntry newfolder(&trans, CREATE, ids_.FromNumber(1), PSTR("local")); | 1899 MutableEntry newfolder(&trans, CREATE, ids_.FromNumber(1), PSTR("local")); |
| 1912 ASSERT_TRUE(newfolder.good()); | 1900 ASSERT_TRUE(newfolder.good()); |
| 1913 newfolder.Put(IS_UNSYNCED, true); | 1901 newfolder.Put(IS_UNSYNCED, true); |
| 1914 newfolder_metahandle = newfolder.Get(META_HANDLE); | 1902 newfolder_metahandle = newfolder.Get(META_HANDLE); |
| 1915 } | 1903 } |
| 1916 mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20); | 1904 mock_server_->AddUpdateDirectory(1, 0, "bob", 2, 20); |
| 1917 mock_server_->SetLastUpdateDeleted(); | 1905 mock_server_->SetLastUpdateDeleted(); |
| 1918 syncer_->SyncShare(SYNCER_BEGIN, APPLY_UPDATES); | 1906 syncer_->SyncShare(SYNCER_BEGIN, APPLY_UPDATES, this); |
| 1919 { | 1907 { |
| 1920 ReadTransaction trans(dir, __FILE__, __LINE__); | 1908 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1921 Entry entry(&trans, syncable::GET_BY_HANDLE, newfolder_metahandle); | 1909 Entry entry(&trans, syncable::GET_BY_HANDLE, newfolder_metahandle); |
| 1922 ASSERT_TRUE(entry.good()); | 1910 ASSERT_TRUE(entry.good()); |
| 1923 } | 1911 } |
| 1924 } | 1912 } |
| 1925 | 1913 |
| 1926 TEST_F(SyncerTest, FolderSwapUpdate) { | 1914 TEST_F(SyncerTest, FolderSwapUpdate) { |
| 1927 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1915 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1928 CHECK(dir.good()); | 1916 CHECK(dir.good()); |
| 1929 mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10); | 1917 mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10); |
| 1930 mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10); | 1918 mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10); |
| 1931 syncer_->SyncShare(); | 1919 syncer_->SyncShare(this); |
| 1932 mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20); | 1920 mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20); |
| 1933 mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20); | 1921 mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20); |
| 1934 syncer_->SyncShare(); | 1922 syncer_->SyncShare(this); |
| 1935 { | 1923 { |
| 1936 ReadTransaction trans(dir, __FILE__, __LINE__); | 1924 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1937 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); | 1925 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); |
| 1938 ASSERT_TRUE(id1.good()); | 1926 ASSERT_TRUE(id1.good()); |
| 1939 EXPECT_TRUE(PSTR("fred") == id1.Get(NON_UNIQUE_NAME)); | 1927 EXPECT_TRUE(PSTR("fred") == id1.Get(NON_UNIQUE_NAME)); |
| 1940 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); | 1928 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); |
| 1941 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); | 1929 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); |
| 1942 ASSERT_TRUE(id2.good()); | 1930 ASSERT_TRUE(id2.good()); |
| 1943 EXPECT_TRUE(PSTR("bob") == id2.Get(NON_UNIQUE_NAME)); | 1931 EXPECT_TRUE(PSTR("bob") == id2.Get(NON_UNIQUE_NAME)); |
| 1944 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); | 1932 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); |
| 1945 } | 1933 } |
| 1946 syncer_events_.clear(); | 1934 syncer_events_.clear(); |
| 1947 } | 1935 } |
| 1948 | 1936 |
| 1949 TEST_F(SyncerTest, NameCollidingFolderSwapWorksFine) { | 1937 TEST_F(SyncerTest, NameCollidingFolderSwapWorksFine) { |
| 1950 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1938 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 1951 CHECK(dir.good()); | 1939 CHECK(dir.good()); |
| 1952 mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10); | 1940 mock_server_->AddUpdateDirectory(7801, 0, "bob", 1, 10); |
| 1953 mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10); | 1941 mock_server_->AddUpdateDirectory(1024, 0, "fred", 1, 10); |
| 1954 mock_server_->AddUpdateDirectory(4096, 0, "alice", 1, 10); | 1942 mock_server_->AddUpdateDirectory(4096, 0, "alice", 1, 10); |
| 1955 syncer_->SyncShare(); | 1943 syncer_->SyncShare(this); |
| 1956 { | 1944 { |
| 1957 ReadTransaction trans(dir, __FILE__, __LINE__); | 1945 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1958 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); | 1946 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); |
| 1959 ASSERT_TRUE(id1.good()); | 1947 ASSERT_TRUE(id1.good()); |
| 1960 EXPECT_TRUE(PSTR("bob") == id1.Get(NON_UNIQUE_NAME)); | 1948 EXPECT_TRUE(PSTR("bob") == id1.Get(NON_UNIQUE_NAME)); |
| 1961 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); | 1949 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); |
| 1962 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); | 1950 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); |
| 1963 ASSERT_TRUE(id2.good()); | 1951 ASSERT_TRUE(id2.good()); |
| 1964 EXPECT_TRUE(PSTR("fred") == id2.Get(NON_UNIQUE_NAME)); | 1952 EXPECT_TRUE(PSTR("fred") == id2.Get(NON_UNIQUE_NAME)); |
| 1965 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); | 1953 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); |
| 1966 Entry id3(&trans, GET_BY_ID, ids_.FromNumber(4096)); | 1954 Entry id3(&trans, GET_BY_ID, ids_.FromNumber(4096)); |
| 1967 ASSERT_TRUE(id3.good()); | 1955 ASSERT_TRUE(id3.good()); |
| 1968 EXPECT_TRUE(PSTR("alice") == id3.Get(NON_UNIQUE_NAME)); | 1956 EXPECT_TRUE(PSTR("alice") == id3.Get(NON_UNIQUE_NAME)); |
| 1969 EXPECT_TRUE(root_id_ == id3.Get(PARENT_ID)); | 1957 EXPECT_TRUE(root_id_ == id3.Get(PARENT_ID)); |
| 1970 } | 1958 } |
| 1971 mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20); | 1959 mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20); |
| 1972 mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20); | 1960 mock_server_->AddUpdateDirectory(7801, 0, "fred", 2, 20); |
| 1973 mock_server_->AddUpdateDirectory(4096, 0, "bob", 2, 20); | 1961 mock_server_->AddUpdateDirectory(4096, 0, "bob", 2, 20); |
| 1974 syncer_->SyncShare(); | 1962 syncer_->SyncShare(this); |
| 1975 { | 1963 { |
| 1976 ReadTransaction trans(dir, __FILE__, __LINE__); | 1964 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 1977 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); | 1965 Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); |
| 1978 ASSERT_TRUE(id1.good()); | 1966 ASSERT_TRUE(id1.good()); |
| 1979 EXPECT_TRUE(PSTR("fred") == id1.Get(NON_UNIQUE_NAME)); | 1967 EXPECT_TRUE(PSTR("fred") == id1.Get(NON_UNIQUE_NAME)); |
| 1980 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); | 1968 EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); |
| 1981 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); | 1969 Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); |
| 1982 ASSERT_TRUE(id2.good()); | 1970 ASSERT_TRUE(id2.good()); |
| 1983 EXPECT_TRUE(PSTR("bob") == id2.Get(NON_UNIQUE_NAME)); | 1971 EXPECT_TRUE(PSTR("bob") == id2.Get(NON_UNIQUE_NAME)); |
| 1984 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); | 1972 EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1999 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 1987 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2000 for (uint32 i = 0; i < items_to_commit; i++) { | 1988 for (uint32 i = 0; i < items_to_commit; i++) { |
| 2001 string nameutf8 = StringPrintf("%d", i); | 1989 string nameutf8 = StringPrintf("%d", i); |
| 2002 PathString name(nameutf8.begin(), nameutf8.end()); | 1990 PathString name(nameutf8.begin(), nameutf8.end()); |
| 2003 MutableEntry e(&trans, CREATE, trans.root_id(), name); | 1991 MutableEntry e(&trans, CREATE, trans.root_id(), name); |
| 2004 e.Put(IS_UNSYNCED, true); | 1992 e.Put(IS_UNSYNCED, true); |
| 2005 e.Put(IS_DIR, true); | 1993 e.Put(IS_DIR, true); |
| 2006 } | 1994 } |
| 2007 } | 1995 } |
| 2008 uint32 num_loops = 0; | 1996 uint32 num_loops = 0; |
| 2009 while (syncer_->SyncShare()) { | 1997 while (syncer_->SyncShare(this)) { |
| 2010 num_loops++; | 1998 num_loops++; |
| 2011 ASSERT_LT(num_loops, max_batches * 2); | 1999 ASSERT_LT(num_loops, max_batches * 2); |
| 2012 } | 2000 } |
| 2013 EXPECT_GE(mock_server_->commit_messages().size(), max_batches); | 2001 EXPECT_GE(mock_server_->commit_messages().size(), max_batches); |
| 2014 } | 2002 } |
| 2015 | 2003 |
| 2016 TEST_F(SyncerTest, HugeConflict) { | 2004 TEST_F(SyncerTest, HugeConflict) { |
| 2017 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2005 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2018 int item_count = 300; // We should be able to do 300 or 3000 w/o issue. | 2006 int item_count = 300; // We should be able to do 300 or 3000 w/o issue. |
| 2019 CHECK(dir.good()); | 2007 CHECK(dir.good()); |
| 2020 | 2008 |
| 2021 syncable::Id parent_id = ids_.NewServerId(); | 2009 syncable::Id parent_id = ids_.NewServerId(); |
| 2022 syncable::Id last_id = parent_id; | 2010 syncable::Id last_id = parent_id; |
| 2023 vector<syncable::Id> tree_ids; | 2011 vector<syncable::Id> tree_ids; |
| 2024 | 2012 |
| 2025 // Create a lot of updates for which the parent does not exist yet. | 2013 // Create a lot of updates for which the parent does not exist yet. |
| 2026 // Generate a huge deep tree which should all fail to apply at first. | 2014 // Generate a huge deep tree which should all fail to apply at first. |
| 2027 { | 2015 { |
| 2028 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2016 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2029 for (int i = 0; i < item_count; i++) { | 2017 for (int i = 0; i < item_count ; i++) { |
| 2030 syncable::Id next_id = ids_.NewServerId(); | 2018 syncable::Id next_id = ids_.NewServerId(); |
| 2031 tree_ids.push_back(next_id); | 2019 tree_ids.push_back(next_id); |
| 2032 mock_server_->AddUpdateDirectory(next_id, last_id, "BOB", 2, 20); | 2020 mock_server_->AddUpdateDirectory(next_id, last_id, "BOB", 2, 20); |
| 2033 last_id = next_id; | 2021 last_id = next_id; |
| 2034 } | 2022 } |
| 2035 } | 2023 } |
| 2036 | 2024 syncer_->SyncShare(this); |
| 2037 syncer_->SyncShare(); | |
| 2038 | 2025 |
| 2039 // Check they're in the expected conflict state. | 2026 // Check they're in the expected conflict state. |
| 2040 { | 2027 { |
| 2041 ReadTransaction trans(dir, __FILE__, __LINE__); | 2028 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2042 for (int i = 0; i < item_count; i++) { | 2029 for (int i = 0; i < item_count; i++) { |
| 2043 Entry e(&trans, GET_BY_ID, tree_ids[i]); | 2030 Entry e(&trans, GET_BY_ID, tree_ids[i]); |
| 2044 // They should all exist but none should be applied. | 2031 // They should all exist but none should be applied. |
| 2045 ASSERT_TRUE(e.good()); | 2032 ASSERT_TRUE(e.good()); |
| 2046 EXPECT_TRUE(e.Get(IS_DEL)); | 2033 EXPECT_TRUE(e.Get(IS_DEL)); |
| 2047 EXPECT_TRUE(e.Get(IS_UNAPPLIED_UPDATE)); | 2034 EXPECT_TRUE(e.Get(IS_UNAPPLIED_UPDATE)); |
| 2048 } | 2035 } |
| 2049 } | 2036 } |
| 2050 | 2037 |
| 2051 // Add the missing parent directory. | 2038 // Add the missing parent directory. |
| 2052 mock_server_->AddUpdateDirectory(parent_id, TestIdFactory::root(), | 2039 mock_server_->AddUpdateDirectory(parent_id, TestIdFactory::root(), |
| 2053 "BOB", 2, 20); | 2040 "BOB", 2, 20); |
| 2054 syncer_->SyncShare(); | 2041 syncer_->SyncShare(this); |
| 2055 | 2042 |
| 2056 // Now they should all be OK. | 2043 // Now they should all be OK. |
| 2057 { | 2044 { |
| 2058 ReadTransaction trans(dir, __FILE__, __LINE__); | 2045 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2059 for (int i = 0; i < item_count; i++) { | 2046 for (int i = 0; i < item_count; i++) { |
| 2060 Entry e(&trans, GET_BY_ID, tree_ids[i]); | 2047 Entry e(&trans, GET_BY_ID, tree_ids[i]); |
| 2061 ASSERT_TRUE(e.good()); | 2048 ASSERT_TRUE(e.good()); |
| 2062 EXPECT_FALSE(e.Get(IS_DEL)); | 2049 EXPECT_FALSE(e.Get(IS_DEL)); |
| 2063 EXPECT_FALSE(e.Get(IS_UNAPPLIED_UPDATE)); | 2050 EXPECT_FALSE(e.Get(IS_UNAPPLIED_UPDATE)); |
| 2064 } | 2051 } |
| 2065 } | 2052 } |
| 2066 } | 2053 } |
| 2067 | 2054 |
| 2068 TEST_F(SyncerTest, DontCrashOnCaseChange) { | 2055 TEST_F(SyncerTest, DontCrashOnCaseChange) { |
| 2069 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2056 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2070 CHECK(dir.good()); | 2057 CHECK(dir.good()); |
| 2071 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 2058 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
| 2072 syncer_->SyncShare(); | 2059 syncer_->SyncShare(this); |
| 2073 { | 2060 { |
| 2074 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2061 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2075 MutableEntry e(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2062 MutableEntry e(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2076 ASSERT_TRUE(e.good()); | 2063 ASSERT_TRUE(e.good()); |
| 2077 e.Put(IS_UNSYNCED, true); | 2064 e.Put(IS_UNSYNCED, true); |
| 2078 } | 2065 } |
| 2079 mock_server_->set_conflict_all_commits(true); | 2066 mock_server_->set_conflict_all_commits(true); |
| 2080 mock_server_->AddUpdateDirectory(1, 0, "BOB", 2, 20); | 2067 mock_server_->AddUpdateDirectory(1, 0, "BOB", 2, 20); |
| 2081 syncer_->SyncShare(); // USED TO CAUSE AN ASSERT | 2068 syncer_->SyncShare(this); // USED TO CAUSE AN ASSERT |
| 2082 syncer_events_.clear(); | 2069 syncer_events_.clear(); |
| 2083 } | 2070 } |
| 2084 | 2071 |
| 2085 TEST_F(SyncerTest, UnsyncedItemAndUpdate) { | 2072 TEST_F(SyncerTest, UnsyncedItemAndUpdate) { |
| 2086 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2073 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2087 CHECK(dir.good()); | 2074 CHECK(dir.good()); |
| 2088 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 2075 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
| 2089 syncer_->SyncShare(); | 2076 syncer_->SyncShare(this); |
| 2090 mock_server_->set_conflict_all_commits(true); | 2077 mock_server_->set_conflict_all_commits(true); |
| 2091 mock_server_->AddUpdateDirectory(2, 0, "bob", 2, 20); | 2078 mock_server_->AddUpdateDirectory(2, 0, "bob", 2, 20); |
| 2092 syncer_->SyncShare(); // USED TO CAUSE AN ASSERT | 2079 syncer_->SyncShare(this); // USED TO CAUSE AN ASSERT |
| 2093 syncer_events_.clear(); | 2080 syncer_events_.clear(); |
| 2094 } | 2081 } |
| 2095 | 2082 |
| 2096 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) { | 2083 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) { |
| 2097 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2084 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2098 CHECK(dir.good()); | 2085 CHECK(dir.good()); |
| 2099 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10); | 2086 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10); |
| 2100 syncer_->SyncShare(); | 2087 syncer_->SyncShare(this); |
| 2101 int64 local_folder_handle; | 2088 int64 local_folder_handle; |
| 2102 syncable::Id local_folder_id; | 2089 syncable::Id local_folder_id; |
| 2103 { | 2090 { |
| 2104 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 2091 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 2105 MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), PSTR("Bar.htm")); | 2092 MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), PSTR("Bar.htm")); |
| 2106 ASSERT_TRUE(new_entry.good()); | 2093 ASSERT_TRUE(new_entry.good()); |
| 2107 local_folder_id = new_entry.Get(ID); | 2094 local_folder_id = new_entry.Get(ID); |
| 2108 local_folder_handle = new_entry.Get(META_HANDLE); | 2095 local_folder_handle = new_entry.Get(META_HANDLE); |
| 2109 new_entry.Put(IS_UNSYNCED, true); | 2096 new_entry.Put(IS_UNSYNCED, true); |
| 2110 MutableEntry old(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2097 MutableEntry old(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
| 2111 ASSERT_TRUE(old.good()); | 2098 ASSERT_TRUE(old.good()); |
| 2112 WriteTestDataToEntry(&wtrans, &old); | 2099 WriteTestDataToEntry(&wtrans, &old); |
| 2113 } | 2100 } |
| 2114 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20); | 2101 mock_server_->AddUpdateBookmark(1, 0, "Bar.htm", 20, 20); |
| 2115 mock_server_->set_conflict_all_commits(true); | 2102 mock_server_->set_conflict_all_commits(true); |
| 2116 syncer_->SyncShare(); | 2103 syncer_->SyncShare(this); |
| 2117 syncer_events_.clear(); | 2104 syncer_events_.clear(); |
| 2118 } | 2105 } |
| 2119 | 2106 |
| 2120 // Circular links should be resolved by the server. | 2107 // Circular links should be resolved by the server. |
| 2121 TEST_F(SyncerTest, SiblingDirectoriesBecomeCircular) { | 2108 TEST_F(SyncerTest, SiblingDirectoriesBecomeCircular) { |
| 2122 // we don't currently resolve this. This test ensures we don't. | 2109 // we don't currently resolve this. This test ensures we don't. |
| 2123 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2110 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2124 CHECK(dir.good()); | 2111 CHECK(dir.good()); |
| 2125 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 2112 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
| 2126 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); | 2113 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); |
| 2127 syncer_->SyncShare(); | 2114 syncer_->SyncShare(this); |
| 2128 { | 2115 { |
| 2129 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 2116 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 2130 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2117 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
| 2131 ASSERT_TRUE(A.good()); | 2118 ASSERT_TRUE(A.good()); |
| 2132 A.Put(IS_UNSYNCED, true); | 2119 A.Put(IS_UNSYNCED, true); |
| 2133 ASSERT_TRUE(A.Put(PARENT_ID, ids_.FromNumber(2))); | 2120 ASSERT_TRUE(A.Put(PARENT_ID, ids_.FromNumber(2))); |
| 2134 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, PSTR("B"))); | 2121 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, PSTR("B"))); |
| 2135 } | 2122 } |
| 2136 mock_server_->AddUpdateDirectory(2, 1, "A", 20, 20); | 2123 mock_server_->AddUpdateDirectory(2, 1, "A", 20, 20); |
| 2137 mock_server_->set_conflict_all_commits(true); | 2124 mock_server_->set_conflict_all_commits(true); |
| 2138 syncer_->SyncShare(); | 2125 syncer_->SyncShare(this); |
| 2139 syncer_events_.clear(); | 2126 syncer_events_.clear(); |
| 2140 { | 2127 { |
| 2141 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 2128 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 2142 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2129 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
| 2143 ASSERT_TRUE(A.good()); | 2130 ASSERT_TRUE(A.good()); |
| 2144 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 2131 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
| 2145 ASSERT_TRUE(B.good()); | 2132 ASSERT_TRUE(B.good()); |
| 2146 EXPECT_TRUE(A.Get(NON_UNIQUE_NAME) == PSTR("B")); | 2133 EXPECT_TRUE(A.Get(NON_UNIQUE_NAME) == PSTR("B")); |
| 2147 EXPECT_TRUE(B.Get(NON_UNIQUE_NAME) == PSTR("B")); | 2134 EXPECT_TRUE(B.Get(NON_UNIQUE_NAME) == PSTR("B")); |
| 2148 } | 2135 } |
| 2149 } | 2136 } |
| 2150 | 2137 |
| 2151 TEST_F(SyncerTest, ConflictSetClassificationError) { | 2138 TEST_F(SyncerTest, ConflictSetClassificationError) { |
| 2152 // This code used to cause a CHECK failure because we incorrectly thought | 2139 // This code used to cause a CHECK failure because we incorrectly thought |
| 2153 // a set was only unapplied updates. | 2140 // a set was only unapplied updates. |
| 2154 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2141 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2155 CHECK(dir.good()); | 2142 CHECK(dir.good()); |
| 2156 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 2143 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
| 2157 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); | 2144 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); |
| 2158 mock_server_->set_conflict_all_commits(true); | 2145 mock_server_->set_conflict_all_commits(true); |
| 2159 syncer_->SyncShare(); | 2146 syncer_->SyncShare(this); |
| 2160 { | 2147 { |
| 2161 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 2148 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 2162 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2149 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
| 2163 ASSERT_TRUE(A.good()); | 2150 ASSERT_TRUE(A.good()); |
| 2164 A.Put(IS_UNSYNCED, true); | 2151 A.Put(IS_UNSYNCED, true); |
| 2165 A.Put(IS_UNAPPLIED_UPDATE, true); | 2152 A.Put(IS_UNAPPLIED_UPDATE, true); |
| 2166 A.Put(SERVER_NON_UNIQUE_NAME, PSTR("B")); | 2153 A.Put(SERVER_NON_UNIQUE_NAME, PSTR("B")); |
| 2167 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 2154 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
| 2168 ASSERT_TRUE(B.good()); | 2155 ASSERT_TRUE(B.good()); |
| 2169 B.Put(IS_UNAPPLIED_UPDATE, true); | 2156 B.Put(IS_UNAPPLIED_UPDATE, true); |
| 2170 B.Put(SERVER_NON_UNIQUE_NAME, PSTR("A")); | 2157 B.Put(SERVER_NON_UNIQUE_NAME, PSTR("A")); |
| 2171 } | 2158 } |
| 2172 syncer_->SyncShare(); | 2159 syncer_->SyncShare(this); |
| 2173 syncer_events_.clear(); | 2160 syncer_events_.clear(); |
| 2174 } | 2161 } |
| 2175 | 2162 |
| 2176 TEST_F(SyncerTest, SwapEntryNames) { | 2163 TEST_F(SyncerTest, SwapEntryNames) { |
| 2177 // Simple transaction test. | 2164 // Simple transaction test. |
| 2178 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2165 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2179 CHECK(dir.good()); | 2166 CHECK(dir.good()); |
| 2180 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 2167 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
| 2181 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); | 2168 mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); |
| 2182 mock_server_->set_conflict_all_commits(true); | 2169 mock_server_->set_conflict_all_commits(true); |
| 2183 syncer_->SyncShare(); | 2170 syncer_->SyncShare(this); |
| 2184 { | 2171 { |
| 2185 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 2172 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 2186 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 2173 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
| 2187 ASSERT_TRUE(A.good()); | 2174 ASSERT_TRUE(A.good()); |
| 2188 A.Put(IS_UNSYNCED, true); | 2175 A.Put(IS_UNSYNCED, true); |
| 2189 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); | 2176 MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); |
| 2190 ASSERT_TRUE(B.good()); | 2177 ASSERT_TRUE(B.good()); |
| 2191 B.Put(IS_UNSYNCED, true); | 2178 B.Put(IS_UNSYNCED, true); |
| 2192 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, PSTR("C"))); | 2179 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, PSTR("C"))); |
| 2193 ASSERT_TRUE(B.Put(NON_UNIQUE_NAME, PSTR("A"))); | 2180 ASSERT_TRUE(B.Put(NON_UNIQUE_NAME, PSTR("A"))); |
| 2194 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, PSTR("B"))); | 2181 ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, PSTR("B"))); |
| 2195 } | 2182 } |
| 2196 syncer_->SyncShare(); | 2183 syncer_->SyncShare(this); |
| 2197 syncer_events_.clear(); | 2184 syncer_events_.clear(); |
| 2198 } | 2185 } |
| 2199 | 2186 |
| 2200 TEST_F(SyncerTest, DualDeletionWithNewItemNameClash) { | 2187 TEST_F(SyncerTest, DualDeletionWithNewItemNameClash) { |
| 2201 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2188 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2202 CHECK(dir.good()); | 2189 CHECK(dir.good()); |
| 2203 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 2190 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
| 2204 mock_server_->AddUpdateBookmark(2, 0, "B", 10, 10); | 2191 mock_server_->AddUpdateBookmark(2, 0, "B", 10, 10); |
| 2205 mock_server_->set_conflict_all_commits(true); | 2192 mock_server_->set_conflict_all_commits(true); |
| 2206 syncer_->SyncShare(); | 2193 syncer_->SyncShare(this); |
| 2207 { | 2194 { |
| 2208 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2195 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2209 MutableEntry B(&trans, GET_BY_ID, ids_.FromNumber(2)); | 2196 MutableEntry B(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 2210 ASSERT_TRUE(B.good()); | 2197 ASSERT_TRUE(B.good()); |
| 2211 WriteTestDataToEntry(&trans, &B); | 2198 WriteTestDataToEntry(&trans, &B); |
| 2212 B.Put(IS_DEL, true); | 2199 B.Put(IS_DEL, true); |
| 2213 } | 2200 } |
| 2214 mock_server_->AddUpdateBookmark(2, 0, "A", 11, 11); | 2201 mock_server_->AddUpdateBookmark(2, 0, "A", 11, 11); |
| 2215 mock_server_->SetLastUpdateDeleted(); | 2202 mock_server_->SetLastUpdateDeleted(); |
| 2216 syncer_->SyncShare(); | 2203 syncer_->SyncShare(this); |
| 2217 { | 2204 { |
| 2218 ReadTransaction trans(dir, __FILE__, __LINE__); | 2205 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2219 Entry B(&trans, GET_BY_ID, ids_.FromNumber(2)); | 2206 Entry B(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 2220 ASSERT_TRUE(B.good()); | 2207 ASSERT_TRUE(B.good()); |
| 2221 EXPECT_FALSE(B.Get(IS_UNSYNCED)); | 2208 EXPECT_FALSE(B.Get(IS_UNSYNCED)); |
| 2222 EXPECT_FALSE(B.Get(IS_UNAPPLIED_UPDATE)); | 2209 EXPECT_FALSE(B.Get(IS_UNAPPLIED_UPDATE)); |
| 2223 } | 2210 } |
| 2224 syncer_events_.clear(); | 2211 syncer_events_.clear(); |
| 2225 } | 2212 } |
| 2226 | 2213 |
| 2227 TEST_F(SyncerTest, FixDirectoryLoopConflict) { | 2214 TEST_F(SyncerTest, FixDirectoryLoopConflict) { |
| 2228 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2215 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2229 CHECK(dir.good()); | 2216 CHECK(dir.good()); |
| 2230 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 2217 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
| 2231 mock_server_->AddUpdateDirectory(2, 0, "fred", 1, 10); | 2218 mock_server_->AddUpdateDirectory(2, 0, "fred", 1, 10); |
| 2232 syncer_->SyncShare(); | 2219 syncer_->SyncShare(this); |
| 2233 { | 2220 { |
| 2234 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2221 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2235 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2222 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2236 ASSERT_TRUE(bob.good()); | 2223 ASSERT_TRUE(bob.good()); |
| 2237 bob.Put(IS_UNSYNCED, true); | 2224 bob.Put(IS_UNSYNCED, true); |
| 2238 bob.Put(PARENT_ID, ids_.FromNumber(2)); | 2225 bob.Put(PARENT_ID, ids_.FromNumber(2)); |
| 2239 } | 2226 } |
| 2240 mock_server_->AddUpdateDirectory(2, 1, "fred", 2, 20); | 2227 mock_server_->AddUpdateDirectory(2, 1, "fred", 2, 20); |
| 2241 mock_server_->set_conflict_all_commits(true); | 2228 mock_server_->set_conflict_all_commits(true); |
| 2242 syncer_->SyncShare(); | 2229 syncer_->SyncShare(this); |
| 2243 syncer_->SyncShare(); | 2230 syncer_->SyncShare(this); |
| 2244 { | 2231 { |
| 2245 ReadTransaction trans(dir, __FILE__, __LINE__); | 2232 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2246 Entry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2233 Entry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2247 ASSERT_TRUE(bob.good()); | 2234 ASSERT_TRUE(bob.good()); |
| 2248 Entry fred(&trans, GET_BY_ID, ids_.FromNumber(2)); | 2235 Entry fred(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 2249 ASSERT_TRUE(fred.good()); | 2236 ASSERT_TRUE(fred.good()); |
| 2250 EXPECT_TRUE(fred.Get(IS_UNSYNCED)); | 2237 EXPECT_TRUE(fred.Get(IS_UNSYNCED)); |
| 2251 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); | 2238 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); |
| 2252 EXPECT_FALSE(fred.Get(IS_UNAPPLIED_UPDATE)); | 2239 EXPECT_FALSE(fred.Get(IS_UNAPPLIED_UPDATE)); |
| 2253 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); | 2240 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); |
| 2254 } | 2241 } |
| 2255 syncer_events_.clear(); | 2242 syncer_events_.clear(); |
| 2256 } | 2243 } |
| 2257 | 2244 |
| 2258 TEST_F(SyncerTest, ResolveWeWroteTheyDeleted) { | 2245 TEST_F(SyncerTest, ResolveWeWroteTheyDeleted) { |
| 2259 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2246 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2260 CHECK(dir.good()); | 2247 CHECK(dir.good()); |
| 2261 | 2248 |
| 2262 int64 bob_metahandle; | 2249 int64 bob_metahandle; |
| 2263 | 2250 |
| 2264 mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10); | 2251 mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10); |
| 2265 syncer_->SyncShare(); | 2252 syncer_->SyncShare(this); |
| 2266 { | 2253 { |
| 2267 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2254 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2268 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2255 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2269 ASSERT_TRUE(bob.good()); | 2256 ASSERT_TRUE(bob.good()); |
| 2270 bob_metahandle = bob.Get(META_HANDLE); | 2257 bob_metahandle = bob.Get(META_HANDLE); |
| 2271 WriteTestDataToEntry(&trans, &bob); | 2258 WriteTestDataToEntry(&trans, &bob); |
| 2272 } | 2259 } |
| 2273 mock_server_->AddUpdateBookmark(1, 0, "bob", 2, 10); | 2260 mock_server_->AddUpdateBookmark(1, 0, "bob", 2, 10); |
| 2274 mock_server_->SetLastUpdateDeleted(); | 2261 mock_server_->SetLastUpdateDeleted(); |
| 2275 mock_server_->set_conflict_all_commits(true); | 2262 mock_server_->set_conflict_all_commits(true); |
| 2276 syncer_->SyncShare(); | 2263 syncer_->SyncShare(this); |
| 2277 syncer_->SyncShare(); | 2264 syncer_->SyncShare(this); |
| 2278 { | 2265 { |
| 2279 ReadTransaction trans(dir, __FILE__, __LINE__); | 2266 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2280 Entry bob(&trans, GET_BY_HANDLE, bob_metahandle); | 2267 Entry bob(&trans, GET_BY_HANDLE, bob_metahandle); |
| 2281 ASSERT_TRUE(bob.good()); | 2268 ASSERT_TRUE(bob.good()); |
| 2282 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); | 2269 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); |
| 2283 EXPECT_FALSE(bob.Get(ID).ServerKnows()); | 2270 EXPECT_FALSE(bob.Get(ID).ServerKnows()); |
| 2284 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); | 2271 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); |
| 2285 EXPECT_FALSE(bob.Get(IS_DEL)); | 2272 EXPECT_FALSE(bob.Get(IS_DEL)); |
| 2286 } | 2273 } |
| 2287 syncer_events_.clear(); | 2274 syncer_events_.clear(); |
| 2288 } | 2275 } |
| 2289 | 2276 |
| 2290 TEST_F(SyncerTest, ServerDeletingFolderWeHaveMovedSomethingInto) { | 2277 TEST_F(SyncerTest, ServerDeletingFolderWeHaveMovedSomethingInto) { |
| 2291 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2278 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2292 CHECK(dir.good()); | 2279 CHECK(dir.good()); |
| 2293 | 2280 |
| 2294 syncable::Id bob_id = ids_.NewServerId(); | 2281 syncable::Id bob_id = ids_.NewServerId(); |
| 2295 syncable::Id fred_id = ids_.NewServerId(); | 2282 syncable::Id fred_id = ids_.NewServerId(); |
| 2296 | 2283 |
| 2297 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), | 2284 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), |
| 2298 "bob", 1, 10); | 2285 "bob", 1, 10); |
| 2299 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2286 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 2300 "fred", 1, 10); | 2287 "fred", 1, 10); |
| 2301 syncer_->SyncShare(); | 2288 syncer_->SyncShare(this); |
| 2302 { | 2289 { |
| 2303 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2290 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2304 MutableEntry bob(&trans, GET_BY_ID, bob_id); | 2291 MutableEntry bob(&trans, GET_BY_ID, bob_id); |
| 2305 ASSERT_TRUE(bob.good()); | 2292 ASSERT_TRUE(bob.good()); |
| 2306 bob.Put(IS_UNSYNCED, true); | 2293 bob.Put(IS_UNSYNCED, true); |
| 2307 bob.Put(PARENT_ID, fred_id); | 2294 bob.Put(PARENT_ID, fred_id); |
| 2308 } | 2295 } |
| 2309 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2296 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 2310 "fred", 2, 20); | 2297 "fred", 2, 20); |
| 2311 mock_server_->SetLastUpdateDeleted(); | 2298 mock_server_->SetLastUpdateDeleted(); |
| 2312 mock_server_->set_conflict_all_commits(true); | 2299 mock_server_->set_conflict_all_commits(true); |
| 2313 syncer_->SyncShare(); | 2300 syncer_->SyncShare(this); |
| 2314 syncer_->SyncShare(); | 2301 syncer_->SyncShare(this); |
| 2315 { | 2302 { |
| 2316 ReadTransaction trans(dir, __FILE__, __LINE__); | 2303 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2317 | 2304 |
| 2318 Entry bob(&trans, GET_BY_ID, bob_id); | 2305 Entry bob(&trans, GET_BY_ID, bob_id); |
| 2319 ASSERT_TRUE(bob.good()); | 2306 ASSERT_TRUE(bob.good()); |
| 2320 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); | 2307 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); |
| 2321 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); | 2308 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); |
| 2322 EXPECT_TRUE(bob.Get(NON_UNIQUE_NAME) == PSTR("bob")); | 2309 EXPECT_TRUE(bob.Get(NON_UNIQUE_NAME) == PSTR("bob")); |
| 2323 EXPECT_NE(bob.Get(PARENT_ID), fred_id); | 2310 EXPECT_NE(bob.Get(PARENT_ID), fred_id); |
| 2324 | 2311 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2339 | 2326 |
| 2340 // TODO(ncarter): This test is bogus, but it actually seems to hit an | 2327 // TODO(ncarter): This test is bogus, but it actually seems to hit an |
| 2341 // interesting case the 4th time SyncShare is called. | 2328 // interesting case the 4th time SyncShare is called. |
| 2342 // TODO(chron): The fourth time that SyncShare is called it crashes. | 2329 // TODO(chron): The fourth time that SyncShare is called it crashes. |
| 2343 // This seems to be due to a bug in the conflict set building logic. | 2330 // This seems to be due to a bug in the conflict set building logic. |
| 2344 TEST_F(SyncerTest, DISABLED_ServerDeletingFolderWeHaveAnOpenEntryIn) { | 2331 TEST_F(SyncerTest, DISABLED_ServerDeletingFolderWeHaveAnOpenEntryIn) { |
| 2345 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2332 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2346 CHECK(dir.good()); | 2333 CHECK(dir.good()); |
| 2347 mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10); | 2334 mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10); |
| 2348 mock_server_->AddUpdateDirectory(2, 0, "fred", 1, 10); | 2335 mock_server_->AddUpdateDirectory(2, 0, "fred", 1, 10); |
| 2349 syncer_->SyncShare(state_.get()); | 2336 syncer_->SyncShare(this); |
| 2350 { | 2337 { |
| 2351 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2338 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2352 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2339 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2353 ASSERT_TRUE(bob.good()); | 2340 ASSERT_TRUE(bob.good()); |
| 2354 bob.Put(IS_UNSYNCED, true); | 2341 bob.Put(IS_UNSYNCED, true); |
| 2355 WriteTestDataToEntry(&trans, &bob); | 2342 WriteTestDataToEntry(&trans, &bob); |
| 2356 } | 2343 } |
| 2357 syncer_->SyncShare(state_.get()); | 2344 syncer_->SyncShare(this); |
| 2358 { | 2345 { |
| 2359 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2346 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2360 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2347 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2361 ASSERT_TRUE(bob.good()); | 2348 ASSERT_TRUE(bob.good()); |
| 2362 EXPECT_FALSE(bob.Get(IS_UNSYNCED)); | 2349 EXPECT_FALSE(bob.Get(IS_UNSYNCED)); |
| 2363 bob.Put(IS_UNSYNCED, true); | 2350 bob.Put(IS_UNSYNCED, true); |
| 2364 bob.Put(PARENT_ID, ids_.FromNumber(2)); | 2351 bob.Put(PARENT_ID, ids_.FromNumber(2)); |
| 2365 } | 2352 } |
| 2366 mock_server_->AddUpdateDirectory(2, 0, "fred", 2, 20); | 2353 mock_server_->AddUpdateDirectory(2, 0, "fred", 2, 20); |
| 2367 mock_server_->SetLastUpdateDeleted(); | 2354 mock_server_->SetLastUpdateDeleted(); |
| 2368 mock_server_->set_conflict_all_commits(true); | 2355 mock_server_->set_conflict_all_commits(true); |
| 2369 syncer_events_.clear(); | 2356 syncer_events_.clear(); |
| 2370 // These SyncShares would cause a CHECK because we'd think we were stuck. | 2357 // These SyncShares would cause a CHECK because we'd think we were stuck. |
| 2371 syncer_->SyncShare(state_.get()); | 2358 syncer_->SyncShare(this); |
| 2372 syncer_->SyncShare(state_.get()); | 2359 syncer_->SyncShare(this); |
| 2373 syncer_->SyncShare(state_.get()); | 2360 syncer_->SyncShare(this); |
| 2374 syncer_->SyncShare(state_.get()); | 2361 syncer_->SyncShare(this); |
| 2375 syncer_->SyncShare(state_.get()); | 2362 syncer_->SyncShare(this); |
| 2376 syncer_->SyncShare(state_.get()); | 2363 syncer_->SyncShare(this); |
| 2377 syncer_->SyncShare(state_.get()); | 2364 syncer_->SyncShare(this); |
| 2378 syncer_->SyncShare(state_.get()); | 2365 syncer_->SyncShare(this); |
| 2379 EXPECT_TRUE(0 == syncer_events_.size()); | 2366 EXPECT_TRUE(0 == syncer_events_.size()); |
| 2380 { | 2367 { |
| 2381 ReadTransaction trans(dir, __FILE__, __LINE__); | 2368 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2382 Entry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2369 Entry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2383 ASSERT_TRUE(bob.good()); | 2370 ASSERT_TRUE(bob.good()); |
| 2384 Id fred_id = | 2371 Id fred_id = |
| 2385 GetOnlyEntryWithName(&trans, TestIdFactory::root(), PSTR("fred")); | 2372 GetOnlyEntryWithName(&trans, TestIdFactory::root(), PSTR("fred")); |
| 2386 Entry fred(&trans, GET_BY_ID, fred_id); | 2373 Entry fred(&trans, GET_BY_ID, fred_id); |
| 2387 ASSERT_TRUE(fred.good()); | 2374 ASSERT_TRUE(fred.good()); |
| 2388 EXPECT_FALSE(fred.Get(IS_UNSYNCED)); | 2375 EXPECT_FALSE(fred.Get(IS_UNSYNCED)); |
| 2389 EXPECT_TRUE(fred.Get(IS_UNAPPLIED_UPDATE)); | 2376 EXPECT_TRUE(fred.Get(IS_UNAPPLIED_UPDATE)); |
| 2390 EXPECT_TRUE(bob.Get(PARENT_ID) == fred.Get(ID)); | 2377 EXPECT_TRUE(bob.Get(PARENT_ID) == fred.Get(ID)); |
| 2391 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); | 2378 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); |
| 2392 } | 2379 } |
| 2393 syncer_events_.clear(); | 2380 syncer_events_.clear(); |
| 2394 } | 2381 } |
| 2395 | 2382 |
| 2396 | 2383 |
| 2397 TEST_F(SyncerTest, WeMovedSomethingIntoAFolderServerHasDeleted) { | 2384 TEST_F(SyncerTest, WeMovedSomethingIntoAFolderServerHasDeleted) { |
| 2398 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2385 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2399 CHECK(dir.good()); | 2386 CHECK(dir.good()); |
| 2400 | 2387 |
| 2401 syncable::Id bob_id = ids_.NewServerId(); | 2388 syncable::Id bob_id = ids_.NewServerId(); |
| 2402 syncable::Id fred_id = ids_.NewServerId(); | 2389 syncable::Id fred_id = ids_.NewServerId(); |
| 2403 | 2390 |
| 2404 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), | 2391 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), |
| 2405 "bob", 1, 10); | 2392 "bob", 1, 10); |
| 2406 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2393 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 2407 "fred", 1, 10); | 2394 "fred", 1, 10); |
| 2408 syncer_->SyncShare(); | 2395 syncer_->SyncShare(this); |
| 2409 { | 2396 { |
| 2410 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2397 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2411 Entry fred(&trans, GET_BY_ID, fred_id); | 2398 Entry fred(&trans, GET_BY_ID, fred_id); |
| 2412 ASSERT_TRUE(fred.good()); | 2399 ASSERT_TRUE(fred.good()); |
| 2413 | 2400 |
| 2414 MutableEntry bob(&trans, GET_BY_ID, bob_id); | 2401 MutableEntry bob(&trans, GET_BY_ID, bob_id); |
| 2415 ASSERT_TRUE(bob.good()); | 2402 ASSERT_TRUE(bob.good()); |
| 2416 bob.Put(IS_UNSYNCED, true); | 2403 bob.Put(IS_UNSYNCED, true); |
| 2417 bob.Put(PARENT_ID, fred_id); | 2404 bob.Put(PARENT_ID, fred_id); |
| 2418 } | 2405 } |
| 2419 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2406 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 2420 "fred", 2, 20); | 2407 "fred", 2, 20); |
| 2421 mock_server_->SetLastUpdateDeleted(); | 2408 mock_server_->SetLastUpdateDeleted(); |
| 2422 mock_server_->set_conflict_all_commits(true); | 2409 mock_server_->set_conflict_all_commits(true); |
| 2423 syncer_->SyncShare(); | 2410 syncer_->SyncShare(this); |
| 2424 syncer_->SyncShare(); | 2411 syncer_->SyncShare(this); |
| 2425 { | 2412 { |
| 2426 ReadTransaction trans(dir, __FILE__, __LINE__); | 2413 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2427 Entry bob(&trans, GET_BY_ID, bob_id); | 2414 Entry bob(&trans, GET_BY_ID, bob_id); |
| 2428 ASSERT_TRUE(bob.good()); | 2415 ASSERT_TRUE(bob.good()); |
| 2429 | 2416 |
| 2430 // Entry was deleted by server. We'll make a new one though with a new ID. | 2417 // Entry was deleted by server. We'll make a new one though with a new ID. |
| 2431 Entry dead_fred(&trans, GET_BY_ID, fred_id); | 2418 Entry dead_fred(&trans, GET_BY_ID, fred_id); |
| 2432 EXPECT_FALSE(dead_fred.good()); | 2419 EXPECT_FALSE(dead_fred.good()); |
| 2433 | 2420 |
| 2434 // Fred is reborn with a local ID. | 2421 // Fred is reborn with a local ID. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2463 | 2450 |
| 2464 protected: | 2451 protected: |
| 2465 int move_bob_count_; | 2452 int move_bob_count_; |
| 2466 bool done_; | 2453 bool done_; |
| 2467 | 2454 |
| 2468 bool MoveBobIntoID2() { | 2455 bool MoveBobIntoID2() { |
| 2469 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2456 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2470 CHECK(dir.good()); | 2457 CHECK(dir.good()); |
| 2471 | 2458 |
| 2472 if (--move_bob_count_ > 0) { | 2459 if (--move_bob_count_ > 0) { |
| 2473 return false; | 2460 return false; |
| 2474 } | 2461 } |
| 2475 | 2462 |
| 2476 if (move_bob_count_ == 0) { | 2463 if (move_bob_count_ == 0) { |
| 2477 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2464 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2478 Entry alice(&trans, GET_BY_ID, | 2465 Entry alice(&trans, GET_BY_ID, |
| 2479 TestIdFactory::FromNumber(fred_id_number)); | 2466 TestIdFactory::FromNumber(fred_id_number)); |
| 2480 CHECK(alice.good()); | 2467 CHECK(alice.good()); |
| 2481 CHECK(!alice.Get(IS_DEL)); | 2468 CHECK(!alice.Get(IS_DEL)); |
| 2482 MutableEntry bob(&trans, GET_BY_ID, | 2469 MutableEntry bob(&trans, GET_BY_ID, |
| 2483 TestIdFactory::FromNumber(bob_id_number)); | 2470 TestIdFactory::FromNumber(bob_id_number)); |
| 2484 CHECK(bob.good()); | 2471 CHECK(bob.good()); |
| 2485 bob.Put(IS_UNSYNCED, true); | 2472 bob.Put(IS_UNSYNCED, true); |
| 2486 bob.Put(PARENT_ID, alice.Get(ID)); | 2473 bob.Put(PARENT_ID, alice.Get(ID)); |
| 2487 return true; | 2474 return true; |
| 2488 } | |
| 2489 return false; | |
| 2490 } | 2475 } |
| 2476 return false; |
| 2477 } |
| 2491 }; | 2478 }; |
| 2492 | 2479 |
| 2493 TEST_F(FolderMoveDeleteRenameTest, | 2480 TEST_F(FolderMoveDeleteRenameTest, |
| 2494 WeMovedSomethingIntoAFolderServerHasDeletedAndWeRenamed) { | 2481 WeMovedSomethingIntoAFolderServerHasDeletedAndWeRenamed) { |
| 2495 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2482 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2496 CHECK(dir.good()); | 2483 CHECK(dir.good()); |
| 2497 | 2484 |
| 2498 const syncable::Id bob_id = TestIdFactory::FromNumber( | 2485 const syncable::Id bob_id = TestIdFactory::FromNumber( |
| 2499 FolderMoveDeleteRenameTest::bob_id_number); | 2486 FolderMoveDeleteRenameTest::bob_id_number); |
| 2500 const syncable::Id fred_id = TestIdFactory::FromNumber( | 2487 const syncable::Id fred_id = TestIdFactory::FromNumber( |
| 2501 FolderMoveDeleteRenameTest::fred_id_number); | 2488 FolderMoveDeleteRenameTest::fred_id_number); |
| 2502 | 2489 |
| 2503 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), | 2490 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), |
| 2504 "bob", 1, 10); | 2491 "bob", 1, 10); |
| 2505 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2492 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 2506 "fred", 1, 10); | 2493 "fred", 1, 10); |
| 2507 syncer_->SyncShare(); | 2494 syncer_->SyncShare(this); |
| 2508 { | 2495 { |
| 2509 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2496 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2510 MutableEntry fred(&trans, GET_BY_ID, fred_id); | 2497 MutableEntry fred(&trans, GET_BY_ID, fred_id); |
| 2511 ASSERT_TRUE(fred.good()); | 2498 ASSERT_TRUE(fred.good()); |
| 2512 fred.Put(IS_UNSYNCED, true); | 2499 fred.Put(IS_UNSYNCED, true); |
| 2513 fred.Put(NON_UNIQUE_NAME, PSTR("Alice")); | 2500 fred.Put(NON_UNIQUE_NAME, PSTR("Alice")); |
| 2514 } | 2501 } |
| 2515 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2502 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 2516 "fred", 2, 20); | 2503 "fred", 2, 20); |
| 2517 mock_server_->SetLastUpdateDeleted(); | 2504 mock_server_->SetLastUpdateDeleted(); |
| 2518 mock_server_->set_conflict_all_commits(true); | 2505 mock_server_->set_conflict_all_commits(true); |
| 2519 // This test is a little brittle. We want to move the item into the folder | 2506 // This test is a little brittle. We want to move the item into the folder |
| 2520 // such that we think we're dealing with a simple conflict, but in reality | 2507 // such that we think we're dealing with a simple conflict, but in reality |
| 2521 // it's actually a conflict set. | 2508 // it's actually a conflict set. |
| 2522 move_bob_count_ = 2; | 2509 move_bob_count_ = 2; |
| 2523 mock_server_->SetMidCommitCallback( | 2510 mock_server_->SetMidCommitCallback( |
| 2524 NewCallback<FolderMoveDeleteRenameTest>(this, | 2511 NewCallback<FolderMoveDeleteRenameTest>(this, |
| 2525 &FolderMoveDeleteRenameTest::MoveBobIntoID2Runner)); | 2512 &FolderMoveDeleteRenameTest::MoveBobIntoID2Runner)); |
| 2526 syncer_->SyncShare(); | 2513 syncer_->SyncShare(this); |
| 2527 syncer_->SyncShare(); | 2514 syncer_->SyncShare(this); |
| 2528 syncer_->SyncShare(); | 2515 syncer_->SyncShare(this); |
| 2529 { | 2516 { |
| 2530 ReadTransaction trans(dir, __FILE__, __LINE__); | 2517 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2531 Entry bob(&trans, GET_BY_ID, bob_id); | 2518 Entry bob(&trans, GET_BY_ID, bob_id); |
| 2532 ASSERT_TRUE(bob.good()); | 2519 ASSERT_TRUE(bob.good()); |
| 2533 | 2520 |
| 2534 // Old entry is dead | 2521 // Old entry is dead |
| 2535 Entry dead_fred(&trans, GET_BY_ID, fred_id); | 2522 Entry dead_fred(&trans, GET_BY_ID, fred_id); |
| 2536 EXPECT_FALSE(dead_fred.good()); | 2523 EXPECT_FALSE(dead_fred.good()); |
| 2537 | 2524 |
| 2538 // New ID is created to fill parent folder, named correctly | 2525 // New ID is created to fill parent folder, named correctly |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2556 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2543 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2557 CHECK(dir.good()); | 2544 CHECK(dir.good()); |
| 2558 | 2545 |
| 2559 syncable::Id bob_id = ids_.NewServerId(); | 2546 syncable::Id bob_id = ids_.NewServerId(); |
| 2560 syncable::Id fred_id = ids_.NewServerId(); | 2547 syncable::Id fred_id = ids_.NewServerId(); |
| 2561 | 2548 |
| 2562 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), | 2549 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), |
| 2563 "bob", 1, 10); | 2550 "bob", 1, 10); |
| 2564 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2551 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 2565 "fred", 1, 10); | 2552 "fred", 1, 10); |
| 2566 syncer_->SyncShare(); | 2553 syncer_->SyncShare(this); |
| 2567 syncable::Id new_item_id; | 2554 syncable::Id new_item_id; |
| 2568 { | 2555 { |
| 2569 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2556 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2570 MutableEntry bob(&trans, GET_BY_ID, bob_id); | 2557 MutableEntry bob(&trans, GET_BY_ID, bob_id); |
| 2571 ASSERT_TRUE(bob.good()); | 2558 ASSERT_TRUE(bob.good()); |
| 2572 bob.Put(IS_UNSYNCED, true); | 2559 bob.Put(IS_UNSYNCED, true); |
| 2573 bob.Put(PARENT_ID, fred_id); | 2560 bob.Put(PARENT_ID, fred_id); |
| 2574 MutableEntry new_item(&trans, CREATE, fred_id, PSTR("new_item")); | 2561 MutableEntry new_item(&trans, CREATE, fred_id, PSTR("new_item")); |
| 2575 WriteTestDataToEntry(&trans, &new_item); | 2562 WriteTestDataToEntry(&trans, &new_item); |
| 2576 new_item_id = new_item.Get(ID); | 2563 new_item_id = new_item.Get(ID); |
| 2577 } | 2564 } |
| 2578 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2565 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 2579 "fred", 2, 20); | 2566 "fred", 2, 20); |
| 2580 mock_server_->SetLastUpdateDeleted(); | 2567 mock_server_->SetLastUpdateDeleted(); |
| 2581 mock_server_->set_conflict_all_commits(true); | 2568 mock_server_->set_conflict_all_commits(true); |
| 2582 syncer_->SyncShare(); | 2569 syncer_->SyncShare(this); |
| 2583 syncer_->SyncShare(); | 2570 syncer_->SyncShare(this); |
| 2584 { | 2571 { |
| 2585 ReadTransaction trans(dir, __FILE__, __LINE__); | 2572 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2586 | 2573 |
| 2587 Entry bob(&trans, GET_BY_ID, bob_id); | 2574 Entry bob(&trans, GET_BY_ID, bob_id); |
| 2588 ASSERT_TRUE(bob.good()); | 2575 ASSERT_TRUE(bob.good()); |
| 2589 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); | 2576 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); |
| 2590 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); | 2577 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); |
| 2591 EXPECT_NE(bob.Get(PARENT_ID), fred_id); | 2578 EXPECT_NE(bob.Get(PARENT_ID), fred_id); |
| 2592 | 2579 |
| 2593 // Was recreated. Old one shouldn't exist. | 2580 // Was recreated. Old one shouldn't exist. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 } | 2628 } |
| 2642 syncer_events_.clear(); | 2629 syncer_events_.clear(); |
| 2643 } | 2630 } |
| 2644 | 2631 |
| 2645 TEST_F(SyncerTest, ServerMovedAFolderIntoAFolderWeHaveDeletedAndMovedIntoIt) { | 2632 TEST_F(SyncerTest, ServerMovedAFolderIntoAFolderWeHaveDeletedAndMovedIntoIt) { |
| 2646 // This test combines circular folders and deleted parents. | 2633 // This test combines circular folders and deleted parents. |
| 2647 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2634 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2648 CHECK(dir.good()); | 2635 CHECK(dir.good()); |
| 2649 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 2636 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
| 2650 mock_server_->AddUpdateDirectory(2, 0, "fred", 1, 10); | 2637 mock_server_->AddUpdateDirectory(2, 0, "fred", 1, 10); |
| 2651 syncer_->SyncShare(); | 2638 syncer_->SyncShare(this); |
| 2652 { | 2639 { |
| 2653 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2640 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2654 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2641 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2655 ASSERT_TRUE(bob.good()); | 2642 ASSERT_TRUE(bob.good()); |
| 2656 bob.Put(IS_UNSYNCED, true); | 2643 bob.Put(IS_UNSYNCED, true); |
| 2657 bob.Put(IS_DEL, true); | 2644 bob.Put(IS_DEL, true); |
| 2658 bob.Put(PARENT_ID, ids_.FromNumber(2)); | 2645 bob.Put(PARENT_ID, ids_.FromNumber(2)); |
| 2659 } | 2646 } |
| 2660 mock_server_->AddUpdateDirectory(2, 1, "fred", 2, 20); | 2647 mock_server_->AddUpdateDirectory(2, 1, "fred", 2, 20); |
| 2661 mock_server_->set_conflict_all_commits(true); | 2648 mock_server_->set_conflict_all_commits(true); |
| 2662 syncer_->SyncShare(); | 2649 syncer_->SyncShare(this); |
| 2663 syncer_->SyncShare(); | 2650 syncer_->SyncShare(this); |
| 2664 { | 2651 { |
| 2665 ReadTransaction trans(dir, __FILE__, __LINE__); | 2652 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2666 Entry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 2653 Entry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 2667 ASSERT_TRUE(bob.good()); | 2654 ASSERT_TRUE(bob.good()); |
| 2668 Entry fred(&trans, GET_BY_ID, ids_.FromNumber(2)); | 2655 Entry fred(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 2669 ASSERT_TRUE(fred.good()); | 2656 ASSERT_TRUE(fred.good()); |
| 2670 EXPECT_TRUE(fred.Get(IS_UNSYNCED)); | 2657 EXPECT_TRUE(fred.Get(IS_UNSYNCED)); |
| 2671 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); | 2658 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); |
| 2672 EXPECT_TRUE(bob.Get(IS_DEL)); | 2659 EXPECT_TRUE(bob.Get(IS_DEL)); |
| 2673 EXPECT_TRUE(fred.Get(PARENT_ID) == root_id_); | 2660 EXPECT_TRUE(fred.Get(PARENT_ID) == root_id_); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2809 | 2796 |
| 2810 static const int64 susan_int_id_ = 4; | 2797 static const int64 susan_int_id_ = 4; |
| 2811 | 2798 |
| 2812 void DeleteSusanInRoot() { | 2799 void DeleteSusanInRoot() { |
| 2813 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2800 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 2814 ASSERT_TRUE(dir.good()); | 2801 ASSERT_TRUE(dir.good()); |
| 2815 | 2802 |
| 2816 const syncable::Id susan_id = TestIdFactory::FromNumber(susan_int_id_); | 2803 const syncable::Id susan_id = TestIdFactory::FromNumber(susan_int_id_); |
| 2817 ASSERT_GT(countdown_till_delete_, 0); | 2804 ASSERT_GT(countdown_till_delete_, 0); |
| 2818 if (0 != --countdown_till_delete_) | 2805 if (0 != --countdown_till_delete_) |
| 2819 return; | 2806 return; |
| 2820 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2807 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2821 MutableEntry susan(&trans, GET_BY_ID, susan_id); | 2808 MutableEntry susan(&trans, GET_BY_ID, susan_id); |
| 2822 Directory::ChildHandles children; | 2809 Directory::ChildHandles children; |
| 2823 dir->GetChildHandles(&trans, susan.Get(ID), &children); | 2810 dir->GetChildHandles(&trans, susan.Get(ID), &children); |
| 2824 ASSERT_TRUE(0 == children.size()); | 2811 ASSERT_TRUE(0 == children.size()); |
| 2825 susan.Put(IS_DEL, true); | 2812 susan.Put(IS_DEL, true); |
| 2826 susan.Put(IS_UNSYNCED, true); | 2813 susan.Put(IS_UNSYNCED, true); |
| 2827 } | 2814 } |
| 2828 | 2815 |
| 2829 protected: | 2816 protected: |
| 2830 int countdown_till_delete_; | 2817 int countdown_till_delete_; |
| 2831 }; | 2818 }; |
| 2832 | 2819 |
| 2833 TEST_F(SusanDeletingTest, | 2820 TEST_F(SusanDeletingTest, |
| 2834 NewServerItemInAFolderHierarchyWeHaveDeleted3) { | 2821 NewServerItemInAFolderHierarchyWeHaveDeleted3) { |
| 2835 // Same as 2, except we deleted the folder the set is in between set building | 2822 // Same as 2, except we deleted the folder the set is in between set building |
| 2836 // and conflict resolution. | 2823 // and conflict resolution. |
| 2837 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2824 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2858 ASSERT_TRUE(joe.good()); | 2845 ASSERT_TRUE(joe.good()); |
| 2859 joe.Put(IS_UNSYNCED, true); | 2846 joe.Put(IS_UNSYNCED, true); |
| 2860 joe.Put(IS_DEL, true); | 2847 joe.Put(IS_DEL, true); |
| 2861 } | 2848 } |
| 2862 mock_server_->AddUpdateDirectory(fred_id, joe_id, "fred", 2, 20); | 2849 mock_server_->AddUpdateDirectory(fred_id, joe_id, "fred", 2, 20); |
| 2863 mock_server_->set_conflict_all_commits(true); | 2850 mock_server_->set_conflict_all_commits(true); |
| 2864 countdown_till_delete_ = 2; | 2851 countdown_till_delete_ = 2; |
| 2865 syncer_->pre_conflict_resolution_closure_ = | 2852 syncer_->pre_conflict_resolution_closure_ = |
| 2866 NewCallback<SusanDeletingTest>(this, | 2853 NewCallback<SusanDeletingTest>(this, |
| 2867 &SusanDeletingTest::DeleteSusanInRoot); | 2854 &SusanDeletingTest::DeleteSusanInRoot); |
| 2868 syncer_->SyncShare(); | 2855 syncer_->SyncShare(this); |
| 2869 syncer_->SyncShare(); | 2856 syncer_->SyncShare(this); |
| 2870 { | 2857 { |
| 2871 ReadTransaction trans(dir, __FILE__, __LINE__); | 2858 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2872 Entry bob(&trans, GET_BY_ID, bob_id); | 2859 Entry bob(&trans, GET_BY_ID, bob_id); |
| 2873 ASSERT_TRUE(bob.good()); | 2860 ASSERT_TRUE(bob.good()); |
| 2874 Entry joe(&trans, GET_BY_ID, joe_id); | 2861 Entry joe(&trans, GET_BY_ID, joe_id); |
| 2875 ASSERT_TRUE(joe.good()); | 2862 ASSERT_TRUE(joe.good()); |
| 2876 Entry fred(&trans, GET_BY_ID, fred_id); | 2863 Entry fred(&trans, GET_BY_ID, fred_id); |
| 2877 ASSERT_TRUE(fred.good()); | 2864 ASSERT_TRUE(fred.good()); |
| 2878 Entry susan(&trans, GET_BY_ID, susan_id); | 2865 Entry susan(&trans, GET_BY_ID, susan_id); |
| 2879 ASSERT_TRUE(susan.good()); | 2866 ASSERT_TRUE(susan.good()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2922 | 2909 |
| 2923 const syncable::Id bob_id = ids_.NewServerId(); | 2910 const syncable::Id bob_id = ids_.NewServerId(); |
| 2924 const syncable::Id fred_id = ids_.NewServerId(); | 2911 const syncable::Id fred_id = ids_.NewServerId(); |
| 2925 const syncable::Id alice_id = ids_.NewServerId(); | 2912 const syncable::Id alice_id = ids_.NewServerId(); |
| 2926 | 2913 |
| 2927 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), | 2914 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), |
| 2928 "bob", 1, 10); | 2915 "bob", 1, 10); |
| 2929 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2916 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 2930 "fred", 1, 10); | 2917 "fred", 1, 10); |
| 2931 mock_server_->AddUpdateDirectory(alice_id, fred_id, "alice", 1, 10); | 2918 mock_server_->AddUpdateDirectory(alice_id, fred_id, "alice", 1, 10); |
| 2932 syncer_->SyncShare(); | 2919 syncer_->SyncShare(this); |
| 2933 { | 2920 { |
| 2934 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2921 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 2935 MutableEntry bob(&trans, GET_BY_ID, bob_id); | 2922 MutableEntry bob(&trans, GET_BY_ID, bob_id); |
| 2936 ASSERT_TRUE(bob.good()); | 2923 ASSERT_TRUE(bob.good()); |
| 2937 bob.Put(IS_UNSYNCED, true); | 2924 bob.Put(IS_UNSYNCED, true); |
| 2938 bob.Put(PARENT_ID, alice_id); // Move into alice. | 2925 bob.Put(PARENT_ID, alice_id); // Move into alice. |
| 2939 } | 2926 } |
| 2940 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2927 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 2941 "fred", 2, 20); | 2928 "fred", 2, 20); |
| 2942 mock_server_->SetLastUpdateDeleted(); | 2929 mock_server_->SetLastUpdateDeleted(); |
| 2943 mock_server_->AddUpdateDirectory(alice_id, TestIdFactory::root(), | 2930 mock_server_->AddUpdateDirectory(alice_id, TestIdFactory::root(), |
| 2944 "alice", 2, 20); | 2931 "alice", 2, 20); |
| 2945 mock_server_->SetLastUpdateDeleted(); | 2932 mock_server_->SetLastUpdateDeleted(); |
| 2946 mock_server_->set_conflict_all_commits(true); | 2933 mock_server_->set_conflict_all_commits(true); |
| 2947 syncer_->SyncShare(); | 2934 syncer_->SyncShare(this); |
| 2948 syncer_->SyncShare(); | 2935 syncer_->SyncShare(this); |
| 2949 { | 2936 { |
| 2950 // Bob is the entry at the bottom of the tree. | 2937 // Bob is the entry at the bottom of the tree. |
| 2951 // The tree should be regenerated and old IDs removed. | 2938 // The tree should be regenerated and old IDs removed. |
| 2952 ReadTransaction trans(dir, __FILE__, __LINE__); | 2939 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 2953 Entry bob(&trans, GET_BY_ID, bob_id); | 2940 Entry bob(&trans, GET_BY_ID, bob_id); |
| 2954 ASSERT_TRUE(bob.good()); | 2941 ASSERT_TRUE(bob.good()); |
| 2955 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); | 2942 EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); |
| 2956 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); | 2943 EXPECT_TRUE(bob.Get(IS_UNSYNCED)); |
| 2957 | 2944 |
| 2958 // Old one should be deleted, but new one should have been made. | 2945 // Old one should be deleted, but new one should have been made. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2994 const syncable::Id fred_id = ids_.NewServerId(); | 2981 const syncable::Id fred_id = ids_.NewServerId(); |
| 2995 const syncable::Id alice_id = ids_.NewServerId(); | 2982 const syncable::Id alice_id = ids_.NewServerId(); |
| 2996 const syncable::Id susan_id = ids_.NewServerId(); | 2983 const syncable::Id susan_id = ids_.NewServerId(); |
| 2997 | 2984 |
| 2998 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), | 2985 mock_server_->AddUpdateDirectory(bob_id, TestIdFactory::root(), |
| 2999 "bob", 1, 10); | 2986 "bob", 1, 10); |
| 3000 mock_server_->AddUpdateDirectory(susan_id, TestIdFactory::root(), | 2987 mock_server_->AddUpdateDirectory(susan_id, TestIdFactory::root(), |
| 3001 "susan", 1, 10); | 2988 "susan", 1, 10); |
| 3002 mock_server_->AddUpdateDirectory(fred_id, susan_id, "fred", 1, 10); | 2989 mock_server_->AddUpdateDirectory(fred_id, susan_id, "fred", 1, 10); |
| 3003 mock_server_->AddUpdateDirectory(alice_id, fred_id, "alice", 1, 10); | 2990 mock_server_->AddUpdateDirectory(alice_id, fred_id, "alice", 1, 10); |
| 3004 syncer_->SyncShare(); | 2991 syncer_->SyncShare(this); |
| 3005 { | 2992 { |
| 3006 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2993 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 3007 MutableEntry bob(&trans, GET_BY_ID, bob_id); | 2994 MutableEntry bob(&trans, GET_BY_ID, bob_id); |
| 3008 ASSERT_TRUE(bob.good()); | 2995 ASSERT_TRUE(bob.good()); |
| 3009 bob.Put(IS_UNSYNCED, true); | 2996 bob.Put(IS_UNSYNCED, true); |
| 3010 bob.Put(PARENT_ID, alice_id); // Move into alice. | 2997 bob.Put(PARENT_ID, alice_id); // Move into alice. |
| 3011 } | 2998 } |
| 3012 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), | 2999 mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), |
| 3013 "fred", 2, 20); | 3000 "fred", 2, 20); |
| 3014 mock_server_->SetLastUpdateDeleted(); | 3001 mock_server_->SetLastUpdateDeleted(); |
| 3015 mock_server_->AddUpdateDirectory(alice_id, TestIdFactory::root(), | 3002 mock_server_->AddUpdateDirectory(alice_id, TestIdFactory::root(), |
| 3016 "alice", 2, 20); | 3003 "alice", 2, 20); |
| 3017 mock_server_->SetLastUpdateDeleted(); | 3004 mock_server_->SetLastUpdateDeleted(); |
| 3018 mock_server_->set_conflict_all_commits(true); | 3005 mock_server_->set_conflict_all_commits(true); |
| 3019 syncer_->SyncShare(); | 3006 syncer_->SyncShare(this); |
| 3020 syncer_->SyncShare(); | 3007 syncer_->SyncShare(this); |
| 3021 { | 3008 { |
| 3022 // Root | 3009 // Root |
| 3023 // |- Susan | 3010 // |- Susan |
| 3024 // |- Fred | 3011 // |- Fred |
| 3025 // |- Alice | 3012 // |- Alice |
| 3026 // |- Bob | 3013 // |- Bob |
| 3027 | 3014 |
| 3028 ReadTransaction trans(dir, __FILE__, __LINE__); | 3015 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3029 Entry bob(&trans, GET_BY_ID, bob_id); | 3016 Entry bob(&trans, GET_BY_ID, bob_id); |
| 3030 ASSERT_TRUE(bob.good()); | 3017 ASSERT_TRUE(bob.good()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3077 folder.Put(IS_DIR, true); | 3064 folder.Put(IS_DIR, true); |
| 3078 MutableEntry folder2(&trans, CREATE, trans.root_id(), PSTR("fred")); | 3065 MutableEntry folder2(&trans, CREATE, trans.root_id(), PSTR("fred")); |
| 3079 ASSERT_TRUE(folder2.good()); | 3066 ASSERT_TRUE(folder2.good()); |
| 3080 folder2.Put(IS_UNSYNCED, false); | 3067 folder2.Put(IS_UNSYNCED, false); |
| 3081 folder2.Put(IS_DIR, true); | 3068 folder2.Put(IS_DIR, true); |
| 3082 folder2.Put(BASE_VERSION, 3); | 3069 folder2.Put(BASE_VERSION, 3); |
| 3083 folder2.Put(ID, syncable::Id::CreateFromServerId("mock_server:10000")); | 3070 folder2.Put(ID, syncable::Id::CreateFromServerId("mock_server:10000")); |
| 3084 } | 3071 } |
| 3085 mock_server_->set_next_new_id(10000); | 3072 mock_server_->set_next_new_id(10000); |
| 3086 EXPECT_TRUE(1 == dir->unsynced_entity_count()); | 3073 EXPECT_TRUE(1 == dir->unsynced_entity_count()); |
| 3087 syncer_->SyncShare(); // we get back a bad id in here (should never happen). | 3074 syncer_->SyncShare(this); // we get back a bad id in here (should never happe
n). |
| 3088 EXPECT_TRUE(1 == dir->unsynced_entity_count()); | 3075 EXPECT_TRUE(1 == dir->unsynced_entity_count()); |
| 3089 syncer_->SyncShare(); // another bad id in here. | 3076 syncer_->SyncShare(this); // another bad id in here. |
| 3090 EXPECT_TRUE(0 == dir->unsynced_entity_count()); | 3077 EXPECT_TRUE(0 == dir->unsynced_entity_count()); |
| 3091 syncer_events_.clear(); | 3078 syncer_events_.clear(); |
| 3092 } | 3079 } |
| 3093 | 3080 |
| 3094 TEST_F(SyncerTest, DeletedEntryWithBadParentInLoopCalculation) { | 3081 TEST_F(SyncerTest, DeletedEntryWithBadParentInLoopCalculation) { |
| 3095 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3082 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3096 ASSERT_TRUE(dir.good()); | 3083 ASSERT_TRUE(dir.good()); |
| 3097 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); | 3084 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10); |
| 3098 syncer_->SyncShare(); | 3085 syncer_->SyncShare(this); |
| 3099 { | 3086 { |
| 3100 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 3087 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 3101 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 3088 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 3102 ASSERT_TRUE(bob.good()); | 3089 ASSERT_TRUE(bob.good()); |
| 3103 // This is valid, because the parent could have gone away a long time ago. | 3090 // This is valid, because the parent could have gone away a long time ago. |
| 3104 bob.Put(PARENT_ID, ids_.FromNumber(54)); | 3091 bob.Put(PARENT_ID, ids_.FromNumber(54)); |
| 3105 bob.Put(IS_DEL, true); | 3092 bob.Put(IS_DEL, true); |
| 3106 bob.Put(IS_UNSYNCED, true); | 3093 bob.Put(IS_UNSYNCED, true); |
| 3107 } | 3094 } |
| 3108 mock_server_->AddUpdateDirectory(2, 1, "fred", 1, 10); | 3095 mock_server_->AddUpdateDirectory(2, 1, "fred", 1, 10); |
| 3109 syncer_->SyncShare(); | 3096 syncer_->SyncShare(this); |
| 3110 syncer_->SyncShare(); | 3097 syncer_->SyncShare(this); |
| 3111 } | 3098 } |
| 3112 | 3099 |
| 3113 TEST_F(SyncerTest, ConflictResolverMergeOverwritesLocalEntry) { | 3100 TEST_F(SyncerTest, ConflictResolverMergeOverwritesLocalEntry) { |
| 3114 // This test would die because it would rename a entry to a name that was | 3101 // This test would die because it would rename a entry to a name that was |
| 3115 // taken in the namespace | 3102 // taken in the namespace |
| 3116 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3103 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3117 CHECK(dir.good()); | 3104 CHECK(dir.good()); |
| 3118 | 3105 |
| 3119 ConflictSet conflict_set; | 3106 ConflictSet conflict_set; |
| 3120 { | 3107 { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3133 MutableEntry update(&trans, CREATE_NEW_UPDATE_ITEM, ids_.FromNumber(3)); | 3120 MutableEntry update(&trans, CREATE_NEW_UPDATE_ITEM, ids_.FromNumber(3)); |
| 3134 update.Put(BASE_VERSION, 1); | 3121 update.Put(BASE_VERSION, 1); |
| 3135 update.Put(SERVER_NON_UNIQUE_NAME, PSTR("name")); | 3122 update.Put(SERVER_NON_UNIQUE_NAME, PSTR("name")); |
| 3136 update.Put(PARENT_ID, ids_.FromNumber(0)); | 3123 update.Put(PARENT_ID, ids_.FromNumber(0)); |
| 3137 update.Put(IS_UNAPPLIED_UPDATE, true); | 3124 update.Put(IS_UNAPPLIED_UPDATE, true); |
| 3138 | 3125 |
| 3139 conflict_set.push_back(ids_.FromNumber(1)); | 3126 conflict_set.push_back(ids_.FromNumber(1)); |
| 3140 conflict_set.push_back(ids_.FromNumber(3)); | 3127 conflict_set.push_back(ids_.FromNumber(3)); |
| 3141 } | 3128 } |
| 3142 { | 3129 { |
| 3143 SyncCycleState cycle_state; | |
| 3144 SyncerSession session(&cycle_state, state_.get()); | |
| 3145 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 3130 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 3146 syncer_->conflict_resolver()->ProcessConflictSet(&trans, &conflict_set, 50, | 3131 context_->resolver()->ProcessConflictSet(&trans, &conflict_set, 50); |
| 3147 &session); | |
| 3148 } | 3132 } |
| 3149 } | 3133 } |
| 3150 | 3134 |
| 3151 TEST_F(SyncerTest, ConflictResolverMergesLocalDeleteAndServerUpdate) { | 3135 TEST_F(SyncerTest, ConflictResolverMergesLocalDeleteAndServerUpdate) { |
| 3152 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3136 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3153 CHECK(dir.good()); | 3137 CHECK(dir.good()); |
| 3154 | 3138 |
| 3155 { | 3139 { |
| 3156 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 3140 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 3157 | 3141 |
| 3158 MutableEntry local_deleted(&trans, CREATE, trans.root_id(), PSTR("name")); | 3142 MutableEntry local_deleted(&trans, CREATE, trans.root_id(), PSTR("name")); |
| 3159 local_deleted.Put(ID, ids_.FromNumber(1)); | 3143 local_deleted.Put(ID, ids_.FromNumber(1)); |
| 3160 local_deleted.Put(BASE_VERSION, 1); | 3144 local_deleted.Put(BASE_VERSION, 1); |
| 3161 local_deleted.Put(IS_DEL, true); | 3145 local_deleted.Put(IS_DEL, true); |
| 3162 local_deleted.Put(IS_DIR, false); | 3146 local_deleted.Put(IS_DIR, false); |
| 3163 local_deleted.Put(IS_UNSYNCED, true); | 3147 local_deleted.Put(IS_UNSYNCED, true); |
| 3164 local_deleted.Put(IS_BOOKMARK_OBJECT, true); | 3148 local_deleted.Put(IS_BOOKMARK_OBJECT, true); |
| 3165 } | 3149 } |
| 3166 | 3150 |
| 3167 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); | 3151 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); |
| 3168 | 3152 |
| 3169 // We don't care about actually committing, just the resolution. | 3153 // We don't care about actually committing, just the resolution. |
| 3170 mock_server_->set_conflict_all_commits(true); | 3154 mock_server_->set_conflict_all_commits(true); |
| 3171 syncer_->SyncShare(); | 3155 syncer_->SyncShare(this); |
| 3172 | 3156 |
| 3173 { | 3157 { |
| 3174 ReadTransaction trans(dir, __FILE__, __LINE__); | 3158 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3175 Entry local_deleted(&trans, GET_BY_ID, ids_.FromNumber(1)); | 3159 Entry local_deleted(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 3176 EXPECT_TRUE(local_deleted.Get(BASE_VERSION) == 10); | 3160 EXPECT_TRUE(local_deleted.Get(BASE_VERSION) == 10); |
| 3177 EXPECT_TRUE(local_deleted.Get(IS_UNAPPLIED_UPDATE) == false); | 3161 EXPECT_TRUE(local_deleted.Get(IS_UNAPPLIED_UPDATE) == false); |
| 3178 EXPECT_TRUE(local_deleted.Get(IS_UNSYNCED) == true); | 3162 EXPECT_TRUE(local_deleted.Get(IS_UNSYNCED) == true); |
| 3179 EXPECT_TRUE(local_deleted.Get(IS_DEL) == true); | 3163 EXPECT_TRUE(local_deleted.Get(IS_DEL) == true); |
| 3180 EXPECT_TRUE(local_deleted.Get(IS_DIR) == false); | 3164 EXPECT_TRUE(local_deleted.Get(IS_DIR) == false); |
| 3181 } | 3165 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3199 local_deleted.Put(IS_UNSYNCED, true); | 3183 local_deleted.Put(IS_UNSYNCED, true); |
| 3200 } | 3184 } |
| 3201 | 3185 |
| 3202 // Server update: entry-type object (not a container), revision 10. | 3186 // Server update: entry-type object (not a container), revision 10. |
| 3203 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); | 3187 mock_server_->AddUpdateBookmark(ids_.FromNumber(1), root_id_, "name", 10, 10); |
| 3204 | 3188 |
| 3205 // Don't attempt to commit. | 3189 // Don't attempt to commit. |
| 3206 mock_server_->set_conflict_all_commits(true); | 3190 mock_server_->set_conflict_all_commits(true); |
| 3207 | 3191 |
| 3208 // The syncer should not attempt to apply the invalid update. | 3192 // The syncer should not attempt to apply the invalid update. |
| 3209 syncer_->SyncShare(); | 3193 syncer_->SyncShare(this); |
| 3210 | 3194 |
| 3211 { | 3195 { |
| 3212 ReadTransaction trans(dir, __FILE__, __LINE__); | 3196 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3213 Entry local_deleted(&trans, GET_BY_ID, ids_.FromNumber(1)); | 3197 Entry local_deleted(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 3214 EXPECT_TRUE(local_deleted.Get(BASE_VERSION) == 1); | 3198 EXPECT_TRUE(local_deleted.Get(BASE_VERSION) == 1); |
| 3215 EXPECT_TRUE(local_deleted.Get(IS_UNAPPLIED_UPDATE) == false); | 3199 EXPECT_TRUE(local_deleted.Get(IS_UNAPPLIED_UPDATE) == false); |
| 3216 EXPECT_TRUE(local_deleted.Get(IS_UNSYNCED) == true); | 3200 EXPECT_TRUE(local_deleted.Get(IS_UNSYNCED) == true); |
| 3217 EXPECT_TRUE(local_deleted.Get(IS_DEL) == true); | 3201 EXPECT_TRUE(local_deleted.Get(IS_DEL) == true); |
| 3218 EXPECT_TRUE(local_deleted.Get(IS_DIR) == true); | 3202 EXPECT_TRUE(local_deleted.Get(IS_DIR) == true); |
| 3219 } | 3203 } |
| 3220 } | 3204 } |
| 3221 | 3205 |
| 3222 TEST(SyncerSyncProcessState, MergeSetsTest) { | 3206 TEST(SyncerSyncProcessState, MergeSetsTest) { |
| 3223 TestIdFactory id_factory; | 3207 TestIdFactory id_factory; |
| 3224 syncable::Id id[7]; | 3208 syncable::Id id[7]; |
| 3225 for (int i = 1; i < 7; i++) { | 3209 for (int i = 1; i < 7; i++) { |
| 3226 id[i] = id_factory.NewServerId(); | 3210 id[i] = id_factory.NewServerId(); |
| 3227 } | 3211 } |
| 3228 SyncProcessState c; | 3212 ConflictProgress c; |
| 3229 c.MergeSets(id[1], id[2]); | 3213 c.MergeSets(id[1], id[2]); |
| 3230 c.MergeSets(id[2], id[3]); | 3214 c.MergeSets(id[2], id[3]); |
| 3231 c.MergeSets(id[4], id[5]); | 3215 c.MergeSets(id[4], id[5]); |
| 3232 c.MergeSets(id[5], id[6]); | 3216 c.MergeSets(id[5], id[6]); |
| 3233 EXPECT_TRUE(6 == c.IdToConflictSetSize()); | 3217 EXPECT_TRUE(6 == c.IdToConflictSetSize()); |
| 3234 for (int i = 1; i < 7; i++) { | 3218 for (int i = 1; i < 7; i++) { |
| 3235 EXPECT_TRUE(NULL != c.IdToConflictSetGet(id[i])); | 3219 EXPECT_TRUE(NULL != c.IdToConflictSetGet(id[i])); |
| 3236 EXPECT_TRUE(c.IdToConflictSetGet(id[(i & ~3) + 1]) == | 3220 EXPECT_TRUE(c.IdToConflictSetGet(id[(i & ~3) + 1]) == |
| 3237 c.IdToConflictSetGet(id[i])); | 3221 c.IdToConflictSetGet(id[i])); |
| 3238 } | 3222 } |
| 3239 c.MergeSets(id[1], id[6]); | 3223 c.MergeSets(id[1], id[6]); |
| 3240 for (int i = 1; i < 7; i++) { | 3224 for (int i = 1; i < 7; i++) { |
| 3241 EXPECT_TRUE(NULL != c.IdToConflictSetGet(id[i])); | 3225 EXPECT_TRUE(NULL != c.IdToConflictSetGet(id[i])); |
| 3242 EXPECT_TRUE(c.IdToConflictSetGet(id[1]) == c.IdToConflictSetGet(id[i])); | 3226 EXPECT_TRUE(c.IdToConflictSetGet(id[1]) == c.IdToConflictSetGet(id[i])); |
| 3243 } | 3227 } |
| 3244 | 3228 |
| 3245 // Check dupes don't cause double sets. | 3229 // Check dupes don't cause double sets. |
| 3246 SyncProcessState identical_set; | 3230 ConflictProgress identical_set; |
| 3247 identical_set.MergeSets(id[1], id[1]); | 3231 identical_set.MergeSets(id[1], id[1]); |
| 3248 EXPECT_TRUE(identical_set.IdToConflictSetSize() == 1); | 3232 EXPECT_TRUE(identical_set.IdToConflictSetSize() == 1); |
| 3249 EXPECT_TRUE(identical_set.IdToConflictSetGet(id[1])->size() == 1); | 3233 EXPECT_TRUE(identical_set.IdToConflictSetGet(id[1])->size() == 1); |
| 3250 } | 3234 } |
| 3251 | 3235 |
| 3252 // Bug Synopsis: | 3236 // Bug Synopsis: |
| 3253 // Merge conflict resolution will merge a new local entry with another entry | 3237 // Merge conflict resolution will merge a new local entry with another entry |
| 3254 // that needs updates, resulting in CHECK. | 3238 // that needs updates, resulting in CHECK. |
| 3255 TEST_F(SyncerTest, MergingExistingItems) { | 3239 TEST_F(SyncerTest, MergingExistingItems) { |
| 3256 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3240 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3257 CHECK(dir.good()); | 3241 CHECK(dir.good()); |
| 3258 mock_server_->set_conflict_all_commits(true); | 3242 mock_server_->set_conflict_all_commits(true); |
| 3259 mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10); | 3243 mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10); |
| 3260 syncer_->SyncShare(); | 3244 syncer_->SyncShare(this); |
| 3261 { | 3245 { |
| 3262 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 3246 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 3263 MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("Copy of base")); | 3247 MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("Copy of base")); |
| 3264 WriteTestDataToEntry(&trans, &entry); | 3248 WriteTestDataToEntry(&trans, &entry); |
| 3265 } | 3249 } |
| 3266 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); | 3250 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); |
| 3267 SyncRepeatedlyToTriggerConflictResolution(state_.get()); | 3251 SyncRepeatedlyToTriggerConflictResolution(session_.get()); |
| 3268 } | 3252 } |
| 3269 | 3253 |
| 3270 // In this test a long changelog contains a child at the start of the changelog | 3254 // In this test a long changelog contains a child at the start of the changelog |
| 3271 // and a parent at the end. While these updates are in progress the client would | 3255 // and a parent at the end. While these updates are in progress the client would |
| 3272 // appear stuck. | 3256 // appear stuck. |
| 3273 TEST_F(SyncerTest, LongChangelistWithApplicationConflict) { | 3257 TEST_F(SyncerTest, LongChangelistWithApplicationConflict) { |
| 3274 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3258 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3275 CHECK(dir.good()); | 3259 CHECK(dir.good()); |
| 3276 const int DEPTH = 400; | 3260 const int DEPTH = 400; |
| 3277 syncable::Id folder_id = ids_.FromNumber(1); | 3261 syncable::Id folder_id = ids_.FromNumber(1); |
| 3278 | 3262 |
| 3279 // First we an item in a folder in the root. However the folder won't come | 3263 // First we an item in a folder in the root. However the folder won't come |
| 3280 // till much later. | 3264 // till much later. |
| 3281 syncable::Id stuck_entry_id = TestIdFactory::FromNumber(99999); | 3265 syncable::Id stuck_entry_id = TestIdFactory::FromNumber(99999); |
| 3282 mock_server_->AddUpdateDirectory(stuck_entry_id, | 3266 mock_server_->AddUpdateDirectory(stuck_entry_id, |
| 3283 folder_id, "stuck", 1, 1); | 3267 folder_id, "stuck", 1, 1); |
| 3284 mock_server_->SetChangesRemaining(DEPTH - 1); | 3268 mock_server_->SetChangesRemaining(DEPTH - 1); |
| 3285 syncer_->SyncShare(state_.get()); | 3269 syncer_->SyncShare(session_.get()); |
| 3286 | 3270 |
| 3287 // Very long changelist. We should never be stuck. | 3271 // Very long changelist. We should never be stuck. |
| 3288 for (int i = 0; i < DEPTH; i++) { | 3272 for (int i = 0; i < DEPTH; i++) { |
| 3289 mock_server_->SetNewTimestamp(i); | 3273 mock_server_->SetNewTimestamp(i); |
| 3290 mock_server_->SetChangesRemaining(DEPTH - i); | 3274 mock_server_->SetChangesRemaining(DEPTH - i); |
| 3291 syncer_->SyncShare(state_.get()); | 3275 syncer_->SyncShare(session_.get()); |
| 3292 EXPECT_FALSE(SyncerStuck(state_.get())); | 3276 EXPECT_FALSE(session_->status_controller()->syncer_status().syncer_stuck); |
| 3293 | 3277 |
| 3294 // Ensure our folder hasn't somehow applied. | 3278 // Ensure our folder hasn't somehow applied. |
| 3295 ReadTransaction trans(dir, __FILE__, __LINE__); | 3279 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3296 Entry child(&trans, GET_BY_ID, stuck_entry_id); | 3280 Entry child(&trans, GET_BY_ID, stuck_entry_id); |
| 3297 EXPECT_TRUE(child.good()); | 3281 EXPECT_TRUE(child.good()); |
| 3298 EXPECT_TRUE(child.Get(IS_UNAPPLIED_UPDATE)); | 3282 EXPECT_TRUE(child.Get(IS_UNAPPLIED_UPDATE)); |
| 3299 EXPECT_TRUE(child.Get(IS_DEL)); | 3283 EXPECT_TRUE(child.Get(IS_DEL)); |
| 3300 EXPECT_FALSE(child.Get(IS_UNSYNCED)); | 3284 EXPECT_FALSE(child.Get(IS_UNSYNCED)); |
| 3301 } | 3285 } |
| 3302 | 3286 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3317 EXPECT_TRUE(child.good()); | 3301 EXPECT_TRUE(child.good()); |
| 3318 } | 3302 } |
| 3319 } | 3303 } |
| 3320 | 3304 |
| 3321 TEST_F(SyncerTest, DontMergeTwoExistingItems) { | 3305 TEST_F(SyncerTest, DontMergeTwoExistingItems) { |
| 3322 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3306 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3323 EXPECT_TRUE(dir.good()); | 3307 EXPECT_TRUE(dir.good()); |
| 3324 mock_server_->set_conflict_all_commits(true); | 3308 mock_server_->set_conflict_all_commits(true); |
| 3325 mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10); | 3309 mock_server_->AddUpdateBookmark(1, 0, "base", 10, 10); |
| 3326 mock_server_->AddUpdateBookmark(2, 0, "base2", 10, 10); | 3310 mock_server_->AddUpdateBookmark(2, 0, "base2", 10, 10); |
| 3327 syncer_->SyncShare(); | 3311 syncer_->SyncShare(this); |
| 3328 { | 3312 { |
| 3329 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 3313 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 3330 MutableEntry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3314 MutableEntry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 3331 ASSERT_TRUE(entry.good()); | 3315 ASSERT_TRUE(entry.good()); |
| 3332 EXPECT_TRUE(entry.Put(NON_UNIQUE_NAME, PSTR("Copy of base"))); | 3316 EXPECT_TRUE(entry.Put(NON_UNIQUE_NAME, PSTR("Copy of base"))); |
| 3333 entry.Put(IS_UNSYNCED, true); | 3317 entry.Put(IS_UNSYNCED, true); |
| 3334 } | 3318 } |
| 3335 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); | 3319 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); |
| 3336 SyncRepeatedlyToTriggerConflictResolution(state_.get()); | 3320 SyncRepeatedlyToTriggerConflictResolution(session_.get()); |
| 3337 { | 3321 { |
| 3338 ReadTransaction trans(dir, __FILE__, __LINE__); | 3322 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3339 Entry entry1(&trans, GET_BY_ID, ids_.FromNumber(1)); | 3323 Entry entry1(&trans, GET_BY_ID, ids_.FromNumber(1)); |
| 3340 EXPECT_FALSE(entry1.Get(IS_UNAPPLIED_UPDATE)); | 3324 EXPECT_FALSE(entry1.Get(IS_UNAPPLIED_UPDATE)); |
| 3341 EXPECT_FALSE(entry1.Get(IS_UNSYNCED)); | 3325 EXPECT_FALSE(entry1.Get(IS_UNSYNCED)); |
| 3342 EXPECT_FALSE(entry1.Get(IS_DEL)); | 3326 EXPECT_FALSE(entry1.Get(IS_DEL)); |
| 3343 Entry entry2(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3327 Entry entry2(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 3344 EXPECT_FALSE(entry2.Get(IS_UNAPPLIED_UPDATE)); | 3328 EXPECT_FALSE(entry2.Get(IS_UNAPPLIED_UPDATE)); |
| 3345 EXPECT_TRUE(entry2.Get(IS_UNSYNCED)); | 3329 EXPECT_TRUE(entry2.Get(IS_UNSYNCED)); |
| 3346 EXPECT_FALSE(entry2.Get(IS_DEL)); | 3330 EXPECT_FALSE(entry2.Get(IS_DEL)); |
| 3347 EXPECT_EQ(entry1.Get(NON_UNIQUE_NAME), entry2.Get(NON_UNIQUE_NAME)); | 3331 EXPECT_EQ(entry1.Get(NON_UNIQUE_NAME), entry2.Get(NON_UNIQUE_NAME)); |
| 3348 } | 3332 } |
| 3349 } | 3333 } |
| 3350 | 3334 |
| 3351 TEST_F(SyncerTest, TestUndeleteUpdate) { | 3335 TEST_F(SyncerTest, TestUndeleteUpdate) { |
| 3352 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3336 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3353 EXPECT_TRUE(dir.good()); | 3337 EXPECT_TRUE(dir.good()); |
| 3354 mock_server_->set_conflict_all_commits(true); | 3338 mock_server_->set_conflict_all_commits(true); |
| 3355 mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1); | 3339 mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1); |
| 3356 mock_server_->AddUpdateDirectory(2, 1, "bar", 1, 2); | 3340 mock_server_->AddUpdateDirectory(2, 1, "bar", 1, 2); |
| 3357 syncer_->SyncShare(); | 3341 syncer_->SyncShare(this); |
| 3358 mock_server_->AddUpdateDirectory(2, 1, "bar", 2, 3); | 3342 mock_server_->AddUpdateDirectory(2, 1, "bar", 2, 3); |
| 3359 mock_server_->SetLastUpdateDeleted(); | 3343 mock_server_->SetLastUpdateDeleted(); |
| 3360 syncer_->SyncShare(); | 3344 syncer_->SyncShare(this); |
| 3361 { | 3345 { |
| 3362 ReadTransaction trans(dir, __FILE__, __LINE__); | 3346 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3363 Entry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3347 Entry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 3364 ASSERT_TRUE(entry.good()); | 3348 ASSERT_TRUE(entry.good()); |
| 3365 EXPECT_TRUE(entry.Get(IS_DEL)); | 3349 EXPECT_TRUE(entry.Get(IS_DEL)); |
| 3366 } | 3350 } |
| 3367 mock_server_->AddUpdateDirectory(1, 0, "foo", 2, 4); | 3351 mock_server_->AddUpdateDirectory(1, 0, "foo", 2, 4); |
| 3368 mock_server_->SetLastUpdateDeleted(); | 3352 mock_server_->SetLastUpdateDeleted(); |
| 3369 syncer_->SyncShare(); | 3353 syncer_->SyncShare(this); |
| 3370 // This used to be rejected as it's an undeletion. Now, it results in moving | 3354 // This used to be rejected as it's an undeletion. Now, it results in moving |
| 3371 // the delete path aside. | 3355 // the delete path aside. |
| 3372 mock_server_->AddUpdateDirectory(2, 1, "bar", 3, 5); | 3356 mock_server_->AddUpdateDirectory(2, 1, "bar", 3, 5); |
| 3373 syncer_->SyncShare(); | 3357 syncer_->SyncShare(this); |
| 3374 { | 3358 { |
| 3375 ReadTransaction trans(dir, __FILE__, __LINE__); | 3359 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3376 Entry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3360 Entry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 3377 ASSERT_TRUE(entry.good()); | 3361 ASSERT_TRUE(entry.good()); |
| 3378 EXPECT_TRUE(entry.Get(IS_DEL)); | 3362 EXPECT_TRUE(entry.Get(IS_DEL)); |
| 3379 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); | 3363 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); |
| 3380 EXPECT_TRUE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3364 EXPECT_TRUE(entry.Get(IS_UNAPPLIED_UPDATE)); |
| 3381 } | 3365 } |
| 3382 } | 3366 } |
| 3383 | 3367 |
| 3384 TEST_F(SyncerTest, TestMoveSanitizedNamedFolder) { | 3368 TEST_F(SyncerTest, TestMoveSanitizedNamedFolder) { |
| 3385 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3369 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3386 EXPECT_TRUE(dir.good()); | 3370 EXPECT_TRUE(dir.good()); |
| 3387 mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1); | 3371 mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1); |
| 3388 mock_server_->AddUpdateDirectory(2, 0, ":::", 1, 2); | 3372 mock_server_->AddUpdateDirectory(2, 0, ":::", 1, 2); |
| 3389 syncer_->SyncShare(); | 3373 syncer_->SyncShare(this); |
| 3390 { | 3374 { |
| 3391 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 3375 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 3392 MutableEntry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3376 MutableEntry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); |
| 3393 ASSERT_TRUE(entry.good()); | 3377 ASSERT_TRUE(entry.good()); |
| 3394 EXPECT_TRUE(entry.Put(PARENT_ID, ids_.FromNumber(1))); | 3378 EXPECT_TRUE(entry.Put(PARENT_ID, ids_.FromNumber(1))); |
| 3395 EXPECT_TRUE(entry.Put(IS_UNSYNCED, true)); | 3379 EXPECT_TRUE(entry.Put(IS_UNSYNCED, true)); |
| 3396 } | 3380 } |
| 3397 syncer_->SyncShare(); | 3381 syncer_->SyncShare(this); |
| 3398 // We use the same sync ts as before so our times match up. | 3382 // We use the same sync ts as before so our times match up. |
| 3399 mock_server_->AddUpdateDirectory(2, 1, ":::", 2, 2); | 3383 mock_server_->AddUpdateDirectory(2, 1, ":::", 2, 2); |
| 3400 syncer_->SyncShare(); | 3384 syncer_->SyncShare(this); |
| 3401 } | 3385 } |
| 3402 | 3386 |
| 3403 TEST(SortedCollectionsIntersect, SortedCollectionsIntersectTest) { | 3387 TEST(SortedCollectionsIntersect, SortedCollectionsIntersectTest) { |
| 3404 int negative[] = {-3, -2, -1}; | 3388 int negative[] = {-3, -2, -1}; |
| 3405 int straddle[] = {-1, 0, 1}; | 3389 int straddle[] = {-1, 0, 1}; |
| 3406 int positive[] = {1, 2, 3}; | 3390 int positive[] = {1, 2, 3}; |
| 3407 EXPECT_TRUE(SortedCollectionsIntersect(negative, negative + 3, | 3391 EXPECT_TRUE(SortedCollectionsIntersect(negative, negative + 3, |
| 3408 straddle, straddle + 3)); | 3392 straddle, straddle + 3)); |
| 3409 EXPECT_FALSE(SortedCollectionsIntersect(negative, negative + 3, | 3393 EXPECT_FALSE(SortedCollectionsIntersect(negative, negative + 3, |
| 3410 positive, positive + 3)); | 3394 positive, positive + 3)); |
| 3411 EXPECT_TRUE(SortedCollectionsIntersect(straddle, straddle + 3, | 3395 EXPECT_TRUE(SortedCollectionsIntersect(straddle, straddle + 3, |
| 3412 positive, positive + 3)); | 3396 positive, positive + 3)); |
| 3413 EXPECT_FALSE(SortedCollectionsIntersect(straddle + 2, straddle + 3, | 3397 EXPECT_FALSE(SortedCollectionsIntersect(straddle + 2, straddle + 3, |
| 3414 positive, positive)); | 3398 positive, positive)); |
| 3415 EXPECT_FALSE(SortedCollectionsIntersect(straddle, straddle + 3, | 3399 EXPECT_FALSE(SortedCollectionsIntersect(straddle, straddle + 3, |
| 3416 positive + 1, positive + 1)); | 3400 positive + 1, positive + 1)); |
| 3417 EXPECT_TRUE(SortedCollectionsIntersect(straddle, straddle + 3, | 3401 EXPECT_TRUE(SortedCollectionsIntersect(straddle, straddle + 3, |
| 3418 positive, positive + 1)); | 3402 positive, positive + 1)); |
| 3419 } | 3403 } |
| 3420 | 3404 |
| 3421 // Don't crash when this occurs. | 3405 // Don't crash when this occurs. |
| 3422 TEST_F(SyncerTest, UpdateWhereParentIsNotAFolder) { | 3406 TEST_F(SyncerTest, UpdateWhereParentIsNotAFolder) { |
| 3423 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3407 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3424 CHECK(dir.good()); | 3408 CHECK(dir.good()); |
| 3425 mock_server_->AddUpdateBookmark(1, 0, "B", 10, 10); | 3409 mock_server_->AddUpdateBookmark(1, 0, "B", 10, 10); |
| 3426 mock_server_->AddUpdateDirectory(2, 1, "BookmarkParent", 10, 10); | 3410 mock_server_->AddUpdateDirectory(2, 1, "BookmarkParent", 10, 10); |
| 3427 // Used to cause a CHECK | 3411 // Used to cause a CHECK |
| 3428 syncer_->SyncShare(); | 3412 syncer_->SyncShare(this); |
| 3429 { | 3413 { |
| 3430 ReadTransaction rtrans(dir, __FILE__, __LINE__); | 3414 ReadTransaction rtrans(dir, __FILE__, __LINE__); |
| 3431 Entry good_entry(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); | 3415 Entry good_entry(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); |
| 3432 ASSERT_TRUE(good_entry.good()); | 3416 ASSERT_TRUE(good_entry.good()); |
| 3433 EXPECT_FALSE(good_entry.Get(IS_UNAPPLIED_UPDATE)); | 3417 EXPECT_FALSE(good_entry.Get(IS_UNAPPLIED_UPDATE)); |
| 3434 Entry bad_parent(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2)); | 3418 Entry bad_parent(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(2)); |
| 3435 ASSERT_TRUE(bad_parent.good()); | 3419 ASSERT_TRUE(bad_parent.good()); |
| 3436 EXPECT_TRUE(bad_parent.Get(IS_UNAPPLIED_UPDATE)); | 3420 EXPECT_TRUE(bad_parent.Get(IS_UNAPPLIED_UPDATE)); |
| 3437 } | 3421 } |
| 3438 } | 3422 } |
| 3439 | 3423 |
| 3440 const char kRootId[] = "0"; | 3424 const char kRootId[] = "0"; |
| 3441 | 3425 |
| 3442 TEST_F(SyncerTest, DirectoryUpdateTest) { | 3426 TEST_F(SyncerTest, DirectoryUpdateTest) { |
| 3443 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3427 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3444 CHECK(dir.good()); | 3428 CHECK(dir.good()); |
| 3445 | 3429 |
| 3446 Id in_root_id = ids_.NewServerId(); | 3430 Id in_root_id = ids_.NewServerId(); |
| 3447 Id in_in_root_id = ids_.NewServerId(); | 3431 Id in_in_root_id = ids_.NewServerId(); |
| 3448 | 3432 |
| 3449 mock_server_->AddUpdateDirectory(in_root_id, TestIdFactory::root(), | 3433 mock_server_->AddUpdateDirectory(in_root_id, TestIdFactory::root(), |
| 3450 "in_root_name", 2, 2); | 3434 "in_root_name", 2, 2); |
| 3451 mock_server_->AddUpdateDirectory(in_in_root_id, in_root_id, | 3435 mock_server_->AddUpdateDirectory(in_in_root_id, in_root_id, |
| 3452 "in_in_root_name", 3, 3); | 3436 "in_in_root_name", 3, 3); |
| 3453 syncer_->SyncShare(); | 3437 syncer_->SyncShare(this); |
| 3454 { | 3438 { |
| 3455 ReadTransaction trans(dir, __FILE__, __LINE__); | 3439 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3456 Entry in_root(&trans, GET_BY_ID, in_root_id); | 3440 Entry in_root(&trans, GET_BY_ID, in_root_id); |
| 3457 ASSERT_TRUE(in_root.good()); | 3441 ASSERT_TRUE(in_root.good()); |
| 3458 EXPECT_EQ(PSTR("in_root_name"), in_root.Get(NON_UNIQUE_NAME)); | 3442 EXPECT_EQ(PSTR("in_root_name"), in_root.Get(NON_UNIQUE_NAME)); |
| 3459 EXPECT_EQ(TestIdFactory::root(), in_root.Get(PARENT_ID)); | 3443 EXPECT_EQ(TestIdFactory::root(), in_root.Get(PARENT_ID)); |
| 3460 | 3444 |
| 3461 Entry in_in_root(&trans, GET_BY_ID, in_in_root_id); | 3445 Entry in_in_root(&trans, GET_BY_ID, in_in_root_id); |
| 3462 ASSERT_TRUE(in_in_root.good()); | 3446 ASSERT_TRUE(in_in_root.good()); |
| 3463 EXPECT_EQ(PSTR("in_in_root_name"), in_in_root.Get(NON_UNIQUE_NAME)); | 3447 EXPECT_EQ(PSTR("in_in_root_name"), in_in_root.Get(NON_UNIQUE_NAME)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3482 in_root_id = parent.Get(syncable::ID); | 3466 in_root_id = parent.Get(syncable::ID); |
| 3483 foo_metahandle = parent.Get(META_HANDLE); | 3467 foo_metahandle = parent.Get(META_HANDLE); |
| 3484 | 3468 |
| 3485 MutableEntry child(&wtrans, syncable::CREATE, parent.Get(ID), PSTR("bar")); | 3469 MutableEntry child(&wtrans, syncable::CREATE, parent.Get(ID), PSTR("bar")); |
| 3486 ASSERT_TRUE(child.good()); | 3470 ASSERT_TRUE(child.good()); |
| 3487 child.Put(syncable::IS_UNSYNCED, true); | 3471 child.Put(syncable::IS_UNSYNCED, true); |
| 3488 child.Put(syncable::IS_DIR, true); | 3472 child.Put(syncable::IS_DIR, true); |
| 3489 bar_metahandle = child.Get(META_HANDLE); | 3473 bar_metahandle = child.Get(META_HANDLE); |
| 3490 in_dir_id = parent.Get(syncable::ID); | 3474 in_dir_id = parent.Get(syncable::ID); |
| 3491 } | 3475 } |
| 3492 syncer_->SyncShare(); | 3476 syncer_->SyncShare(this); |
| 3493 { | 3477 { |
| 3494 ReadTransaction trans(dir, __FILE__, __LINE__); | 3478 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3495 Entry fail_by_old_id_entry(&trans, GET_BY_ID, in_root_id); | 3479 Entry fail_by_old_id_entry(&trans, GET_BY_ID, in_root_id); |
| 3496 ASSERT_FALSE(fail_by_old_id_entry.good()); | 3480 ASSERT_FALSE(fail_by_old_id_entry.good()); |
| 3497 | 3481 |
| 3498 Entry foo_entry(&trans, GET_BY_HANDLE, foo_metahandle); | 3482 Entry foo_entry(&trans, GET_BY_HANDLE, foo_metahandle); |
| 3499 ASSERT_TRUE(foo_entry.good()); | 3483 ASSERT_TRUE(foo_entry.good()); |
| 3500 EXPECT_EQ(PSTR("foo"), foo_entry.Get(NON_UNIQUE_NAME)); | 3484 EXPECT_EQ(PSTR("foo"), foo_entry.Get(NON_UNIQUE_NAME)); |
| 3501 EXPECT_NE(foo_entry.Get(syncable::ID), in_root_id); | 3485 EXPECT_NE(foo_entry.Get(syncable::ID), in_root_id); |
| 3502 | 3486 |
| 3503 Entry bar_entry(&trans, GET_BY_HANDLE, bar_metahandle); | 3487 Entry bar_entry(&trans, GET_BY_HANDLE, bar_metahandle); |
| 3504 ASSERT_TRUE(bar_entry.good()); | 3488 ASSERT_TRUE(bar_entry.good()); |
| 3505 EXPECT_EQ(PSTR("bar"), bar_entry.Get(NON_UNIQUE_NAME)); | 3489 EXPECT_EQ(PSTR("bar"), bar_entry.Get(NON_UNIQUE_NAME)); |
| 3506 EXPECT_NE(bar_entry.Get(syncable::ID), in_dir_id); | 3490 EXPECT_NE(bar_entry.Get(syncable::ID), in_dir_id); |
| 3507 EXPECT_EQ(foo_entry.Get(syncable::ID), bar_entry.Get(PARENT_ID)); | 3491 EXPECT_EQ(foo_entry.Get(syncable::ID), bar_entry.Get(PARENT_ID)); |
| 3508 } | 3492 } |
| 3509 } | 3493 } |
| 3510 | 3494 |
| 3511 TEST_F(SyncerTest, ConflictSetSizeReducedToOne) { | 3495 TEST_F(SyncerTest, ConflictSetSizeReducedToOne) { |
| 3512 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3496 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3513 CHECK(dir.good()); | 3497 CHECK(dir.good()); |
| 3514 | 3498 |
| 3515 syncable::Id in_root_id = ids_.NewServerId(); | 3499 syncable::Id in_root_id = ids_.NewServerId(); |
| 3516 | 3500 |
| 3517 mock_server_->AddUpdateBookmark(in_root_id, TestIdFactory::root(), | 3501 mock_server_->AddUpdateBookmark(in_root_id, TestIdFactory::root(), |
| 3518 "in_root", 1, 1); | 3502 "in_root", 1, 1); |
| 3519 syncer_->SyncShare(); | 3503 syncer_->SyncShare(this); |
| 3520 { | 3504 { |
| 3521 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 3505 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 3522 MutableEntry oentry(&trans, GET_BY_ID, in_root_id); | 3506 MutableEntry oentry(&trans, GET_BY_ID, in_root_id); |
| 3523 ASSERT_TRUE(oentry.good()); | 3507 ASSERT_TRUE(oentry.good()); |
| 3524 oentry.Put(NON_UNIQUE_NAME, PSTR("old_in_root")); | 3508 oentry.Put(NON_UNIQUE_NAME, PSTR("old_in_root")); |
| 3525 WriteTestDataToEntry(&trans, &oentry); | 3509 WriteTestDataToEntry(&trans, &oentry); |
| 3526 MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("in_root")); | 3510 MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("in_root")); |
| 3527 ASSERT_TRUE(entry.good()); | 3511 ASSERT_TRUE(entry.good()); |
| 3528 WriteTestDataToEntry(&trans, &entry); | 3512 WriteTestDataToEntry(&trans, &entry); |
| 3529 } | 3513 } |
| 3530 mock_server_->set_conflict_all_commits(true); | 3514 mock_server_->set_conflict_all_commits(true); |
| 3531 // This SyncShare call used to result in a CHECK failure. | 3515 // This SyncShare call used to result in a CHECK failure. |
| 3532 syncer_->SyncShare(); | 3516 syncer_->SyncShare(this); |
| 3533 syncer_events_.clear(); | 3517 syncer_events_.clear(); |
| 3534 } | 3518 } |
| 3535 | 3519 |
| 3536 TEST_F(SyncerTest, TestClientCommand) { | 3520 TEST_F(SyncerTest, TestClientCommand) { |
| 3537 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3521 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3538 CHECK(dir.good()); | 3522 CHECK(dir.good()); |
| 3539 using sync_pb::ClientCommand; | 3523 using sync_pb::ClientCommand; |
| 3540 | 3524 |
| 3541 ClientCommand* command = mock_server_->GetNextClientCommand(); | 3525 ClientCommand* command = mock_server_->GetNextClientCommand(); |
| 3542 command->set_set_sync_poll_interval(8); | 3526 command->set_set_sync_poll_interval(8); |
| 3543 command->set_set_sync_long_poll_interval(800); | 3527 command->set_set_sync_long_poll_interval(800); |
| 3544 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1); | 3528 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1); |
| 3545 syncer_->SyncShare(); | 3529 syncer_->SyncShare(this); |
| 3546 | 3530 |
| 3547 EXPECT_TRUE(last_client_command_.has_set_sync_poll_interval()); | 3531 EXPECT_TRUE(TimeDelta::FromSeconds(8) == |
| 3548 EXPECT_TRUE(last_client_command_.has_set_sync_long_poll_interval()); | 3532 last_short_poll_interval_received_); |
| 3549 EXPECT_TRUE(8 == last_client_command_.set_sync_poll_interval()); | 3533 EXPECT_TRUE(TimeDelta::FromSeconds(800) == |
| 3550 EXPECT_TRUE(800 == last_client_command_.set_sync_long_poll_interval()); | 3534 last_long_poll_interval_received_); |
| 3551 | 3535 |
| 3552 command = mock_server_->GetNextClientCommand(); | 3536 command = mock_server_->GetNextClientCommand(); |
| 3553 command->set_set_sync_poll_interval(180); | 3537 command->set_set_sync_poll_interval(180); |
| 3554 command->set_set_sync_long_poll_interval(190); | 3538 command->set_set_sync_long_poll_interval(190); |
| 3555 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1); | 3539 mock_server_->AddUpdateDirectory(1, 0, "in_root", 1, 1); |
| 3556 syncer_->SyncShare(); | 3540 syncer_->SyncShare(this); |
| 3557 | 3541 |
| 3558 EXPECT_TRUE(last_client_command_.has_set_sync_poll_interval()); | 3542 EXPECT_TRUE(TimeDelta::FromSeconds(180) == |
| 3559 EXPECT_TRUE(last_client_command_.has_set_sync_long_poll_interval()); | 3543 last_short_poll_interval_received_); |
| 3560 EXPECT_TRUE(180 == last_client_command_.set_sync_poll_interval()); | 3544 EXPECT_TRUE(TimeDelta::FromSeconds(190) == |
| 3561 EXPECT_TRUE(190 == last_client_command_.set_sync_long_poll_interval()); | 3545 last_long_poll_interval_received_); |
| 3562 } | 3546 } |
| 3563 | 3547 |
| 3564 TEST_F(SyncerTest, EnsureWeSendUpOldParent) { | 3548 TEST_F(SyncerTest, EnsureWeSendUpOldParent) { |
| 3565 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3549 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3566 CHECK(dir.good()); | 3550 CHECK(dir.good()); |
| 3567 | 3551 |
| 3568 syncable::Id folder_one_id = ids_.FromNumber(1); | 3552 syncable::Id folder_one_id = ids_.FromNumber(1); |
| 3569 syncable::Id folder_two_id = ids_.FromNumber(2); | 3553 syncable::Id folder_two_id = ids_.FromNumber(2); |
| 3570 | 3554 |
| 3571 mock_server_->AddUpdateDirectory(folder_one_id, TestIdFactory::root(), | 3555 mock_server_->AddUpdateDirectory(folder_one_id, TestIdFactory::root(), |
| 3572 "folder_one", 1, 1); | 3556 "folder_one", 1, 1); |
| 3573 mock_server_->AddUpdateDirectory(folder_two_id, TestIdFactory::root(), | 3557 mock_server_->AddUpdateDirectory(folder_two_id, TestIdFactory::root(), |
| 3574 "folder_two", 1, 1); | 3558 "folder_two", 1, 1); |
| 3575 syncer_->SyncShare(); | 3559 syncer_->SyncShare(this); |
| 3576 { | 3560 { |
| 3577 // A moved entry should send an old parent. | 3561 // A moved entry should send an old parent. |
| 3578 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 3562 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
| 3579 MutableEntry entry(&trans, GET_BY_ID, folder_one_id); | 3563 MutableEntry entry(&trans, GET_BY_ID, folder_one_id); |
| 3580 ASSERT_TRUE(entry.good()); | 3564 ASSERT_TRUE(entry.good()); |
| 3581 entry.Put(PARENT_ID, folder_two_id); | 3565 entry.Put(PARENT_ID, folder_two_id); |
| 3582 entry.Put(IS_UNSYNCED, true); | 3566 entry.Put(IS_UNSYNCED, true); |
| 3583 // A new entry should send no parent. | 3567 // A new entry should send no parent. |
| 3584 MutableEntry create(&trans, CREATE, trans.root_id(), PSTR("new_folder")); | 3568 MutableEntry create(&trans, CREATE, trans.root_id(), PSTR("new_folder")); |
| 3585 create.Put(IS_UNSYNCED, true); | 3569 create.Put(IS_UNSYNCED, true); |
| 3586 } | 3570 } |
| 3587 syncer_->SyncShare(); | 3571 syncer_->SyncShare(this); |
| 3588 const sync_pb::CommitMessage& commit = mock_server_->last_sent_commit(); | 3572 const sync_pb::CommitMessage& commit = mock_server_->last_sent_commit(); |
| 3589 ASSERT_TRUE(2 == commit.entries_size()); | 3573 ASSERT_TRUE(2 == commit.entries_size()); |
| 3590 EXPECT_TRUE(commit.entries(0).parent_id_string() == "2"); | 3574 EXPECT_TRUE(commit.entries(0).parent_id_string() == "2"); |
| 3591 EXPECT_TRUE(commit.entries(0).old_parent_id() == "0"); | 3575 EXPECT_TRUE(commit.entries(0).old_parent_id() == "0"); |
| 3592 EXPECT_FALSE(commit.entries(1).has_old_parent_id()); | 3576 EXPECT_FALSE(commit.entries(1).has_old_parent_id()); |
| 3593 } | 3577 } |
| 3594 | 3578 |
| 3595 TEST_F(SyncerTest, Test64BitVersionSupport) { | 3579 TEST_F(SyncerTest, Test64BitVersionSupport) { |
| 3596 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3580 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3597 CHECK(dir.good()); | 3581 CHECK(dir.good()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3616 EXPECT_TRUE(really_big_int == entry.Get(syncable::BASE_VERSION)); | 3600 EXPECT_TRUE(really_big_int == entry.Get(syncable::BASE_VERSION)); |
| 3617 } | 3601 } |
| 3618 | 3602 |
| 3619 TEST_F(SyncerTest, TestSimpleUndelete) { | 3603 TEST_F(SyncerTest, TestSimpleUndelete) { |
| 3620 Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root(); | 3604 Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root(); |
| 3621 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3605 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3622 EXPECT_TRUE(dir.good()); | 3606 EXPECT_TRUE(dir.good()); |
| 3623 mock_server_->set_conflict_all_commits(true); | 3607 mock_server_->set_conflict_all_commits(true); |
| 3624 // Let there be an entry from the server. | 3608 // Let there be an entry from the server. |
| 3625 mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10); | 3609 mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10); |
| 3626 syncer_->SyncShare(); | 3610 syncer_->SyncShare(this); |
| 3627 // Check it out and delete it. | 3611 // Check it out and delete it. |
| 3628 { | 3612 { |
| 3629 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 3613 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 3630 MutableEntry entry(&wtrans, GET_BY_ID, id); | 3614 MutableEntry entry(&wtrans, GET_BY_ID, id); |
| 3631 ASSERT_TRUE(entry.good()); | 3615 ASSERT_TRUE(entry.good()); |
| 3632 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3616 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
| 3633 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3617 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
| 3634 EXPECT_FALSE(entry.Get(IS_DEL)); | 3618 EXPECT_FALSE(entry.Get(IS_DEL)); |
| 3635 // Delete it locally. | 3619 // Delete it locally. |
| 3636 entry.Put(IS_DEL, true); | 3620 entry.Put(IS_DEL, true); |
| 3637 } | 3621 } |
| 3638 syncer_->SyncShare(); | 3622 syncer_->SyncShare(this); |
| 3639 // Confirm we see IS_DEL and not SERVER_IS_DEL. | 3623 // Confirm we see IS_DEL and not SERVER_IS_DEL. |
| 3640 { | 3624 { |
| 3641 ReadTransaction trans(dir, __FILE__, __LINE__); | 3625 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3642 Entry entry(&trans, GET_BY_ID, id); | 3626 Entry entry(&trans, GET_BY_ID, id); |
| 3643 ASSERT_TRUE(entry.good()); | 3627 ASSERT_TRUE(entry.good()); |
| 3644 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3628 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
| 3645 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3629 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
| 3646 EXPECT_TRUE(entry.Get(IS_DEL)); | 3630 EXPECT_TRUE(entry.Get(IS_DEL)); |
| 3647 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); | 3631 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); |
| 3648 } | 3632 } |
| 3649 syncer_->SyncShare(); | 3633 syncer_->SyncShare(this); |
| 3650 // Update from server confirming deletion. | 3634 // Update from server confirming deletion. |
| 3651 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 11); | 3635 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 11); |
| 3652 mock_server_->SetLastUpdateDeleted(); | 3636 mock_server_->SetLastUpdateDeleted(); |
| 3653 syncer_->SyncShare(); | 3637 syncer_->SyncShare(this); |
| 3654 // IS_DEL AND SERVER_IS_DEL now both true. | 3638 // IS_DEL AND SERVER_IS_DEL now both true. |
| 3655 { | 3639 { |
| 3656 ReadTransaction trans(dir, __FILE__, __LINE__); | 3640 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3657 Entry entry(&trans, GET_BY_ID, id); | 3641 Entry entry(&trans, GET_BY_ID, id); |
| 3658 ASSERT_TRUE(entry.good()); | 3642 ASSERT_TRUE(entry.good()); |
| 3659 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3643 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
| 3660 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3644 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
| 3661 EXPECT_TRUE(entry.Get(IS_DEL)); | 3645 EXPECT_TRUE(entry.Get(IS_DEL)); |
| 3662 EXPECT_TRUE(entry.Get(SERVER_IS_DEL)); | 3646 EXPECT_TRUE(entry.Get(SERVER_IS_DEL)); |
| 3663 } | 3647 } |
| 3664 // Undelete from server. | 3648 // Undelete from server. |
| 3665 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12); | 3649 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12); |
| 3666 syncer_->SyncShare(); | 3650 syncer_->SyncShare(this); |
| 3667 // IS_DEL and SERVER_IS_DEL now both false. | 3651 // IS_DEL and SERVER_IS_DEL now both false. |
| 3668 { | 3652 { |
| 3669 ReadTransaction trans(dir, __FILE__, __LINE__); | 3653 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3670 Entry entry(&trans, GET_BY_ID, id); | 3654 Entry entry(&trans, GET_BY_ID, id); |
| 3671 ASSERT_TRUE(entry.good()); | 3655 ASSERT_TRUE(entry.good()); |
| 3672 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3656 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
| 3673 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3657 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
| 3674 EXPECT_FALSE(entry.Get(IS_DEL)); | 3658 EXPECT_FALSE(entry.Get(IS_DEL)); |
| 3675 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); | 3659 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); |
| 3676 } | 3660 } |
| 3677 } | 3661 } |
| 3678 | 3662 |
| 3679 TEST_F(SyncerTest, TestUndeleteWithMissingDeleteUpdate) { | 3663 TEST_F(SyncerTest, TestUndeleteWithMissingDeleteUpdate) { |
| 3680 Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root(); | 3664 Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root(); |
| 3681 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3665 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3682 EXPECT_TRUE(dir.good()); | 3666 EXPECT_TRUE(dir.good()); |
| 3683 // Let there be a entry, from the server. | 3667 // Let there be a entry, from the server. |
| 3684 mock_server_->set_conflict_all_commits(true); | 3668 mock_server_->set_conflict_all_commits(true); |
| 3685 mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10); | 3669 mock_server_->AddUpdateBookmark(id, root, "foo", 1, 10); |
| 3686 syncer_->SyncShare(); | 3670 syncer_->SyncShare(this); |
| 3687 // Check it out and delete it. | 3671 // Check it out and delete it. |
| 3688 { | 3672 { |
| 3689 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); | 3673 WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); |
| 3690 MutableEntry entry(&wtrans, GET_BY_ID, id); | 3674 MutableEntry entry(&wtrans, GET_BY_ID, id); |
| 3691 ASSERT_TRUE(entry.good()); | 3675 ASSERT_TRUE(entry.good()); |
| 3692 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3676 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
| 3693 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3677 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
| 3694 EXPECT_FALSE(entry.Get(IS_DEL)); | 3678 EXPECT_FALSE(entry.Get(IS_DEL)); |
| 3695 // Delete it locally. | 3679 // Delete it locally. |
| 3696 entry.Put(IS_DEL, true); | 3680 entry.Put(IS_DEL, true); |
| 3697 } | 3681 } |
| 3698 syncer_->SyncShare(); | 3682 syncer_->SyncShare(this); |
| 3699 // Confirm we see IS_DEL and not SERVER_IS_DEL. | 3683 // Confirm we see IS_DEL and not SERVER_IS_DEL. |
| 3700 { | 3684 { |
| 3701 ReadTransaction trans(dir, __FILE__, __LINE__); | 3685 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3702 Entry entry(&trans, GET_BY_ID, id); | 3686 Entry entry(&trans, GET_BY_ID, id); |
| 3703 ASSERT_TRUE(entry.good()); | 3687 ASSERT_TRUE(entry.good()); |
| 3704 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3688 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
| 3705 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3689 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
| 3706 EXPECT_TRUE(entry.Get(IS_DEL)); | 3690 EXPECT_TRUE(entry.Get(IS_DEL)); |
| 3707 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); | 3691 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); |
| 3708 } | 3692 } |
| 3709 syncer_->SyncShare(); | 3693 syncer_->SyncShare(this); |
| 3710 // Say we do not get an update from server confirming deletion. Undelete | 3694 // Say we do not get an update from server confirming deletion. Undelete |
| 3711 // from server | 3695 // from server |
| 3712 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12); | 3696 mock_server_->AddUpdateBookmark(id, root, "foo", 2, 12); |
| 3713 syncer_->SyncShare(); | 3697 syncer_->SyncShare(this); |
| 3714 // IS_DEL and SERVER_IS_DEL now both false. | 3698 // IS_DEL and SERVER_IS_DEL now both false. |
| 3715 { | 3699 { |
| 3716 ReadTransaction trans(dir, __FILE__, __LINE__); | 3700 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3717 Entry entry(&trans, GET_BY_ID, id); | 3701 Entry entry(&trans, GET_BY_ID, id); |
| 3718 ASSERT_TRUE(entry.good()); | 3702 ASSERT_TRUE(entry.good()); |
| 3719 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); | 3703 EXPECT_FALSE(entry.Get(IS_UNAPPLIED_UPDATE)); |
| 3720 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); | 3704 EXPECT_FALSE(entry.Get(IS_UNSYNCED)); |
| 3721 EXPECT_FALSE(entry.Get(IS_DEL)); | 3705 EXPECT_FALSE(entry.Get(IS_DEL)); |
| 3722 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); | 3706 EXPECT_FALSE(entry.Get(SERVER_IS_DEL)); |
| 3723 } | 3707 } |
| 3724 } | 3708 } |
| 3725 | 3709 |
| 3726 TEST_F(SyncerTest, TestUndeleteIgnoreCorrectlyUnappliedUpdate) { | 3710 TEST_F(SyncerTest, TestUndeleteIgnoreCorrectlyUnappliedUpdate) { |
| 3727 Id id1 = ids_.MakeServer("first"), id2 = ids_.MakeServer("second"); | 3711 Id id1 = ids_.MakeServer("first"), id2 = ids_.MakeServer("second"); |
| 3728 Id root = TestIdFactory::root(); | 3712 Id root = TestIdFactory::root(); |
| 3729 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3713 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3730 EXPECT_TRUE(dir.good()); | 3714 EXPECT_TRUE(dir.good()); |
| 3731 // Duplicate! expect path clashing! | 3715 // Duplicate! expect path clashing! |
| 3732 mock_server_->set_conflict_all_commits(true); | 3716 mock_server_->set_conflict_all_commits(true); |
| 3733 mock_server_->AddUpdateBookmark(id1, root, "foo", 1, 10); | 3717 mock_server_->AddUpdateBookmark(id1, root, "foo", 1, 10); |
| 3734 mock_server_->AddUpdateBookmark(id2, root, "foo", 1, 10); | 3718 mock_server_->AddUpdateBookmark(id2, root, "foo", 1, 10); |
| 3735 syncer_->SyncShare(); | 3719 syncer_->SyncShare(this); |
| 3736 mock_server_->AddUpdateBookmark(id2, root, "foo2", 1, 10); | 3720 mock_server_->AddUpdateBookmark(id2, root, "foo2", 1, 10); |
| 3737 syncer_->SyncShare(); // Now just don't explode. | 3721 syncer_->SyncShare(this); // Now just don't explode. |
| 3738 } | |
| 3739 | |
| 3740 TEST_F(SyncerTest, CopySyncProcessState) { | |
| 3741 scoped_ptr<SyncProcessState> b; | |
| 3742 { | |
| 3743 SyncProcessState a; | |
| 3744 a.MergeSets(ids_.FromNumber(1), ids_.FromNumber(2)); | |
| 3745 a.MergeSets(ids_.FromNumber(2), ids_.FromNumber(3)); | |
| 3746 a.MergeSets(ids_.FromNumber(4), ids_.FromNumber(5)); | |
| 3747 EXPECT_TRUE(a.ConflictSetsSize() == 2); | |
| 3748 { | |
| 3749 SyncProcessState b = a; | |
| 3750 b = b; | |
| 3751 EXPECT_TRUE(b.ConflictSetsSize() == 2); | |
| 3752 } | |
| 3753 EXPECT_TRUE(a.ConflictSetsSize() == 2); | |
| 3754 a.MergeSets(ids_.FromNumber(3), ids_.FromNumber(4)); | |
| 3755 EXPECT_TRUE(a.ConflictSetsSize() == 1); | |
| 3756 b.reset(new SyncProcessState(a)); | |
| 3757 } | |
| 3758 EXPECT_TRUE(b->ConflictSetsSize() == 1); | |
| 3759 } | 3722 } |
| 3760 | 3723 |
| 3761 TEST_F(SyncerTest, SingletonTagUpdates) { | 3724 TEST_F(SyncerTest, SingletonTagUpdates) { |
| 3762 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3725 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 3763 EXPECT_TRUE(dir.good()); | 3726 EXPECT_TRUE(dir.good()); |
| 3764 // As a hurdle, introduce an item whose name is the same as the tag value | 3727 // As a hurdle, introduce an item whose name is the same as the tag value |
| 3765 // we'll use later. | 3728 // we'll use later. |
| 3766 int64 hurdle_handle = CreateUnsyncedDirectory(PSTR("bob"), "id_bob"); | 3729 int64 hurdle_handle = CreateUnsyncedDirectory(PSTR("bob"), "id_bob"); |
| 3767 { | 3730 { |
| 3768 ReadTransaction trans(dir, __FILE__, __LINE__); | 3731 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3769 Entry hurdle(&trans, GET_BY_HANDLE, hurdle_handle); | 3732 Entry hurdle(&trans, GET_BY_HANDLE, hurdle_handle); |
| 3770 ASSERT_TRUE(hurdle.good()); | 3733 ASSERT_TRUE(hurdle.good()); |
| 3771 ASSERT_TRUE(!hurdle.Get(IS_DEL)); | 3734 ASSERT_TRUE(!hurdle.Get(IS_DEL)); |
| 3772 ASSERT_TRUE(hurdle.Get(SINGLETON_TAG).empty()); | 3735 ASSERT_TRUE(hurdle.Get(SINGLETON_TAG).empty()); |
| 3773 ASSERT_TRUE(hurdle.Get(NON_UNIQUE_NAME) == PSTR("bob")); | 3736 ASSERT_TRUE(hurdle.Get(NON_UNIQUE_NAME) == PSTR("bob")); |
| 3774 | 3737 |
| 3775 // Try to lookup by the tagname. These should fail. | 3738 // Try to lookup by the tagname. These should fail. |
| 3776 Entry tag_alpha(&trans, GET_BY_TAG, PSTR("alpha")); | 3739 Entry tag_alpha(&trans, GET_BY_TAG, PSTR("alpha")); |
| 3777 EXPECT_FALSE(tag_alpha.good()); | 3740 EXPECT_FALSE(tag_alpha.good()); |
| 3778 Entry tag_bob(&trans, GET_BY_TAG, PSTR("bob")); | 3741 Entry tag_bob(&trans, GET_BY_TAG, PSTR("bob")); |
| 3779 EXPECT_FALSE(tag_bob.good()); | 3742 EXPECT_FALSE(tag_bob.good()); |
| 3780 } | 3743 } |
| 3781 | 3744 |
| 3782 // Now download some tagged items as updates. | 3745 // Now download some tagged items as updates. |
| 3783 mock_server_->AddUpdateDirectory(1, 0, "update1", 1, 10); | 3746 mock_server_->AddUpdateDirectory(1, 0, "update1", 1, 10); |
| 3784 mock_server_->SetLastUpdateSingletonTag("alpha"); | 3747 mock_server_->SetLastUpdateSingletonTag("alpha"); |
| 3785 mock_server_->AddUpdateDirectory(2, 0, "update2", 2, 20); | 3748 mock_server_->AddUpdateDirectory(2, 0, "update2", 2, 20); |
| 3786 mock_server_->SetLastUpdateSingletonTag("bob"); | 3749 mock_server_->SetLastUpdateSingletonTag("bob"); |
| 3787 syncer_->SyncShare(); | 3750 syncer_->SyncShare(this); |
| 3788 | 3751 |
| 3789 { | 3752 { |
| 3790 ReadTransaction trans(dir, __FILE__, __LINE__); | 3753 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 3791 | 3754 |
| 3792 // The new items should be applied as new entries, and we should be able | 3755 // The new items should be applied as new entries, and we should be able |
| 3793 // to look them up by their tag values. | 3756 // to look them up by their tag values. |
| 3794 Entry tag_alpha(&trans, GET_BY_TAG, PSTR("alpha")); | 3757 Entry tag_alpha(&trans, GET_BY_TAG, PSTR("alpha")); |
| 3795 ASSERT_TRUE(tag_alpha.good()); | 3758 ASSERT_TRUE(tag_alpha.good()); |
| 3796 ASSERT_TRUE(!tag_alpha.Get(IS_DEL)); | 3759 ASSERT_TRUE(!tag_alpha.Get(IS_DEL)); |
| 3797 ASSERT_TRUE(tag_alpha.Get(SINGLETON_TAG) == PSTR("alpha")); | 3760 ASSERT_TRUE(tag_alpha.Get(SINGLETON_TAG) == PSTR("alpha")); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3861 | 3824 |
| 3862 TEST_F(SyncerPositionUpdateTest, InOrderPositive) { | 3825 TEST_F(SyncerPositionUpdateTest, InOrderPositive) { |
| 3863 // Add a bunch of items in increasing order, starting with just positive | 3826 // Add a bunch of items in increasing order, starting with just positive |
| 3864 // position values. | 3827 // position values. |
| 3865 AddRootItemWithPosition(100); | 3828 AddRootItemWithPosition(100); |
| 3866 AddRootItemWithPosition(199); | 3829 AddRootItemWithPosition(199); |
| 3867 AddRootItemWithPosition(200); | 3830 AddRootItemWithPosition(200); |
| 3868 AddRootItemWithPosition(201); | 3831 AddRootItemWithPosition(201); |
| 3869 AddRootItemWithPosition(400); | 3832 AddRootItemWithPosition(400); |
| 3870 | 3833 |
| 3871 syncer_->SyncShare(); | 3834 syncer_->SyncShare(this); |
| 3872 ExpectLocalItemsInServerOrder(); | 3835 ExpectLocalItemsInServerOrder(); |
| 3873 } | 3836 } |
| 3874 | 3837 |
| 3875 TEST_F(SyncerPositionUpdateTest, InOrderNegative) { | 3838 TEST_F(SyncerPositionUpdateTest, InOrderNegative) { |
| 3876 // Test negative position values, but in increasing order. | 3839 // Test negative position values, but in increasing order. |
| 3877 AddRootItemWithPosition(-400); | 3840 AddRootItemWithPosition(-400); |
| 3878 AddRootItemWithPosition(-201); | 3841 AddRootItemWithPosition(-201); |
| 3879 AddRootItemWithPosition(-200); | 3842 AddRootItemWithPosition(-200); |
| 3880 AddRootItemWithPosition(-150); | 3843 AddRootItemWithPosition(-150); |
| 3881 AddRootItemWithPosition(100); | 3844 AddRootItemWithPosition(100); |
| 3882 | 3845 |
| 3883 syncer_->SyncShare(); | 3846 syncer_->SyncShare(this); |
| 3884 ExpectLocalItemsInServerOrder(); | 3847 ExpectLocalItemsInServerOrder(); |
| 3885 } | 3848 } |
| 3886 | 3849 |
| 3887 TEST_F(SyncerPositionUpdateTest, ReverseOrder) { | 3850 TEST_F(SyncerPositionUpdateTest, ReverseOrder) { |
| 3888 // Test when items are sent in the reverse order. | 3851 // Test when items are sent in the reverse order. |
| 3889 AddRootItemWithPosition(400); | 3852 AddRootItemWithPosition(400); |
| 3890 AddRootItemWithPosition(201); | 3853 AddRootItemWithPosition(201); |
| 3891 AddRootItemWithPosition(200); | 3854 AddRootItemWithPosition(200); |
| 3892 AddRootItemWithPosition(100); | 3855 AddRootItemWithPosition(100); |
| 3893 AddRootItemWithPosition(-150); | 3856 AddRootItemWithPosition(-150); |
| 3894 AddRootItemWithPosition(-201); | 3857 AddRootItemWithPosition(-201); |
| 3895 AddRootItemWithPosition(-200); | 3858 AddRootItemWithPosition(-200); |
| 3896 AddRootItemWithPosition(-400); | 3859 AddRootItemWithPosition(-400); |
| 3897 | 3860 |
| 3898 syncer_->SyncShare(); | 3861 syncer_->SyncShare(this); |
| 3899 ExpectLocalItemsInServerOrder(); | 3862 ExpectLocalItemsInServerOrder(); |
| 3900 } | 3863 } |
| 3901 | 3864 |
| 3902 TEST_F(SyncerPositionUpdateTest, RandomOrderInBatches) { | 3865 TEST_F(SyncerPositionUpdateTest, RandomOrderInBatches) { |
| 3903 // Mix it all up, interleaving position values, and try multiple batches of | 3866 // Mix it all up, interleaving position values, and try multiple batches of |
| 3904 // updates. | 3867 // updates. |
| 3905 AddRootItemWithPosition(400); | 3868 AddRootItemWithPosition(400); |
| 3906 AddRootItemWithPosition(201); | 3869 AddRootItemWithPosition(201); |
| 3907 AddRootItemWithPosition(-400); | 3870 AddRootItemWithPosition(-400); |
| 3908 AddRootItemWithPosition(100); | 3871 AddRootItemWithPosition(100); |
| 3909 | 3872 |
| 3910 syncer_->SyncShare(); | 3873 syncer_->SyncShare(this); |
| 3911 ExpectLocalItemsInServerOrder(); | 3874 ExpectLocalItemsInServerOrder(); |
| 3912 | 3875 |
| 3913 AddRootItemWithPosition(-150); | 3876 AddRootItemWithPosition(-150); |
| 3914 AddRootItemWithPosition(-200); | 3877 AddRootItemWithPosition(-200); |
| 3915 AddRootItemWithPosition(200); | 3878 AddRootItemWithPosition(200); |
| 3916 AddRootItemWithPosition(-201); | 3879 AddRootItemWithPosition(-201); |
| 3917 | 3880 |
| 3918 syncer_->SyncShare(); | 3881 syncer_->SyncShare(this); |
| 3919 ExpectLocalItemsInServerOrder(); | 3882 ExpectLocalItemsInServerOrder(); |
| 3920 | 3883 |
| 3921 AddRootItemWithPosition(-144); | 3884 AddRootItemWithPosition(-144); |
| 3922 | 3885 |
| 3923 syncer_->SyncShare(); | 3886 syncer_->SyncShare(this); |
| 3924 ExpectLocalItemsInServerOrder(); | 3887 ExpectLocalItemsInServerOrder(); |
| 3925 } | 3888 } |
| 3926 | 3889 |
| 3927 class SyncerPositionTiebreakingTest : public SyncerTest { | 3890 class SyncerPositionTiebreakingTest : public SyncerTest { |
| 3928 public: | 3891 public: |
| 3929 SyncerPositionTiebreakingTest() | 3892 SyncerPositionTiebreakingTest() |
| 3930 : low_id_(Id::CreateFromServerId("A")), | 3893 : low_id_(Id::CreateFromServerId("A")), |
| 3931 mid_id_(Id::CreateFromServerId("M")), | 3894 mid_id_(Id::CreateFromServerId("M")), |
| 3932 high_id_(Id::CreateFromServerId("Z")), | 3895 high_id_(Id::CreateFromServerId("Z")), |
| 3933 next_revision_(1) { | 3896 next_revision_(1) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3975 | 3938 |
| 3976 private: | 3939 private: |
| 3977 int next_revision_; | 3940 int next_revision_; |
| 3978 DISALLOW_COPY_AND_ASSIGN(SyncerPositionTiebreakingTest); | 3941 DISALLOW_COPY_AND_ASSIGN(SyncerPositionTiebreakingTest); |
| 3979 }; | 3942 }; |
| 3980 | 3943 |
| 3981 TEST_F(SyncerPositionTiebreakingTest, LowMidHigh) { | 3944 TEST_F(SyncerPositionTiebreakingTest, LowMidHigh) { |
| 3982 Add(low_id_); | 3945 Add(low_id_); |
| 3983 Add(mid_id_); | 3946 Add(mid_id_); |
| 3984 Add(high_id_); | 3947 Add(high_id_); |
| 3985 syncer_->SyncShare(); | 3948 syncer_->SyncShare(this); |
| 3986 ExpectLocalOrderIsByServerId(); | 3949 ExpectLocalOrderIsByServerId(); |
| 3987 } | 3950 } |
| 3988 | 3951 |
| 3989 TEST_F(SyncerPositionTiebreakingTest, LowHighMid) { | 3952 TEST_F(SyncerPositionTiebreakingTest, LowHighMid) { |
| 3990 Add(low_id_); | 3953 Add(low_id_); |
| 3991 Add(high_id_); | 3954 Add(high_id_); |
| 3992 Add(mid_id_); | 3955 Add(mid_id_); |
| 3993 syncer_->SyncShare(); | 3956 syncer_->SyncShare(this); |
| 3994 ExpectLocalOrderIsByServerId(); | 3957 ExpectLocalOrderIsByServerId(); |
| 3995 } | 3958 } |
| 3996 | 3959 |
| 3997 TEST_F(SyncerPositionTiebreakingTest, HighMidLow) { | 3960 TEST_F(SyncerPositionTiebreakingTest, HighMidLow) { |
| 3998 Add(high_id_); | 3961 Add(high_id_); |
| 3999 Add(mid_id_); | 3962 Add(mid_id_); |
| 4000 Add(low_id_); | 3963 Add(low_id_); |
| 4001 syncer_->SyncShare(); | 3964 syncer_->SyncShare(this); |
| 4002 ExpectLocalOrderIsByServerId(); | 3965 ExpectLocalOrderIsByServerId(); |
| 4003 } | 3966 } |
| 4004 | 3967 |
| 4005 TEST_F(SyncerPositionTiebreakingTest, HighLowMid) { | 3968 TEST_F(SyncerPositionTiebreakingTest, HighLowMid) { |
| 4006 Add(high_id_); | 3969 Add(high_id_); |
| 4007 Add(low_id_); | 3970 Add(low_id_); |
| 4008 Add(mid_id_); | 3971 Add(mid_id_); |
| 4009 syncer_->SyncShare(); | 3972 syncer_->SyncShare(this); |
| 4010 ExpectLocalOrderIsByServerId(); | 3973 ExpectLocalOrderIsByServerId(); |
| 4011 } | 3974 } |
| 4012 | 3975 |
| 4013 TEST_F(SyncerPositionTiebreakingTest, MidHighLow) { | 3976 TEST_F(SyncerPositionTiebreakingTest, MidHighLow) { |
| 4014 Add(mid_id_); | 3977 Add(mid_id_); |
| 4015 Add(high_id_); | 3978 Add(high_id_); |
| 4016 Add(low_id_); | 3979 Add(low_id_); |
| 4017 syncer_->SyncShare(); | 3980 syncer_->SyncShare(this); |
| 4018 ExpectLocalOrderIsByServerId(); | 3981 ExpectLocalOrderIsByServerId(); |
| 4019 } | 3982 } |
| 4020 | 3983 |
| 4021 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { | 3984 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { |
| 4022 Add(mid_id_); | 3985 Add(mid_id_); |
| 4023 Add(low_id_); | 3986 Add(low_id_); |
| 4024 Add(high_id_); | 3987 Add(high_id_); |
| 4025 syncer_->SyncShare(); | 3988 syncer_->SyncShare(this); |
| 4026 ExpectLocalOrderIsByServerId(); | 3989 ExpectLocalOrderIsByServerId(); |
| 4027 } | 3990 } |
| 4028 | 3991 |
| 4029 const SyncerTest::CommitOrderingTest | 3992 const SyncerTest::CommitOrderingTest |
| 4030 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; | 3993 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; |
| 4031 | 3994 |
| 4032 } // namespace browser_sync | 3995 } // namespace browser_sync |
| OLD | NEW |