[Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions.
[chromium-blink-merge.git] / chrome / browser / sync / profile_sync_service_mock.h
blob96c39ee2b196a846936fad5c7f007d55f8673411
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_
8 #include <string>
9 #include <vector>
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 {
27 public:
28 explicit ProfileSyncServiceMock(Profile* profile);
29 ProfileSyncServiceMock(
30 scoped_ptr<ProfileSyncComponentsFactory> factory, Profile* profile);
31 virtual ~ProfileSyncServiceMock();
33 // A utility used by sync tests to create a TestingProfile with a Google
34 // Services username stored in a (Testing)PrefService.
35 static TestingProfile* MakeSignedInTestingProfile();
37 // Helper routine to be used in conjunction with
38 // BrowserContextKeyedServiceFactory::SetTestingFactory().
39 static scoped_ptr<KeyedService> BuildMockProfileSyncService(
40 content::BrowserContext* profile);
42 MOCK_METHOD0(DisableForUser, void());
43 MOCK_METHOD4(OnBackendInitialized,
44 void(const syncer::WeakHandle<syncer::JsBackend>&,
45 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&,
46 const std::string&,
47 bool));
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());
69 MOCK_METHOD1(AddObserver, void(sync_driver::SyncServiceObserver*));
70 MOCK_METHOD1(RemoveObserver, void(sync_driver::SyncServiceObserver*));
71 MOCK_METHOD0(GetJsController, base::WeakPtr<syncer::JsController>());
72 MOCK_CONST_METHOD0(HasSyncSetupCompleted, bool());
74 MOCK_CONST_METHOD0(EncryptEverythingAllowed, bool());
75 MOCK_CONST_METHOD0(EncryptEverythingEnabled, bool());
76 MOCK_METHOD0(EnableEncryptEverything, void());
78 MOCK_METHOD1(ChangePreferredDataTypes,
79 void(syncer::ModelTypeSet preferred_types));
80 MOCK_CONST_METHOD0(GetActiveDataTypes, syncer::ModelTypeSet());
81 MOCK_CONST_METHOD0(GetPreferredDataTypes, syncer::ModelTypeSet());
82 MOCK_CONST_METHOD0(GetRegisteredDataTypes, syncer::ModelTypeSet());
83 MOCK_CONST_METHOD0(GetLastSessionSnapshot,
84 syncer::sessions::SyncSessionSnapshot());
86 MOCK_METHOD1(QueryDetailedSyncStatus,
87 bool(browser_sync::SyncBackendHost::Status* result));
88 MOCK_CONST_METHOD0(GetAuthError, const GoogleServiceAuthError&());
89 MOCK_CONST_METHOD0(FirstSetupInProgress, bool());
90 MOCK_CONST_METHOD0(GetLastSyncedTimeString, base::string16());
91 MOCK_CONST_METHOD0(HasUnrecoverableError, bool());
92 MOCK_CONST_METHOD0(IsSyncActive, bool());
93 MOCK_CONST_METHOD0(backend_initialized, bool());
94 MOCK_CONST_METHOD0(IsSyncRequested, bool());
95 MOCK_CONST_METHOD0(waiting_for_auth, bool());
96 MOCK_METHOD1(OnActionableError, void(const syncer::SyncProtocolError&));
97 MOCK_METHOD1(SetSetupInProgress, void(bool));
98 MOCK_CONST_METHOD1(IsDataTypeControllerRunning, bool(syncer::ModelType));
100 // DataTypeManagerObserver mocks.
101 MOCK_METHOD0(OnConfigureBlocked, void());
102 MOCK_METHOD1(OnConfigureDone,
103 void(const sync_driver::DataTypeManager::ConfigureResult&));
104 MOCK_METHOD0(OnConfigureStart, void());
106 MOCK_METHOD0(IsSyncEnabledAndLoggedIn, bool());
107 MOCK_CONST_METHOD0(IsManaged, bool());
108 MOCK_METHOD0(IsOAuthRefreshTokenAvailable, bool());
110 MOCK_CONST_METHOD0(IsPassphraseRequired, bool());
111 MOCK_CONST_METHOD0(IsPassphraseRequiredForDecryption, bool());
112 MOCK_CONST_METHOD0(IsUsingSecondaryPassphrase, bool());
113 MOCK_CONST_METHOD0(GetPassphraseType, syncer::PassphraseType());
114 MOCK_CONST_METHOD0(GetPassphraseTime, base::Time());
115 MOCK_CONST_METHOD0(GetExplicitPassphraseTime, base::Time());
117 MOCK_METHOD1(SetDecryptionPassphrase, bool(const std::string& passphrase));
118 MOCK_METHOD2(SetEncryptionPassphrase, void(const std::string& passphrase,
119 PassphraseType type));
121 MOCK_METHOD1(StartUpSlowBackendComponents, void(BackendMode));
124 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_