1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H_
6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H_
10 #include "base/callback.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/sync/glue/sync_backend_host.h"
13 #include "sync/internal_api/public/util/weak_handle.h"
15 namespace browser_sync {
17 // A mock of the SyncBackendHost.
19 // This class implements the bare minimum required for the ProfileSyncService to
20 // get through initialization. It often returns NULL pointers or nonesense
21 // values; it is not intended to be used in tests that depend on SyncBackendHost
23 class SyncBackendHostMock : public SyncBackendHost {
25 SyncBackendHostMock();
26 virtual ~SyncBackendHostMock();
28 virtual void Initialize(
29 sync_driver::SyncFrontend* frontend,
30 scoped_ptr<base::Thread> sync_thread,
31 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
32 const GURL& service_url,
33 const syncer::SyncCredentials& credentials,
34 bool delete_sync_data_folder,
35 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory,
36 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler,
37 syncer::ReportUnrecoverableErrorFunction
38 report_unrecoverable_error_function,
39 syncer::NetworkResources* network_resources) OVERRIDE;
41 virtual void UpdateCredentials(
42 const syncer::SyncCredentials& credentials) OVERRIDE;
44 virtual void StartSyncingWithServer() OVERRIDE;
46 virtual void SetEncryptionPassphrase(
47 const std::string& passphrase,
48 bool is_explicit) OVERRIDE;
50 virtual bool SetDecryptionPassphrase(
51 const std::string& passphrase) OVERRIDE;
53 virtual void StopSyncingForShutdown() OVERRIDE;
55 virtual scoped_ptr<base::Thread> Shutdown(syncer::ShutdownReason reason)
58 virtual void UnregisterInvalidationIds() OVERRIDE;
60 virtual void ConfigureDataTypes(
61 syncer::ConfigureReason reason,
62 const DataTypeConfigStateMap& config_state_map,
63 const base::Callback<void(syncer::ModelTypeSet,
64 syncer::ModelTypeSet)>& ready_task,
65 const base::Callback<void()>& retry_callback) OVERRIDE;
67 virtual void EnableEncryptEverything() OVERRIDE;
69 virtual void ActivateDataType(
70 syncer::ModelType type, syncer::ModelSafeGroup group,
71 sync_driver::ChangeProcessor* change_processor) OVERRIDE;
72 virtual void DeactivateDataType(syncer::ModelType type) OVERRIDE;
74 virtual syncer::UserShare* GetUserShare() const OVERRIDE;
76 virtual scoped_ptr<syncer::SyncContextProxy> GetSyncContextProxy() OVERRIDE;
78 virtual Status GetDetailedStatus() OVERRIDE;
80 virtual syncer::sessions::SyncSessionSnapshot
81 GetLastSessionSnapshot() const OVERRIDE;
83 virtual bool HasUnsyncedItems() const OVERRIDE;
85 virtual bool IsNigoriEnabled() const OVERRIDE;
87 virtual syncer::PassphraseType GetPassphraseType() const OVERRIDE;
89 virtual base::Time GetExplicitPassphraseTime() const OVERRIDE;
91 virtual bool IsCryptographerReady(
92 const syncer::BaseTransaction* trans) const OVERRIDE;
94 virtual void GetModelSafeRoutingInfo(
95 syncer::ModelSafeRoutingInfo* out) const OVERRIDE;
97 virtual void RequestBufferedProtocolEventsAndEnableForwarding() OVERRIDE;
98 virtual void DisableProtocolEventForwarding() OVERRIDE;
100 virtual void EnableDirectoryTypeDebugInfoForwarding() OVERRIDE;
101 virtual void DisableDirectoryTypeDebugInfoForwarding() OVERRIDE;
103 virtual void GetAllNodesForTypes(
104 syncer::ModelTypeSet types,
105 base::Callback<void(const std::vector<syncer::ModelType>& type,
106 ScopedVector<base::ListValue>) > callback) OVERRIDE;
108 virtual base::MessageLoop* GetSyncLoopForTesting() OVERRIDE;
110 void set_fail_initial_download(bool should_fail);
113 bool fail_initial_download_;
116 } // namespace browser_sync
118 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H_