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

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

Issue 1310553005: [Sync] Replace ProfileSyncComponentsFactory with SyncClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Really fix GN Created 5 years, 3 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
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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 // Asserts that if you disable types via the command line, all other types 102 // Asserts that if you disable types via the command line, all other types
103 // are enabled. 103 // are enabled.
104 void TestSwitchDisablesType(syncer::ModelTypeSet types) { 104 void TestSwitchDisablesType(syncer::ModelTypeSet types) {
105 command_line_->AppendSwitchASCII(switches::kDisableSyncTypes, 105 command_line_->AppendSwitchASCII(switches::kDisableSyncTypes,
106 syncer::ModelTypeSetToString(types)); 106 syncer::ModelTypeSetToString(types));
107 GURL sync_service_url = GetSyncServiceURL(*command_line_); 107 GURL sync_service_url = GetSyncServiceURL(*command_line_);
108 ProfileOAuth2TokenService* token_service = 108 ProfileOAuth2TokenService* token_service =
109 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); 109 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get());
110 scoped_ptr<ProfileSyncService> pss(new ProfileSyncService( 110 scoped_ptr<ProfileSyncService> pss(new ProfileSyncService(
111 scoped_ptr<ProfileSyncComponentsFactory>( 111 scoped_ptr<sync_driver::SyncApiComponentFactory>(
112 new ProfileSyncComponentsFactoryImpl( 112 new ProfileSyncComponentsFactoryImpl(
113 profile_.get(), 113 profile_.get(),
114 command_line_.get(), 114 command_line_.get(),
115 GetSyncServiceURL(*command_line_), 115 GetSyncServiceURL(*command_line_),
116 token_service, 116 token_service,
117 profile_->GetRequestContext())), 117 profile_->GetRequestContext())),
118 profile_.get(), 118 profile_.get(),
119 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL), 119 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL),
120 token_service, 120 token_service,
121 browser_sync::MANUAL_START)); 121 browser_sync::MANUAL_START));
122 pss->factory()->RegisterDataTypes(pss.get()); 122 pss->factory()->Initialize(pss.get());
123 pss->factory()->RegisterDataTypes();
123 DataTypeController::StateMap controller_states; 124 DataTypeController::StateMap controller_states;
124 pss->GetDataTypeControllerStates(&controller_states); 125 pss->GetDataTypeControllerStates(&controller_states);
125 EXPECT_EQ(DefaultDatatypesCount() - types.Size(), controller_states.size()); 126 EXPECT_EQ(DefaultDatatypesCount() - types.Size(), controller_states.size());
126 CheckDefaultDatatypesInMapExcept(&controller_states, types); 127 CheckDefaultDatatypesInMapExcept(&controller_states, types);
127 } 128 }
128 129
129 content::TestBrowserThreadBundle thread_bundle_; 130 content::TestBrowserThreadBundle thread_bundle_;
130 scoped_ptr<Profile> profile_; 131 scoped_ptr<Profile> profile_;
131 scoped_ptr<base::CommandLine> command_line_; 132 scoped_ptr<base::CommandLine> command_line_;
132 OAuth2TokenService::ScopeSet scope_set_; 133 OAuth2TokenService::ScopeSet scope_set_;
133 }; 134 };
134 135
135 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDefault) { 136 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDefault) {
136 ProfileOAuth2TokenService* token_service = 137 ProfileOAuth2TokenService* token_service =
137 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); 138 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get());
138 scoped_ptr<ProfileSyncService> pss(new ProfileSyncService( 139 scoped_ptr<ProfileSyncService> pss(new ProfileSyncService(
139 scoped_ptr<ProfileSyncComponentsFactory>( 140 scoped_ptr<sync_driver::SyncApiComponentFactory>(
140 new ProfileSyncComponentsFactoryImpl( 141 new ProfileSyncComponentsFactoryImpl(
141 profile_.get(), 142 profile_.get(),
142 command_line_.get(), 143 command_line_.get(),
143 GetSyncServiceURL(*command_line_), 144 GetSyncServiceURL(*command_line_),
144 token_service, 145 token_service,
145 profile_->GetRequestContext())), 146 profile_->GetRequestContext())),
146 profile_.get(), 147 profile_.get(),
147 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL), 148 make_scoped_ptr<SupervisedUserSigninManagerWrapper>(NULL),
148 token_service, 149 token_service,
149 browser_sync::MANUAL_START)); 150 browser_sync::MANUAL_START));
150 pss->factory()->RegisterDataTypes(pss.get()); 151 pss->factory()->Initialize(pss.get());
152 pss->factory()->RegisterDataTypes();
151 DataTypeController::StateMap controller_states; 153 DataTypeController::StateMap controller_states;
152 pss->GetDataTypeControllerStates(&controller_states); 154 pss->GetDataTypeControllerStates(&controller_states);
153 EXPECT_EQ(DefaultDatatypesCount(), controller_states.size()); 155 EXPECT_EQ(DefaultDatatypesCount(), controller_states.size());
154 CheckDefaultDatatypesInMapExcept(&controller_states, syncer::ModelTypeSet()); 156 CheckDefaultDatatypesInMapExcept(&controller_states, syncer::ModelTypeSet());
155 } 157 }
156 158
157 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableOne) { 159 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableOne) {
158 TestSwitchDisablesType(syncer::ModelTypeSet(syncer::AUTOFILL)); 160 TestSwitchDisablesType(syncer::ModelTypeSet(syncer::AUTOFILL));
159 } 161 }
160 162
161 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableMultiple) { 163 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableMultiple) {
162 TestSwitchDisablesType( 164 TestSwitchDisablesType(
163 syncer::ModelTypeSet(syncer::AUTOFILL_PROFILE, syncer::BOOKMARKS)); 165 syncer::ModelTypeSet(syncer::AUTOFILL_PROFILE, syncer::BOOKMARKS));
164 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698