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 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 const base::Closure
& report_unrecoverable_error_function
,
38 syncer::NetworkResources
* network_resources
,
39 scoped_ptr
<syncer::SyncEncryptionHandler::NigoriState
> saved_nigori_state
)
42 void UpdateCredentials(const syncer::SyncCredentials
& credentials
) override
;
44 void StartSyncingWithServer() override
;
46 void SetEncryptionPassphrase(const std::string
& passphrase
,
47 bool is_explicit
) override
;
49 bool SetDecryptionPassphrase(const std::string
& passphrase
) override
;
51 void StopSyncingForShutdown() override
;
53 scoped_ptr
<base::Thread
> Shutdown(syncer::ShutdownReason reason
) override
;
55 void UnregisterInvalidationIds() override
;
57 syncer::ModelTypeSet
ConfigureDataTypes(
58 syncer::ConfigureReason reason
,
59 const DataTypeConfigStateMap
& config_state_map
,
60 const base::Callback
<void(syncer::ModelTypeSet
, syncer::ModelTypeSet
)>&
62 const base::Callback
<void()>& retry_callback
) override
;
64 void EnableEncryptEverything() override
;
66 void ActivateDataType(
67 syncer::ModelType type
,
68 syncer::ModelSafeGroup group
,
69 sync_driver::ChangeProcessor
* change_processor
) override
;
70 void DeactivateDataType(syncer::ModelType type
) override
;
72 syncer::UserShare
* GetUserShare() const override
;
74 scoped_ptr
<syncer_v2::SyncContextProxy
> GetSyncContextProxy() override
;
76 Status
GetDetailedStatus() override
;
78 syncer::sessions::SyncSessionSnapshot
GetLastSessionSnapshot() const override
;
80 bool HasUnsyncedItems() const override
;
82 bool IsNigoriEnabled() const override
;
84 syncer::PassphraseType
GetPassphraseType() const override
;
86 base::Time
GetExplicitPassphraseTime() const override
;
88 bool IsCryptographerReady(
89 const syncer::BaseTransaction
* trans
) const override
;
91 void GetModelSafeRoutingInfo(
92 syncer::ModelSafeRoutingInfo
* out
) const override
;
94 void FlushDirectory() const override
;
96 void RequestBufferedProtocolEventsAndEnableForwarding() override
;
97 void DisableProtocolEventForwarding() override
;
99 void EnableDirectoryTypeDebugInfoForwarding() override
;
100 void DisableDirectoryTypeDebugInfoForwarding() override
;
102 void GetAllNodesForTypes(
103 syncer::ModelTypeSet types
,
104 base::Callback
<void(const std::vector
<syncer::ModelType
>& type
,
105 ScopedVector
<base::ListValue
>)> callback
) override
;
107 base::MessageLoop
* GetSyncLoopForTesting() override
;
109 void RefreshTypesForTest(syncer::ModelTypeSet types
) override
;
111 void ClearServerData(
112 const syncer::SyncManager::ClearServerDataCallback
& callback
) override
;
114 void set_fail_initial_download(bool should_fail
);
117 bool fail_initial_download_
;
120 } // namespace browser_sync
122 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H_