| 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/engine/throttled_data_type_tracker.h" | 8 #include "sync/engine/throttled_data_type_tracker.h" |
| 9 #include "sync/sessions/sync_session_context.h" | 9 #include "sync/sessions/sync_session_context.h" |
| 10 #include "sync/sessions/test_util.h" | 10 #include "sync/sessions/test_util.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 ResetWaitInterval(); | 100 ResetWaitInterval(); |
| 101 SetLastSyncedTime(base::TimeTicks::Now()); | 101 SetLastSyncedTime(base::TimeTicks::Now()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 SyncScheduler::JobProcessDecision CreateAndDecideJob( | 104 SyncScheduler::JobProcessDecision CreateAndDecideJob( |
| 105 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) { | 105 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) { |
| 106 SyncSession* s = scheduler_->CreateSyncSession(SyncSourceInfo()); | 106 SyncSession* s = scheduler_->CreateSyncSession(SyncSourceInfo()); |
| 107 SyncScheduler::SyncSessionJob job(purpose, TimeTicks::Now(), | 107 SyncScheduler::SyncSessionJob job(purpose, TimeTicks::Now(), |
| 108 make_linked_ptr(s), | 108 make_linked_ptr(s), |
| 109 false, | 109 false, |
| 110 ConfigurationParams(), |
| 110 FROM_HERE); | 111 FROM_HERE); |
| 111 return DecideOnJob(job); | 112 return DecideOnJob(job); |
| 112 } | 113 } |
| 113 | 114 |
| 114 SyncSessionContext* context() { return context_.get(); } | 115 SyncSessionContext* context() { return context_.get(); } |
| 115 | 116 |
| 116 private: | 117 private: |
| 117 MessageLoop message_loop_; | 118 MessageLoop message_loop_; |
| 118 scoped_ptr<MockConnectionManager> connection_; | 119 scoped_ptr<MockConnectionManager> connection_; |
| 119 scoped_ptr<SyncSessionContext> context_; | 120 scoped_ptr<SyncSessionContext> context_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 types_with_payload[syncable::BOOKMARKS] = ""; | 154 types_with_payload[syncable::BOOKMARKS] = ""; |
| 154 | 155 |
| 155 SyncSourceInfo info(GetUpdatesCallerInfo::LOCAL, types_with_payload); | 156 SyncSourceInfo info(GetUpdatesCallerInfo::LOCAL, types_with_payload); |
| 156 SyncSession* s = scheduler_->CreateSyncSession(info); | 157 SyncSession* s = scheduler_->CreateSyncSession(info); |
| 157 | 158 |
| 158 // Now schedule a nudge with just bookmarks and the change is local. | 159 // Now schedule a nudge with just bookmarks and the change is local. |
| 159 SyncScheduler::SyncSessionJob job(SyncScheduler::SyncSessionJob::NUDGE, | 160 SyncScheduler::SyncSessionJob job(SyncScheduler::SyncSessionJob::NUDGE, |
| 160 TimeTicks::Now(), | 161 TimeTicks::Now(), |
| 161 make_linked_ptr(s), | 162 make_linked_ptr(s), |
| 162 false, | 163 false, |
| 164 ConfigurationParams(), |
| 163 FROM_HERE); | 165 FROM_HERE); |
| 164 | 166 |
| 165 SyncScheduler::JobProcessDecision decision = DecideOnJob(job); | 167 SyncScheduler::JobProcessDecision decision = DecideOnJob(job); |
| 166 EXPECT_EQ(decision, SyncScheduler::SAVE); | 168 EXPECT_EQ(decision, SyncScheduler::SAVE); |
| 167 } | 169 } |
| 168 | 170 |
| 169 TEST_F(SyncSchedulerWhiteboxTest, ContinueNudge) { | 171 TEST_F(SyncSchedulerWhiteboxTest, ContinueNudge) { |
| 170 InitializeSyncerOnNormalMode(); | 172 InitializeSyncerOnNormalMode(); |
| 171 | 173 |
| 172 SyncScheduler::JobProcessDecision decision = CreateAndDecideJob( | 174 SyncScheduler::JobProcessDecision decision = CreateAndDecideJob( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 struct SyncScheduler::SyncSessionJob job; | 278 struct SyncScheduler::SyncSessionJob job; |
| 277 job.purpose = SyncScheduler::SyncSessionJob::CONFIGURATION; | 279 job.purpose = SyncScheduler::SyncSessionJob::CONFIGURATION; |
| 278 job.scheduled_start = TimeTicks::Now(); | 280 job.scheduled_start = TimeTicks::Now(); |
| 279 job.is_canary_job = true; | 281 job.is_canary_job = true; |
| 280 SyncScheduler::JobProcessDecision decision = DecideOnJob(job); | 282 SyncScheduler::JobProcessDecision decision = DecideOnJob(job); |
| 281 | 283 |
| 282 EXPECT_EQ(decision, SyncScheduler::CONTINUE); | 284 EXPECT_EQ(decision, SyncScheduler::CONTINUE); |
| 283 } | 285 } |
| 284 | 286 |
| 285 } // namespace browser_sync | 287 } // namespace browser_sync |
| OLD | NEW |