OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_ |
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "chrome/browser/sync/glue/device_info.h" | 13 #include "chrome/browser/sync/glue/device_info.h" |
14 #include "chrome/browser/sync/profile_sync_service.h" | 14 #include "chrome/browser/sync/profile_sync_service.h" |
15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
16 #include "components/sync_driver/change_processor.h" | 16 #include "components/sync_driver/change_processor.h" |
17 #include "components/sync_driver/data_type_controller.h" | 17 #include "components/sync_driver/data_type_controller.h" |
18 #include "google_apis/gaia/google_service_auth_error.h" | 18 #include "google_apis/gaia/google_service_auth_error.h" |
19 #include "sync/internal_api/public/base/model_type.h" | 19 #include "sync/internal_api/public/base/model_type.h" |
20 #include "sync/protocol/sync_protocol_error.h" | 20 #include "sync/protocol/sync_protocol_error.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
22 | 22 |
23 using ::testing::Invoke; | 23 using ::testing::Invoke; |
24 | 24 |
25 class ProfileSyncServiceMock : public ProfileSyncService { | 25 class ProfileSyncServiceMock : public ProfileSyncService { |
26 public: | 26 public: |
27 explicit ProfileSyncServiceMock(Profile* profile); | 27 explicit ProfileSyncServiceMock(Profile* profile); |
| 28 ProfileSyncServiceMock( |
| 29 scoped_ptr<ProfileSyncComponentsFactory> factory, Profile* profile); |
28 virtual ~ProfileSyncServiceMock(); | 30 virtual ~ProfileSyncServiceMock(); |
29 | 31 |
30 // A utility used by sync tests to create a TestingProfile with a Google | 32 // A utility used by sync tests to create a TestingProfile with a Google |
31 // Services username stored in a (Testing)PrefService. | 33 // Services username stored in a (Testing)PrefService. |
32 static TestingProfile* MakeSignedInTestingProfile(); | 34 static TestingProfile* MakeSignedInTestingProfile(); |
33 | 35 |
34 // Helper routine to be used in conjunction with | 36 // Helper routine to be used in conjunction with |
35 // BrowserContextKeyedServiceFactory::SetTestingFactory(). | 37 // BrowserContextKeyedServiceFactory::SetTestingFactory(). |
36 static KeyedService* BuildMockProfileSyncService( | 38 static KeyedService* BuildMockProfileSyncService( |
37 content::BrowserContext* profile); | 39 content::BrowserContext* profile); |
38 | 40 |
39 MOCK_METHOD0(DisableForUser, void()); | 41 MOCK_METHOD0(DisableForUser, void()); |
40 MOCK_METHOD3(OnBackendInitialized, | 42 MOCK_METHOD4(OnBackendInitialized, |
41 void(const syncer::WeakHandle<syncer::JsBackend>&, | 43 void(const syncer::WeakHandle<syncer::JsBackend>&, |
42 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&, | 44 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&, |
| 45 const std::string&, |
43 bool)); | 46 bool)); |
44 MOCK_METHOD0(OnSyncCycleCompleted, void()); | 47 MOCK_METHOD0(OnSyncCycleCompleted, void()); |
45 MOCK_METHOD0(OnAuthError, void()); | 48 MOCK_METHOD0(OnAuthError, void()); |
46 MOCK_METHOD4(OnUserSubmittedAuth, | 49 MOCK_METHOD4(OnUserSubmittedAuth, |
47 void(const std::string& username, | 50 void(const std::string& username, |
48 const std::string& password, | 51 const std::string& password, |
49 const std::string& captcha, | 52 const std::string& captcha, |
50 const std::string& access_code)); | 53 const std::string& access_code)); |
51 MOCK_METHOD0(OnUserCancelledDialog, void()); | 54 MOCK_METHOD0(OnUserCancelledDialog, void()); |
52 MOCK_CONST_METHOD0(GetAuthenticatedUsername, base::string16()); | 55 MOCK_CONST_METHOD0(GetAuthenticatedUsername, base::string16()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 const syncer::SyncProtocolError&)); | 94 const syncer::SyncProtocolError&)); |
92 MOCK_METHOD1(SetSetupInProgress, void(bool)); | 95 MOCK_METHOD1(SetSetupInProgress, void(bool)); |
93 MOCK_CONST_METHOD0(IsSessionsDataTypeControllerRunning, bool()); | 96 MOCK_CONST_METHOD0(IsSessionsDataTypeControllerRunning, bool()); |
94 | 97 |
95 MOCK_CONST_METHOD0(GetAllSignedInDevicesMock, | 98 MOCK_CONST_METHOD0(GetAllSignedInDevicesMock, |
96 std::vector<browser_sync::DeviceInfo*>* ()); | 99 std::vector<browser_sync::DeviceInfo*>* ()); |
97 // This is to get around the fact that GMOCK does not handle Scoped*. | 100 // This is to get around the fact that GMOCK does not handle Scoped*. |
98 virtual ScopedVector<browser_sync::DeviceInfo> | 101 virtual ScopedVector<browser_sync::DeviceInfo> |
99 GetAllSignedInDevices() const OVERRIDE; | 102 GetAllSignedInDevices() const OVERRIDE; |
100 | 103 |
101 virtual scoped_ptr<browser_sync::DeviceInfo> GetLocalDeviceInfo() | |
102 const OVERRIDE; | |
103 MOCK_CONST_METHOD0(GetLocalDeviceInfoMock, | |
104 browser_sync::DeviceInfo*()); | |
105 MOCK_CONST_METHOD0(GetLocalSyncCacheGUID, std::string()); | |
106 | |
107 // DataTypeManagerObserver mocks. | 104 // DataTypeManagerObserver mocks. |
108 MOCK_METHOD0(OnConfigureBlocked, void()); | 105 MOCK_METHOD0(OnConfigureBlocked, void()); |
109 MOCK_METHOD1(OnConfigureDone, | 106 MOCK_METHOD1(OnConfigureDone, |
110 void(const browser_sync::DataTypeManager::ConfigureResult&)); | 107 void(const browser_sync::DataTypeManager::ConfigureResult&)); |
111 MOCK_METHOD0(OnConfigureRetry, void()); | 108 MOCK_METHOD0(OnConfigureRetry, void()); |
112 MOCK_METHOD0(OnConfigureStart, void()); | 109 MOCK_METHOD0(OnConfigureStart, void()); |
113 | 110 |
114 MOCK_METHOD0(IsSyncEnabledAndLoggedIn, bool()); | 111 MOCK_METHOD0(IsSyncEnabledAndLoggedIn, bool()); |
115 MOCK_CONST_METHOD0(IsManaged, bool()); | 112 MOCK_CONST_METHOD0(IsManaged, bool()); |
116 MOCK_METHOD0(IsOAuthRefreshTokenAvailable, bool()); | 113 MOCK_METHOD0(IsOAuthRefreshTokenAvailable, bool()); |
117 | 114 |
118 MOCK_CONST_METHOD0(IsPassphraseRequired, bool()); | 115 MOCK_CONST_METHOD0(IsPassphraseRequired, bool()); |
119 MOCK_CONST_METHOD0(IsPassphraseRequiredForDecryption, bool()); | 116 MOCK_CONST_METHOD0(IsPassphraseRequiredForDecryption, bool()); |
120 MOCK_CONST_METHOD0(IsUsingSecondaryPassphrase, bool()); | 117 MOCK_CONST_METHOD0(IsUsingSecondaryPassphrase, bool()); |
121 MOCK_CONST_METHOD0(GetPassphraseType, syncer::PassphraseType()); | 118 MOCK_CONST_METHOD0(GetPassphraseType, syncer::PassphraseType()); |
122 MOCK_CONST_METHOD0(GetPassphraseTime, base::Time()); | 119 MOCK_CONST_METHOD0(GetPassphraseTime, base::Time()); |
123 MOCK_CONST_METHOD0(GetExplicitPassphraseTime, base::Time()); | 120 MOCK_CONST_METHOD0(GetExplicitPassphraseTime, base::Time()); |
124 | 121 |
125 MOCK_METHOD1(SetDecryptionPassphrase, bool(const std::string& passphrase)); | 122 MOCK_METHOD1(SetDecryptionPassphrase, bool(const std::string& passphrase)); |
126 MOCK_METHOD2(SetEncryptionPassphrase, void(const std::string& passphrase, | 123 MOCK_METHOD2(SetEncryptionPassphrase, void(const std::string& passphrase, |
127 PassphraseType type)); | 124 PassphraseType type)); |
128 | 125 |
129 MOCK_METHOD1(StartUpSlowBackendComponents, void(BackendMode)); | 126 MOCK_METHOD1(StartUpSlowBackendComponents, void(BackendMode)); |
130 }; | 127 }; |
131 | 128 |
132 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_ | 129 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_ |
OLD | NEW |