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

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: More review fixes 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
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 workers_.clear(); 123 workers_.clear();
124 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI))); 124 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI)));
125 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB))); 125 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB)));
126 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); 126 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE)));
127 127
128 std::vector<ModelSafeWorker*> workers; 128 std::vector<ModelSafeWorker*> workers;
129 for (std::vector<scoped_refptr<FakeModelWorker> >::iterator it = 129 for (std::vector<scoped_refptr<FakeModelWorker> >::iterator it =
130 workers_.begin(); it != workers_.end(); ++it) { 130 workers_.begin(); it != workers_.end(); ++it) {
131 workers.push_back(it->get()); 131 workers.push_back(it->get());
132 } 132 }
133 model_type_registry_.reset(new ModelTypeRegistry(workers, directory()));
133 134
134 connection_.reset(new MockConnectionManager(directory(), 135 connection_.reset(new MockConnectionManager(directory(),
135 &cancelation_signal_)); 136 &cancelation_signal_));
136 connection_->SetServerReachable(); 137 connection_->SetServerReachable();
137 context_.reset(new SyncSessionContext( 138 context_.reset(new SyncSessionContext(
138 connection_.get(), directory(), workers, 139 connection_.get(), directory(),
139 extensions_activity_.get(), 140 extensions_activity_.get(),
140 std::vector<SyncEngineEventListener*>(), NULL, NULL, 141 std::vector<SyncEngineEventListener*>(), NULL, NULL,
142 model_type_registry_.get(),
141 true, // enable keystore encryption 143 true, // enable keystore encryption
142 false, // force enable pre-commit GU avoidance 144 false, // force enable pre-commit GU avoidance
143 "fake_invalidator_client_id")); 145 "fake_invalidator_client_id"));
144 context_->set_routing_info(routing_info_); 146 context_->SetRoutingInfo(routing_info_);
145 context_->set_notifications_enabled(true); 147 context_->set_notifications_enabled(true);
146 context_->set_account_name("Test"); 148 context_->set_account_name("Test");
147 scheduler_.reset( 149 scheduler_.reset(
148 new SyncSchedulerImpl("TestSyncScheduler", 150 new SyncSchedulerImpl("TestSyncScheduler",
149 BackoffDelayProvider::FromDefaults(), 151 BackoffDelayProvider::FromDefaults(),
150 context(), 152 context(),
151 syncer_)); 153 syncer_));
152 } 154 }
153 155
154 SyncSchedulerImpl* scheduler() { return scheduler_.get(); } 156 SyncSchedulerImpl* scheduler() { return scheduler_.get(); }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 220
219 private: 221 private:
220 syncable::Directory* directory() { 222 syncable::Directory* directory() {
221 return dir_maker_.directory(); 223 return dir_maker_.directory();
222 } 224 }
223 225
224 base::MessageLoop loop_; 226 base::MessageLoop loop_;
225 TestDirectorySetterUpper dir_maker_; 227 TestDirectorySetterUpper dir_maker_;
226 CancelationSignal cancelation_signal_; 228 CancelationSignal cancelation_signal_;
227 scoped_ptr<MockConnectionManager> connection_; 229 scoped_ptr<MockConnectionManager> connection_;
230 scoped_ptr<ModelTypeRegistry> model_type_registry_;
228 scoped_ptr<SyncSessionContext> context_; 231 scoped_ptr<SyncSessionContext> context_;
229 scoped_ptr<SyncSchedulerImpl> scheduler_; 232 scoped_ptr<SyncSchedulerImpl> scheduler_;
230 MockSyncer* syncer_; 233 MockSyncer* syncer_;
231 MockDelayProvider* delay_; 234 MockDelayProvider* delay_;
232 std::vector<scoped_refptr<FakeModelWorker> > workers_; 235 std::vector<scoped_refptr<FakeModelWorker> > workers_;
233 scoped_refptr<ExtensionsActivity> extensions_activity_; 236 scoped_refptr<ExtensionsActivity> extensions_activity_;
234 ModelSafeRoutingInfo routing_info_; 237 ModelSafeRoutingInfo routing_info_;
235 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; 238 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_;
236 }; 239 };
237 240
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 886
884 // Switch to NORMAL_MODE to ensure NUDGES were properly saved and run. 887 // Switch to NORMAL_MODE to ensure NUDGES were properly saved and run.
885 scheduler()->OnReceivedLongPollIntervalUpdate(TimeDelta::FromDays(1)); 888 scheduler()->OnReceivedLongPollIntervalUpdate(TimeDelta::FromDays(1));
886 SyncShareTimes times2; 889 SyncShareTimes times2;
887 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)) 890 EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_))
888 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess), 891 .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
889 RecordSyncShare(&times2))); 892 RecordSyncShare(&times2)));
890 893
891 // TODO(tim): Figure out how to remove this dangerous need to reset 894 // TODO(tim): Figure out how to remove this dangerous need to reset
892 // routing info between mode switches. 895 // routing info between mode switches.
893 context()->set_routing_info(routing_info()); 896 context()->SetRoutingInfo(routing_info());
894 StartSyncScheduler(SyncScheduler::NORMAL_MODE); 897 StartSyncScheduler(SyncScheduler::NORMAL_MODE);
895 898
896 RunLoop(); 899 RunLoop();
897 Mock::VerifyAndClearExpectations(syncer()); 900 Mock::VerifyAndClearExpectations(syncer());
898 } 901 }
899 902
900 class BackoffTriggersSyncSchedulerTest : public SyncSchedulerTest { 903 class BackoffTriggersSyncSchedulerTest : public SyncSchedulerTest {
901 virtual void SetUp() { 904 virtual void SetUp() {
902 SyncSchedulerTest::SetUp(); 905 SyncSchedulerTest::SetUp();
903 UseMockDelayProvider(); 906 UseMockDelayProvider();
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 EXPECT_CALL(*syncer(), PollSyncShare(_,_)) 1293 EXPECT_CALL(*syncer(), PollSyncShare(_,_))
1291 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), 1294 .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess),
1292 RecordSyncShare(&times))); 1295 RecordSyncShare(&times)));
1293 scheduler()->OnCredentialsUpdated(); 1296 scheduler()->OnCredentialsUpdated();
1294 connection()->SetServerStatus(HttpResponse::SERVER_CONNECTION_OK); 1297 connection()->SetServerStatus(HttpResponse::SERVER_CONNECTION_OK);
1295 RunLoop(); 1298 RunLoop();
1296 StopSyncScheduler(); 1299 StopSyncScheduler();
1297 } 1300 }
1298 1301
1299 } // namespace syncer 1302 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698