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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc

Issue 73723006: Allow customization of HttpPostProviderFactory via ProfileSyncService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/sync/glue/sync_backend_host_impl.h" 5 #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/sync/sync_prefs.h" 21 #include "chrome/browser/sync/sync_prefs.h"
22 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
23 #include "components/user_prefs/pref_registry_syncable.h" 23 #include "components/user_prefs/pref_registry_syncable.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
27 #include "google/cacheinvalidation/include/types.h" 27 #include "google/cacheinvalidation/include/types.h"
28 #include "net/url_request/test_url_fetcher_factory.h" 28 #include "net/url_request/test_url_fetcher_factory.h"
29 #include "sync/internal_api/public/base/model_type.h" 29 #include "sync/internal_api/public/base/model_type.h"
30 #include "sync/internal_api/public/engine/model_safe_worker.h" 30 #include "sync/internal_api/public/engine/model_safe_worker.h"
31 #include "sync/internal_api/public/http_bridge_factory_factory.h"
32 #include "sync/internal_api/public/http_post_provider_factory_factory.h"
31 #include "sync/internal_api/public/sync_manager_factory.h" 33 #include "sync/internal_api/public/sync_manager_factory.h"
32 #include "sync/internal_api/public/test/fake_sync_manager.h" 34 #include "sync/internal_api/public/test/fake_sync_manager.h"
33 #include "sync/internal_api/public/util/experiments.h" 35 #include "sync/internal_api/public/util/experiments.h"
34 #include "sync/notifier/invalidator_state.h" 36 #include "sync/notifier/invalidator_state.h"
35 #include "sync/protocol/encryption.pb.h" 37 #include "sync/protocol/encryption.pb.h"
36 #include "sync/protocol/sync_protocol_error.h" 38 #include "sync/protocol/sync_protocol_error.h"
37 #include "sync/util/test_unrecoverable_error_handler.h" 39 #include "sync/util/test_unrecoverable_error_handler.h"
38 #include "testing/gmock/include/gmock/gmock.h" 40 #include "testing/gmock/include/gmock/gmock.h"
39 #include "testing/gtest/include/gtest/gtest.h" 41 #include "testing/gtest/include/gtest/gtest.h"
40 #include "url/gurl.h" 42 #include "url/gurl.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // NOTE: We can't include Passwords or Typed URLs due to the Sync Backend 156 // NOTE: We can't include Passwords or Typed URLs due to the Sync Backend
155 // Registrar removing them if it can't find their model workers. 157 // Registrar removing them if it can't find their model workers.
156 enabled_types_.Put(syncer::BOOKMARKS); 158 enabled_types_.Put(syncer::BOOKMARKS);
157 enabled_types_.Put(syncer::NIGORI); 159 enabled_types_.Put(syncer::NIGORI);
158 enabled_types_.Put(syncer::DEVICE_INFO); 160 enabled_types_.Put(syncer::DEVICE_INFO);
159 enabled_types_.Put(syncer::PREFERENCES); 161 enabled_types_.Put(syncer::PREFERENCES);
160 enabled_types_.Put(syncer::SESSIONS); 162 enabled_types_.Put(syncer::SESSIONS);
161 enabled_types_.Put(syncer::SEARCH_ENGINES); 163 enabled_types_.Put(syncer::SEARCH_ENGINES);
162 enabled_types_.Put(syncer::AUTOFILL); 164 enabled_types_.Put(syncer::AUTOFILL);
163 enabled_types_.Put(syncer::EXPERIMENTS); 165 enabled_types_.Put(syncer::EXPERIMENTS);
166
167 http_post_provider_factory_factory_.reset(
168 new syncer::HttpBridgeFactoryFactory());
164 } 169 }
165 170
166 virtual void TearDown() OVERRIDE { 171 virtual void TearDown() OVERRIDE {
167 if (backend_) { 172 if (backend_) {
168 backend_->StopSyncingForShutdown(); 173 backend_->StopSyncingForShutdown();
169 backend_->Shutdown(SyncBackendHost::STOP); 174 backend_->Shutdown(SyncBackendHost::STOP);
170 } 175 }
171 backend_.reset(); 176 backend_.reset();
172 sync_prefs_.reset(); 177 sync_prefs_.reset();
173 profile_.reset(); 178 profile_.reset();
(...skipping 12 matching lines...) Expand all
186 backend_->Initialize( 191 backend_->Initialize(
187 &mock_frontend_, 192 &mock_frontend_,
188 scoped_ptr<base::Thread>(), 193 scoped_ptr<base::Thread>(),
189 syncer::WeakHandle<syncer::JsEventHandler>(), 194 syncer::WeakHandle<syncer::JsEventHandler>(),
190 GURL(std::string()), 195 GURL(std::string()),
191 credentials_, 196 credentials_,
192 true, 197 true,
193 fake_manager_factory_.PassAs<syncer::SyncManagerFactory>(), 198 fake_manager_factory_.PassAs<syncer::SyncManagerFactory>(),
194 scoped_ptr<syncer::UnrecoverableErrorHandler>( 199 scoped_ptr<syncer::UnrecoverableErrorHandler>(
195 new syncer::TestUnrecoverableErrorHandler).Pass(), 200 new syncer::TestUnrecoverableErrorHandler).Pass(),
196 NULL); 201 NULL,
202 http_post_provider_factory_factory_.get());
197 base::RunLoop run_loop; 203 base::RunLoop run_loop;
198 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, 204 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE,
199 run_loop.QuitClosure(), 205 run_loop.QuitClosure(),
200 TestTimeouts::action_timeout()); 206 TestTimeouts::action_timeout());
201 run_loop.Run(); 207 run_loop.Run();
202 // |fake_manager_factory_|'s fake_manager() is set on the sync 208 // |fake_manager_factory_|'s fake_manager() is set on the sync
203 // thread, but we can rely on the message loop barriers to 209 // thread, but we can rely on the message loop barriers to
204 // guarantee that we see the updated value. 210 // guarantee that we see the updated value.
205 DCHECK(fake_manager_); 211 DCHECK(fake_manager_);
206 } 212 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 259
254 content::TestBrowserThreadBundle thread_bundle_; 260 content::TestBrowserThreadBundle thread_bundle_;
255 StrictMock<MockSyncFrontend> mock_frontend_; 261 StrictMock<MockSyncFrontend> mock_frontend_;
256 syncer::SyncCredentials credentials_; 262 syncer::SyncCredentials credentials_;
257 scoped_ptr<TestingProfile> profile_; 263 scoped_ptr<TestingProfile> profile_;
258 scoped_ptr<SyncPrefs> sync_prefs_; 264 scoped_ptr<SyncPrefs> sync_prefs_;
259 scoped_ptr<SyncBackendHost> backend_; 265 scoped_ptr<SyncBackendHost> backend_;
260 scoped_ptr<FakeSyncManagerFactory> fake_manager_factory_; 266 scoped_ptr<FakeSyncManagerFactory> fake_manager_factory_;
261 FakeSyncManager* fake_manager_; 267 FakeSyncManager* fake_manager_;
262 syncer::ModelTypeSet enabled_types_; 268 syncer::ModelTypeSet enabled_types_;
269 scoped_ptr<syncer::HttpPostProviderFactoryFactory>
270 http_post_provider_factory_factory_;
263 }; 271 };
264 272
265 // Test basic initialization with no initial types (first time initialization). 273 // Test basic initialization with no initial types (first time initialization).
266 // Only the nigori should be configured. 274 // Only the nigori should be configured.
267 TEST_F(SyncBackendHostTest, InitShutdown) { 275 TEST_F(SyncBackendHostTest, InitShutdown) {
268 InitializeBackend(true); 276 InitializeBackend(true);
269 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( 277 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals(
270 syncer::ControlTypes())); 278 syncer::ControlTypes()));
271 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals( 279 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(
272 syncer::ControlTypes())); 280 syncer::ControlTypes()));
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 ASSERT_NE(-1, file_util::WriteFile(sync_file, nonsense, strlen(nonsense))); 707 ASSERT_NE(-1, file_util::WriteFile(sync_file, nonsense, strlen(nonsense)));
700 708
701 InitializeBackend(true); 709 InitializeBackend(true);
702 710
703 EXPECT_FALSE(base::PathExists(sync_file)); 711 EXPECT_FALSE(base::PathExists(sync_file));
704 } 712 }
705 713
706 } // namespace 714 } // namespace
707 715
708 } // namespace browser_sync 716 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698