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 25 matching lines...) Expand all Loading... | |
| 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_database.h" | 45 #include "chrome/browser/webdata/web_database.h" | 
| 46 #include "chrome/common/chrome_notification_types.h" | |
| 47 #include "components/autofill/browser/autofill_common_test.h" | 46 #include "components/autofill/browser/autofill_common_test.h" | 
| 48 #include "components/autofill/browser/personal_data_manager.h" | 47 #include "components/autofill/browser/personal_data_manager.h" | 
| 49 #include "content/public/browser/notification_source.h" | |
| 50 #include "content/public/test/test_browser_thread.h" | 48 #include "content/public/test/test_browser_thread.h" | 
| 51 #include "google_apis/gaia/gaia_constants.h" | 49 #include "google_apis/gaia/gaia_constants.h" | 
| 52 #include "sync/internal_api/public/base/model_type.h" | 50 #include "sync/internal_api/public/base/model_type.h" | 
| 53 #include "sync/internal_api/public/read_node.h" | 51 #include "sync/internal_api/public/read_node.h" | 
| 54 #include "sync/internal_api/public/read_transaction.h" | 52 #include "sync/internal_api/public/read_transaction.h" | 
| 55 #include "sync/internal_api/public/write_node.h" | 53 #include "sync/internal_api/public/write_node.h" | 
| 56 #include "sync/internal_api/public/write_transaction.h" | 54 #include "sync/internal_api/public/write_transaction.h" | 
| 57 #include "sync/protocol/autofill_specifics.pb.h" | 55 #include "sync/protocol/autofill_specifics.pb.h" | 
| 58 #include "sync/syncable/mutable_entry.h" | 56 #include "sync/syncable/mutable_entry.h" | 
| 59 #include "sync/syncable/syncable_write_transaction.h" | 57 #include "sync/syncable/syncable_write_transaction.h" | 
| (...skipping 25 matching lines...) Expand all Loading... | |
| 85 using testing::ElementsAre; | 83 using testing::ElementsAre; | 
| 86 using testing::SetArgumentPointee; | 84 using testing::SetArgumentPointee; | 
| 87 using testing::Return; | 85 using testing::Return; | 
| 88 | 86 | 
| 89 namespace syncable { | 87 namespace syncable { | 
| 90 class Id; | 88 class Id; | 
| 91 } | 89 } | 
| 92 | 90 | 
| 93 class HistoryService; | 91 class HistoryService; | 
| 94 | 92 | 
| 93 namespace { | |
| 94 | |
| 95 void RunAndSignal(const base::Closure& cb, WaitableEvent* event) { | |
| 96 cb.Run(); | |
| 97 event->Signal(); | |
| 98 } | |
| 99 | |
| 100 } // namespace | |
| 101 | |
| 95 class AutofillTableMock : public AutofillTable { | 102 class AutofillTableMock : public AutofillTable { | 
| 96 public: | 103 public: | 
| 97 AutofillTableMock() : AutofillTable(NULL, NULL) {} | 104 AutofillTableMock() : AutofillTable(NULL, NULL) {} | 
| 98 MOCK_METHOD2(RemoveFormElement, | 105 MOCK_METHOD2(RemoveFormElement, | 
| 99 bool(const string16& name, const string16& value)); // NOLINT | 106 bool(const string16& name, const string16& value)); // NOLINT | 
| 100 MOCK_METHOD1(GetAllAutofillEntries, | 107 MOCK_METHOD1(GetAllAutofillEntries, | 
| 101 bool(std::vector<AutofillEntry>* entries)); // NOLINT | 108 bool(std::vector<AutofillEntry>* entries)); // NOLINT | 
| 102 MOCK_METHOD3(GetAutofillTimestamps, | 109 MOCK_METHOD3(GetAutofillTimestamps, | 
| 103 bool(const string16& name, // NOLINT | 110 bool(const string16& name, // NOLINT | 
| 104 const string16& value, | 111 const string16& value, | 
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 virtual AutofillProfileSyncableService* | 222 virtual AutofillProfileSyncableService* | 
| 216 GetAutofillProfileSyncableService() const OVERRIDE { | 223 GetAutofillProfileSyncableService() const OVERRIDE { | 
| 217 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 224 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 
| 218 EXPECT_TRUE(autofill_profile_syncable_service_); | 225 EXPECT_TRUE(autofill_profile_syncable_service_); | 
| 219 | 226 | 
| 220 return autofill_profile_syncable_service_; | 227 return autofill_profile_syncable_service_; | 
| 221 } | 228 } | 
| 222 | 229 | 
| 223 virtual void ShutdownOnUIThread() OVERRIDE {} | 230 virtual void ShutdownOnUIThread() OVERRIDE {} | 
| 224 | 231 | 
| 232 void OnAutofillEntriesChanged(const AutofillChangeList& changes) { | |
| 233 WaitableEvent event(true, false); | |
| 234 | |
| 235 base::Closure notify_cb = | |
| 236 base::Bind(&AutocompleteSyncableService::AutofillEntriesChanged, | |
| 237 base::Unretained(autocomplete_syncable_service_), | |
| 238 changes); | |
| 239 BrowserThread::PostTask( | |
| 240 BrowserThread::DB, | |
| 241 FROM_HERE, | |
| 242 base::Bind(&RunAndSignal, notify_cb, &event)); | |
| 243 event.Wait(); | |
| 244 } | |
| 245 | |
| 246 void OnAutofillProfileChanged(const AutofillProfileChange& changes) { | |
| 247 WaitableEvent event(true, false); | |
| 248 | |
| 249 base::Closure notify_cb = | |
| 250 base::Bind(&AutocompleteSyncableService::AutofillProfileChanged, | |
| 251 base::Unretained(autofill_profile_syncable_service_), | |
| 252 changes); | |
| 253 BrowserThread::PostTask( | |
| 254 BrowserThread::DB, | |
| 255 FROM_HERE, | |
| 256 base::Bind(&RunAndSignal, notify_cb, &event)); | |
| 257 event.Wait(); | |
| 258 } | |
| 259 | |
| 225 private: | 260 private: | 
| 226 virtual ~WebDataServiceFake() {} | 261 virtual ~WebDataServiceFake() {} | 
| 227 | 262 | 
| 228 void CreateSyncableService() { | 263 void CreateSyncableService() { | 
| 229 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 264 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 
| 230 // These services are deleted in DestroySyncableService(). | 265 // These services are deleted in DestroySyncableService(). | 
| 231 autocomplete_syncable_service_ = new AutocompleteSyncableService(this); | 266 autocomplete_syncable_service_ = new AutocompleteSyncableService(this); | 
| 232 autofill_profile_syncable_service_ = | 267 autofill_profile_syncable_service_ = | 
| 233 new AutofillProfileSyncableService(this); | 268 new AutofillProfileSyncableService(this); | 
| 234 syncable_service_created_or_destroyed_.Signal(); | 269 syncable_service_created_or_destroyed_.Signal(); | 
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 MOCK_METHOD0(LoadCreditCards, void()); | 386 MOCK_METHOD0(LoadCreditCards, void()); | 
| 352 MOCK_METHOD0(Refresh, void()); | 387 MOCK_METHOD0(Refresh, void()); | 
| 353 }; | 388 }; | 
| 354 | 389 | 
| 355 class MockPersonalDataManagerService : public PersonalDataManagerService { | 390 class MockPersonalDataManagerService : public PersonalDataManagerService { | 
| 356 public: | 391 public: | 
| 357 static ProfileKeyedService* Build(Profile* profile) { | 392 static ProfileKeyedService* Build(Profile* profile) { | 
| 358 return new MockPersonalDataManagerService(); | 393 return new MockPersonalDataManagerService(); | 
| 359 } | 394 } | 
| 360 | 395 | 
| 361 MockPersonalDataManagerService() {} | 396 MockPersonalDataManagerService() { | 
| 397 personal_data_manager_.reset(new MockPersonalDataManager()); | |
| 398 } | |
| 362 virtual ~MockPersonalDataManagerService() {} | 399 virtual ~MockPersonalDataManagerService() {} | 
| 363 | 400 | 
| 401 virtual void Shutdown() OVERRIDE { | |
| 402 personal_data_manager_.reset(); | |
| 403 } | |
| 404 | |
| 364 virtual MockPersonalDataManager* GetPersonalDataManager() OVERRIDE { | 405 virtual MockPersonalDataManager* GetPersonalDataManager() OVERRIDE { | 
| 365 return &personal_data_manager_; | 406 return personal_data_manager_.get(); | 
| 366 } | 407 } | 
| 367 | 408 | 
| 368 private: | 409 private: | 
| 369 MockPersonalDataManager personal_data_manager_; | 410 scoped_ptr<MockPersonalDataManager> personal_data_manager_; | 
| 370 DISALLOW_COPY_AND_ASSIGN(MockPersonalDataManagerService); | 411 DISALLOW_COPY_AND_ASSIGN(MockPersonalDataManagerService); | 
| 371 }; | 412 }; | 
| 372 | 413 | 
| 373 template <class T> class AddAutofillHelper; | 414 template <class T> class AddAutofillHelper; | 
| 374 | 415 | 
| 375 class ProfileSyncServiceAutofillTest | 416 class ProfileSyncServiceAutofillTest | 
| 376 : public AbstractProfileSyncServiceTest, | 417 : public AbstractProfileSyncServiceTest, | 
| 377 public syncer::DataTypeDebugInfoListener { | 418 public syncer::DataTypeDebugInfoListener { | 
| 378 public: | 419 public: | 
| 379 // DataTypeDebugInfoListener implementation. | 420 // DataTypeDebugInfoListener implementation. | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 personal_data_manager_service->GetPersonalDataManager(); | 465 personal_data_manager_service->GetPersonalDataManager(); | 
| 425 | 466 | 
| 426 token_service_ = static_cast<TokenService*>( | 467 token_service_ = static_cast<TokenService*>( | 
| 427 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 468 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 
| 428 profile_.get(), BuildTokenService)); | 469 profile_.get(), BuildTokenService)); | 
| 429 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); | 470 EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); | 
| 430 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); | 471 EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); | 
| 431 | 472 | 
| 432 personal_data_manager_->Init(profile_.get()); | 473 personal_data_manager_->Init(profile_.get()); | 
| 433 | 474 | 
| 434 // Note: This must be called *after* the notification service is created. | |
| 435 web_data_service_->StartSyncableService(); | 475 web_data_service_->StartSyncableService(); | 
| 436 } | 476 } | 
| 437 | 477 | 
| 438 virtual void TearDown() OVERRIDE { | 478 virtual void TearDown() OVERRIDE { | 
| 439 // Note: The tear down order is important. | 479 // Note: The tear down order is important. | 
| 440 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( | 480 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( | 
| 441 profile_.get(), NULL); | 481 profile_.get(), NULL); | 
| 442 web_data_service_->ShutdownSyncableService(); | 482 web_data_service_->ShutdownSyncableService(); | 
| 443 profile_->ResetRequestContext(); | 483 profile_->ResetRequestContext(); | 
| 444 // To prevent a leak, fully release TestURLRequestContext to ensure its | 484 // To prevent a leak, fully release TestURLRequestContext to ensure its | 
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 StartSyncService(create_root.callback(), false, syncer::AUTOFILL); | 912 StartSyncService(create_root.callback(), false, syncer::AUTOFILL); | 
| 873 ASSERT_TRUE(create_root.success()); | 913 ASSERT_TRUE(create_root.success()); | 
| 874 std::vector<AutofillEntry> sync_entries; | 914 std::vector<AutofillEntry> sync_entries; | 
| 875 std::vector<AutofillProfile> sync_profiles; | 915 std::vector<AutofillProfile> sync_profiles; | 
| 876 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 916 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 
| 877 ASSERT_EQ(1U, entries.size()); | 917 ASSERT_EQ(1U, entries.size()); | 
| 878 EXPECT_TRUE(entries[0] == sync_entries[0]); | 918 EXPECT_TRUE(entries[0] == sync_entries[0]); | 
| 879 EXPECT_EQ(0U, sync_profiles.size()); | 919 EXPECT_EQ(0U, sync_profiles.size()); | 
| 880 } | 920 } | 
| 881 | 921 | 
| 882 TEST_F(ProfileSyncServiceAutofillTest, HasProfileEmptySync) { | 922 TEST_F(ProfileSyncServiceAutofillTest, HasProfileEmptySync) { | 
| 
 
dhollowa
2013/03/13 16:17:09
This is failing.
 
 | |
| 883 std::vector<AutofillProfile*> profiles; | 923 std::vector<AutofillProfile*> profiles; | 
| 884 std::vector<AutofillProfile> expected_profiles; | 924 std::vector<AutofillProfile> expected_profiles; | 
| 885 // Owned by GetAutofillProfiles caller. | 925 // Owned by GetAutofillProfiles caller. | 
| 886 AutofillProfile* profile0 = new AutofillProfile; | 926 AutofillProfile* profile0 = new AutofillProfile; | 
| 887 autofill_test::SetProfileInfoWithGuid(profile0, | 927 autofill_test::SetProfileInfoWithGuid(profile0, | 
| 888 "54B3F9AA-335E-4F71-A27D-719C41564230", "Billing", | 928 "54B3F9AA-335E-4F71-A27D-719C41564230", "Billing", | 
| 889 "Mitchell", "Morrison", | 929 "Mitchell", "Morrison", | 
| 890 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 930 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 
| 891 "91601", "US", "12345678910"); | 931 "91601", "US", "12345678910"); | 
| 892 profiles.push_back(profile0); | 932 profiles.push_back(profile0); | 
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1126 ASSERT_TRUE(create_root.success()); | 1166 ASSERT_TRUE(create_root.success()); | 
| 1127 | 1167 | 
| 1128 AutofillEntry added_entry(MakeAutofillEntry("added", "entry", 1)); | 1168 AutofillEntry added_entry(MakeAutofillEntry("added", "entry", 1)); | 
| 1129 std::vector<base::Time> timestamps(added_entry.timestamps()); | 1169 std::vector<base::Time> timestamps(added_entry.timestamps()); | 
| 1130 | 1170 | 
| 1131 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). | 1171 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). | 
| 1132 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); | 1172 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); | 
| 1133 | 1173 | 
| 1134 AutofillChangeList changes; | 1174 AutofillChangeList changes; | 
| 1135 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key())); | 1175 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key())); | 
| 1136 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( | 1176 | 
| 1137 db_thread_.DeprecatedGetThreadObject())); | 1177 web_data_service_->OnAutofillEntriesChanged(changes); | 
| 1138 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
| 1139 content::Source<WebDataService>(web_data_service_.get()), | |
| 1140 content::Details<AutofillChangeList>(&changes)); | |
| 1141 | 1178 | 
| 1142 std::vector<AutofillEntry> new_sync_entries; | 1179 std::vector<AutofillEntry> new_sync_entries; | 
| 1143 std::vector<AutofillProfile> new_sync_profiles; | 1180 std::vector<AutofillProfile> new_sync_profiles; | 
| 1144 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, | 1181 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, | 
| 1145 &new_sync_profiles)); | 1182 &new_sync_profiles)); | 
| 1146 ASSERT_EQ(1U, new_sync_entries.size()); | 1183 ASSERT_EQ(1U, new_sync_entries.size()); | 
| 1147 EXPECT_TRUE(added_entry == new_sync_entries[0]); | 1184 EXPECT_TRUE(added_entry == new_sync_entries[0]); | 
| 1148 } | 1185 } | 
| 1149 | 1186 | 
| 1150 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) { | 1187 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) { | 
| 1151 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); | 1188 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); | 
| 1152 EXPECT_CALL(*personal_data_manager_, Refresh()); | 1189 EXPECT_CALL(*personal_data_manager_, Refresh()); | 
| 1153 SetIdleChangeProcessorExpectations(); | 1190 SetIdleChangeProcessorExpectations(); | 
| 1154 CreateRootHelper create_root(this, syncer::AUTOFILL_PROFILE); | 1191 CreateRootHelper create_root(this, syncer::AUTOFILL_PROFILE); | 
| 1155 StartSyncService(create_root.callback(), false, syncer::AUTOFILL_PROFILE); | 1192 StartSyncService(create_root.callback(), false, syncer::AUTOFILL_PROFILE); | 
| 1156 ASSERT_TRUE(create_root.success()); | 1193 ASSERT_TRUE(create_root.success()); | 
| 1157 | 1194 | 
| 1158 AutofillProfile added_profile; | 1195 AutofillProfile added_profile; | 
| 1159 autofill_test::SetProfileInfoWithGuid(&added_profile, | 1196 autofill_test::SetProfileInfoWithGuid(&added_profile, | 
| 1160 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz", | 1197 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz", | 
| 1161 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 1198 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 
| 1162 "32801", "US", "19482937549"); | 1199 "32801", "US", "19482937549"); | 
| 1163 | 1200 | 
| 1164 AutofillProfileChange change(AutofillProfileChange::ADD, | 1201 AutofillProfileChange change( | 
| 1165 added_profile.guid(), &added_profile); | 1202 AutofillProfileChange::ADD, added_profile.guid(), &added_profile); | 
| 1166 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( | 1203 web_data_service_->OnAutofillProfileChanged(change); | 
| 1167 db_thread_.DeprecatedGetThreadObject())); | |
| 1168 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | |
| 1169 content::Source<WebDataService>(web_data_service_.get()), | |
| 1170 content::Details<AutofillProfileChange>(&change)); | |
| 1171 | 1204 | 
| 1172 std::vector<AutofillProfile> new_sync_profiles; | 1205 std::vector<AutofillProfile> new_sync_profiles; | 
| 1173 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( | 1206 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( | 
| 1174 &new_sync_profiles)); | 1207 &new_sync_profiles)); | 
| 1175 ASSERT_EQ(1U, new_sync_profiles.size()); | 1208 ASSERT_EQ(1U, new_sync_profiles.size()); | 
| 1176 EXPECT_EQ(0, added_profile.Compare(new_sync_profiles[0])); | 1209 EXPECT_EQ(0, added_profile.Compare(new_sync_profiles[0])); | 
| 1177 } | 1210 } | 
| 1178 | 1211 | 
| 1179 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) { | 1212 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) { | 
| 1180 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); | 1213 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); | 
| 1181 std::vector<AutofillEntry> original_entries; | 1214 std::vector<AutofillEntry> original_entries; | 
| 1182 original_entries.push_back(original_entry); | 1215 original_entries.push_back(original_entry); | 
| 1183 | 1216 | 
| 1184 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). | 1217 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). | 
| 1185 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); | 1218 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); | 
| 1186 EXPECT_CALL(*personal_data_manager_, Refresh()); | 1219 EXPECT_CALL(*personal_data_manager_, Refresh()); | 
| 1187 CreateRootHelper create_root(this, syncer::AUTOFILL); | 1220 CreateRootHelper create_root(this, syncer::AUTOFILL); | 
| 1188 StartSyncService(create_root.callback(), false, syncer::AUTOFILL); | 1221 StartSyncService(create_root.callback(), false, syncer::AUTOFILL); | 
| 1189 ASSERT_TRUE(create_root.success()); | 1222 ASSERT_TRUE(create_root.success()); | 
| 1190 | 1223 | 
| 1191 AutofillEntry updated_entry(MakeAutofillEntry("my", "entry", 1, 2)); | 1224 AutofillEntry updated_entry(MakeAutofillEntry("my", "entry", 1, 2)); | 
| 1192 std::vector<base::Time> timestamps(updated_entry.timestamps()); | 1225 std::vector<base::Time> timestamps(updated_entry.timestamps()); | 
| 1193 | 1226 | 
| 1194 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). | 1227 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). | 
| 1195 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); | 1228 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); | 
| 1196 | 1229 | 
| 1197 AutofillChangeList changes; | 1230 AutofillChangeList changes; | 
| 1198 changes.push_back(AutofillChange(AutofillChange::UPDATE, | 1231 changes.push_back(AutofillChange(AutofillChange::UPDATE, | 
| 1199 updated_entry.key())); | 1232 updated_entry.key())); | 
| 1200 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( | 1233 web_data_service_->OnAutofillEntriesChanged(changes); | 
| 1201 db_thread_.DeprecatedGetThreadObject())); | |
| 1202 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
| 1203 content::Source<WebDataService>(web_data_service_.get()), | |
| 1204 content::Details<AutofillChangeList>(&changes)); | |
| 1205 | 1234 | 
| 1206 std::vector<AutofillEntry> new_sync_entries; | 1235 std::vector<AutofillEntry> new_sync_entries; | 
| 1207 std::vector<AutofillProfile> new_sync_profiles; | 1236 std::vector<AutofillProfile> new_sync_profiles; | 
| 1208 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, | 1237 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, | 
| 1209 &new_sync_profiles)); | 1238 &new_sync_profiles)); | 
| 1210 ASSERT_EQ(1U, new_sync_entries.size()); | 1239 ASSERT_EQ(1U, new_sync_entries.size()); | 
| 1211 EXPECT_TRUE(updated_entry == new_sync_entries[0]); | 1240 EXPECT_TRUE(updated_entry == new_sync_entries[0]); | 
| 1212 } | 1241 } | 
| 1213 | 1242 | 
| 1214 | 1243 | 
| 1215 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) { | 1244 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) { | 
| 1216 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); | 1245 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); | 
| 1217 std::vector<AutofillEntry> original_entries; | 1246 std::vector<AutofillEntry> original_entries; | 
| 1218 original_entries.push_back(original_entry); | 1247 original_entries.push_back(original_entry); | 
| 1219 | 1248 | 
| 1220 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). | 1249 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). | 
| 1221 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); | 1250 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); | 
| 1222 EXPECT_CALL(*personal_data_manager_, Refresh()); | 1251 EXPECT_CALL(*personal_data_manager_, Refresh()); | 
| 1223 CreateRootHelper create_root(this, syncer::AUTOFILL); | 1252 CreateRootHelper create_root(this, syncer::AUTOFILL); | 
| 1224 StartSyncService(create_root.callback(), false, syncer::AUTOFILL); | 1253 StartSyncService(create_root.callback(), false, syncer::AUTOFILL); | 
| 1225 ASSERT_TRUE(create_root.success()); | 1254 ASSERT_TRUE(create_root.success()); | 
| 1226 | 1255 | 
| 1227 AutofillChangeList changes; | 1256 AutofillChangeList changes; | 
| 1228 changes.push_back(AutofillChange(AutofillChange::REMOVE, | 1257 changes.push_back(AutofillChange(AutofillChange::REMOVE, | 
| 1229 original_entry.key())); | 1258 original_entry.key())); | 
| 1230 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( | 1259 web_data_service_->OnAutofillEntriesChanged(changes); | 
| 1231 db_thread_.DeprecatedGetThreadObject())); | |
| 1232 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
| 1233 content::Source<WebDataService>(web_data_service_.get()), | |
| 1234 content::Details<AutofillChangeList>(&changes)); | |
| 1235 | 1260 | 
| 1236 std::vector<AutofillEntry> new_sync_entries; | 1261 std::vector<AutofillEntry> new_sync_entries; | 
| 1237 std::vector<AutofillProfile> new_sync_profiles; | 1262 std::vector<AutofillProfile> new_sync_profiles; | 
| 1238 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, | 1263 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, | 
| 1239 &new_sync_profiles)); | 1264 &new_sync_profiles)); | 
| 1240 ASSERT_EQ(0U, new_sync_entries.size()); | 1265 ASSERT_EQ(0U, new_sync_entries.size()); | 
| 1241 } | 1266 } | 
| 1242 | 1267 | 
| 1243 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) { | 1268 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) { | 
| 1244 AutofillProfile sync_profile; | 1269 AutofillProfile sync_profile; | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1257 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). | 1282 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). | 
| 1258 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); | 1283 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); | 
| 1259 | 1284 | 
| 1260 std::vector<AutofillProfile> sync_profiles; | 1285 std::vector<AutofillProfile> sync_profiles; | 
| 1261 sync_profiles.push_back(sync_profile); | 1286 sync_profiles.push_back(sync_profile); | 
| 1262 AddAutofillHelper<AutofillProfile> add_autofill(this, sync_profiles); | 1287 AddAutofillHelper<AutofillProfile> add_autofill(this, sync_profiles); | 
| 1263 EXPECT_CALL(*personal_data_manager_, Refresh()); | 1288 EXPECT_CALL(*personal_data_manager_, Refresh()); | 
| 1264 StartSyncService(add_autofill.callback(), false, syncer::AUTOFILL_PROFILE); | 1289 StartSyncService(add_autofill.callback(), false, syncer::AUTOFILL_PROFILE); | 
| 1265 ASSERT_TRUE(add_autofill.success()); | 1290 ASSERT_TRUE(add_autofill.success()); | 
| 1266 | 1291 | 
| 1267 AutofillProfileChange change(AutofillProfileChange::REMOVE, | 1292 AutofillProfileChange change( | 
| 1268 sync_profile.guid(), NULL); | 1293 AutofillProfileChange::REMOVE, sync_profile.guid(), NULL); | 
| 1269 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( | 1294 web_data_service_->OnAutofillProfileChanged(change); | 
| 1270 db_thread_.DeprecatedGetThreadObject())); | |
| 1271 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | |
| 1272 content::Source<WebDataService>(web_data_service_.get()), | |
| 1273 content::Details<AutofillProfileChange>(&change)); | |
| 1274 | 1295 | 
| 1275 std::vector<AutofillProfile> new_sync_profiles; | 1296 std::vector<AutofillProfile> new_sync_profiles; | 
| 1276 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( | 1297 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( | 
| 1277 &new_sync_profiles)); | 1298 &new_sync_profiles)); | 
| 1278 ASSERT_EQ(0U, new_sync_profiles.size()); | 1299 ASSERT_EQ(0U, new_sync_profiles.size()); | 
| 1279 } | 1300 } | 
| 1280 | 1301 | 
| 1281 // http://crbug.com/57884 | 1302 // http://crbug.com/57884 | 
| 1282 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) { | 1303 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) { | 
| 1283 // Once for MergeDataAndStartSyncing() and twice for ProcessSyncChanges(), via | 1304 // Once for MergeDataAndStartSyncing() and twice for ProcessSyncChanges(), via | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1319 std::vector<AutofillEntry> sync_entries; | 1340 std::vector<AutofillEntry> sync_entries; | 
| 1320 std::vector<AutofillProfile> sync_profiles; | 1341 std::vector<AutofillProfile> sync_profiles; | 
| 1321 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1342 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 
| 1322 EXPECT_EQ(3U, sync_entries.size()); | 1343 EXPECT_EQ(3U, sync_entries.size()); | 
| 1323 EXPECT_EQ(0U, sync_profiles.size()); | 1344 EXPECT_EQ(0U, sync_profiles.size()); | 
| 1324 for (size_t i = 0; i < sync_entries.size(); i++) { | 1345 for (size_t i = 0; i < sync_entries.size(); i++) { | 
| 1325 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1346 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 
| 1326 << ", " << sync_entries[i].key().value(); | 1347 << ", " << sync_entries[i].key().value(); | 
| 1327 } | 1348 } | 
| 1328 } | 1349 } | 
| OLD | NEW |