| 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 "components/sync/engine_impl/sync_scheduler_impl.h" | 5 #include "components/sync/engine_impl/sync_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 public: | 50 public: |
| 51 MockSyncer(); | 51 MockSyncer(); |
| 52 MOCK_METHOD3(NormalSyncShare, bool(ModelTypeSet, NudgeTracker*, SyncCycle*)); | 52 MOCK_METHOD3(NormalSyncShare, bool(ModelTypeSet, NudgeTracker*, SyncCycle*)); |
| 53 MOCK_METHOD3(ConfigureSyncShare, | 53 MOCK_METHOD3(ConfigureSyncShare, |
| 54 bool(ModelTypeSet, | 54 bool(ModelTypeSet, |
| 55 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource, | 55 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource, |
| 56 SyncCycle*)); | 56 SyncCycle*)); |
| 57 MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, SyncCycle*)); | 57 MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, SyncCycle*)); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 MockSyncer::MockSyncer() : Syncer(NULL) {} | 60 MockSyncer::MockSyncer() : Syncer(nullptr) {} |
| 61 | 61 |
| 62 typedef std::vector<TimeTicks> SyncShareTimes; | 62 typedef std::vector<TimeTicks> SyncShareTimes; |
| 63 | 63 |
| 64 void QuitLoopNow() { | 64 void QuitLoopNow() { |
| 65 // We use QuitNow() instead of Quit() as the latter may get stalled | 65 // We use QuitNow() instead of Quit() as the latter may get stalled |
| 66 // indefinitely in the presence of repeated timers with low delays | 66 // indefinitely in the presence of repeated timers with low delays |
| 67 // and a slow test (e.g., ThrottlingDoesThrottle [which has a poll | 67 // and a slow test (e.g., ThrottlingDoesThrottle [which has a poll |
| 68 // delay of 5ms] run under TSAN on the trybots). | 68 // delay of 5ms] run under TSAN on the trybots). |
| 69 base::MessageLoop::current()->QuitNow(); | 69 base::MessageLoop::current()->QuitNow(); |
| 70 } | 70 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // | 104 // |
| 105 // These tests execute in real time with real timers. We try to keep the | 105 // These tests execute in real time with real timers. We try to keep the |
| 106 // delays short, but there is a limit to how short we can make them. The | 106 // delays short, but there is a limit to how short we can make them. The |
| 107 // timers on some platforms (ie. Windows) have a timer resolution greater than | 107 // timers on some platforms (ie. Windows) have a timer resolution greater than |
| 108 // 1ms. Using 1ms delays may result in test flakiness. | 108 // 1ms. Using 1ms delays may result in test flakiness. |
| 109 // | 109 // |
| 110 // See crbug.com/402212 for more info. | 110 // See crbug.com/402212 for more info. |
| 111 class SyncSchedulerImplTest : public testing::Test { | 111 class SyncSchedulerImplTest : public testing::Test { |
| 112 public: | 112 public: |
| 113 SyncSchedulerImplTest() | 113 SyncSchedulerImplTest() |
| 114 : syncer_(NULL), delay_(NULL), weak_ptr_factory_(this) {} | 114 : syncer_(nullptr), delay_(nullptr), weak_ptr_factory_(this) {} |
| 115 | 115 |
| 116 class MockDelayProvider : public BackoffDelayProvider { | 116 class MockDelayProvider : public BackoffDelayProvider { |
| 117 public: | 117 public: |
| 118 MockDelayProvider() | 118 MockDelayProvider() |
| 119 : BackoffDelayProvider( | 119 : BackoffDelayProvider( |
| 120 TimeDelta::FromSeconds(kInitialBackoffRetrySeconds), | 120 TimeDelta::FromSeconds(kInitialBackoffRetrySeconds), |
| 121 TimeDelta::FromSeconds(kInitialBackoffImmediateRetrySeconds)) {} | 121 TimeDelta::FromSeconds(kInitialBackoffImmediateRetrySeconds)) {} |
| 122 | 122 |
| 123 MOCK_METHOD1(GetDelay, TimeDelta(const TimeDelta&)); | 123 MOCK_METHOD1(GetDelay, TimeDelta(const TimeDelta&)); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 void SetUp() override { | 126 void SetUp() override { |
| 127 dir_maker_.SetUp(); | 127 dir_maker_.SetUp(); |
| 128 syncer_ = new testing::StrictMock<MockSyncer>(); | 128 syncer_ = new testing::StrictMock<MockSyncer>(); |
| 129 delay_ = NULL; | 129 delay_ = nullptr; |
| 130 extensions_activity_ = new ExtensionsActivity(); | 130 extensions_activity_ = new ExtensionsActivity(); |
| 131 | 131 |
| 132 routing_info_[THEMES] = GROUP_UI; | 132 routing_info_[THEMES] = GROUP_UI; |
| 133 routing_info_[TYPED_URLS] = GROUP_DB; | 133 routing_info_[TYPED_URLS] = GROUP_DB; |
| 134 routing_info_[THEMES] = GROUP_UI; | 134 routing_info_[THEMES] = GROUP_UI; |
| 135 routing_info_[NIGORI] = GROUP_PASSIVE; | 135 routing_info_[NIGORI] = GROUP_PASSIVE; |
| 136 | 136 |
| 137 workers_.clear(); | 137 workers_.clear(); |
| 138 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI))); | 138 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI))); |
| 139 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB))); | 139 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB))); |
| (...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 ASSERT_TRUE(scheduler()->IsBackingOff()); | 1430 ASSERT_TRUE(scheduler()->IsBackingOff()); |
| 1431 | 1431 |
| 1432 // Now succeed. | 1432 // Now succeed. |
| 1433 connection()->SetServerReachable(); | 1433 connection()->SetServerReachable(); |
| 1434 PumpLoopFor(2 * delta); | 1434 PumpLoopFor(2 * delta); |
| 1435 ASSERT_EQ(1, success_counter.times_called()); | 1435 ASSERT_EQ(1, success_counter.times_called()); |
| 1436 ASSERT_FALSE(scheduler()->IsBackingOff()); | 1436 ASSERT_FALSE(scheduler()->IsBackingOff()); |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 } // namespace syncer | 1439 } // namespace syncer |
| OLD | NEW |