Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/sync/profile_sync_service_unittest.cc

Issue 1410013008: [Sync] Remove some http-related chrome deps from SyncBackendHostImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/invalidation/fake_invalidation_service.h" 17 #include "chrome/browser/invalidation/fake_invalidation_service.h"
18 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 18 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
19 #include "chrome/browser/signin/account_tracker_service_factory.h" 19 #include "chrome/browser/signin/account_tracker_service_factory.h"
20 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" 20 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
22 #include "chrome/browser/signin/signin_manager_factory.h" 22 #include "chrome/browser/signin/signin_manager_factory.h"
23 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" 23 #include "chrome/browser/sync/glue/sync_backend_host_mock.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 24 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/browser/sync/profile_sync_test_util.h"
25 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
27 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
28 #include "chrome/test/base/testing_browser_process.h" 29 #include "chrome/test/base/testing_browser_process.h"
29 #include "chrome/test/base/testing_profile.h" 30 #include "chrome/test/base/testing_profile.h"
30 #include "chrome/test/base/testing_profile_manager.h" 31 #include "chrome/test/base/testing_profile_manager.h"
31 #include "components/invalidation/impl/profile_invalidation_provider.h" 32 #include "components/invalidation/impl/profile_invalidation_provider.h"
32 #include "components/invalidation/public/invalidation_service.h" 33 #include "components/invalidation/public/invalidation_service.h"
33 #include "components/signin/core/browser/account_tracker_service.h" 34 #include "components/signin/core/browser/account_tracker_service.h"
34 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" 35 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread, 125 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread,
125 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 126 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
126 const GURL& service_url, 127 const GURL& service_url,
127 const std::string& sync_user_agent, 128 const std::string& sync_user_agent,
128 const syncer::SyncCredentials& credentials, 129 const syncer::SyncCredentials& credentials,
129 bool delete_sync_data_folder, 130 bool delete_sync_data_folder,
130 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, 131 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory,
131 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& 132 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>&
132 unrecoverable_error_handler, 133 unrecoverable_error_handler,
133 const base::Closure& report_unrecoverable_error_function, 134 const base::Closure& report_unrecoverable_error_function,
134 syncer::NetworkResources* network_resources, 135 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter,
135 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> saved_nigori_state) 136 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> saved_nigori_state)
136 override {} 137 override {}
137 }; 138 };
138 139
139 class SyncBackendHostMockCollectDeleteDirParam : public SyncBackendHostMock { 140 class SyncBackendHostMockCollectDeleteDirParam : public SyncBackendHostMock {
140 public: 141 public:
141 explicit SyncBackendHostMockCollectDeleteDirParam( 142 explicit SyncBackendHostMockCollectDeleteDirParam(
142 std::vector<bool>* delete_dir_param) 143 std::vector<bool>* delete_dir_param)
143 : delete_dir_param_(delete_dir_param) {} 144 : delete_dir_param_(delete_dir_param) {}
144 145
145 void Initialize( 146 void Initialize(
146 sync_driver::SyncFrontend* frontend, 147 sync_driver::SyncFrontend* frontend,
147 scoped_ptr<base::Thread> sync_thread, 148 scoped_ptr<base::Thread> sync_thread,
148 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, 149 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
149 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread, 150 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread,
150 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 151 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
151 const GURL& service_url, 152 const GURL& service_url,
152 const std::string& sync_user_agent, 153 const std::string& sync_user_agent,
153 const syncer::SyncCredentials& credentials, 154 const syncer::SyncCredentials& credentials,
154 bool delete_sync_data_folder, 155 bool delete_sync_data_folder,
155 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, 156 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory,
156 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& 157 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>&
157 unrecoverable_error_handler, 158 unrecoverable_error_handler,
158 const base::Closure& report_unrecoverable_error_function, 159 const base::Closure& report_unrecoverable_error_function,
159 syncer::NetworkResources* network_resources, 160 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter,
160 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> saved_nigori_state) 161 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> saved_nigori_state)
161 override { 162 override {
162 delete_dir_param_->push_back(delete_sync_data_folder); 163 delete_dir_param_->push_back(delete_sync_data_folder);
163 SyncBackendHostMock::Initialize( 164 SyncBackendHostMock::Initialize(
164 frontend, sync_thread.Pass(), db_thread, file_thread, event_handler, 165 frontend, sync_thread.Pass(), db_thread, file_thread, event_handler,
165 service_url, sync_user_agent, credentials, delete_sync_data_folder, 166 service_url, sync_user_agent, credentials, delete_sync_data_folder,
166 sync_manager_factory.Pass(), unrecoverable_error_handler, 167 sync_manager_factory.Pass(), unrecoverable_error_handler,
167 report_unrecoverable_error_function, network_resources, 168 report_unrecoverable_error_function, http_post_provider_factory_getter,
168 saved_nigori_state.Pass()); 169 saved_nigori_state.Pass());
169 } 170 }
170 171
171 private: 172 private:
172 std::vector<bool>* delete_dir_param_; 173 std::vector<bool>* delete_dir_param_;
173 }; 174 };
174 175
175 // SyncBackendHostMock that calls an external callback when ClearServerData is 176 // SyncBackendHostMock that calls an external callback when ClearServerData is
176 // called. 177 // called.
177 class SyncBackendHostCaptureClearServerData : public SyncBackendHostMock { 178 class SyncBackendHostCaptureClearServerData : public SyncBackendHostMock {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 SigninManagerFactory::GetForProfile(profile_); 277 SigninManagerFactory::GetForProfile(profile_);
277 signin->SetAuthenticatedAccountInfo(kGaiaId, kEmail); 278 signin->SetAuthenticatedAccountInfo(kGaiaId, kEmail);
278 ProfileOAuth2TokenService* oauth2_token_service = 279 ProfileOAuth2TokenService* oauth2_token_service =
279 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 280 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
280 components_factory_.reset(new SyncApiComponentFactoryMock()); 281 components_factory_.reset(new SyncApiComponentFactoryMock());
281 scoped_ptr<sync_driver::FakeSyncClient> sync_client( 282 scoped_ptr<sync_driver::FakeSyncClient> sync_client(
282 new sync_driver::FakeSyncClient(components_factory_.get())); 283 new sync_driver::FakeSyncClient(components_factory_.get()));
283 service_.reset(new ProfileSyncService( 284 service_.reset(new ProfileSyncService(
284 sync_client.Pass(), profile_, 285 sync_client.Pass(), profile_,
285 make_scoped_ptr(new SigninManagerWrapper(signin)), oauth2_token_service, 286 make_scoped_ptr(new SigninManagerWrapper(signin)), oauth2_token_service,
286 behavior)); 287 behavior, base::Bind(&EmptyNetworkTimeUpdate)));
287 service_->SetClearingBrowseringDataForTesting( 288 service_->SetClearingBrowseringDataForTesting(
288 base::Bind(&ProfileSyncServiceTest::ClearBrowsingDataCallback, 289 base::Bind(&ProfileSyncServiceTest::ClearBrowsingDataCallback,
289 base::Unretained(this))); 290 base::Unretained(this)));
290 service_->RegisterDataTypeController( 291 service_->RegisterDataTypeController(
291 new sync_driver::FakeDataTypeController(syncer::BOOKMARKS)); 292 new sync_driver::FakeDataTypeController(syncer::BOOKMARKS));
292 } 293 }
293 294
294 #if defined(OS_WIN) || defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_C HROMEOS)) 295 #if defined(OS_WIN) || defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_C HROMEOS))
295 void CreateServiceWithoutSignIn() { 296 void CreateServiceWithoutSignIn() {
296 CreateService(browser_sync::AUTO_START); 297 CreateService(browser_sync::AUTO_START);
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 InitializeForNthSync(); 997 InitializeForNthSync();
997 998
998 syncer::SyncProtocolError client_cmd; 999 syncer::SyncProtocolError client_cmd;
999 client_cmd.action = syncer::RESET_LOCAL_SYNC_DATA; 1000 client_cmd.action = syncer::RESET_LOCAL_SYNC_DATA;
1000 service()->OnActionableError(client_cmd); 1001 service()->OnActionableError(client_cmd);
1001 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); 1002 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode());
1002 } 1003 }
1003 1004
1004 } // namespace 1005 } // namespace
1005 } // namespace browser_sync 1006 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_startup_unittest.cc ('k') | chrome/browser/sync/profile_sync_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698