| 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/sync_scheduler.h" | 7 #include "sync/engine/sync_scheduler.h" |
| 8 #include "sync/sessions/sync_session_context.h" | 8 #include "sync/sessions/sync_session_context.h" |
| 9 #include "sync/sessions/test_util.h" | 9 #include "sync/sessions/test_util.h" |
| 10 #include "sync/test/engine/fake_model_worker.h" | 10 #include "sync/test/engine/fake_model_worker.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 ResetWaitInterval(); | 97 ResetWaitInterval(); |
| 98 SetLastSyncedTime(base::TimeTicks::Now()); | 98 SetLastSyncedTime(base::TimeTicks::Now()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 SyncScheduler::JobProcessDecision CreateAndDecideJob( | 101 SyncScheduler::JobProcessDecision CreateAndDecideJob( |
| 102 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) { | 102 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) { |
| 103 SyncSession* s = scheduler_->CreateSyncSession(SyncSourceInfo()); | 103 SyncSession* s = scheduler_->CreateSyncSession(SyncSourceInfo()); |
| 104 SyncScheduler::SyncSessionJob job(purpose, TimeTicks::Now(), | 104 SyncScheduler::SyncSessionJob job(purpose, TimeTicks::Now(), |
| 105 make_linked_ptr(s), | 105 make_linked_ptr(s), |
| 106 false, | 106 false, |
| 107 ConfigureParams(), |
| 107 FROM_HERE); | 108 FROM_HERE); |
| 108 return DecideOnJob(job); | 109 return DecideOnJob(job); |
| 109 } | 110 } |
| 110 | 111 |
| 111 SyncSessionContext* context() { return context_.get(); } | 112 SyncSessionContext* context() { return context_.get(); } |
| 112 | 113 |
| 113 private: | 114 private: |
| 114 MessageLoop message_loop_; | 115 MessageLoop message_loop_; |
| 115 scoped_ptr<MockConnectionManager> connection_; | 116 scoped_ptr<MockConnectionManager> connection_; |
| 116 scoped_ptr<SyncSessionContext> context_; | 117 scoped_ptr<SyncSessionContext> context_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 types_with_payload[syncable::BOOKMARKS] = ""; | 150 types_with_payload[syncable::BOOKMARKS] = ""; |
| 150 | 151 |
| 151 SyncSourceInfo info(GetUpdatesCallerInfo::LOCAL, types_with_payload); | 152 SyncSourceInfo info(GetUpdatesCallerInfo::LOCAL, types_with_payload); |
| 152 SyncSession* s = scheduler_->CreateSyncSession(info); | 153 SyncSession* s = scheduler_->CreateSyncSession(info); |
| 153 | 154 |
| 154 // 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. |
| 155 SyncScheduler::SyncSessionJob job(SyncScheduler::SyncSessionJob::NUDGE, | 156 SyncScheduler::SyncSessionJob job(SyncScheduler::SyncSessionJob::NUDGE, |
| 156 TimeTicks::Now(), | 157 TimeTicks::Now(), |
| 157 make_linked_ptr(s), | 158 make_linked_ptr(s), |
| 158 false, | 159 false, |
| 160 ConfigureParams(), |
| 159 FROM_HERE); | 161 FROM_HERE); |
| 160 | 162 |
| 161 SyncScheduler::JobProcessDecision decision = DecideOnJob(job); | 163 SyncScheduler::JobProcessDecision decision = DecideOnJob(job); |
| 162 EXPECT_EQ(decision, SyncScheduler::SAVE); | 164 EXPECT_EQ(decision, SyncScheduler::SAVE); |
| 163 } | 165 } |
| 164 | 166 |
| 165 TEST_F(SyncSchedulerWhiteboxTest, ContinueNudge) { | 167 TEST_F(SyncSchedulerWhiteboxTest, ContinueNudge) { |
| 166 InitializeSyncerOnNormalMode(); | 168 InitializeSyncerOnNormalMode(); |
| 167 | 169 |
| 168 SyncScheduler::JobProcessDecision decision = CreateAndDecideJob( | 170 SyncScheduler::JobProcessDecision decision = CreateAndDecideJob( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 struct SyncScheduler::SyncSessionJob job; | 274 struct SyncScheduler::SyncSessionJob job; |
| 273 job.purpose = SyncScheduler::SyncSessionJob::CONFIGURATION; | 275 job.purpose = SyncScheduler::SyncSessionJob::CONFIGURATION; |
| 274 job.scheduled_start = TimeTicks::Now(); | 276 job.scheduled_start = TimeTicks::Now(); |
| 275 job.is_canary_job = true; | 277 job.is_canary_job = true; |
| 276 SyncScheduler::JobProcessDecision decision = DecideOnJob(job); | 278 SyncScheduler::JobProcessDecision decision = DecideOnJob(job); |
| 277 | 279 |
| 278 EXPECT_EQ(decision, SyncScheduler::CONTINUE); | 280 EXPECT_EQ(decision, SyncScheduler::CONTINUE); |
| 279 } | 281 } |
| 280 | 282 |
| 281 } // namespace browser_sync | 283 } // namespace browser_sync |
| OLD | NEW |