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

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

Issue 553015: Support for multiple sync ModelSafeWorkers.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/engine/syncer_types.h ('k') | chrome/browser/sync/engine/syncer_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 using sessions::StatusController; 89 using sessions::StatusController;
90 using sessions::SyncSessionContext; 90 using sessions::SyncSessionContext;
91 using sessions::SyncSession; 91 using sessions::SyncSession;
92 92
93 namespace { 93 namespace {
94 const char* kTestData = "Hello World!"; 94 const char* kTestData = "Hello World!";
95 const int kTestDataLen = 12; 95 const int kTestDataLen = 12;
96 const int64 kTestLogRequestTimestamp = 123456; 96 const int64 kTestLogRequestTimestamp = 123456;
97 } // namespace 97 } // namespace
98 98
99 class SyncerTest : public testing::Test, public SyncSession::Delegate { 99 class SyncerTest : public testing::Test,
100 public SyncSession::Delegate,
101 public ModelSafeWorkerRegistrar {
100 protected: 102 protected:
101 SyncerTest() : syncer_(NULL) {} 103 SyncerTest() : syncer_(NULL) {}
102 104
103 // SyncSession::Delegate implementation. 105 // SyncSession::Delegate implementation.
104 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) { 106 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) {
105 FAIL() << "Should not get silenced."; 107 FAIL() << "Should not get silenced.";
106 } 108 }
107 virtual bool IsSyncingCurrentlySilenced() { 109 virtual bool IsSyncingCurrentlySilenced() {
108 return false; 110 return false;
109 } 111 }
110 virtual void OnReceivedLongPollIntervalUpdate( 112 virtual void OnReceivedLongPollIntervalUpdate(
111 const base::TimeDelta& new_interval) { 113 const base::TimeDelta& new_interval) {
112 last_long_poll_interval_received_ = new_interval; 114 last_long_poll_interval_received_ = new_interval;
113 } 115 }
114 virtual void OnReceivedShortPollIntervalUpdate( 116 virtual void OnReceivedShortPollIntervalUpdate(
115 const base::TimeDelta& new_interval) { 117 const base::TimeDelta& new_interval) {
116 last_short_poll_interval_received_ = new_interval; 118 last_short_poll_interval_received_ = new_interval;
117 } 119 }
118 120
121 // ModelSafeWorkerRegistrar implementation.
122 virtual void GetWorkers(std::vector<ModelSafeWorker*>* out) {
123 out->push_back(worker_.get());
124 }
125
126 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) {
127 // We're just testing the sync engine here, so we shunt everything to
128 // the SyncerThread.
129 (*out)[syncable::BOOKMARKS] = GROUP_PASSIVE;
130 }
131
119 void HandleSyncerEvent(SyncerEvent event) { 132 void HandleSyncerEvent(SyncerEvent event) {
120 LOG(INFO) << "HandleSyncerEvent in unittest " << event.what_happened; 133 LOG(INFO) << "HandleSyncerEvent in unittest " << event.what_happened;
121 // we only test for entry-specific events, not status changed ones. 134 // we only test for entry-specific events, not status changed ones.
122 switch (event.what_happened) { 135 switch (event.what_happened) {
123 case SyncerEvent::STATUS_CHANGED: 136 case SyncerEvent::STATUS_CHANGED:
124 // fall through 137 // fall through
125 case SyncerEvent::SYNC_CYCLE_ENDED: 138 case SyncerEvent::SYNC_CYCLE_ENDED:
126 // fall through 139 // fall through
127 case SyncerEvent::COMMITS_SUCCEEDED: 140 case SyncerEvent::COMMITS_SUCCEEDED:
128 return; 141 return;
(...skipping 15 matching lines...) Expand all
144 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix"; 157 ASSERT_LT(++loop_iterations, 100) << "infinite loop detected. please fix";
145 should_loop = syncer->SyncShare(this); 158 should_loop = syncer->SyncShare(this);
146 } while (should_loop); 159 } while (should_loop);
147 } 160 }
148 161
149 virtual void SetUp() { 162 virtual void SetUp() {
150 syncdb_.SetUp(); 163 syncdb_.SetUp();
151 164
152 mock_server_.reset( 165 mock_server_.reset(
153 new MockConnectionManager(syncdb_.manager(), syncdb_.name())); 166 new MockConnectionManager(syncdb_.manager(), syncdb_.name()));
154 167 worker_.reset(new ModelSafeWorker());
155 context_.reset(new SyncSessionContext(mock_server_.get(), syncdb_.manager(), 168 context_.reset(new SyncSessionContext(mock_server_.get(), syncdb_.manager(),
156 new ModelSafeWorker())); 169 this));
157 context_->set_account_name(syncdb_.name()); 170 context_->set_account_name(syncdb_.name());
158 ASSERT_FALSE(context_->syncer_event_channel()); 171 ASSERT_FALSE(context_->syncer_event_channel());
159 ASSERT_FALSE(context_->resolver()); 172 ASSERT_FALSE(context_->resolver());
160 syncer_ = new Syncer(context_.get()); 173 syncer_ = new Syncer(context_.get());
161 // The Syncer installs some components on the context. 174 // The Syncer installs some components on the context.
162 ASSERT_TRUE(context_->syncer_event_channel()); 175 ASSERT_TRUE(context_->syncer_event_channel());
163 ASSERT_TRUE(context_->resolver()); 176 ASSERT_TRUE(context_->resolver());
164 177
165 hookup_.reset(NewEventListenerHookup(context_->syncer_event_channel(), this, 178 hookup_.reset(NewEventListenerHookup(context_->syncer_event_channel(), this,
166 &SyncerTest::HandleSyncerEvent)); 179 &SyncerTest::HandleSyncerEvent));
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 scoped_ptr<MockConnectionManager> mock_server_; 370 scoped_ptr<MockConnectionManager> mock_server_;
358 scoped_ptr<EventListenerHookup> hookup_; 371 scoped_ptr<EventListenerHookup> hookup_;
359 372
360 Syncer* syncer_; 373 Syncer* syncer_;
361 374
362 scoped_ptr<SyncSession> session_; 375 scoped_ptr<SyncSession> session_;
363 scoped_ptr<SyncSessionContext> context_; 376 scoped_ptr<SyncSessionContext> context_;
364 std::set<SyncerEvent> syncer_events_; 377 std::set<SyncerEvent> syncer_events_;
365 base::TimeDelta last_short_poll_interval_received_; 378 base::TimeDelta last_short_poll_interval_received_;
366 base::TimeDelta last_long_poll_interval_received_; 379 base::TimeDelta last_long_poll_interval_received_;
380 scoped_ptr<ModelSafeWorker> worker_;
367 381
368 DISALLOW_COPY_AND_ASSIGN(SyncerTest); 382 DISALLOW_COPY_AND_ASSIGN(SyncerTest);
369 }; 383 };
370 384
371 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { 385 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) {
372 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); 386 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
373 ASSERT_TRUE(dir.good()); 387 ASSERT_TRUE(dir.good());
374 { 388 {
375 Syncer::UnsyncedMetaHandles handles; 389 Syncer::UnsyncedMetaHandles handles;
376 { 390 {
(...skipping 3608 matching lines...) Expand 10 before | Expand all | Expand 10 after
3985 Add(low_id_); 3999 Add(low_id_);
3986 Add(high_id_); 4000 Add(high_id_);
3987 syncer_->SyncShare(this); 4001 syncer_->SyncShare(this);
3988 ExpectLocalOrderIsByServerId(); 4002 ExpectLocalOrderIsByServerId();
3989 } 4003 }
3990 4004
3991 const SyncerTest::CommitOrderingTest 4005 const SyncerTest::CommitOrderingTest
3992 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; 4006 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()};
3993 4007
3994 } // namespace browser_sync 4008 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_types.h ('k') | chrome/browser/sync/engine/syncer_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698