diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-19 22:19:18 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-19 22:19:18 +0000 |
commit | 6d2dc98e938a0ff4da17e78e96ae6261bece64ef (patch) | |
tree | 9127eb2b563f30bbc4a7b3d38969ba0768289f85 /sync/test | |
parent | 0b9db6796ae57fe8bb36b2e89528efa51f8e938b (diff) | |
download | chromium_src-6d2dc98e938a0ff4da17e78e96ae6261bece64ef.zip chromium_src-6d2dc98e938a0ff4da17e78e96ae6261bece64ef.tar.gz chromium_src-6d2dc98e938a0ff4da17e78e96ae6261bece64ef.tar.bz2 |
sync: Remove SyncManager::TestingMode in favour of InternalComponentsFactory.
Turns SyncScheduler into an interface and adds a FakeSyncScheduler class for tests.
BUG=117836
TEST=
Review URL: https://chromiumcodereview.appspot.com/10701046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147553 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/test')
-rw-r--r-- | sync/test/engine/fake_sync_scheduler.cc | 81 | ||||
-rw-r--r-- | sync/test/engine/fake_sync_scheduler.h | 61 |
2 files changed, 142 insertions, 0 deletions
diff --git a/sync/test/engine/fake_sync_scheduler.cc b/sync/test/engine/fake_sync_scheduler.cc new file mode 100644 index 0000000..2327949 --- /dev/null +++ b/sync/test/engine/fake_sync_scheduler.cc @@ -0,0 +1,81 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "sync/test/engine/fake_sync_scheduler.h" + +namespace syncer { + +FakeSyncScheduler::FakeSyncScheduler() + : created_on_loop_(MessageLoop::current()) {} + +FakeSyncScheduler::~FakeSyncScheduler() {} + +void FakeSyncScheduler::Start(Mode mode) { +} + +void FakeSyncScheduler::RequestStop(const base::Closure& callback) { + created_on_loop_->PostTask(FROM_HERE, callback); +} + +void FakeSyncScheduler::ScheduleNudgeAsync( + const base::TimeDelta& delay, + NudgeSource source, + ModelTypeSet types, + const tracked_objects::Location& nudge_location) { +} + +void FakeSyncScheduler::ScheduleNudgeWithPayloadsAsync( + const base::TimeDelta& delay, NudgeSource source, + const ModelTypePayloadMap& types_with_payloads, + const tracked_objects::Location& nudge_location) { +} + +bool FakeSyncScheduler::ScheduleConfiguration( + const ConfigurationParams& params) { + params.ready_task.Run(); + return true; +} + +void FakeSyncScheduler::SetNotificationsEnabled(bool notifications_enabled) { +} + +base::TimeDelta FakeSyncScheduler::GetSessionsCommitDelay() const { + return base::TimeDelta(); +} + +void FakeSyncScheduler::OnCredentialsUpdated() { + +} + +void FakeSyncScheduler::OnConnectionStatusChange() { + +} + +void FakeSyncScheduler::OnSilencedUntil( + const base::TimeTicks& silenced_until) { +} +bool FakeSyncScheduler::IsSyncingCurrentlySilenced() { + return false; +} + +void FakeSyncScheduler::OnReceivedShortPollIntervalUpdate( + const base::TimeDelta& new_interval) { +} + +void FakeSyncScheduler::OnReceivedLongPollIntervalUpdate( + const base::TimeDelta& new_interval) { +} + +void FakeSyncScheduler::OnReceivedSessionsCommitDelay( + const base::TimeDelta& new_delay) { +} + +void FakeSyncScheduler::OnShouldStopSyncingPermanently() { +} + +void FakeSyncScheduler::OnSyncProtocolError( + const sessions::SyncSessionSnapshot& snapshot) { +} + +} // namespace syncer diff --git a/sync/test/engine/fake_sync_scheduler.h b/sync/test/engine/fake_sync_scheduler.h new file mode 100644 index 0000000..4c2fbba --- /dev/null +++ b/sync/test/engine/fake_sync_scheduler.h @@ -0,0 +1,61 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// A fake implementation of the SyncScheduler. If needed, we should add default +// logic needed for tests (invoking callbacks, etc) here rather than in higher +// level test classes. + +#ifndef SYNC_TEST_ENGINE_FAKE_SYNC_SCHEDULER_H_ +#define SYNC_TEST_ENGINE_FAKE_SYNC_SCHEDULER_H_ + +#include "base/message_loop.h" +#include "sync/engine/sync_scheduler.h" + +namespace syncer { + +class FakeSyncScheduler : public SyncScheduler { + public: + FakeSyncScheduler(); + virtual ~FakeSyncScheduler(); + + virtual void Start(Mode mode) OVERRIDE; + virtual void RequestStop(const base::Closure& callback) OVERRIDE; + virtual void ScheduleNudgeAsync( + const base::TimeDelta& delay, + NudgeSource source, + ModelTypeSet types, + const tracked_objects::Location& nudge_location) OVERRIDE; + virtual void ScheduleNudgeWithPayloadsAsync( + const base::TimeDelta& delay, NudgeSource source, + const ModelTypePayloadMap& types_with_payloads, + const tracked_objects::Location& nudge_location) OVERRIDE; + virtual bool ScheduleConfiguration( + const ConfigurationParams& params) OVERRIDE; + virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE; + + virtual base::TimeDelta GetSessionsCommitDelay() const OVERRIDE; + virtual void OnCredentialsUpdated() OVERRIDE; + virtual void OnConnectionStatusChange() OVERRIDE; + + // SyncSession::Delegate implementation. + virtual void OnSilencedUntil( + const base::TimeTicks& silenced_until) OVERRIDE; + virtual bool IsSyncingCurrentlySilenced() OVERRIDE; + virtual void OnReceivedShortPollIntervalUpdate( + const base::TimeDelta& new_interval) OVERRIDE; + virtual void OnReceivedLongPollIntervalUpdate( + const base::TimeDelta& new_interval) OVERRIDE; + virtual void OnReceivedSessionsCommitDelay( + const base::TimeDelta& new_delay) OVERRIDE; + virtual void OnShouldStopSyncingPermanently() OVERRIDE; + virtual void OnSyncProtocolError( + const sessions::SyncSessionSnapshot& snapshot) OVERRIDE; + + private: + MessageLoop* const created_on_loop_; +}; + +} // namespace syncer + +#endif // SYNC_TEST_ENGINE_FAKE_SYNC_SCHEDULER_H_ |