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 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(ShutdownOption option
) OVERRIDE
;
57 virtual void UnregisterInvalidationIds() OVERRIDE
;
59 virtual void ConfigureDataTypes(
60 syncer::ConfigureReason reason
,
61 const DataTypeConfigStateMap
& config_state_map
,
62 const base::Callback
<void(syncer::ModelTypeSet
,
63 syncer::ModelTypeSet
)>& ready_task
,
64 const base::Callback
<void()>& retry_callback
) OVERRIDE
;
66 virtual void EnableEncryptEverything() OVERRIDE
;
68 virtual void ActivateDataType(
69 syncer::ModelType type
, syncer::ModelSafeGroup group
,
70 ChangeProcessor
* change_processor
) OVERRIDE
;
71 virtual void DeactivateDataType(syncer::ModelType type
) OVERRIDE
;
73 virtual syncer::UserShare
* GetUserShare() const OVERRIDE
;
75 virtual Status
GetDetailedStatus() OVERRIDE
;
77 virtual syncer::sessions::SyncSessionSnapshot
78 GetLastSessionSnapshot() const OVERRIDE
;
80 virtual bool HasUnsyncedItems() const OVERRIDE
;
82 virtual bool IsNigoriEnabled() const OVERRIDE
;
84 virtual syncer::PassphraseType
GetPassphraseType() const OVERRIDE
;
86 virtual base::Time
GetExplicitPassphraseTime() const OVERRIDE
;
88 virtual bool IsCryptographerReady(
89 const syncer::BaseTransaction
* trans
) const OVERRIDE
;
91 virtual void GetModelSafeRoutingInfo(
92 syncer::ModelSafeRoutingInfo
* out
) const OVERRIDE
;
94 virtual SyncedDeviceTracker
* GetSyncedDeviceTracker() const OVERRIDE
;
96 virtual base::MessageLoop
* GetSyncLoopForTesting() OVERRIDE
;
98 void set_fail_initial_download(bool should_fail
);
101 bool fail_initial_download_
;
104 } // namespace browser_sync
106 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H_