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

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 451743002: Pass args to SyncManager::Init via a struct. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use scoped_ptr instead of raw pointer. Created 6 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « sync/internal_api/sync_manager_impl.cc ('k') | sync/internal_api/sync_rollback_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Unit tests for the SyncApi. Note that a lot of the underlying 5 // Unit tests for the SyncApi. Note that a lot of the underlying
6 // functionality is provided by the Syncable layer, which has its own 6 // functionality is provided by the Syncable layer, which has its own
7 // unit tests. We'll test SyncApi specific things in this harness. 7 // unit tests. We'll test SyncApi specific things in this harness.
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 std::vector<scoped_refptr<ModelSafeWorker> > workers; 808 std::vector<scoped_refptr<ModelSafeWorker> > workers;
809 ModelSafeRoutingInfo routing_info; 809 ModelSafeRoutingInfo routing_info;
810 GetModelSafeRoutingInfo(&routing_info); 810 GetModelSafeRoutingInfo(&routing_info);
811 811
812 // This works only because all routing info types are GROUP_PASSIVE. 812 // This works only because all routing info types are GROUP_PASSIVE.
813 // If we had types in other groups, we would need additional workers 813 // If we had types in other groups, we would need additional workers
814 // to support them. 814 // to support them.
815 scoped_refptr<ModelSafeWorker> worker = new FakeModelWorker(GROUP_PASSIVE); 815 scoped_refptr<ModelSafeWorker> worker = new FakeModelWorker(GROUP_PASSIVE);
816 workers.push_back(worker); 816 workers.push_back(worker);
817 817
818 // Takes ownership of |fake_invalidator_|. 818 SyncManager::InitArgs args;
819 sync_manager_.Init( 819 args.database_location = temp_dir_.path();
820 temp_dir_.path(), 820 args.service_url = GURL("https://example.com/");
821 WeakHandle<JsEventHandler>(), 821 args.post_factory =
822 GURL("https://example.com/"), 822 scoped_ptr<HttpPostProviderFactory>(new TestHttpPostProviderFactory());
823 scoped_ptr<HttpPostProviderFactory>(new TestHttpPostProviderFactory()), 823 args.workers = workers;
824 workers, 824 args.extensions_activity = extensions_activity_.get(),
825 extensions_activity_.get(), 825 args.change_delegate = this;
826 this, 826 args.credentials = credentials;
827 credentials, 827 args.invalidator_client_id = "fake_invalidator_client_id";
828 "fake_invalidator_client_id", 828 args.internal_components_factory.reset(GetFactory());
829 std::string(), 829 args.encryptor = &encryptor_;
830 std::string(), // bootstrap tokens 830 args.unrecoverable_error_handler.reset(new TestUnrecoverableErrorHandler);
831 scoped_ptr<InternalComponentsFactory>(GetFactory()).get(), 831 args.cancelation_signal = &cancelation_signal_;
832 &encryptor_, 832 sync_manager_.Init(&args);
833 scoped_ptr<UnrecoverableErrorHandler>(new TestUnrecoverableErrorHandler)
834 .Pass(),
835 NULL,
836 &cancelation_signal_);
837 833
838 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_); 834 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_);
839 835
840 EXPECT_TRUE(js_backend_.IsInitialized()); 836 EXPECT_TRUE(js_backend_.IsInitialized());
841 837
842 if (initialization_succeeded_) { 838 if (initialization_succeeded_) {
843 for (ModelSafeRoutingInfo::iterator i = routing_info.begin(); 839 for (ModelSafeRoutingInfo::iterator i = routing_info.begin();
844 i != routing_info.end(); ++i) { 840 i != routing_info.end(); ++i) {
845 type_roots_[i->first] = MakeServerNodeForType( 841 type_roots_[i->first] = MakeServerNodeForType(
846 sync_manager_.GetUserShare(), i->first); 842 sync_manager_.GetUserShare(), i->first);
(...skipping 2341 matching lines...) Expand 10 before | Expand all | Expand 10 after
3188 // SyncManagerInitInvalidStorageTest::GetFactory will return 3184 // SyncManagerInitInvalidStorageTest::GetFactory will return
3189 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3185 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3190 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3186 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3191 // task is to ensure that SyncManagerImpl reported initialization failure in 3187 // task is to ensure that SyncManagerImpl reported initialization failure in
3192 // OnInitializationComplete callback. 3188 // OnInitializationComplete callback.
3193 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3189 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3194 EXPECT_FALSE(initialization_succeeded_); 3190 EXPECT_FALSE(initialization_succeeded_);
3195 } 3191 }
3196 3192
3197 } // namespace syncer 3193 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl.cc ('k') | sync/internal_api/sync_rollback_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698