Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / sync / test_profile_sync_service.h
blob890f699c422c7819cff11a6e9fec8a184bef32fd
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_TEST_PROFILE_SYNC_SERVICE_H_
6 #define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
14 #include "chrome/browser/sync/profile_sync_service.h"
15 #include "components/signin/core/browser/profile_oauth2_token_service.h"
16 #include "components/sync_driver/data_type_manager_impl.h"
17 #include "components/sync_driver/sync_prefs.h"
18 #include "sync/test/engine/test_id_factory.h"
19 #include "testing/gmock/include/gmock/gmock.h"
21 class Profile;
22 class ProfileOAuth2TokenService;
23 class ProfileSyncComponentsFactory;
24 class ProfileSyncComponentsFactoryMock;
26 ACTION(ReturnNewDataTypeManager) {
27 return new sync_driver::DataTypeManagerImpl(base::Closure(),
28 arg0,
29 arg1,
30 arg2,
31 arg3,
32 arg4);
35 namespace browser_sync {
37 class SyncBackendHostForProfileSyncTest : public SyncBackendHostImpl {
38 public:
39 SyncBackendHostForProfileSyncTest(
40 Profile* profile,
41 invalidation::InvalidationService* invalidator,
42 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs,
43 base::Closure callback);
44 ~SyncBackendHostForProfileSyncTest() override;
46 void RequestConfigureSyncer(
47 syncer::ConfigureReason reason,
48 syncer::ModelTypeSet to_download,
49 syncer::ModelTypeSet to_purge,
50 syncer::ModelTypeSet to_journal,
51 syncer::ModelTypeSet to_unapply,
52 syncer::ModelTypeSet to_ignore,
53 const syncer::ModelSafeRoutingInfo& routing_info,
54 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
55 ready_task,
56 const base::Closure& retry_callback) override;
58 protected:
59 void InitCore(scoped_ptr<DoInitializeOptions> options) override;
61 private:
62 // Invoked at the start of HandleSyncManagerInitializationOnFrontendLoop.
63 // Allows extra initialization work to be performed before the backend comes
64 // up.
65 base::Closure callback_;
68 } // namespace browser_sync
70 class TestProfileSyncService : public ProfileSyncService {
71 public:
72 // TODO(tim): Add ability to inject TokenService alongside SigninManager.
73 // TODO(rogerta): what does above comment mean?
74 TestProfileSyncService(
75 scoped_ptr<ProfileSyncComponentsFactory> factory,
76 Profile* profile,
77 SigninManagerBase* signin,
78 ProfileOAuth2TokenService* oauth2_token_service,
79 browser_sync::ProfileSyncServiceStartBehavior behavior);
81 ~TestProfileSyncService() override;
83 void OnConfigureDone(
84 const sync_driver::DataTypeManager::ConfigureResult& result) override;
86 // We implement our own version to avoid some DCHECKs.
87 syncer::UserShare* GetUserShare() const override;
89 static TestProfileSyncService* BuildAutoStartAsyncInit(
90 Profile* profile, base::Closure callback);
92 ProfileSyncComponentsFactoryMock* components_factory_mock();
94 syncer::TestIdFactory* id_factory();
96 // Raise visibility to ease testing.
97 using ProfileSyncService::NotifyObservers;
99 protected:
100 static scoped_ptr<KeyedService> TestFactoryFunction(
101 content::BrowserContext* profile);
103 // Return NULL handle to use in backend initialization to avoid receiving
104 // js messages on UI loop when it's being destroyed, which are not deleted
105 // and cause memory leak in test.
106 syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler() override;
108 bool NeedBackup() const override;
110 private:
111 syncer::TestIdFactory id_factory_;
114 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_