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

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

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

Powered by Google App Engine
This is Rietveld 408576698