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

Side by Side Diff: sync/engine/sync_scheduler_unittest.cc

Issue 93433006: sync: Introduce ModelTypeRegistry and helpers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leak in tests Created 6 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 | « sync/engine/sync_scheduler_impl.cc ('k') | sync/engine/syncer.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 routing_info_[NIGORI] = GROUP_PASSIVE; 123 routing_info_[NIGORI] = GROUP_PASSIVE;
124 124
125 workers_.clear(); 125 workers_.clear();
126 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI))); 126 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI)));
127 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB))); 127 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB)));
128 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); 128 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE)));
129 129
130 connection_.reset(new MockConnectionManager(directory(), 130 connection_.reset(new MockConnectionManager(directory(),
131 &cancelation_signal_)); 131 &cancelation_signal_));
132 connection_->SetServerReachable(); 132 connection_->SetServerReachable();
133
134 model_type_registry_.reset(new ModelTypeRegistry(workers_, directory()));
135
133 context_.reset(new SyncSessionContext( 136 context_.reset(new SyncSessionContext(
134 connection_.get(), directory(), workers_, 137 connection_.get(), directory(),
135 extensions_activity_.get(), 138 extensions_activity_.get(),
136 std::vector<SyncEngineEventListener*>(), NULL, NULL, 139 std::vector<SyncEngineEventListener*>(), NULL, NULL,
140 model_type_registry_.get(),
137 true, // enable keystore encryption 141 true, // enable keystore encryption
138 false, // force enable pre-commit GU avoidance 142 false, // force enable pre-commit GU avoidance
139 "fake_invalidator_client_id")); 143 "fake_invalidator_client_id"));
140 context_->set_routing_info(routing_info_); 144 context_->SetRoutingInfo(routing_info_);
141 context_->set_notifications_enabled(true); 145 context_->set_notifications_enabled(true);
142 context_->set_account_name("Test"); 146 context_->set_account_name("Test");
143 scheduler_.reset( 147 scheduler_.reset(
144 new SyncSchedulerImpl("TestSyncScheduler", 148 new SyncSchedulerImpl("TestSyncScheduler",
145 BackoffDelayProvider::FromDefaults(), 149 BackoffDelayProvider::FromDefaults(),
146 context(), 150 context(),
147 syncer_)); 151 syncer_));
148 } 152 }
149 153
150 SyncSchedulerImpl* scheduler() { return scheduler_.get(); } 154 SyncSchedulerImpl* scheduler() { return scheduler_.get(); }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 223
220 private: 224 private:
221 syncable::Directory* directory() { 225 syncable::Directory* directory() {
222 return dir_maker_.directory(); 226 return dir_maker_.directory();
223 } 227 }
224 228
225 base::MessageLoop loop_; 229 base::MessageLoop loop_;
226 TestDirectorySetterUpper dir_maker_; 230 TestDirectorySetterUpper dir_maker_;
227 CancelationSignal cancelation_signal_; 231 CancelationSignal cancelation_signal_;
228 scoped_ptr<MockConnectionManager> connection_; 232 scoped_ptr<MockConnectionManager> connection_;
233 scoped_ptr<ModelTypeRegistry> model_type_registry_;
229 scoped_ptr<SyncSessionContext> context_; 234 scoped_ptr<SyncSessionContext> context_;
230 scoped_ptr<SyncSchedulerImpl> scheduler_; 235 scoped_ptr<SyncSchedulerImpl> scheduler_;
231 MockSyncer* syncer_; 236 MockSyncer* syncer_;
232 MockDelayProvider* delay_; 237 MockDelayProvider* delay_;
233 std::vector<scoped_refptr<ModelSafeWorker> > workers_; 238 std::vector<scoped_refptr<ModelSafeWorker> > workers_;
234 scoped_refptr<ExtensionsActivity> extensions_activity_; 239 scoped_refptr<ExtensionsActivity> extensions_activity_;
235 ModelSafeRoutingInfo routing_info_; 240 ModelSafeRoutingInfo routing_info_;
236 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; 241 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_;
237 }; 242 };
238 243
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 892
888 // Switch to NORMAL_MODE to ensure NUDGES were properly saved and run. 893 // Switch to NORMAL_MODE to ensure NUDGES were properly saved and run.
889 scheduler()->OnReceivedLongPollIntervalUpdate(TimeDelta::FromDays(1)); 894 scheduler()->OnReceivedLongPollIntervalUpdate(TimeDelta::FromDays(1));
890 SyncShareTimes times2; 895 SyncShareTimes times2;
891 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)) 896 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
892 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess), 897 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
893 RecordSyncShare(&times2))); 898 RecordSyncShare(&times2)));
894 899
895 // TODO(tim): Figure out how to remove this dangerous need to reset 900 // TODO(tim): Figure out how to remove this dangerous need to reset
896 // routing info between mode switches. 901 // routing info between mode switches.
897 context()->set_routing_info(routing_info()); 902 context()->SetRoutingInfo(routing_info());
898 StartSyncScheduler(SyncScheduler::NORMAL_MODE); 903 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
899 904
900 RunLoop(); 905 RunLoop();
901 Mock::VerifyAndClearExpectations(syncer()); 906 Mock::VerifyAndClearExpectations(syncer());
902 } 907 }
903 908
904 class BackoffTriggersSyncSchedulerTest : public SyncSchedulerTest { 909 class BackoffTriggersSyncSchedulerTest : public SyncSchedulerTest {
905 virtual void SetUp() { 910 virtual void SetUp() {
906 SyncSchedulerTest::SetUp(); 911 SyncSchedulerTest::SetUp();
907 UseMockDelayProvider(); 912 UseMockDelayProvider();
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), 1385 DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess),
1381 RecordSyncShare(&times))); 1386 RecordSyncShare(&times)));
1382 1387
1383 // Run to wait for retrying. 1388 // Run to wait for retrying.
1384 RunLoop(); 1389 RunLoop();
1385 1390
1386 StopSyncScheduler(); 1391 StopSyncScheduler();
1387 } 1392 }
1388 1393
1389 } // namespace syncer 1394 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler_impl.cc ('k') | sync/engine/syncer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698