| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Syncer unit tests. Unfortunately a lot of these tests | 5 // Syncer unit tests. Unfortunately a lot of these tests |
| 6 // are outdated and need to be reworked and updated. | 6 // are outdated and need to be reworked and updated. |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 SyncSession* MakeSession() { | 148 SyncSession* MakeSession() { |
| 149 ModelSafeRoutingInfo info; | 149 ModelSafeRoutingInfo info; |
| 150 std::vector<ModelSafeWorker*> workers; | 150 std::vector<ModelSafeWorker*> workers; |
| 151 GetModelSafeRoutingInfo(&info); | 151 GetModelSafeRoutingInfo(&info); |
| 152 GetWorkers(&workers); | 152 GetWorkers(&workers); |
| 153 return new SyncSession(context_.get(), this, sessions::SyncSourceInfo(), | 153 return new SyncSession(context_.get(), this, sessions::SyncSourceInfo(), |
| 154 info, workers); | 154 info, workers); |
| 155 } | 155 } |
| 156 | 156 |
| 157 bool SyncShareAsDelegate() { | 157 bool SyncShareAsDelegate() { |
| 158 scoped_ptr<SyncSession> session(MakeSession()); | 158 scoped_refptr<SyncSession> session(MakeSession()); |
| 159 syncer_->SyncShare(session.get()); | 159 syncer_->SyncShare(session.get()); |
| 160 return session->HasMoreToSync(); | 160 return session->HasMoreToSync(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void LoopSyncShare() { | 163 void LoopSyncShare() { |
| 164 bool should_loop = false; | 164 bool should_loop = false; |
| 165 int loop_iterations = 0; | 165 int loop_iterations = 0; |
| 166 do { | 166 do { |
| 167 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; | 167 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; |
| 168 should_loop = SyncShareAsDelegate(); | 168 should_loop = SyncShareAsDelegate(); |
| 169 } while (should_loop); | 169 } while (should_loop); |
| 170 } | 170 } |
| 171 | 171 |
| 172 virtual void SetUp() { | 172 virtual void SetUp() { |
| 173 syncdb_.SetUp(); | 173 syncdb_.SetUp(); |
| 174 | 174 |
| 175 mock_server_.reset( | 175 mock_server_.reset( |
| 176 new MockConnectionManager(syncdb_.manager(), syncdb_.name())); | 176 new MockConnectionManager(syncdb_.manager(), syncdb_.name())); |
| 177 EnableDatatype(syncable::BOOKMARKS); | 177 EnableDatatype(syncable::BOOKMARKS); |
| 178 worker_ = new ModelSafeWorker(); | 178 worker_ = new ModelSafeWorker(); |
| 179 std::vector<SyncEngineEventListener*> listeners; | 179 std::vector<SyncEngineEventListener*> listeners; |
| 180 listeners.push_back(this); | 180 listeners.push_back(this); |
| 181 context_.reset(new SyncSessionContext(mock_server_.get(), | 181 context_.reset(new SyncSessionContext(mock_server_.get(), |
| 182 syncdb_.manager(), this, listeners)); | 182 syncdb_.manager(), this, listeners)); |
| 183 context_->set_account_name(syncdb_.name()); | 183 context_->set_account_name(syncdb_.name()); |
| 184 ASSERT_FALSE(context_->resolver()); | 184 ASSERT_FALSE(context_->resolver()); |
| 185 syncer_ = new Syncer(); | 185 syncer_ = new Syncer(); |
| 186 session_.reset(MakeSession()); | 186 session_ = MakeSession(); |
| 187 | 187 |
| 188 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 188 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 189 CHECK(dir.good()); | 189 CHECK(dir.good()); |
| 190 ReadTransaction trans(dir, __FILE__, __LINE__); | 190 ReadTransaction trans(dir, __FILE__, __LINE__); |
| 191 syncable::Directory::ChildHandles children; | 191 syncable::Directory::ChildHandles children; |
| 192 dir->GetChildHandles(&trans, trans.root_id(), &children); | 192 dir->GetChildHandles(&trans, trans.root_id(), &children); |
| 193 ASSERT_TRUE(0 == children.size()); | 193 ASSERT_TRUE(0 == children.size()); |
| 194 saw_syncer_event_ = false; | 194 saw_syncer_event_ = false; |
| 195 root_id_ = TestIdFactory::root(); | 195 root_id_ = TestIdFactory::root(); |
| 196 parent_id_ = ids_.MakeServer("parent id"); | 196 parent_id_ = ids_.MakeServer("parent id"); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 syncable::Id parent_id_; | 454 syncable::Id parent_id_; |
| 455 syncable::Id child_id_; | 455 syncable::Id child_id_; |
| 456 | 456 |
| 457 TestIdFactory ids_; | 457 TestIdFactory ids_; |
| 458 | 458 |
| 459 TestDirectorySetterUpper syncdb_; | 459 TestDirectorySetterUpper syncdb_; |
| 460 scoped_ptr<MockConnectionManager> mock_server_; | 460 scoped_ptr<MockConnectionManager> mock_server_; |
| 461 | 461 |
| 462 Syncer* syncer_; | 462 Syncer* syncer_; |
| 463 | 463 |
| 464 scoped_ptr<SyncSession> session_; | 464 scoped_refptr<SyncSession> session_; |
| 465 scoped_ptr<SyncSessionContext> context_; | 465 scoped_ptr<SyncSessionContext> context_; |
| 466 bool saw_syncer_event_; | 466 bool saw_syncer_event_; |
| 467 base::TimeDelta last_short_poll_interval_received_; | 467 base::TimeDelta last_short_poll_interval_received_; |
| 468 base::TimeDelta last_long_poll_interval_received_; | 468 base::TimeDelta last_long_poll_interval_received_; |
| 469 scoped_refptr<ModelSafeWorker> worker_; | 469 scoped_refptr<ModelSafeWorker> worker_; |
| 470 | 470 |
| 471 syncable::ModelTypeBitSet enabled_datatypes_; | 471 syncable::ModelTypeBitSet enabled_datatypes_; |
| 472 | 472 |
| 473 DISALLOW_COPY_AND_ASSIGN(SyncerTest); | 473 DISALLOW_COPY_AND_ASSIGN(SyncerTest); |
| 474 }; | 474 }; |
| (...skipping 4688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5163 Add(low_id_); | 5163 Add(low_id_); |
| 5164 Add(high_id_); | 5164 Add(high_id_); |
| 5165 SyncShareAsDelegate(); | 5165 SyncShareAsDelegate(); |
| 5166 ExpectLocalOrderIsByServerId(); | 5166 ExpectLocalOrderIsByServerId(); |
| 5167 } | 5167 } |
| 5168 | 5168 |
| 5169 const SyncerTest::CommitOrderingTest | 5169 const SyncerTest::CommitOrderingTest |
| 5170 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; | 5170 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; |
| 5171 | 5171 |
| 5172 } // namespace browser_sync | 5172 } // namespace browser_sync |
| OLD | NEW |