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

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

Issue 12897009: Autofill Webdata Split TRY ONLY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try again 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 22 matching lines...) Expand all
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/web_data_service.h" 43 #include "chrome/browser/webdata/autofill_web_data_service_impl.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_data_service_test_util.h"
46 #include "chrome/browser/webdata/web_database.h" 46 #include "chrome/browser/webdata/web_database.h"
47 #include "chrome/common/chrome_notification_types.h" 47 #include "chrome/common/chrome_notification_types.h"
48 #include "components/autofill/browser/autofill_common_test.h" 48 #include "components/autofill/browser/autofill_common_test.h"
49 #include "components/autofill/browser/personal_data_manager.h" 49 #include "components/autofill/browser/personal_data_manager.h"
50 #include "content/public/browser/notification_source.h" 50 #include "content/public/browser/notification_source.h"
51 #include "content/public/test/test_browser_thread.h" 51 #include "content/public/test/test_browser_thread.h"
52 #include "google_apis/gaia/gaia_constants.h" 52 #include "google_apis/gaia/gaia_constants.h"
53 #include "sync/internal_api/public/base/model_type.h" 53 #include "sync/internal_api/public/base/model_type.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 template<> 137 template<>
138 syncer::ModelType GetModelType<AutofillEntry>() { 138 syncer::ModelType GetModelType<AutofillEntry>() {
139 return syncer::AUTOFILL; 139 return syncer::AUTOFILL;
140 } 140 }
141 141
142 template<> 142 template<>
143 syncer::ModelType GetModelType<AutofillProfile>() { 143 syncer::ModelType GetModelType<AutofillProfile>() {
144 return syncer::AUTOFILL_PROFILE; 144 return syncer::AUTOFILL_PROFILE;
145 } 145 }
146 146
147 class WebDataServiceFake : public WebDataService { 147 class TokenWebDataServiceFake : public WebDataService {
148 public:
149 TokenWebDataServiceFake()
150 : WebDataService() {
151 }
152
153 virtual bool IsDatabaseLoaded() OVERRIDE {
154 return true;
155 }
156
157 virtual WebDataService::Handle GetAllTokens(
158 WebDataServiceConsumer* consumer) OVERRIDE {
159 // TODO(tim): It would be nice if WebDataService was injected on
160 // construction of TokenService rather than fetched by Initialize so that
161 // this isn't necessary (we could pass a NULL service). We currently do
162 // return it via EXPECT_CALLs, but without depending on order-of-
163 // initialization (which seems way more fragile) we can't tell which
164 // component is asking at what time, and some components in these Autofill
165 // tests require a WebDataService.
166 return 0;
167 }
168
169 private:
170 virtual ~TokenWebDataServiceFake() {}
171
172 DISALLOW_COPY_AND_ASSIGN(TokenWebDataServiceFake);
173 };
174
175 class WebDataServiceFake : public AutofillWebDataServiceImpl {
148 public: 176 public:
149 WebDataServiceFake() 177 WebDataServiceFake()
150 : web_database_(NULL), 178 : AutofillWebDataServiceImpl(
179 NULL, WebDataServiceBase::ProfileErrorCallback()),
180 web_database_(NULL),
151 syncable_service_created_or_destroyed_(false, false) { 181 syncable_service_created_or_destroyed_(false, false) {
152 } 182 }
153 183
154 void SetDatabase(WebDatabase* web_database) { 184 void SetDatabase(WebDatabase* web_database) {
155 web_database_ = web_database; 185 web_database_ = web_database;
156 } 186 }
157 187
158 void StartSyncableService() { 188 void StartSyncableService() {
159 // The |autofill_profile_syncable_service_| must be constructed on the DB 189 // The |autofill_profile_syncable_service_| must be constructed on the DB
160 // thread. 190 // thread.
(...skipping 13 matching lines...) Expand all
174 } 204 }
175 205
176 virtual bool IsDatabaseLoaded() OVERRIDE { 206 virtual bool IsDatabaseLoaded() OVERRIDE {
177 return true; 207 return true;
178 } 208 }
179 209
180 virtual WebDatabase* GetDatabase() OVERRIDE { 210 virtual WebDatabase* GetDatabase() OVERRIDE {
181 return web_database_; 211 return web_database_;
182 } 212 }
183 213
184 virtual WebDataService::Handle GetAllTokens(
185 WebDataServiceConsumer* consumer) OVERRIDE {
186 // TODO(tim): It would be nice if WebDataService was injected on
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
189 // return it via EXPECT_CALLs, but without depending on order-of-
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
192 // tests require a WebDataService.
193 return 0;
194 }
195
196 virtual void ShutdownOnUIThread() OVERRIDE {} 214 virtual void ShutdownOnUIThread() OVERRIDE {}
197 215
198 private: 216 private:
199 virtual ~WebDataServiceFake() {} 217 virtual ~WebDataServiceFake() {}
200 218
201 void CreateSyncableService() { 219 void CreateSyncableService() {
202 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 220 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
203 // These services are deleted in DestroySyncableService(). 221 // These services are deleted in DestroySyncableService().
204 AutocompleteSyncableService::CreateForWebDataService(this); 222 AutocompleteSyncableService::CreateForWebDataService(this);
205 AutofillProfileSyncableService::CreateForWebDataService(this); 223 AutofillProfileSyncableService::CreateForWebDataService(this);
206 syncable_service_created_or_destroyed_.Signal(); 224 syncable_service_created_or_destroyed_.Signal();
207 } 225 }
208 226
209 void DestroySyncableService() { 227 void DestroySyncableService() {
210 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 228 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
211 WebDataServiceBase::ShutdownOnDBThread(); 229 WebDataServiceBase::ShutdownOnDBThread();
212 syncable_service_created_or_destroyed_.Signal(); 230 syncable_service_created_or_destroyed_.Signal();
213 } 231 }
214 232
215 WebDatabase* web_database_; 233 WebDatabase* web_database_;
216 234
217 WaitableEvent syncable_service_created_or_destroyed_; 235 WaitableEvent syncable_service_created_or_destroyed_;
236
237 DISALLOW_COPY_AND_ASSIGN(WebDataServiceFake);
218 }; 238 };
219 239
220 ProfileKeyedService* BuildMockWebDataServiceWrapper(Profile* profile) { 240 ProfileKeyedService* BuildMockWebDataServiceWrapper(Profile* profile) {
221 return new MockWebDataServiceWrapper(new WebDataServiceFake()); 241 return new MockWebDataServiceWrapper(
242 new TokenWebDataServiceFake(),
243 new WebDataServiceFake());
222 } 244 }
223 245
224 ACTION_P(MakeAutocompleteSyncComponents, wds) { 246 ACTION_P(MakeAutocompleteSyncComponents, wds) {
225 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 247 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
226 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) 248 if (!BrowserThread::CurrentlyOn(BrowserThread::DB))
227 return base::WeakPtr<syncer::SyncableService>(); 249 return base::WeakPtr<syncer::SyncableService>();
228 return AutocompleteSyncableService::FromWebDataService(wds)->AsWeakPtr(); 250 return AutocompleteSyncableService::FromWebDataService(wds)->AsWeakPtr();
229 } 251 }
230 252
231 ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) { 253 ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) {
(...skipping 26 matching lines...) Expand all
258 } 280 }
259 281
260 class AbstractAutofillFactory { 282 class AbstractAutofillFactory {
261 public: 283 public:
262 virtual DataTypeController* CreateDataTypeController( 284 virtual DataTypeController* CreateDataTypeController(
263 ProfileSyncComponentsFactory* factory, 285 ProfileSyncComponentsFactory* factory,
264 ProfileMock* profile, 286 ProfileMock* profile,
265 ProfileSyncService* service) = 0; 287 ProfileSyncService* service) = 0;
266 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 288 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
267 ProfileSyncService* service, 289 ProfileSyncService* service,
268 WebDataService* wds, 290 AutofillWebDataService* wds,
269 DataTypeController* dtc) = 0; 291 DataTypeController* dtc) = 0;
270 virtual ~AbstractAutofillFactory() {} 292 virtual ~AbstractAutofillFactory() {}
271 }; 293 };
272 294
273 class AutofillEntryFactory : public AbstractAutofillFactory { 295 class AutofillEntryFactory : public AbstractAutofillFactory {
274 public: 296 public:
275 virtual browser_sync::DataTypeController* CreateDataTypeController( 297 virtual browser_sync::DataTypeController* CreateDataTypeController(
276 ProfileSyncComponentsFactory* factory, 298 ProfileSyncComponentsFactory* factory,
277 ProfileMock* profile, 299 ProfileMock* profile,
278 ProfileSyncService* service) OVERRIDE { 300 ProfileSyncService* service) OVERRIDE {
279 return new AutofillDataTypeController(factory, profile, service); 301 return new AutofillDataTypeController(factory, profile, service);
280 } 302 }
281 303
282 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 304 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
283 ProfileSyncService* service, 305 ProfileSyncService* service,
284 WebDataService* wds, 306 AutofillWebDataService* wds,
285 DataTypeController* dtc) OVERRIDE { 307 DataTypeController* dtc) OVERRIDE {
286 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)). 308 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)).
287 WillOnce(MakeGenericChangeProcessor()); 309 WillOnce(MakeGenericChangeProcessor());
288 EXPECT_CALL(*factory, CreateSharedChangeProcessor()). 310 EXPECT_CALL(*factory, CreateSharedChangeProcessor()).
289 WillOnce(MakeSharedChangeProcessor()); 311 WillOnce(MakeSharedChangeProcessor());
290 EXPECT_CALL(*factory, GetSyncableServiceForType(syncer::AUTOFILL)). 312 EXPECT_CALL(*factory, GetSyncableServiceForType(syncer::AUTOFILL)).
291 WillOnce(MakeAutocompleteSyncComponents(wds)); 313 WillOnce(MakeAutocompleteSyncComponents(wds));
292 } 314 }
293 }; 315 };
294 316
295 class AutofillProfileFactory : public AbstractAutofillFactory { 317 class AutofillProfileFactory : public AbstractAutofillFactory {
296 public: 318 public:
297 virtual browser_sync::DataTypeController* CreateDataTypeController( 319 virtual browser_sync::DataTypeController* CreateDataTypeController(
298 ProfileSyncComponentsFactory* factory, 320 ProfileSyncComponentsFactory* factory,
299 ProfileMock* profile, 321 ProfileMock* profile,
300 ProfileSyncService* service) OVERRIDE { 322 ProfileSyncService* service) OVERRIDE {
301 return new AutofillProfileDataTypeController(factory, profile, service); 323 return new AutofillProfileDataTypeController(factory, profile, service);
302 } 324 }
303 325
304 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 326 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
305 ProfileSyncService* service, 327 ProfileSyncService* service,
306 WebDataService* wds, 328 AutofillWebDataService* wds,
307 DataTypeController* dtc) OVERRIDE { 329 DataTypeController* dtc) OVERRIDE {
308 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)). 330 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)).
309 WillOnce(MakeGenericChangeProcessor()); 331 WillOnce(MakeGenericChangeProcessor());
310 EXPECT_CALL(*factory, CreateSharedChangeProcessor()). 332 EXPECT_CALL(*factory, CreateSharedChangeProcessor()).
311 WillOnce(MakeSharedChangeProcessor()); 333 WillOnce(MakeSharedChangeProcessor());
312 EXPECT_CALL(*factory, 334 EXPECT_CALL(*factory,
313 GetSyncableServiceForType(syncer::AUTOFILL_PROFILE)). 335 GetSyncableServiceForType(syncer::AUTOFILL_PROFILE)).
314 WillOnce(MakeAutofillProfileSyncComponents(wds)); 336 WillOnce(MakeAutofillProfileSyncComponents(wds));
315 } 337 }
316 }; 338 };
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 virtual void SetUp() OVERRIDE { 402 virtual void SetUp() OVERRIDE {
381 AbstractProfileSyncServiceTest::SetUp(); 403 AbstractProfileSyncServiceTest::SetUp();
382 profile_.reset(new ProfileMock()); 404 profile_.reset(new ProfileMock());
383 profile_->CreateRequestContext(); 405 profile_->CreateRequestContext();
384 web_database_.reset(new WebDatabaseFake(&autofill_table_)); 406 web_database_.reset(new WebDatabaseFake(&autofill_table_));
385 MockWebDataServiceWrapper* wrapper = 407 MockWebDataServiceWrapper* wrapper =
386 static_cast<MockWebDataServiceWrapper*>( 408 static_cast<MockWebDataServiceWrapper*>(
387 WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse( 409 WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse(
388 profile_.get(), BuildMockWebDataServiceWrapper)); 410 profile_.get(), BuildMockWebDataServiceWrapper));
389 web_data_service_ = 411 web_data_service_ =
390 static_cast<WebDataServiceFake*>(wrapper->GetWebData().get()); 412 static_cast<WebDataServiceFake*>(wrapper->GetAutofillWebData().get());
391 web_data_service_->SetDatabase(web_database_.get()); 413 web_data_service_->SetDatabase(web_database_.get());
392 414
393 MockPersonalDataManagerService* personal_data_manager_service = 415 MockPersonalDataManagerService* personal_data_manager_service =
394 static_cast<MockPersonalDataManagerService*>( 416 static_cast<MockPersonalDataManagerService*>(
395 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse( 417 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse(
396 profile_.get(), MockPersonalDataManagerService::Build)); 418 profile_.get(), MockPersonalDataManagerService::Build));
397 personal_data_manager_ = 419 personal_data_manager_ =
398 personal_data_manager_service->GetPersonalDataManager(); 420 personal_data_manager_service->GetPersonalDataManager();
399 421
400 token_service_ = static_cast<TokenService*>( 422 token_service_ = static_cast<TokenService*>(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 481
460 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). 482 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()).
461 WillRepeatedly(Return(true)); 483 WillRepeatedly(Return(true));
462 484
463 // We need tokens to get the tests going 485 // We need tokens to get the tests going
464 token_service_->IssueAuthTokenForTest(GaiaConstants::kSyncService, "token"); 486 token_service_->IssueAuthTokenForTest(GaiaConstants::kSyncService, "token");
465 487
466 sync_service_->RegisterDataTypeController(data_type_controller); 488 sync_service_->RegisterDataTypeController(data_type_controller);
467 sync_service_->Initialize(); 489 sync_service_->Initialize();
468 MessageLoop::current()->Run(); 490 MessageLoop::current()->Run();
469
470 // It's possible this test triggered an unrecoverable error, in which case 491 // It's possible this test triggered an unrecoverable error, in which case
471 // we can't get the sync count. 492 // we can't get the sync count.
472 if (sync_service_->ShouldPushChanges()) { 493 if (sync_service_->ShouldPushChanges()) {
473 EXPECT_EQ(GetSyncCount(type), 494 EXPECT_EQ(GetSyncCount(type),
474 association_stats_.num_sync_items_after_association); 495 association_stats_.num_sync_items_after_association);
475 } 496 }
476 EXPECT_EQ(association_stats_.num_sync_items_after_association, 497 EXPECT_EQ(association_stats_.num_sync_items_after_association,
477 association_stats_.num_sync_items_before_association + 498 association_stats_.num_sync_items_before_association +
478 association_stats_.num_sync_items_added - 499 association_stats_.num_sync_items_added -
479 association_stats_.num_sync_items_deleted); 500 association_stats_.num_sync_items_deleted);
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 std::vector<base::Time> timestamps(added_entry.timestamps()); 1124 std::vector<base::Time> timestamps(added_entry.timestamps());
1104 1125
1105 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). 1126 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).
1106 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); 1127 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true)));
1107 1128
1108 AutofillChangeList changes; 1129 AutofillChangeList changes;
1109 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key())); 1130 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key()));
1110 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1131 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1111 db_thread_.DeprecatedGetThreadObject())); 1132 db_thread_.DeprecatedGetThreadObject()));
1112 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1133 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1113 content::Source<WebDataService>(web_data_service_.get()), 1134 content::Source<AutofillWebDataService>(
1135 web_data_service_.get()),
1114 content::Details<AutofillChangeList>(&changes)); 1136 content::Details<AutofillChangeList>(&changes));
1115 1137
1116 std::vector<AutofillEntry> new_sync_entries; 1138 std::vector<AutofillEntry> new_sync_entries;
1117 std::vector<AutofillProfile> new_sync_profiles; 1139 std::vector<AutofillProfile> new_sync_profiles;
1118 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1140 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1119 &new_sync_profiles)); 1141 &new_sync_profiles));
1120 ASSERT_EQ(1U, new_sync_entries.size()); 1142 ASSERT_EQ(1U, new_sync_entries.size());
1121 EXPECT_TRUE(added_entry == new_sync_entries[0]); 1143 EXPECT_TRUE(added_entry == new_sync_entries[0]);
1122 } 1144 }
1123 1145
1124 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) { 1146 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) {
1125 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 1147 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
1126 EXPECT_CALL(*personal_data_manager_, Refresh()); 1148 EXPECT_CALL(*personal_data_manager_, Refresh());
1127 SetIdleChangeProcessorExpectations(); 1149 SetIdleChangeProcessorExpectations();
1128 CreateRootHelper create_root(this, syncer::AUTOFILL_PROFILE); 1150 CreateRootHelper create_root(this, syncer::AUTOFILL_PROFILE);
1129 StartSyncService(create_root.callback(), false, syncer::AUTOFILL_PROFILE); 1151 StartSyncService(create_root.callback(), false, syncer::AUTOFILL_PROFILE);
1130 ASSERT_TRUE(create_root.success()); 1152 ASSERT_TRUE(create_root.success());
1131 1153
1132 AutofillProfile added_profile; 1154 AutofillProfile added_profile;
1133 autofill_test::SetProfileInfoWithGuid(&added_profile, 1155 autofill_test::SetProfileInfoWithGuid(&added_profile,
1134 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz", 1156 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz",
1135 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 1157 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
1136 "32801", "US", "19482937549"); 1158 "32801", "US", "19482937549");
1137 1159
1138 AutofillProfileChange change(AutofillProfileChange::ADD, 1160 AutofillProfileChange change(AutofillProfileChange::ADD,
1139 added_profile.guid(), &added_profile); 1161 added_profile.guid(), &added_profile);
1140 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1162 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1141 db_thread_.DeprecatedGetThreadObject())); 1163 db_thread_.DeprecatedGetThreadObject()));
1142 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, 1164 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
1143 content::Source<WebDataService>(web_data_service_.get()), 1165 content::Source<AutofillWebDataService>(
1166 web_data_service_.get()),
1144 content::Details<AutofillProfileChange>(&change)); 1167 content::Details<AutofillProfileChange>(&change));
1145 1168
1146 std::vector<AutofillProfile> new_sync_profiles; 1169 std::vector<AutofillProfile> new_sync_profiles;
1147 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( 1170 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(
1148 &new_sync_profiles)); 1171 &new_sync_profiles));
1149 ASSERT_EQ(1U, new_sync_profiles.size()); 1172 ASSERT_EQ(1U, new_sync_profiles.size());
1150 EXPECT_EQ(0, added_profile.Compare(new_sync_profiles[0])); 1173 EXPECT_EQ(0, added_profile.Compare(new_sync_profiles[0]));
1151 } 1174 }
1152 1175
1153 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) { 1176 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) {
(...skipping 13 matching lines...) Expand all
1167 1190
1168 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). 1191 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).
1169 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); 1192 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true)));
1170 1193
1171 AutofillChangeList changes; 1194 AutofillChangeList changes;
1172 changes.push_back(AutofillChange(AutofillChange::UPDATE, 1195 changes.push_back(AutofillChange(AutofillChange::UPDATE,
1173 updated_entry.key())); 1196 updated_entry.key()));
1174 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1197 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1175 db_thread_.DeprecatedGetThreadObject())); 1198 db_thread_.DeprecatedGetThreadObject()));
1176 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1199 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1177 content::Source<WebDataService>(web_data_service_.get()), 1200 content::Source<AutofillWebDataService>(
1201 web_data_service_.get()),
1178 content::Details<AutofillChangeList>(&changes)); 1202 content::Details<AutofillChangeList>(&changes));
1179 1203
1180 std::vector<AutofillEntry> new_sync_entries; 1204 std::vector<AutofillEntry> new_sync_entries;
1181 std::vector<AutofillProfile> new_sync_profiles; 1205 std::vector<AutofillProfile> new_sync_profiles;
1182 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1206 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1183 &new_sync_profiles)); 1207 &new_sync_profiles));
1184 ASSERT_EQ(1U, new_sync_entries.size()); 1208 ASSERT_EQ(1U, new_sync_entries.size());
1185 EXPECT_TRUE(updated_entry == new_sync_entries[0]); 1209 EXPECT_TRUE(updated_entry == new_sync_entries[0]);
1186 } 1210 }
1187 1211
1188 1212
1189 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) { 1213 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) {
1190 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); 1214 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1));
1191 std::vector<AutofillEntry> original_entries; 1215 std::vector<AutofillEntry> original_entries;
1192 original_entries.push_back(original_entry); 1216 original_entries.push_back(original_entry);
1193 1217
1194 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). 1218 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)).
1195 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 1219 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true)));
1196 EXPECT_CALL(*personal_data_manager_, Refresh()); 1220 EXPECT_CALL(*personal_data_manager_, Refresh());
1197 CreateRootHelper create_root(this, syncer::AUTOFILL); 1221 CreateRootHelper create_root(this, syncer::AUTOFILL);
1198 StartSyncService(create_root.callback(), false, syncer::AUTOFILL); 1222 StartSyncService(create_root.callback(), false, syncer::AUTOFILL);
1199 ASSERT_TRUE(create_root.success()); 1223 ASSERT_TRUE(create_root.success());
1200 1224
1201 AutofillChangeList changes; 1225 AutofillChangeList changes;
1202 changes.push_back(AutofillChange(AutofillChange::REMOVE, 1226 changes.push_back(AutofillChange(AutofillChange::REMOVE,
1203 original_entry.key())); 1227 original_entry.key()));
1204 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1228 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1205 db_thread_.DeprecatedGetThreadObject())); 1229 db_thread_.DeprecatedGetThreadObject()));
1206 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1230 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1207 content::Source<WebDataService>(web_data_service_.get()), 1231 content::Source<AutofillWebDataService>(
1232 web_data_service_.get()),
1208 content::Details<AutofillChangeList>(&changes)); 1233 content::Details<AutofillChangeList>(&changes));
1209 1234
1210 std::vector<AutofillEntry> new_sync_entries; 1235 std::vector<AutofillEntry> new_sync_entries;
1211 std::vector<AutofillProfile> new_sync_profiles; 1236 std::vector<AutofillProfile> new_sync_profiles;
1212 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1237 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1213 &new_sync_profiles)); 1238 &new_sync_profiles));
1214 ASSERT_EQ(0U, new_sync_entries.size()); 1239 ASSERT_EQ(0U, new_sync_entries.size());
1215 } 1240 }
1216 1241
1217 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) { 1242 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) {
(...skipping 18 matching lines...) Expand all
1236 AddAutofillHelper<AutofillProfile> add_autofill(this, sync_profiles); 1261 AddAutofillHelper<AutofillProfile> add_autofill(this, sync_profiles);
1237 EXPECT_CALL(*personal_data_manager_, Refresh()); 1262 EXPECT_CALL(*personal_data_manager_, Refresh());
1238 StartSyncService(add_autofill.callback(), false, syncer::AUTOFILL_PROFILE); 1263 StartSyncService(add_autofill.callback(), false, syncer::AUTOFILL_PROFILE);
1239 ASSERT_TRUE(add_autofill.success()); 1264 ASSERT_TRUE(add_autofill.success());
1240 1265
1241 AutofillProfileChange change(AutofillProfileChange::REMOVE, 1266 AutofillProfileChange change(AutofillProfileChange::REMOVE,
1242 sync_profile.guid(), NULL); 1267 sync_profile.guid(), NULL);
1243 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1268 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1244 db_thread_.DeprecatedGetThreadObject())); 1269 db_thread_.DeprecatedGetThreadObject()));
1245 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, 1270 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
1246 content::Source<WebDataService>(web_data_service_.get()), 1271 content::Source<AutofillWebDataService>(
1272 web_data_service_.get()),
1247 content::Details<AutofillProfileChange>(&change)); 1273 content::Details<AutofillProfileChange>(&change));
1248 1274
1249 std::vector<AutofillProfile> new_sync_profiles; 1275 std::vector<AutofillProfile> new_sync_profiles;
1250 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( 1276 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(
1251 &new_sync_profiles)); 1277 &new_sync_profiles));
1252 ASSERT_EQ(0U, new_sync_profiles.size()); 1278 ASSERT_EQ(0U, new_sync_profiles.size());
1253 } 1279 }
1254 1280
1255 // http://crbug.com/57884 1281 // http://crbug.com/57884
1256 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) { 1282 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 std::vector<AutofillEntry> sync_entries; 1319 std::vector<AutofillEntry> sync_entries;
1294 std::vector<AutofillProfile> sync_profiles; 1320 std::vector<AutofillProfile> sync_profiles;
1295 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1321 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1296 EXPECT_EQ(3U, sync_entries.size()); 1322 EXPECT_EQ(3U, sync_entries.size());
1297 EXPECT_EQ(0U, sync_profiles.size()); 1323 EXPECT_EQ(0U, sync_profiles.size());
1298 for (size_t i = 0; i < sync_entries.size(); i++) { 1324 for (size_t i = 0; i < sync_entries.size(); i++) {
1299 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1325 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1300 << ", " << sync_entries[i].key().value(); 1326 << ", " << sync_entries[i].key().value();
1301 } 1327 }
1302 } 1328 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_components_factory_impl.cc ('k') | chrome/browser/sync/test/integration/autofill_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698