| Index: components/sync/engine_impl/sync_scheduler_unittest.cc
|
| diff --git a/sync/engine/sync_scheduler_unittest.cc b/components/sync/engine_impl/sync_scheduler_unittest.cc
|
| similarity index 93%
|
| rename from sync/engine/sync_scheduler_unittest.cc
|
| rename to components/sync/engine_impl/sync_scheduler_unittest.cc
|
| index 56c44f67e022f75662fdc7509a3d531259e28d46..4eb9c89fc019db0127603908b4b065063a993dd7 100644
|
| --- a/sync/engine/sync_scheduler_unittest.cc
|
| +++ b/components/sync/engine_impl/sync_scheduler_unittest.cc
|
| @@ -14,19 +14,19 @@
|
| #include "base/single_thread_task_runner.h"
|
| #include "base/test/test_timeouts.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| -#include "sync/engine/backoff_delay_provider.h"
|
| -#include "sync/engine/sync_scheduler_impl.h"
|
| -#include "sync/engine/syncer.h"
|
| -#include "sync/internal_api/public/base/cancelation_signal.h"
|
| -#include "sync/internal_api/public/base/model_type_test_util.h"
|
| -#include "sync/sessions/test_util.h"
|
| -#include "sync/test/callback_counter.h"
|
| -#include "sync/test/engine/fake_model_worker.h"
|
| -#include "sync/test/engine/mock_connection_manager.h"
|
| -#include "sync/test/engine/mock_nudge_handler.h"
|
| -#include "sync/test/engine/test_directory_setter_upper.h"
|
| -#include "sync/test/mock_invalidation.h"
|
| -#include "sync/util/extensions_activity.h"
|
| +#include "components/sync/base/cancelation_signal.h"
|
| +#include "components/sync/base/extensions_activity.h"
|
| +#include "components/sync/base/model_type_test_util.h"
|
| +#include "components/sync/engine_impl/backoff_delay_provider.h"
|
| +#include "components/sync/engine_impl/sync_scheduler_impl.h"
|
| +#include "components/sync/engine_impl/syncer.h"
|
| +#include "components/sync/sessions_impl/test_util.h"
|
| +#include "components/sync/test/callback_counter.h"
|
| +#include "components/sync/test/engine/fake_model_worker.h"
|
| +#include "components/sync/test/engine/mock_connection_manager.h"
|
| +#include "components/sync/test/engine/mock_nudge_handler.h"
|
| +#include "components/sync/test/engine/test_directory_setter_upper.h"
|
| +#include "components/sync/test/mock_invalidation.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -61,8 +61,7 @@ class MockSyncer : public Syncer {
|
| MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, sessions::SyncSession*));
|
| };
|
|
|
| -MockSyncer::MockSyncer()
|
| - : Syncer(NULL) {}
|
| +MockSyncer::MockSyncer() : Syncer(NULL) {}
|
|
|
| typedef std::vector<TimeTicks> SyncShareTimes;
|
|
|
| @@ -102,7 +101,6 @@ ModelSafeRoutingInfo TypesToRoutingInfo(ModelTypeSet types) {
|
| return routes;
|
| }
|
|
|
| -
|
| static const size_t kMinNumSamples = 5;
|
|
|
| // Test harness for the SyncScheduler. Test the delays and backoff timers used
|
| @@ -120,10 +118,10 @@ class SyncSchedulerTest : public testing::Test {
|
|
|
| class MockDelayProvider : public BackoffDelayProvider {
|
| public:
|
| - MockDelayProvider() : BackoffDelayProvider(
|
| - TimeDelta::FromSeconds(kInitialBackoffRetrySeconds),
|
| - TimeDelta::FromSeconds(kInitialBackoffImmediateRetrySeconds)) {
|
| - }
|
| + MockDelayProvider()
|
| + : BackoffDelayProvider(
|
| + TimeDelta::FromSeconds(kInitialBackoffRetrySeconds),
|
| + TimeDelta::FromSeconds(kInitialBackoffImmediateRetrySeconds)) {}
|
|
|
| MOCK_METHOD1(GetDelay, TimeDelta(const TimeDelta&));
|
| };
|
| @@ -144,29 +142,26 @@ class SyncSchedulerTest : public testing::Test {
|
| workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB)));
|
| workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE)));
|
|
|
| - connection_.reset(new MockConnectionManager(directory(),
|
| - &cancelation_signal_));
|
| + connection_.reset(
|
| + new MockConnectionManager(directory(), &cancelation_signal_));
|
| connection_->SetServerReachable();
|
|
|
| model_type_registry_.reset(
|
| new ModelTypeRegistry(workers_, directory(), &mock_nudge_handler_));
|
|
|
| context_.reset(new SyncSessionContext(
|
| - connection_.get(), directory(),
|
| - extensions_activity_.get(),
|
| - std::vector<SyncEngineEventListener*>(), NULL,
|
| - model_type_registry_.get(),
|
| - true, // enable keystore encryption
|
| - false, // force enable pre-commit GU avoidance
|
| - "fake_invalidator_client_id"));
|
| + connection_.get(), directory(), extensions_activity_.get(),
|
| + std::vector<SyncEngineEventListener*>(), NULL,
|
| + model_type_registry_.get(),
|
| + true, // enable keystore encryption
|
| + false, // force enable pre-commit GU avoidance
|
| + "fake_invalidator_client_id"));
|
| context_->SetRoutingInfo(routing_info_);
|
| context_->set_notifications_enabled(true);
|
| context_->set_account_name("Test");
|
| - scheduler_.reset(
|
| - new SyncSchedulerImpl("TestSyncScheduler",
|
| - BackoffDelayProvider::FromDefaults(),
|
| - context(),
|
| - syncer_));
|
| + scheduler_.reset(new SyncSchedulerImpl("TestSyncScheduler",
|
| + BackoffDelayProvider::FromDefaults(),
|
| + context(), syncer_));
|
| scheduler_->SetDefaultNudgeDelay(default_delay());
|
| }
|
|
|
| @@ -176,9 +171,7 @@ class SyncSchedulerTest : public testing::Test {
|
| MockDelayProvider* delay() { return delay_; }
|
| MockConnectionManager* connection() { return connection_.get(); }
|
| TimeDelta default_delay() { return TimeDelta::FromSeconds(0); }
|
| - TimeDelta timeout() {
|
| - return TestTimeouts::action_timeout();
|
| - }
|
| + TimeDelta timeout() { return TestTimeouts::action_timeout(); }
|
|
|
| void TearDown() override {
|
| PumpLoop();
|
| @@ -187,8 +180,10 @@ class SyncSchedulerTest : public testing::Test {
|
| dir_maker_.TearDown();
|
| }
|
|
|
| - void AnalyzePollRun(const SyncShareTimes& times, size_t min_num_samples,
|
| - const TimeTicks& optimal_start, const TimeDelta& poll_interval) {
|
| + void AnalyzePollRun(const SyncShareTimes& times,
|
| + size_t min_num_samples,
|
| + const TimeTicks& optimal_start,
|
| + const TimeDelta& poll_interval) {
|
| EXPECT_GE(times.size(), min_num_samples);
|
| for (size_t i = 0; i < times.size(); i++) {
|
| SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")");
|
| @@ -197,9 +192,7 @@ class SyncSchedulerTest : public testing::Test {
|
| }
|
| }
|
|
|
| - void DoQuitLoopNow() {
|
| - QuitLoopNow();
|
| - }
|
| + void DoQuitLoopNow() { QuitLoopNow(); }
|
|
|
| void StartSyncConfiguration() {
|
| scheduler()->Start(SyncScheduler::CONFIGURATION_MODE, base::Time());
|
| @@ -250,9 +243,7 @@ class SyncSchedulerTest : public testing::Test {
|
| }
|
|
|
| private:
|
| - syncable::Directory* directory() {
|
| - return dir_maker_.directory();
|
| - }
|
| + syncable::Directory* directory() { return dir_maker_.directory(); }
|
|
|
| base::MessageLoop loop_;
|
| TestDirectorySetterUpper dir_maker_;
|
| @@ -264,7 +255,7 @@ class SyncSchedulerTest : public testing::Test {
|
| MockNudgeHandler mock_nudge_handler_;
|
| MockSyncer* syncer_;
|
| MockDelayProvider* delay_;
|
| - std::vector<scoped_refptr<ModelSafeWorker> > workers_;
|
| + std::vector<scoped_refptr<ModelSafeWorker>> workers_;
|
| scoped_refptr<ExtensionsActivity> extensions_activity_;
|
| ModelSafeRoutingInfo routing_info_;
|
| base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_;
|
| @@ -349,8 +340,7 @@ TEST_F(SyncSchedulerTest, Config) {
|
| CallbackCounter ready_counter;
|
| CallbackCounter retry_counter;
|
| ConfigurationParams params(
|
| - GetUpdatesCallerInfo::RECONFIGURATION,
|
| - model_types,
|
| + GetUpdatesCallerInfo::RECONFIGURATION, model_types,
|
| TypesToRoutingInfo(model_types),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
|
| @@ -379,8 +369,7 @@ TEST_F(SyncSchedulerTest, ConfigWithBackingOff) {
|
| CallbackCounter ready_counter;
|
| CallbackCounter retry_counter;
|
| ConfigurationParams params(
|
| - GetUpdatesCallerInfo::RECONFIGURATION,
|
| - model_types,
|
| + GetUpdatesCallerInfo::RECONFIGURATION, model_types,
|
| TypesToRoutingInfo(model_types),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
|
| @@ -426,8 +415,7 @@ TEST_F(SyncSchedulerTest, ConfigWithStop) {
|
| CallbackCounter ready_counter;
|
| CallbackCounter retry_counter;
|
| ConfigurationParams params(
|
| - GetUpdatesCallerInfo::RECONFIGURATION,
|
| - model_types,
|
| + GetUpdatesCallerInfo::RECONFIGURATION, model_types,
|
| TypesToRoutingInfo(model_types),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
|
| @@ -455,8 +443,7 @@ TEST_F(SyncSchedulerTest, NudgeWithConfigWithBackingOff) {
|
| CallbackCounter ready_counter;
|
| CallbackCounter retry_counter;
|
| ConfigurationParams params(
|
| - GetUpdatesCallerInfo::RECONFIGURATION,
|
| - model_types,
|
| + GetUpdatesCallerInfo::RECONFIGURATION, model_types,
|
| TypesToRoutingInfo(model_types),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
|
| @@ -559,8 +546,8 @@ TEST_F(SyncSchedulerTest, NudgeWithStates) {
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateNormalSuccess),
|
| RecordSyncShare(×1, true)))
|
| .RetiresOnSaturation();
|
| - scheduler()->ScheduleInvalidationNudge(
|
| - THEMES, BuildInvalidation(10, "test"), FROM_HERE);
|
| + scheduler()->ScheduleInvalidationNudge(THEMES, BuildInvalidation(10, "test"),
|
| + FROM_HERE);
|
| RunLoop();
|
|
|
| Mock::VerifyAndClearExpectations(syncer());
|
| @@ -720,9 +707,7 @@ TEST_F(SyncSchedulerTest, ThrottlingDoesThrottle) {
|
| CallbackCounter ready_counter;
|
| CallbackCounter retry_counter;
|
| ConfigurationParams params(
|
| - GetUpdatesCallerInfo::RECONFIGURATION,
|
| - types,
|
| - TypesToRoutingInfo(types),
|
| + GetUpdatesCallerInfo::RECONFIGURATION, types, TypesToRoutingInfo(types),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
|
| scheduler()->ScheduleConfiguration(params);
|
| @@ -809,9 +794,7 @@ TEST_F(SyncSchedulerTest, ThrottlingExpiresFromConfigure) {
|
| CallbackCounter ready_counter;
|
| CallbackCounter retry_counter;
|
| ConfigurationParams params(
|
| - GetUpdatesCallerInfo::RECONFIGURATION,
|
| - types,
|
| - TypesToRoutingInfo(types),
|
| + GetUpdatesCallerInfo::RECONFIGURATION, types, TypesToRoutingInfo(types),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
|
| scheduler()->ScheduleConfiguration(params);
|
| @@ -828,8 +811,7 @@ TEST_F(SyncSchedulerTest, ThrottlingExpiresFromConfigure) {
|
|
|
| TEST_F(SyncSchedulerTest, TypeThrottlingBlocksNudge) {
|
| UseMockDelayProvider();
|
| - EXPECT_CALL(*delay(), GetDelay(_))
|
| - .WillRepeatedly(Return(default_delay()));
|
| + EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(default_delay()));
|
|
|
| TimeDelta poll(TimeDelta::FromDays(1));
|
| TimeDelta throttle1(TimeDelta::FromSeconds(60));
|
| @@ -859,8 +841,7 @@ TEST_F(SyncSchedulerTest, TypeThrottlingBlocksNudge) {
|
|
|
| TEST_F(SyncSchedulerTest, TypeThrottlingDoesBlockOtherSources) {
|
| UseMockDelayProvider();
|
| - EXPECT_CALL(*delay(), GetDelay(_))
|
| - .WillRepeatedly(Return(default_delay()));
|
| + EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(default_delay()));
|
|
|
| SyncShareTimes times;
|
| TimeDelta poll(TimeDelta::FromDays(1));
|
| @@ -884,8 +865,8 @@ TEST_F(SyncSchedulerTest, TypeThrottlingDoesBlockOtherSources) {
|
| EXPECT_TRUE(GetThrottledTypes().HasAll(throttled_types));
|
|
|
| // Ignore invalidations for throttled types.
|
| - scheduler()->ScheduleInvalidationNudge(
|
| - THEMES, BuildInvalidation(10, "test"), FROM_HERE);
|
| + scheduler()->ScheduleInvalidationNudge(THEMES, BuildInvalidation(10, "test"),
|
| + FROM_HERE);
|
| PumpLoop();
|
|
|
| // Ignore refresh requests for throttled types.
|
| @@ -926,8 +907,7 @@ TEST_F(SyncSchedulerTest, ConfigurationMode) {
|
| CallbackCounter ready_counter;
|
| CallbackCounter retry_counter;
|
| ConfigurationParams params(
|
| - GetUpdatesCallerInfo::RECONFIGURATION,
|
| - config_types,
|
| + GetUpdatesCallerInfo::RECONFIGURATION, config_types,
|
| TypesToRoutingInfo(config_types),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
|
| @@ -1029,9 +1009,7 @@ TEST_F(BackoffTriggersSyncSchedulerTest, FailGetEncryptionKey) {
|
| CallbackCounter ready_counter;
|
| CallbackCounter retry_counter;
|
| ConfigurationParams params(
|
| - GetUpdatesCallerInfo::RECONFIGURATION,
|
| - types,
|
| - TypesToRoutingInfo(types),
|
| + GetUpdatesCallerInfo::RECONFIGURATION, types, TypesToRoutingInfo(types),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
|
| scheduler()->ScheduleConfiguration(params);
|
| @@ -1051,8 +1029,8 @@ TEST_F(SyncSchedulerTest, BackoffDropsJobs) {
|
| EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _))
|
| .WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed),
|
| RecordSyncShareMultiple(×, 1U, false)));
|
| - EXPECT_CALL(*delay(), GetDelay(_)).
|
| - WillRepeatedly(Return(TimeDelta::FromDays(1)));
|
| + EXPECT_CALL(*delay(), GetDelay(_))
|
| + .WillRepeatedly(Return(TimeDelta::FromDays(1)));
|
|
|
| StartSyncScheduler(base::Time());
|
|
|
| @@ -1080,9 +1058,7 @@ TEST_F(SyncSchedulerTest, BackoffDropsJobs) {
|
| CallbackCounter ready_counter;
|
| CallbackCounter retry_counter;
|
| ConfigurationParams params(
|
| - GetUpdatesCallerInfo::RECONFIGURATION,
|
| - types,
|
| - TypesToRoutingInfo(types),
|
| + GetUpdatesCallerInfo::RECONFIGURATION, types, TypesToRoutingInfo(types),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
|
| scheduler()->ScheduleConfiguration(params);
|
| @@ -1109,14 +1085,18 @@ TEST_F(SyncSchedulerTest, BackoffElevation) {
|
| const TimeDelta fifth = TimeDelta::FromMilliseconds(50);
|
| const TimeDelta sixth = TimeDelta::FromDays(1);
|
|
|
| - EXPECT_CALL(*delay(), GetDelay(first)).WillOnce(Return(second))
|
| - .RetiresOnSaturation();
|
| - EXPECT_CALL(*delay(), GetDelay(second)).WillOnce(Return(third))
|
| - .RetiresOnSaturation();
|
| - EXPECT_CALL(*delay(), GetDelay(third)).WillOnce(Return(fourth))
|
| - .RetiresOnSaturation();
|
| - EXPECT_CALL(*delay(), GetDelay(fourth)).WillOnce(Return(fifth))
|
| - .RetiresOnSaturation();
|
| + EXPECT_CALL(*delay(), GetDelay(first))
|
| + .WillOnce(Return(second))
|
| + .RetiresOnSaturation();
|
| + EXPECT_CALL(*delay(), GetDelay(second))
|
| + .WillOnce(Return(third))
|
| + .RetiresOnSaturation();
|
| + EXPECT_CALL(*delay(), GetDelay(third))
|
| + .WillOnce(Return(fourth))
|
| + .RetiresOnSaturation();
|
| + EXPECT_CALL(*delay(), GetDelay(fourth))
|
| + .WillOnce(Return(fifth))
|
| + .RetiresOnSaturation();
|
| EXPECT_CALL(*delay(), GetDelay(fifth)).WillOnce(Return(sixth));
|
|
|
| StartSyncScheduler(base::Time());
|
| @@ -1314,8 +1294,7 @@ TEST_F(SyncSchedulerTest, DoubleCanaryInConfigure) {
|
| CallbackCounter ready_counter;
|
| CallbackCounter retry_counter;
|
| ConfigurationParams params(
|
| - GetUpdatesCallerInfo::RECONFIGURATION,
|
| - model_types,
|
| + GetUpdatesCallerInfo::RECONFIGURATION, model_types,
|
| TypesToRoutingInfo(model_types),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&ready_counter)),
|
| base::Bind(&CallbackCounter::Callback, base::Unretained(&retry_counter)));
|
|
|