[email protected] | 99e652f | 2012-01-22 04:05:07 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
maxbogue | 26f4022 | 2016-09-16 20:22:18 | [diff] [blame] | 5 | #ifndef COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_ |
| 6 | #define COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_ |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 7 | |
David Roger | f61bb39 | 2018-02-13 09:00:27 | [diff] [blame] | 8 | #include <memory> |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 9 | #include <string> |
[email protected] | cd1acaf4 | 2013-08-02 22:35:26 | [diff] [blame] | 10 | #include <vector> |
[email protected] | 95f0fe74 | 2010-12-10 01:38:29 | [diff] [blame] | 11 | |
[email protected] | fa13487 | 2011-08-02 18:39:55 | [diff] [blame] | 12 | #include "base/memory/weak_ptr.h" |
[email protected] | 5461886 | 2013-06-10 20:37:09 | [diff] [blame] | 13 | #include "base/strings/string16.h" |
maxbogue | 26f4022 | 2016-09-16 20:22:18 | [diff] [blame] | 14 | #include "components/browser_sync/profile_sync_service.h" |
Max Bogue | fef332d | 2016-07-28 22:09:09 | [diff] [blame] | 15 | #include "components/sync/base/model_type.h" |
maxbogue | f1885f7d | 2016-08-16 19:13:20 | [diff] [blame] | 16 | #include "components/sync/device_info/device_info.h" |
maxbogue | 455a57e3 | 2016-08-14 00:08:32 | [diff] [blame] | 17 | #include "components/sync/driver/data_type_controller.h" |
maxbogue | 6c9a8fb0 | 2016-11-17 20:08:36 | [diff] [blame] | 18 | #include "components/sync/model/change_processor.h" |
Max Bogue | fef332d | 2016-07-28 22:09:09 | [diff] [blame] | 19 | #include "components/sync/protocol/sync_protocol_error.h" |
[email protected] | 6386cf5 | 2012-09-07 04:26:37 | [diff] [blame] | 20 | #include "google_apis/gaia/google_service_auth_error.h" |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 21 | #include "testing/gmock/include/gmock/gmock.h" |
| 22 | |
maxbogue | 0a37945 | 2016-09-22 21:35:05 | [diff] [blame] | 23 | namespace browser_sync { |
| 24 | |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 25 | class ProfileSyncServiceMock : public ProfileSyncService { |
| 26 | public: |
vabr | 596777d | 2015-12-09 15:54:04 | [diff] [blame] | 27 | explicit ProfileSyncServiceMock(InitParams init_params); |
| 28 | // The second constructor defers to the first one. Use it when you need to |
| 29 | // create a StrictMock or NiceMock of ProfileSyncServiceMock, because those |
| 30 | // template classes cannot handle the input class having constructors with |
| 31 | // arguments passed by value. Otherwise use the constructor above for cleaner |
| 32 | // code. |
| 33 | explicit ProfileSyncServiceMock(InitParams* init_params); |
| 34 | |
Daniel Cheng | 6784852 | 2018-04-27 22:04:41 | [diff] [blame] | 35 | ~ProfileSyncServiceMock() override; |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 36 | |
maxbogue | 27ff5590 | 2016-12-08 01:38:14 | [diff] [blame] | 37 | MOCK_METHOD5( |
maxbogue | 6b6f9f43 | 2016-12-05 23:59:14 | [diff] [blame] | 38 | OnEngineInitialized, |
maxbogue | 27ff5590 | 2016-12-08 01:38:14 | [diff] [blame] | 39 | void(syncer::ModelTypeSet initial_types, |
| 40 | const syncer::WeakHandle<syncer::JsBackend>&, |
[email protected] | 12a11e2 | 2012-11-08 06:26:30 | [diff] [blame] | 41 | const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&, |
[email protected] | d85f0ac4 | 2014-07-22 00:36:20 | [diff] [blame] | 42 | const std::string&, |
[email protected] | 12a11e2 | 2012-11-08 06:26:30 | [diff] [blame] | 43 | bool)); |
maxbogue | cbd4762 | 2017-01-13 04:24:17 | [diff] [blame] | 44 | MOCK_METHOD1(OnSyncCycleCompleted, void(const syncer::SyncCycleSnapshot&)); |
[email protected] | c8a61d09 | 2012-03-23 17:22:45 | [diff] [blame] | 45 | MOCK_METHOD2(OnUserChoseDatatypes, |
maxbogue | 26f4022 | 2016-09-16 20:22:18 | [diff] [blame] | 46 | void(bool sync_everything, syncer::ModelTypeSet chosen_types)); |
David Roger | f61bb39 | 2018-02-13 09:00:27 | [diff] [blame] | 47 | MOCK_METHOD0(SetFirstSetupComplete, void()); |
| 48 | MOCK_METHOD0(GetSetupInProgressHandle, |
| 49 | std::unique_ptr<syncer::SyncSetupInProgressHandle>()); |
[email protected] | c8a61d09 | 2012-03-23 17:22:45 | [diff] [blame] | 50 | |
[email protected] | f6ec8b2 | 2010-06-08 23:40:06 | [diff] [blame] | 51 | MOCK_METHOD2(OnUnrecoverableError, |
Brett Wilson | 190fd2ac | 2017-09-12 05:04:30 | [diff] [blame] | 52 | void(const base::Location& location, |
maxbogue | 26f4022 | 2016-09-16 20:22:18 | [diff] [blame] | 53 | const std::string& message)); |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 54 | MOCK_CONST_METHOD0(GetUserShare, syncer::UserShare*()); |
maxbogue | cd3fad6b | 2015-06-09 00:44:53 | [diff] [blame] | 55 | MOCK_METHOD0(RequestStart, void()); |
maxbogue | 699262c9 | 2015-06-19 19:24:58 | [diff] [blame] | 56 | MOCK_METHOD1(RequestStop, void(ProfileSyncService::SyncStopDataFate)); |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 57 | |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 58 | MOCK_METHOD1(AddObserver, void(syncer::SyncServiceObserver*)); |
| 59 | MOCK_METHOD1(RemoveObserver, void(syncer::SyncServiceObserver*)); |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 60 | MOCK_METHOD0(GetJsController, base::WeakPtr<syncer::JsController>()); |
maxbogue | fe00952a | 2016-01-19 19:02:01 | [diff] [blame] | 61 | MOCK_CONST_METHOD0(IsFirstSetupComplete, bool()); |
[email protected] | e78d74e | 2010-04-06 22:49:47 | [diff] [blame] | 62 | |
maxbogue | 81abdf2 | 2015-09-10 17:40:19 | [diff] [blame] | 63 | MOCK_CONST_METHOD0(IsEncryptEverythingAllowed, bool()); |
| 64 | MOCK_CONST_METHOD0(IsEncryptEverythingEnabled, bool()); |
[email protected] | c8a61d09 | 2012-03-23 17:22:45 | [diff] [blame] | 65 | MOCK_METHOD0(EnableEncryptEverything, void()); |
| 66 | |
[email protected] | e78d74e | 2010-04-06 22:49:47 | [diff] [blame] | 67 | MOCK_METHOD1(ChangePreferredDataTypes, |
[email protected] | a4a14765 | 2012-07-03 23:41:32 | [diff] [blame] | 68 | void(syncer::ModelTypeSet preferred_types)); |
[email protected] | 464d74a | 2013-06-04 07:36:46 | [diff] [blame] | 69 | MOCK_CONST_METHOD0(GetActiveDataTypes, syncer::ModelTypeSet()); |
[email protected] | a4a14765 | 2012-07-03 23:41:32 | [diff] [blame] | 70 | MOCK_CONST_METHOD0(GetPreferredDataTypes, syncer::ModelTypeSet()); |
| 71 | MOCK_CONST_METHOD0(GetRegisteredDataTypes, syncer::ModelTypeSet()); |
maxbogue | 3067278a | 2016-08-19 23:16:18 | [diff] [blame] | 72 | MOCK_CONST_METHOD0(GetLastCycleSnapshot, syncer::SyncCycleSnapshot()); |
[email protected] | f1e6e021 | 2010-10-15 20:54:24 | [diff] [blame] | 73 | |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 74 | MOCK_METHOD1(QueryDetailedSyncStatus, |
maxbogue | 6dcda76 | 2016-12-05 20:45:56 | [diff] [blame] | 75 | bool(syncer::SyncEngine::Status* result)); |
[email protected] | f5fb1750 | 2011-11-30 11:03:23 | [diff] [blame] | 76 | MOCK_CONST_METHOD0(GetAuthError, const GoogleServiceAuthError&()); |
maxbogue | 81abdf2 | 2015-09-10 17:40:19 | [diff] [blame] | 77 | MOCK_CONST_METHOD0(IsFirstSetupInProgress, bool()); |
Steven Holte | 30dd3b6 | 2017-10-11 06:58:56 | [diff] [blame] | 78 | MOCK_CONST_METHOD0(GetLastSyncedTime, base::Time()); |
[email protected] | e1c6f126 | 2012-06-14 23:40:10 | [diff] [blame] | 79 | MOCK_CONST_METHOD0(HasUnrecoverableError, bool()); |
maxbogue | 192b360 | 2015-06-04 00:33:55 | [diff] [blame] | 80 | MOCK_CONST_METHOD0(IsSyncActive, bool()); |
maxbogue | 6b6f9f43 | 2016-12-05 23:59:14 | [diff] [blame] | 81 | MOCK_CONST_METHOD0(IsEngineInitialized, bool()); |
maxbogue | cd3fad6b | 2015-06-09 00:44:53 | [diff] [blame] | 82 | MOCK_CONST_METHOD0(IsSyncRequested, bool()); |
pnoland | 0c1d266 | 2017-06-12 20:49:29 | [diff] [blame] | 83 | MOCK_CONST_METHOD0(IsSyncConfirmationNeeded, bool()); |
[email protected] | a41e100e | 2012-02-23 17:59:24 | [diff] [blame] | 84 | MOCK_CONST_METHOD0(waiting_for_auth, bool()); |
bauerb | f03588b9 | 2014-10-27 13:40:15 | [diff] [blame] | 85 | MOCK_METHOD1(OnActionableError, void(const syncer::SyncProtocolError&)); |
stanisc | 3724e60 | 2014-09-22 16:46:49 | [diff] [blame] | 86 | MOCK_CONST_METHOD1(IsDataTypeControllerRunning, bool(syncer::ModelType)); |
[email protected] | cd1acaf4 | 2013-08-02 22:35:26 | [diff] [blame] | 87 | |
sath | 0f51324 | 2017-03-29 19:57:09 | [diff] [blame] | 88 | MOCK_METHOD0(GetOpenTabsUIDelegateMock, sync_sessions::OpenTabsUIDelegate*()); |
| 89 | sync_sessions::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override; |
| 90 | |
[email protected] | 1db7bae | 2012-08-17 22:37:02 | [diff] [blame] | 91 | // DataTypeManagerObserver mocks. |
[email protected] | 1db7bae | 2012-08-17 22:37:02 | [diff] [blame] | 92 | MOCK_METHOD1(OnConfigureDone, |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 93 | void(const syncer::DataTypeManager::ConfigureResult&)); |
[email protected] | 1db7bae | 2012-08-17 22:37:02 | [diff] [blame] | 94 | MOCK_METHOD0(OnConfigureStart, void()); |
| 95 | |
maxbogue | 96b7d27 | 2015-06-16 02:59:58 | [diff] [blame] | 96 | MOCK_CONST_METHOD0(CanSyncStart, bool()); |
[email protected] | 08fafe4 | 2013-02-03 08:10:49 | [diff] [blame] | 97 | MOCK_CONST_METHOD0(IsManaged, bool()); |
[email protected] | a41e100e | 2012-02-23 17:59:24 | [diff] [blame] | 98 | |
[email protected] | 83c130c | 2011-10-12 08:39:16 | [diff] [blame] | 99 | MOCK_CONST_METHOD0(IsPassphraseRequired, bool()); |
| 100 | MOCK_CONST_METHOD0(IsPassphraseRequiredForDecryption, bool()); |
[email protected] | c8a61d09 | 2012-03-23 17:22:45 | [diff] [blame] | 101 | MOCK_CONST_METHOD0(IsUsingSecondaryPassphrase, bool()); |
[email protected] | f6661cc | 2012-10-12 02:22:43 | [diff] [blame] | 102 | MOCK_CONST_METHOD0(GetPassphraseType, syncer::PassphraseType()); |
[email protected] | a374519 | 2013-04-03 03:55:44 | [diff] [blame] | 103 | MOCK_CONST_METHOD0(GetExplicitPassphraseTime, base::Time()); |
[email protected] | c8a61d09 | 2012-03-23 17:22:45 | [diff] [blame] | 104 | |
| 105 | MOCK_METHOD1(SetDecryptionPassphrase, bool(const std::string& passphrase)); |
maxbogue | 26f4022 | 2016-09-16 20:22:18 | [diff] [blame] | 106 | MOCK_METHOD2(SetEncryptionPassphrase, |
| 107 | void(const std::string& passphrase, PassphraseType type)); |
tommycli | f3a1551e | 2016-06-21 18:11:23 | [diff] [blame] | 108 | |
| 109 | MOCK_METHOD0(OnSetupInProgressHandleDestroyed, void()); |
David Roger | f61bb39 | 2018-02-13 09:00:27 | [diff] [blame] | 110 | |
| 111 | // Gives access to the real implementation of ProfileSyncService methods: |
| 112 | std::unique_ptr<syncer::SyncSetupInProgressHandle> |
| 113 | GetSetupInProgressHandleConcrete(); |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 114 | }; |
| 115 | |
maxbogue | 0a37945 | 2016-09-22 21:35:05 | [diff] [blame] | 116 | } // namespace browser_sync |
| 117 | |
maxbogue | 26f4022 | 2016-09-16 20:22:18 | [diff] [blame] | 118 | #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_ |