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

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

Issue 8625005: [Sync] Make ModelSafeWorker a true interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 9 #include "base/message_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
11 #include "chrome/browser/sync/engine/mock_model_safe_workers.h"
12 #include "chrome/browser/sync/engine/sync_scheduler.h" 11 #include "chrome/browser/sync/engine/sync_scheduler.h"
13 #include "chrome/browser/sync/engine/syncer.h" 12 #include "chrome/browser/sync/engine/syncer.h"
14 #include "chrome/browser/sync/sessions/test_util.h" 13 #include "chrome/browser/sync/sessions/test_util.h"
14 #include "chrome/browser/sync/test/engine/fake_model_safe_worker_registrar.h"
15 #include "chrome/browser/sync/test/engine/mock_connection_manager.h" 15 #include "chrome/browser/sync/test/engine/mock_connection_manager.h"
16 #include "chrome/browser/sync/test/engine/test_directory_setter_upper.h" 16 #include "chrome/browser/sync/test/engine/test_directory_setter_upper.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 19
20 using base::TimeDelta; 20 using base::TimeDelta;
21 using base::TimeTicks; 21 using base::TimeTicks;
22 using testing::_; 22 using testing::_;
23 using testing::AtLeast; 23 using testing::AtLeast;
24 using testing::DoAll; 24 using testing::DoAll;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 context_(NULL), 76 context_(NULL),
77 syncer_(NULL), 77 syncer_(NULL),
78 delay_(NULL) {} 78 delay_(NULL) {}
79 79
80 class MockDelayProvider : public SyncScheduler::DelayProvider { 80 class MockDelayProvider : public SyncScheduler::DelayProvider {
81 public: 81 public:
82 MOCK_METHOD1(GetDelay, TimeDelta(const TimeDelta&)); 82 MOCK_METHOD1(GetDelay, TimeDelta(const TimeDelta&));
83 }; 83 };
84 84
85 virtual void SetUp() { 85 virtual void SetUp() {
86 syncable::ModelTypeBitSet model_types;
87 model_types[syncable::BOOKMARKS] = true;
88 model_types[syncable::AUTOFILL] = true;
89 model_types[syncable::THEMES] = true;
90
91 syncdb_.SetUp(); 86 syncdb_.SetUp();
92 syncer_ = new MockSyncer(); 87 syncer_ = new MockSyncer();
93 delay_ = NULL; 88 delay_ = NULL;
94 registrar_.reset(MockModelSafeWorkerRegistrar::PassiveForTypes( 89 ModelSafeRoutingInfo routing_info;
95 model_types)); 90 routing_info[syncable::BOOKMARKS] = GROUP_UI;
91 routing_info[syncable::AUTOFILL] = GROUP_DB;
92 routing_info[syncable::THEMES] = GROUP_UI;
93 routing_info[syncable::NIGORI] = GROUP_PASSIVE;
94 registrar_.reset(new FakeModelSafeWorkerRegistrar(routing_info));
96 connection_.reset(new MockConnectionManager(syncdb_.manager(), "Test")); 95 connection_.reset(new MockConnectionManager(syncdb_.manager(), "Test"));
97 connection_->SetServerReachable(); 96 connection_->SetServerReachable();
98 context_ = new SyncSessionContext(connection_.get(), syncdb_.manager(), 97 context_ = new SyncSessionContext(connection_.get(), syncdb_.manager(),
99 registrar_.get(), std::vector<SyncEngineEventListener*>(), NULL); 98 registrar_.get(), std::vector<SyncEngineEventListener*>(), NULL);
100 context_->set_notifications_enabled(true); 99 context_->set_notifications_enabled(true);
101 context_->set_account_name("Test"); 100 context_->set_account_name("Test");
102 scheduler_.reset( 101 scheduler_.reset(
103 new SyncScheduler("TestSyncScheduler", context_, syncer_)); 102 new SyncScheduler("TestSyncScheduler", context_, syncer_));
104 } 103 }
105 104
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 SyncSessionContext* context() { return context_; } 197 SyncSessionContext* context() { return context_; }
199 198
200 private: 199 private:
201 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_; 200 base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_;
202 MessageLoop message_loop_; 201 MessageLoop message_loop_;
203 scoped_ptr<SyncScheduler> scheduler_; 202 scoped_ptr<SyncScheduler> scheduler_;
204 scoped_ptr<MockConnectionManager> connection_; 203 scoped_ptr<MockConnectionManager> connection_;
205 SyncSessionContext* context_; 204 SyncSessionContext* context_;
206 MockSyncer* syncer_; 205 MockSyncer* syncer_;
207 MockDelayProvider* delay_; 206 MockDelayProvider* delay_;
208 scoped_ptr<MockModelSafeWorkerRegistrar> registrar_; 207 scoped_ptr<FakeModelSafeWorkerRegistrar> registrar_;
209 MockDirectorySetterUpper syncdb_; 208 MockDirectorySetterUpper syncdb_;
210 }; 209 };
211 210
212 void RecordSyncShareImpl(SyncSession* s, SyncShareRecords* record) { 211 void RecordSyncShareImpl(SyncSession* s, SyncShareRecords* record) {
213 record->times.push_back(TimeTicks::Now()); 212 record->times.push_back(TimeTicks::Now());
214 record->snapshots.push_back(make_linked_ptr(new SyncSessionSnapshot( 213 record->snapshots.push_back(make_linked_ptr(new SyncSessionSnapshot(
215 s->TakeSnapshot()))); 214 s->TakeSnapshot())));
216 } 215 }
217 216
218 ACTION_P(RecordSyncShare, record) { 217 ACTION_P(RecordSyncShare, record) {
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 PumpLoop(); 1077 PumpLoop();
1079 // Pump again to run job. 1078 // Pump again to run job.
1080 PumpLoop(); 1079 PumpLoop();
1081 1080
1082 StopSyncScheduler(); 1081 StopSyncScheduler();
1083 1082
1084 EXPECT_TRUE(expected == context()->previous_session_routing_info()); 1083 EXPECT_TRUE(expected == context()->previous_session_routing_info());
1085 } 1084 }
1086 1085
1087 } // namespace browser_sync 1086 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698