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_TEST_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
6 #define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" | 13 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" |
14 #include "chrome/browser/sync/profile_sync_service.h" | 14 #include "chrome/browser/sync/profile_sync_service.h" |
15 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 15 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
16 #include "components/sync_driver/data_type_manager_impl.h" | 16 #include "components/sync_driver/data_type_manager_impl.h" |
17 #include "components/sync_driver/sync_prefs.h" | 17 #include "components/sync_driver/sync_prefs.h" |
18 #include "sync/test/engine/test_id_factory.h" | 18 #include "sync/test/engine/test_id_factory.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 | 20 |
21 class Profile; | 21 class Profile; |
22 class ProfileOAuth2TokenService; | 22 class ProfileOAuth2TokenService; |
23 class ProfileSyncComponentsFactory; | 23 class ProfileSyncComponentsFactory; |
24 class ProfileSyncComponentsFactoryMock; | 24 class ProfileSyncComponentsFactoryMock; |
25 | 25 |
26 ACTION(ReturnNewDataTypeManager) { | 26 ACTION(ReturnNewDataTypeManager) { |
27 return new browser_sync::DataTypeManagerImpl(base::Closure(), | 27 return new sync_driver::DataTypeManagerImpl(base::Closure(), |
28 arg0, | 28 arg0, |
29 arg1, | 29 arg1, |
30 arg2, | 30 arg2, |
31 arg3, | 31 arg3, |
32 arg4, | 32 arg4, |
33 arg5); | 33 arg5); |
34 } | 34 } |
35 | 35 |
36 namespace browser_sync { | 36 namespace browser_sync { |
37 | 37 |
38 class SyncBackendHostForProfileSyncTest : public SyncBackendHostImpl { | 38 class SyncBackendHostForProfileSyncTest : public SyncBackendHostImpl { |
39 public: | 39 public: |
40 SyncBackendHostForProfileSyncTest( | 40 SyncBackendHostForProfileSyncTest( |
41 Profile* profile, | 41 Profile* profile, |
42 invalidation::InvalidationService* invalidator, | 42 invalidation::InvalidationService* invalidator, |
43 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | 43 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 TestProfileSyncService( | 75 TestProfileSyncService( |
76 scoped_ptr<ProfileSyncComponentsFactory> factory, | 76 scoped_ptr<ProfileSyncComponentsFactory> factory, |
77 Profile* profile, | 77 Profile* profile, |
78 SigninManagerBase* signin, | 78 SigninManagerBase* signin, |
79 ProfileOAuth2TokenService* oauth2_token_service, | 79 ProfileOAuth2TokenService* oauth2_token_service, |
80 browser_sync::ProfileSyncServiceStartBehavior behavior); | 80 browser_sync::ProfileSyncServiceStartBehavior behavior); |
81 | 81 |
82 virtual ~TestProfileSyncService(); | 82 virtual ~TestProfileSyncService(); |
83 | 83 |
84 virtual void OnConfigureDone( | 84 virtual void OnConfigureDone( |
85 const browser_sync::DataTypeManager::ConfigureResult& result) OVERRIDE; | 85 const sync_driver::DataTypeManager::ConfigureResult& result) OVERRIDE; |
86 | 86 |
87 // We implement our own version to avoid some DCHECKs. | 87 // We implement our own version to avoid some DCHECKs. |
88 virtual syncer::UserShare* GetUserShare() const OVERRIDE; | 88 virtual syncer::UserShare* GetUserShare() const OVERRIDE; |
89 | 89 |
90 static TestProfileSyncService* BuildAutoStartAsyncInit( | 90 static TestProfileSyncService* BuildAutoStartAsyncInit( |
91 Profile* profile, base::Closure callback); | 91 Profile* profile, base::Closure callback); |
92 | 92 |
93 ProfileSyncComponentsFactoryMock* components_factory_mock(); | 93 ProfileSyncComponentsFactoryMock* components_factory_mock(); |
94 | 94 |
95 syncer::TestIdFactory* id_factory(); | 95 syncer::TestIdFactory* id_factory(); |
96 | 96 |
97 // Raise visibility to ease testing. | 97 // Raise visibility to ease testing. |
98 using ProfileSyncService::NotifyObservers; | 98 using ProfileSyncService::NotifyObservers; |
99 | 99 |
100 protected: | 100 protected: |
101 static KeyedService* TestFactoryFunction(content::BrowserContext* profile); | 101 static KeyedService* TestFactoryFunction(content::BrowserContext* profile); |
102 | 102 |
103 // Return NULL handle to use in backend initialization to avoid receiving | 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 | 104 // js messages on UI loop when it's being destroyed, which are not deleted |
105 // and cause memory leak in test. | 105 // and cause memory leak in test. |
106 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler() | 106 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler() |
107 OVERRIDE; | 107 OVERRIDE; |
108 | 108 |
109 private: | 109 private: |
110 syncer::TestIdFactory id_factory_; | 110 syncer::TestIdFactory id_factory_; |
111 }; | 111 }; |
112 | 112 |
113 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ | 113 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |