OLD | NEW |
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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/time.h" | 6 #include "base/time.h" |
7 #include "sync/engine/backoff_delay_provider.h" | 7 #include "sync/engine/backoff_delay_provider.h" |
8 #include "sync/engine/sync_scheduler_impl.h" | 8 #include "sync/engine/sync_scheduler_impl.h" |
9 #include "sync/engine/throttled_data_type_tracker.h" | 9 #include "sync/engine/throttled_data_type_tracker.h" |
10 #include "sync/internal_api/public/engine/polling_constants.h" | 10 #include "sync/internal_api/public/engine/polling_constants.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 void InitializeSyncerOnNormalMode() { | 99 void InitializeSyncerOnNormalMode() { |
100 SetMode(SyncScheduler::NORMAL_MODE); | 100 SetMode(SyncScheduler::NORMAL_MODE); |
101 ResetWaitInterval(); | 101 ResetWaitInterval(); |
102 } | 102 } |
103 | 103 |
104 SyncSchedulerImpl::JobProcessDecision CreateAndDecideJob( | 104 SyncSchedulerImpl::JobProcessDecision CreateAndDecideJob( |
105 SyncSessionJob::Purpose purpose) { | 105 SyncSessionJob::Purpose purpose) { |
106 scoped_ptr<SyncSession> s(scheduler_->CreateSyncSession(SyncSourceInfo())); | 106 scoped_ptr<SyncSession> s(scheduler_->CreateSyncSession(SyncSourceInfo())); |
107 SyncSessionJob job(purpose, TimeTicks::Now(), s.Pass(), | 107 SyncSessionJob job(purpose, TimeTicks::Now(), s.Pass(), |
108 ConfigurationParams(), FROM_HERE); | 108 ConfigurationParams()); |
109 return DecideOnJob(job); | 109 return DecideOnJob(job); |
110 } | 110 } |
111 | 111 |
112 SyncSessionContext* context() { return context_.get(); } | 112 SyncSessionContext* context() { return context_.get(); } |
113 | 113 |
114 private: | 114 private: |
115 MessageLoop message_loop_; | 115 MessageLoop message_loop_; |
116 scoped_ptr<MockConnectionManager> connection_; | 116 scoped_ptr<MockConnectionManager> connection_; |
117 scoped_ptr<SyncSessionContext> context_; | 117 scoped_ptr<SyncSessionContext> context_; |
118 std::vector<scoped_refptr<FakeModelWorker> > workers_; | 118 std::vector<scoped_refptr<FakeModelWorker> > workers_; |
(...skipping 30 matching lines...) Expand all Loading... |
149 const ModelTypeInvalidationMap& invalidation_map = | 149 const ModelTypeInvalidationMap& invalidation_map = |
150 ModelTypeSetToInvalidationMap(types, std::string()); | 150 ModelTypeSetToInvalidationMap(types, std::string()); |
151 | 151 |
152 SyncSourceInfo info(GetUpdatesCallerInfo::LOCAL, invalidation_map); | 152 SyncSourceInfo info(GetUpdatesCallerInfo::LOCAL, invalidation_map); |
153 scoped_ptr<SyncSession> s(scheduler_->CreateSyncSession(info)); | 153 scoped_ptr<SyncSession> s(scheduler_->CreateSyncSession(info)); |
154 | 154 |
155 // Now schedule a nudge with just bookmarks and the change is local. | 155 // Now schedule a nudge with just bookmarks and the change is local. |
156 SyncSessionJob job(SyncSessionJob::NUDGE, | 156 SyncSessionJob job(SyncSessionJob::NUDGE, |
157 TimeTicks::Now(), | 157 TimeTicks::Now(), |
158 s.Pass(), | 158 s.Pass(), |
159 ConfigurationParams(), | 159 ConfigurationParams()); |
160 FROM_HERE); | |
161 SyncSchedulerImpl::JobProcessDecision decision = DecideOnJob(job); | 160 SyncSchedulerImpl::JobProcessDecision decision = DecideOnJob(job); |
162 EXPECT_EQ(decision, SyncSchedulerImpl::SAVE); | 161 EXPECT_EQ(decision, SyncSchedulerImpl::SAVE); |
163 } | 162 } |
164 | 163 |
165 TEST_F(SyncSchedulerWhiteboxTest, ContinueNudge) { | 164 TEST_F(SyncSchedulerWhiteboxTest, ContinueNudge) { |
166 InitializeSyncerOnNormalMode(); | 165 InitializeSyncerOnNormalMode(); |
167 | 166 |
168 SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob( | 167 SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob( |
169 SyncSessionJob::NUDGE); | 168 SyncSessionJob::NUDGE); |
170 | 169 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 EXPECT_EQ(decision, SyncSchedulerImpl::DROP); | 246 EXPECT_EQ(decision, SyncSchedulerImpl::DROP); |
248 } | 247 } |
249 | 248 |
250 TEST_F(SyncSchedulerWhiteboxTest, ContinueCanaryJobConfig) { | 249 TEST_F(SyncSchedulerWhiteboxTest, ContinueCanaryJobConfig) { |
251 InitializeSyncerOnNormalMode(); | 250 InitializeSyncerOnNormalMode(); |
252 SetMode(SyncScheduler::CONFIGURATION_MODE); | 251 SetMode(SyncScheduler::CONFIGURATION_MODE); |
253 SetWaitIntervalToExponentialBackoff(); | 252 SetWaitIntervalToExponentialBackoff(); |
254 | 253 |
255 SyncSessionJob job(SyncSessionJob::CONFIGURATION, | 254 SyncSessionJob job(SyncSessionJob::CONFIGURATION, |
256 TimeTicks::Now(), scoped_ptr<SyncSession>(), | 255 TimeTicks::Now(), scoped_ptr<SyncSession>(), |
257 ConfigurationParams(), FROM_HERE); | 256 ConfigurationParams()); |
258 | 257 |
259 job.GrantCanaryPrivilege(); | 258 job.GrantCanaryPrivilege(); |
260 SyncSchedulerImpl::JobProcessDecision decision = DecideOnJob(job); | 259 SyncSchedulerImpl::JobProcessDecision decision = DecideOnJob(job); |
261 | 260 |
262 EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE); | 261 EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE); |
263 } | 262 } |
264 | 263 |
265 } // namespace syncer | 264 } // namespace syncer |
OLD | NEW |