Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 #include "chrome/browser/sync/profile_sync_components_factory.h" | 33 #include "chrome/browser/sync/profile_sync_components_factory.h" |
| 34 #include "chrome/browser/sync/profile_sync_service.h" | 34 #include "chrome/browser/sync/profile_sync_service.h" |
| 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/autofill_web_data_service_impl.h" | |
|
Jói
2013/03/20 12:41:29
Needed?
| |
| 43 #include "chrome/browser/webdata/web_data_service.h" | 44 #include "chrome/browser/webdata/web_data_service.h" |
| 44 #include "chrome/browser/webdata/web_data_service_factory.h" | 45 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 45 #include "chrome/browser/webdata/web_data_service_test_util.h" | 46 #include "chrome/browser/webdata/web_data_service_test_util.h" |
| 46 #include "chrome/browser/webdata/web_database.h" | 47 #include "chrome/browser/webdata/web_database.h" |
| 47 #include "chrome/common/chrome_notification_types.h" | 48 #include "chrome/common/chrome_notification_types.h" |
| 48 #include "components/autofill/browser/autofill_common_test.h" | 49 #include "components/autofill/browser/autofill_common_test.h" |
| 49 #include "components/autofill/browser/personal_data_manager.h" | 50 #include "components/autofill/browser/personal_data_manager.h" |
| 50 #include "content/public/browser/notification_source.h" | 51 #include "content/public/browser/notification_source.h" |
| 51 #include "content/public/test/test_browser_thread.h" | 52 #include "content/public/test/test_browser_thread.h" |
| 52 #include "google_apis/gaia/gaia_constants.h" | 53 #include "google_apis/gaia/gaia_constants.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 } | 141 } |
| 141 | 142 |
| 142 template<> | 143 template<> |
| 143 syncer::ModelType GetModelType<AutofillProfile>() { | 144 syncer::ModelType GetModelType<AutofillProfile>() { |
| 144 return syncer::AUTOFILL_PROFILE; | 145 return syncer::AUTOFILL_PROFILE; |
| 145 } | 146 } |
| 146 | 147 |
| 147 class WebDataServiceFake : public WebDataService { | 148 class WebDataServiceFake : public WebDataService { |
| 148 public: | 149 public: |
| 149 WebDataServiceFake() | 150 WebDataServiceFake() |
| 150 : web_database_(NULL), | 151 : WebDataService(), |
| 152 web_database_(NULL), | |
| 151 syncable_service_created_or_destroyed_(false, false) { | 153 syncable_service_created_or_destroyed_(false, false) { |
| 152 } | 154 } |
| 153 | 155 |
| 154 void SetDatabase(WebDatabase* web_database) { | 156 void SetDatabase(WebDatabase* web_database) { |
| 155 web_database_ = web_database; | 157 web_database_ = web_database; |
| 156 } | 158 } |
| 157 | 159 |
| 158 void StartSyncableService() { | 160 void StartSyncableService() { |
| 159 // The |autofill_profile_syncable_service_| must be constructed on the DB | 161 // The |autofill_profile_syncable_service_| must be constructed on the DB |
| 160 // thread. | 162 // thread. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 186 // TODO(tim): It would be nice if WebDataService was injected on | 188 // TODO(tim): It would be nice if WebDataService was injected on |
| 187 // construction of TokenService rather than fetched by Initialize so that | 189 // construction of TokenService rather than fetched by Initialize so that |
| 188 // this isn't necessary (we could pass a NULL service). We currently do | 190 // 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- | 191 // return it via EXPECT_CALLs, but without depending on order-of- |
| 190 // initialization (which seems way more fragile) we can't tell which | 192 // initialization (which seems way more fragile) we can't tell which |
| 191 // component is asking at what time, and some components in these Autofill | 193 // component is asking at what time, and some components in these Autofill |
| 192 // tests require a WebDataService. | 194 // tests require a WebDataService. |
| 193 return 0; | 195 return 0; |
| 194 } | 196 } |
| 195 | 197 |
| 198 | |
| 196 virtual void ShutdownOnUIThread() OVERRIDE {} | 199 virtual void ShutdownOnUIThread() OVERRIDE {} |
| 197 | 200 |
| 198 private: | 201 private: |
| 199 virtual ~WebDataServiceFake() {} | 202 virtual ~WebDataServiceFake() {} |
| 200 | 203 |
| 201 void CreateSyncableService() { | 204 void CreateSyncableService() { |
| 202 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 205 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 203 // These services are deleted in DestroySyncableService(). | 206 // These services are deleted in DestroySyncableService(). |
| 204 AutocompleteSyncableService::CreateForWebDataService(this); | 207 AutocompleteSyncableService::CreateForWebDataService(this); |
| 205 AutofillProfileSyncableService::CreateForWebDataService(this); | 208 AutofillProfileSyncableService::CreateForWebDataService(this); |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1293 std::vector<AutofillEntry> sync_entries; | 1296 std::vector<AutofillEntry> sync_entries; |
| 1294 std::vector<AutofillProfile> sync_profiles; | 1297 std::vector<AutofillProfile> sync_profiles; |
| 1295 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1298 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 1296 EXPECT_EQ(3U, sync_entries.size()); | 1299 EXPECT_EQ(3U, sync_entries.size()); |
| 1297 EXPECT_EQ(0U, sync_profiles.size()); | 1300 EXPECT_EQ(0U, sync_profiles.size()); |
| 1298 for (size_t i = 0; i < sync_entries.size(); i++) { | 1301 for (size_t i = 0; i < sync_entries.size(); i++) { |
| 1299 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1302 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
| 1300 << ", " << sync_entries[i].key().value(); | 1303 << ", " << sync_entries[i].key().value(); |
| 1301 } | 1304 } |
| 1302 } | 1305 } |
| OLD | NEW |