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

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

Issue 12494020: Remove knowledge of Chrome-specific SyncableService classes from WebDataService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test in debug mode. Created 7 years, 9 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
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 #include <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // TODO(tim): It would be nice if WebDataService was injected on 186 // TODO(tim): It would be nice if WebDataService was injected on
187 // construction of TokenService rather than fetched by Initialize so that 187 // construction of TokenService rather than fetched by Initialize so that
188 // this isn't necessary (we could pass a NULL service). We currently do 188 // this isn't necessary (we could pass a NULL service). We currently do
189 // return it via EXPECT_CALLs, but without depending on order-of- 189 // return it via EXPECT_CALLs, but without depending on order-of-
190 // initialization (which seems way more fragile) we can't tell which 190 // initialization (which seems way more fragile) we can't tell which
191 // component is asking at what time, and some components in these Autofill 191 // component is asking at what time, and some components in these Autofill
192 // tests require a WebDataService. 192 // tests require a WebDataService.
193 return 0; 193 return 0;
194 } 194 }
195 195
196 virtual AutocompleteSyncableService* 196 virtual void ShutdownOnUIThread() OVERRIDE {}
197 GetAutocompleteSyncableService() const OVERRIDE {
198 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
199 EXPECT_TRUE(autocomplete_syncable_service_);
200
201 return autocomplete_syncable_service_;
202 }
203
204 virtual AutofillProfileSyncableService*
205 GetAutofillProfileSyncableService() const OVERRIDE {
206 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
207 EXPECT_TRUE(autofill_profile_syncable_service_);
208
209 return autofill_profile_syncable_service_;
210 }
211 197
212 private: 198 private:
213 virtual ~WebDataServiceFake() {} 199 virtual ~WebDataServiceFake() {}
214 200
215 void CreateSyncableService() { 201 void CreateSyncableService() {
216 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 202 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
217 // These services are deleted in DestroySyncableService(). 203 // These services are deleted in DestroySyncableService().
218 autocomplete_syncable_service_ = new AutocompleteSyncableService(this); 204 AutocompleteSyncableService::CreateForWebDataService(this);
219 autofill_profile_syncable_service_ = 205 AutofillProfileSyncableService::CreateForWebDataService(this);
220 new AutofillProfileSyncableService(this);
221 syncable_service_created_or_destroyed_.Signal(); 206 syncable_service_created_or_destroyed_.Signal();
222 } 207 }
223 208
224 void DestroySyncableService() { 209 void DestroySyncableService() {
225 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 210 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
226 delete autofill_profile_syncable_service_; 211 WebDataServiceBase::ShutdownOnDBThread();
227 delete autocomplete_syncable_service_;
228 syncable_service_created_or_destroyed_.Signal(); 212 syncable_service_created_or_destroyed_.Signal();
229 } 213 }
230 214
231 WebDatabase* web_database_; 215 WebDatabase* web_database_;
232 216
233 // We own the syncable services, but don't use a |scoped_ptr| because the
234 // lifetime must be managed on the DB thread.
235 AutocompleteSyncableService* autocomplete_syncable_service_;
236 AutofillProfileSyncableService* autofill_profile_syncable_service_;
237 WaitableEvent syncable_service_created_or_destroyed_; 217 WaitableEvent syncable_service_created_or_destroyed_;
238 }; 218 };
239 219
240 ProfileKeyedService* BuildMockWebDataServiceWrapper(Profile* profile) { 220 ProfileKeyedService* BuildMockWebDataServiceWrapper(Profile* profile) {
241 return new MockWebDataServiceWrapper(new WebDataServiceFake()); 221 return new MockWebDataServiceWrapper(new WebDataServiceFake());
242 } 222 }
243 223
244 ACTION_P(MakeAutocompleteSyncComponents, wds) { 224 ACTION_P(MakeAutocompleteSyncComponents, wds) {
245 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 225 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
246 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) 226 if (!BrowserThread::CurrentlyOn(BrowserThread::DB))
247 return base::WeakPtr<syncer::SyncableService>(); 227 return base::WeakPtr<syncer::SyncableService>();
248 return wds->GetAutocompleteSyncableService()->AsWeakPtr(); 228 return AutocompleteSyncableService::FromWebDataService(wds)->AsWeakPtr();
249 } 229 }
250 230
251 ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) { 231 ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) {
252 return new browser_sync::DataTypeManagerImpl( 232 return new browser_sync::DataTypeManagerImpl(
253 debug_listener, 233 debug_listener,
254 arg1, 234 arg1,
255 arg2, 235 arg2,
256 arg3, 236 arg3,
257 arg4); 237 arg4);
258 } 238 }
259 239
260 ACTION(MakeGenericChangeProcessor) { 240 ACTION(MakeGenericChangeProcessor) {
261 syncer::UserShare* user_share = arg0->GetUserShare(); 241 syncer::UserShare* user_share = arg0->GetUserShare();
262 return new GenericChangeProcessor( 242 return new GenericChangeProcessor(
263 arg1, 243 arg1,
264 arg2, 244 arg2,
265 arg3, 245 arg3,
266 user_share); 246 user_share);
267 } 247 }
268 248
269 ACTION(MakeSharedChangeProcessor) { 249 ACTION(MakeSharedChangeProcessor) {
270 return new SharedChangeProcessor(); 250 return new SharedChangeProcessor();
271 } 251 }
272 252
273 ACTION_P(MakeAutofillProfileSyncComponents, wds) { 253 ACTION_P(MakeAutofillProfileSyncComponents, wds) {
274 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 254 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
275 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) 255 if (!BrowserThread::CurrentlyOn(BrowserThread::DB))
276 return base::WeakPtr<syncer::SyncableService>();; 256 return base::WeakPtr<syncer::SyncableService>();;
277 return wds->GetAutofillProfileSyncableService()->AsWeakPtr(); 257 return AutofillProfileSyncableService::FromWebDataService(wds)->AsWeakPtr();
278 } 258 }
279 259
280 class AbstractAutofillFactory { 260 class AbstractAutofillFactory {
281 public: 261 public:
282 virtual DataTypeController* CreateDataTypeController( 262 virtual DataTypeController* CreateDataTypeController(
283 ProfileSyncComponentsFactory* factory, 263 ProfileSyncComponentsFactory* factory,
284 ProfileMock* profile, 264 ProfileMock* profile,
285 ProfileSyncService* service) = 0; 265 ProfileSyncService* service) = 0;
286 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 266 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
287 ProfileSyncService* service, 267 ProfileSyncService* service,
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 std::vector<AutofillEntry> sync_entries; 1293 std::vector<AutofillEntry> sync_entries;
1314 std::vector<AutofillProfile> sync_profiles; 1294 std::vector<AutofillProfile> sync_profiles;
1315 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1295 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1316 EXPECT_EQ(3U, sync_entries.size()); 1296 EXPECT_EQ(3U, sync_entries.size());
1317 EXPECT_EQ(0U, sync_profiles.size()); 1297 EXPECT_EQ(0U, sync_profiles.size());
1318 for (size_t i = 0; i < sync_entries.size(); i++) { 1298 for (size_t i = 0; i < sync_entries.size(); i++) {
1319 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1299 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1320 << ", " << sync_entries[i].key().value(); 1300 << ", " << sync_entries[i].key().value();
1321 } 1301 }
1322 } 1302 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_components_factory_impl.cc ('k') | chrome/browser/webdata/autocomplete_syncable_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698