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 ~SyncBackendHostMock() override
;
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 std::string
& sync_user_agent
,
34 const syncer::SyncCredentials
& credentials
,
35 bool delete_sync_data_folder
,
36 scoped_ptr
<syncer::SyncManagerFactory
> sync_manager_factory
,
37 const syncer::WeakHandle
<syncer::UnrecoverableErrorHandler
>&
38 unrecoverable_error_handler
,
39 const base::Closure
& report_unrecoverable_error_function
,
40 syncer::NetworkResources
* network_resources
,
41 scoped_ptr
<syncer::SyncEncryptionHandler::NigoriState
> saved_nigori_state
)
44 void UpdateCredentials(const syncer::SyncCredentials
& credentials
) override
;
46 void StartSyncingWithServer() override
;
48 void SetEncryptionPassphrase(const std::string
& passphrase
,
49 bool is_explicit
) override
;
51 bool SetDecryptionPassphrase(const std::string
& passphrase
) override
;
53 void StopSyncingForShutdown() override
;
55 scoped_ptr
<base::Thread
> Shutdown(syncer::ShutdownReason reason
) override
;
57 void UnregisterInvalidationIds() override
;
59 syncer::ModelTypeSet
ConfigureDataTypes(
60 syncer::ConfigureReason reason
,
61 const DataTypeConfigStateMap
& config_state_map
,
62 const base::Callback
<void(syncer::ModelTypeSet
, syncer::ModelTypeSet
)>&
64 const base::Callback
<void()>& retry_callback
) override
;
66 void EnableEncryptEverything() override
;
68 void ActivateDataType(
69 syncer::ModelType type
,
70 syncer::ModelSafeGroup group
,
71 sync_driver::ChangeProcessor
* change_processor
) override
;
72 void DeactivateDataType(syncer::ModelType type
) override
;
74 syncer::UserShare
* GetUserShare() const override
;
76 scoped_ptr
<syncer_v2::SyncContextProxy
> GetSyncContextProxy() override
;
78 Status
GetDetailedStatus() override
;
80 syncer::sessions::SyncSessionSnapshot
GetLastSessionSnapshot() const override
;
82 bool HasUnsyncedItems() const override
;
84 bool IsNigoriEnabled() const override
;
86 syncer::PassphraseType
GetPassphraseType() const override
;
88 base::Time
GetExplicitPassphraseTime() const override
;
90 bool IsCryptographerReady(
91 const syncer::BaseTransaction
* trans
) const override
;
93 void GetModelSafeRoutingInfo(
94 syncer::ModelSafeRoutingInfo
* out
) const override
;
96 void FlushDirectory() const override
;
98 void RequestBufferedProtocolEventsAndEnableForwarding() override
;
99 void DisableProtocolEventForwarding() override
;
101 void EnableDirectoryTypeDebugInfoForwarding() override
;
102 void DisableDirectoryTypeDebugInfoForwarding() override
;
104 void GetAllNodesForTypes(
105 syncer::ModelTypeSet types
,
106 base::Callback
<void(const std::vector
<syncer::ModelType
>& type
,
107 ScopedVector
<base::ListValue
>)> callback
) override
;
109 base::MessageLoop
* GetSyncLoopForTesting() override
;
111 void RefreshTypesForTest(syncer::ModelTypeSet types
) override
;
113 void ClearServerData(
114 const syncer::SyncManager::ClearServerDataCallback
& callback
) override
;
116 void set_fail_initial_download(bool should_fail
);
119 bool fail_initial_download_
;
122 } // namespace browser_sync
124 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H_