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 syncer::ReportUnrecoverableErrorFunction
38 report_unrecoverable_error_function
,
39 syncer::NetworkResources
* network_resources
) override
;
41 void UpdateCredentials(const syncer::SyncCredentials
& credentials
) override
;
43 void StartSyncingWithServer() override
;
45 void SetEncryptionPassphrase(const std::string
& passphrase
,
46 bool is_explicit
) override
;
48 bool SetDecryptionPassphrase(const std::string
& passphrase
) override
;
50 void StopSyncingForShutdown() override
;
52 scoped_ptr
<base::Thread
> Shutdown(syncer::ShutdownReason reason
) override
;
54 void UnregisterInvalidationIds() override
;
56 void ConfigureDataTypes(
57 syncer::ConfigureReason reason
,
58 const DataTypeConfigStateMap
& config_state_map
,
59 const base::Callback
<void(syncer::ModelTypeSet
, syncer::ModelTypeSet
)>&
61 const base::Callback
<void()>& retry_callback
) override
;
63 void EnableEncryptEverything() override
;
65 void ActivateDataType(
66 syncer::ModelType type
,
67 syncer::ModelSafeGroup group
,
68 sync_driver::ChangeProcessor
* change_processor
) override
;
69 void DeactivateDataType(syncer::ModelType type
) override
;
71 syncer::UserShare
* GetUserShare() const override
;
73 scoped_ptr
<syncer::SyncContextProxy
> GetSyncContextProxy() override
;
75 Status
GetDetailedStatus() override
;
77 syncer::sessions::SyncSessionSnapshot
GetLastSessionSnapshot() const override
;
79 bool HasUnsyncedItems() const override
;
81 bool IsNigoriEnabled() const override
;
83 syncer::PassphraseType
GetPassphraseType() const override
;
85 base::Time
GetExplicitPassphraseTime() const override
;
87 bool IsCryptographerReady(
88 const syncer::BaseTransaction
* trans
) const override
;
90 void GetModelSafeRoutingInfo(
91 syncer::ModelSafeRoutingInfo
* out
) const override
;
93 void FlushDirectory() const override
;
95 void RequestBufferedProtocolEventsAndEnableForwarding() override
;
96 void DisableProtocolEventForwarding() override
;
98 void EnableDirectoryTypeDebugInfoForwarding() override
;
99 void DisableDirectoryTypeDebugInfoForwarding() override
;
101 void GetAllNodesForTypes(
102 syncer::ModelTypeSet types
,
103 base::Callback
<void(const std::vector
<syncer::ModelType
>& type
,
104 ScopedVector
<base::ListValue
>)> callback
) override
;
106 base::MessageLoop
* GetSyncLoopForTesting() override
;
108 void set_fail_initial_download(bool should_fail
);
111 bool fail_initial_download_
;
114 } // namespace browser_sync
116 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H_