| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 #include "chrome/browser/sync/profile_sync_service_factory.h" | 35 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 36 #include "chrome/browser/sync/profile_sync_test_util.h" | 36 #include "chrome/browser/sync/profile_sync_test_util.h" |
| 37 #include "chrome/browser/sync/test_profile_sync_service.h" | 37 #include "chrome/browser/sync/test_profile_sync_service.h" |
| 38 #include "chrome/browser/webdata/autocomplete_syncable_service.h" | 38 #include "chrome/browser/webdata/autocomplete_syncable_service.h" |
| 39 #include "chrome/browser/webdata/autofill_change.h" | 39 #include "chrome/browser/webdata/autofill_change.h" |
| 40 #include "chrome/browser/webdata/autofill_entry.h" | 40 #include "chrome/browser/webdata/autofill_entry.h" |
| 41 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" | 41 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" |
| 42 #include "chrome/browser/webdata/autofill_table.h" | 42 #include "chrome/browser/webdata/autofill_table.h" |
| 43 #include "chrome/browser/webdata/web_data_service.h" | 43 #include "chrome/browser/webdata/web_data_service.h" |
| 44 #include "chrome/browser/webdata/web_data_service_factory.h" | 44 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 45 #include "chrome/browser/webdata/web_data_service_test_util.h" |
| 45 #include "chrome/browser/webdata/web_database.h" | 46 #include "chrome/browser/webdata/web_database.h" |
| 46 #include "chrome/common/chrome_notification_types.h" | 47 #include "chrome/common/chrome_notification_types.h" |
| 47 #include "components/autofill/browser/autofill_common_test.h" | 48 #include "components/autofill/browser/autofill_common_test.h" |
| 48 #include "components/autofill/browser/personal_data_manager.h" | 49 #include "components/autofill/browser/personal_data_manager.h" |
| 49 #include "content/public/browser/notification_source.h" | 50 #include "content/public/browser/notification_source.h" |
| 50 #include "content/public/test/test_browser_thread.h" | 51 #include "content/public/test/test_browser_thread.h" |
| 51 #include "google_apis/gaia/gaia_constants.h" | 52 #include "google_apis/gaia/gaia_constants.h" |
| 52 #include "sync/internal_api/public/base/model_type.h" | 53 #include "sync/internal_api/public/base/model_type.h" |
| 53 #include "sync/internal_api/public/read_node.h" | 54 #include "sync/internal_api/public/read_node.h" |
| 54 #include "sync/internal_api/public/read_transaction.h" | 55 #include "sync/internal_api/public/read_transaction.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 236 |
| 236 WebDatabase* web_database_; | 237 WebDatabase* web_database_; |
| 237 | 238 |
| 238 // We own the syncable services, but don't use a |scoped_ptr| because the | 239 // We own the syncable services, but don't use a |scoped_ptr| because the |
| 239 // lifetime must be managed on the DB thread. | 240 // lifetime must be managed on the DB thread. |
| 240 AutocompleteSyncableService* autocomplete_syncable_service_; | 241 AutocompleteSyncableService* autocomplete_syncable_service_; |
| 241 AutofillProfileSyncableService* autofill_profile_syncable_service_; | 242 AutofillProfileSyncableService* autofill_profile_syncable_service_; |
| 242 WaitableEvent syncable_service_created_or_destroyed_; | 243 WaitableEvent syncable_service_created_or_destroyed_; |
| 243 }; | 244 }; |
| 244 | 245 |
| 245 class MockWebDataServiceWrapper : public WebDataServiceWrapper { | 246 ProfileKeyedService* BuildMockWebDataServiceWrapper(Profile* profile) { |
| 246 public: | 247 return new MockWebDataServiceWrapper(new WebDataServiceFake()); |
| 247 static ProfileKeyedService* Build(Profile* profile) { | 248 } |
| 248 return new MockWebDataServiceWrapper(); | |
| 249 } | |
| 250 | |
| 251 MockWebDataServiceWrapper() { | |
| 252 web_data_service_fake_ = new WebDataServiceFake(); | |
| 253 } | |
| 254 | |
| 255 void Shutdown() OVERRIDE { | |
| 256 } | |
| 257 | |
| 258 scoped_refptr<WebDataService> GetWebData() OVERRIDE { | |
| 259 return web_data_service_fake_; | |
| 260 } | |
| 261 | |
| 262 ~MockWebDataServiceWrapper() { | |
| 263 web_data_service_fake_ = NULL; | |
| 264 } | |
| 265 | |
| 266 private: | |
| 267 scoped_refptr<WebDataServiceFake> web_data_service_fake_; | |
| 268 | |
| 269 }; | |
| 270 | 249 |
| 271 ACTION_P(MakeAutocompleteSyncComponents, wds) { | 250 ACTION_P(MakeAutocompleteSyncComponents, wds) { |
| 272 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 251 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 273 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) | 252 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) |
| 274 return base::WeakPtr<syncer::SyncableService>(); | 253 return base::WeakPtr<syncer::SyncableService>(); |
| 275 return wds->GetAutocompleteSyncableService()->AsWeakPtr(); | 254 return wds->GetAutocompleteSyncableService()->AsWeakPtr(); |
| 276 } | 255 } |
| 277 | 256 |
| 278 ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) { | 257 ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) { |
| 279 return new browser_sync::DataTypeManagerImpl( | 258 return new browser_sync::DataTypeManagerImpl( |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 404 } |
| 426 | 405 |
| 427 virtual void SetUp() OVERRIDE { | 406 virtual void SetUp() OVERRIDE { |
| 428 AbstractProfileSyncServiceTest::SetUp(); | 407 AbstractProfileSyncServiceTest::SetUp(); |
| 429 profile_.reset(new ProfileMock()); | 408 profile_.reset(new ProfileMock()); |
| 430 profile_->CreateRequestContext(); | 409 profile_->CreateRequestContext(); |
| 431 web_database_.reset(new WebDatabaseFake(&autofill_table_)); | 410 web_database_.reset(new WebDatabaseFake(&autofill_table_)); |
| 432 MockWebDataServiceWrapper* wrapper = | 411 MockWebDataServiceWrapper* wrapper = |
| 433 static_cast<MockWebDataServiceWrapper*>( | 412 static_cast<MockWebDataServiceWrapper*>( |
| 434 WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 413 WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 435 profile_.get(), MockWebDataServiceWrapper::Build)); | 414 profile_.get(), BuildMockWebDataServiceWrapper)); |
| 436 web_data_service_ = | 415 web_data_service_ = |
| 437 static_cast<WebDataServiceFake*>(wrapper->GetWebData().get()); | 416 static_cast<WebDataServiceFake*>(wrapper->GetWebData().get()); |
| 438 web_data_service_->SetDatabase(web_database_.get()); | 417 web_data_service_->SetDatabase(web_database_.get()); |
| 439 | 418 |
| 440 MockPersonalDataManagerService* personal_data_manager_service = | 419 MockPersonalDataManagerService* personal_data_manager_service = |
| 441 static_cast<MockPersonalDataManagerService*>( | 420 static_cast<MockPersonalDataManagerService*>( |
| 442 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse( | 421 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse( |
| 443 profile_.get(), MockPersonalDataManagerService::Build)); | 422 profile_.get(), MockPersonalDataManagerService::Build)); |
| 444 personal_data_manager_ = | 423 personal_data_manager_ = |
| 445 personal_data_manager_service->GetPersonalDataManager(); | 424 personal_data_manager_service->GetPersonalDataManager(); |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 std::vector<AutofillEntry> sync_entries; | 1319 std::vector<AutofillEntry> sync_entries; |
| 1341 std::vector<AutofillProfile> sync_profiles; | 1320 std::vector<AutofillProfile> sync_profiles; |
| 1342 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1321 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 1343 EXPECT_EQ(3U, sync_entries.size()); | 1322 EXPECT_EQ(3U, sync_entries.size()); |
| 1344 EXPECT_EQ(0U, sync_profiles.size()); | 1323 EXPECT_EQ(0U, sync_profiles.size()); |
| 1345 for (size_t i = 0; i < sync_entries.size(); i++) { | 1324 for (size_t i = 0; i < sync_entries.size(); i++) { |
| 1346 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1325 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
| 1347 << ", " << sync_entries[i].key().value(); | 1326 << ", " << sync_entries[i].key().value(); |
| 1348 } | 1327 } |
| 1349 } | 1328 } |
| OLD | NEW |