1 // Copyright (c) 2012 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_PROFILE_SYNC_SERVICE_MOCK_H_
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14 #include "chrome/browser/sync/profile_sync_service.h"
15 #include "chrome/test/base/testing_profile.h"
16 #include "components/sync_driver/change_processor.h"
17 #include "components/sync_driver/data_type_controller.h"
18 #include "components/sync_driver/device_info.h"
19 #include "google_apis/gaia/google_service_auth_error.h"
20 #include "sync/internal_api/public/base/model_type.h"
21 #include "sync/protocol/sync_protocol_error.h"
22 #include "testing/gmock/include/gmock/gmock.h"
24 using ::testing::Invoke
;
26 class ProfileSyncServiceMock
: public ProfileSyncService
{
28 explicit ProfileSyncServiceMock(Profile
* profile
);
29 ProfileSyncServiceMock(
30 scoped_ptr
<sync_driver::SyncApiComponentFactory
> factory
,
32 virtual ~ProfileSyncServiceMock();
34 // A utility used by sync tests to create a TestingProfile with a Google
35 // Services username stored in a (Testing)PrefService.
36 static TestingProfile
* MakeSignedInTestingProfile();
38 // Helper routine to be used in conjunction with
39 // BrowserContextKeyedServiceFactory::SetTestingFactory().
40 static scoped_ptr
<KeyedService
> BuildMockProfileSyncService(
41 content::BrowserContext
* profile
);
43 MOCK_METHOD4(OnBackendInitialized
,
44 void(const syncer::WeakHandle
<syncer::JsBackend
>&,
45 const syncer::WeakHandle
<syncer::DataTypeDebugInfoListener
>&,
48 MOCK_METHOD0(OnSyncCycleCompleted
, void());
49 MOCK_METHOD0(OnAuthError
, void());
50 MOCK_METHOD4(OnUserSubmittedAuth
,
51 void(const std::string
& username
,
52 const std::string
& password
,
53 const std::string
& captcha
,
54 const std::string
& access_code
));
55 MOCK_METHOD0(OnUserCancelledDialog
, void());
56 MOCK_CONST_METHOD0(GetAuthenticatedUsername
, base::string16());
57 MOCK_METHOD2(OnUserChoseDatatypes
,
58 void(bool sync_everything
,
59 syncer::ModelTypeSet chosen_types
));
61 MOCK_METHOD2(OnUnrecoverableError
,
62 void(const tracked_objects::Location
& location
,
63 const std::string
& message
));
64 MOCK_METHOD1(DisableDatatype
, void(const syncer::SyncError
&));
65 MOCK_CONST_METHOD0(GetUserShare
, syncer::UserShare
*());
66 MOCK_METHOD1(DeactivateDataType
, void(syncer::ModelType
));
67 MOCK_METHOD0(RequestStart
, void());
68 MOCK_METHOD1(RequestStop
, void(ProfileSyncService::SyncStopDataFate
));
70 MOCK_METHOD1(AddObserver
, void(sync_driver::SyncServiceObserver
*));
71 MOCK_METHOD1(RemoveObserver
, void(sync_driver::SyncServiceObserver
*));
72 MOCK_METHOD0(GetJsController
, base::WeakPtr
<syncer::JsController
>());
73 MOCK_CONST_METHOD0(HasSyncSetupCompleted
, bool());
75 MOCK_CONST_METHOD0(EncryptEverythingAllowed
, bool());
76 MOCK_CONST_METHOD0(EncryptEverythingEnabled
, bool());
77 MOCK_METHOD0(EnableEncryptEverything
, void());
79 MOCK_METHOD1(ChangePreferredDataTypes
,
80 void(syncer::ModelTypeSet preferred_types
));
81 MOCK_CONST_METHOD0(GetActiveDataTypes
, syncer::ModelTypeSet());
82 MOCK_CONST_METHOD0(GetPreferredDataTypes
, syncer::ModelTypeSet());
83 MOCK_CONST_METHOD0(GetRegisteredDataTypes
, syncer::ModelTypeSet());
84 MOCK_CONST_METHOD0(GetLastSessionSnapshot
,
85 syncer::sessions::SyncSessionSnapshot());
87 MOCK_METHOD1(QueryDetailedSyncStatus
,
88 bool(browser_sync::SyncBackendHost::Status
* result
));
89 MOCK_CONST_METHOD0(GetAuthError
, const GoogleServiceAuthError
&());
90 MOCK_CONST_METHOD0(FirstSetupInProgress
, bool());
91 MOCK_CONST_METHOD0(GetLastSyncedTimeString
, base::string16());
92 MOCK_CONST_METHOD0(HasUnrecoverableError
, bool());
93 MOCK_CONST_METHOD0(IsSyncActive
, bool());
94 MOCK_CONST_METHOD0(backend_initialized
, bool());
95 MOCK_CONST_METHOD0(IsSyncRequested
, bool());
96 MOCK_CONST_METHOD0(waiting_for_auth
, bool());
97 MOCK_METHOD1(OnActionableError
, void(const syncer::SyncProtocolError
&));
98 MOCK_METHOD1(SetSetupInProgress
, void(bool));
99 MOCK_CONST_METHOD1(IsDataTypeControllerRunning
, bool(syncer::ModelType
));
101 // DataTypeManagerObserver mocks.
102 MOCK_METHOD0(OnConfigureBlocked
, void());
103 MOCK_METHOD1(OnConfigureDone
,
104 void(const sync_driver::DataTypeManager::ConfigureResult
&));
105 MOCK_METHOD0(OnConfigureStart
, void());
107 MOCK_CONST_METHOD0(CanSyncStart
, bool());
108 MOCK_CONST_METHOD0(IsManaged
, bool());
109 MOCK_METHOD0(IsOAuthRefreshTokenAvailable
, bool());
111 MOCK_CONST_METHOD0(IsPassphraseRequired
, bool());
112 MOCK_CONST_METHOD0(IsPassphraseRequiredForDecryption
, bool());
113 MOCK_CONST_METHOD0(IsUsingSecondaryPassphrase
, bool());
114 MOCK_CONST_METHOD0(GetPassphraseType
, syncer::PassphraseType());
115 MOCK_CONST_METHOD0(GetPassphraseTime
, base::Time());
116 MOCK_CONST_METHOD0(GetExplicitPassphraseTime
, base::Time());
118 MOCK_METHOD1(SetDecryptionPassphrase
, bool(const std::string
& passphrase
));
119 MOCK_METHOD2(SetEncryptionPassphrase
, void(const std::string
& passphrase
,
120 PassphraseType type
));
122 MOCK_METHOD1(StartUpSlowBackendComponents
, void(BackendMode
));
125 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_