- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / profile_sync_service_mock.h
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.
4
5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/sync/glue/change_processor.h"
14 #include "chrome/browser/sync/glue/data_type_controller.h"
15 #include "chrome/browser/sync/glue/device_info.h"
16 #include "chrome/browser/sync/profile_sync_service.h"
17 #include "chrome/test/base/testing_profile.h"
18 #include "google_apis/gaia/google_service_auth_error.h"
19 #include "sync/internal_api/public/base/model_type.h"
20 #include "sync/protocol/sync_protocol_error.h"
21 #include "testing/gmock/include/gmock/gmock.h"
22
23 using ::testing::Invoke;
24
25 class ProfileSyncServiceMock : public ProfileSyncService {
26  public:
27   // no-arg constructor provided so TestingProfile can use NiceMock.
28   ProfileSyncServiceMock();
29   explicit ProfileSyncServiceMock(Profile* profile);
30   virtual ~ProfileSyncServiceMock();
31
32   // A utility used by sync tests to create a TestingProfile with a Google
33   // Services username stored in a (Testing)PrefService.
34   static TestingProfile* MakeSignedInTestingProfile();
35
36   // Helper routine to be used in conjunction with
37   // BrowserContextKeyedServiceFactory::SetTestingFactory().
38   static BrowserContextKeyedService* BuildMockProfileSyncService(
39       content::BrowserContext* profile);
40
41   MOCK_METHOD0(DisableForUser, void());
42   MOCK_METHOD3(OnBackendInitialized,
43       void(const syncer::WeakHandle<syncer::JsBackend>&,
44            const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&,
45            bool));
46   MOCK_METHOD0(OnSyncCycleCompleted, void());
47   MOCK_METHOD0(OnAuthError, void());
48   MOCK_METHOD4(OnUserSubmittedAuth,
49                void(const std::string& username,
50                     const std::string& password,
51                     const std::string& captcha,
52                     const std::string& access_code));
53   MOCK_METHOD0(OnUserCancelledDialog, void());
54   MOCK_CONST_METHOD0(GetAuthenticatedUsername, string16());
55   MOCK_METHOD2(OnUserChoseDatatypes,
56                void(bool sync_everything,
57                     syncer::ModelTypeSet chosen_types));
58
59   MOCK_METHOD2(OnUnrecoverableError,
60                void(const tracked_objects::Location& location,
61                const std::string& message));
62   MOCK_METHOD3(DisableBrokenDatatype, void(syncer::ModelType,
63                const tracked_objects::Location&,
64                std::string message));
65   MOCK_CONST_METHOD0(GetUserShare, syncer::UserShare*());
66   MOCK_METHOD3(ActivateDataType,
67                void(syncer::ModelType, syncer::ModelSafeGroup,
68                     browser_sync::ChangeProcessor*));
69   MOCK_METHOD1(DeactivateDataType, void(syncer::ModelType));
70   MOCK_METHOD0(UnsuppressAndStart, void());
71
72   MOCK_METHOD1(AddObserver, void(ProfileSyncServiceBase::Observer*));
73   MOCK_METHOD1(RemoveObserver, void(ProfileSyncServiceBase::Observer*));
74   MOCK_METHOD0(GetJsController, base::WeakPtr<syncer::JsController>());
75   MOCK_CONST_METHOD0(HasSyncSetupCompleted, bool());
76
77   MOCK_CONST_METHOD0(EncryptEverythingEnabled, bool());
78   MOCK_METHOD0(EnableEncryptEverything, void());
79
80   MOCK_METHOD1(ChangePreferredDataTypes,
81                void(syncer::ModelTypeSet preferred_types));
82   MOCK_CONST_METHOD0(GetActiveDataTypes, syncer::ModelTypeSet());
83   MOCK_CONST_METHOD0(GetPreferredDataTypes, syncer::ModelTypeSet());
84   MOCK_CONST_METHOD0(GetRegisteredDataTypes, syncer::ModelTypeSet());
85   MOCK_CONST_METHOD0(GetLastSessionSnapshot,
86                      syncer::sessions::SyncSessionSnapshot());
87
88   MOCK_METHOD1(QueryDetailedSyncStatus,
89                bool(browser_sync::SyncBackendHost::Status* result));
90   MOCK_CONST_METHOD0(GetAuthError, const GoogleServiceAuthError&());
91   MOCK_CONST_METHOD0(FirstSetupInProgress, bool());
92   MOCK_CONST_METHOD0(GetLastSyncedTimeString, string16());
93   MOCK_CONST_METHOD0(HasUnrecoverableError, bool());
94   MOCK_CONST_METHOD0(sync_initialized, bool());
95   MOCK_CONST_METHOD0(IsStartSuppressed, bool());
96   MOCK_CONST_METHOD0(waiting_for_auth, bool());
97   MOCK_METHOD1(OnActionableError, void(
98       const syncer::SyncProtocolError&));
99   MOCK_METHOD1(SetSetupInProgress, void(bool));
100
101   MOCK_METHOD0(GetSessionModelAssociator,
102                browser_sync::SessionModelAssociator*());
103   MOCK_CONST_METHOD0(GetAllSignedInDevicesMock,
104                      std::vector<browser_sync::DeviceInfo*>* ());
105   // This is to get around the fact that GMOCK does not handle Scoped*.
106   virtual ScopedVector<browser_sync::DeviceInfo>
107       GetAllSignedInDevices() const OVERRIDE;
108
109   // DataTypeManagerObserver mocks.
110   MOCK_METHOD0(OnConfigureBlocked, void());
111   MOCK_METHOD1(OnConfigureDone,
112                void(const browser_sync::DataTypeManager::ConfigureResult&));
113   MOCK_METHOD0(OnConfigureRetry, void());
114   MOCK_METHOD0(OnConfigureStart, void());
115
116   MOCK_METHOD0(IsSyncEnabledAndLoggedIn, bool());
117   MOCK_CONST_METHOD0(IsManaged, bool());
118   MOCK_METHOD0(IsOAuthRefreshTokenAvailable, bool());
119
120   MOCK_CONST_METHOD0(IsPassphraseRequired, bool());
121   MOCK_CONST_METHOD0(IsPassphraseRequiredForDecryption, bool());
122   MOCK_CONST_METHOD0(IsUsingSecondaryPassphrase, bool());
123   MOCK_CONST_METHOD0(GetPassphraseType, syncer::PassphraseType());
124   MOCK_CONST_METHOD0(GetPassphraseTime, base::Time());
125   MOCK_CONST_METHOD0(GetExplicitPassphraseTime, base::Time());
126
127   MOCK_METHOD1(SetDecryptionPassphrase, bool(const std::string& passphrase));
128   MOCK_METHOD2(SetEncryptionPassphrase, void(const std::string& passphrase,
129                                              PassphraseType type));
130 };
131
132 #endif  // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_MOCK_H_