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