| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 class ProfileSyncServiceAutofillTest : public testing::Test { | 132 class ProfileSyncServiceAutofillTest : public testing::Test { |
| 133 protected: | 133 protected: |
| 134 ProfileSyncServiceAutofillTest() | 134 ProfileSyncServiceAutofillTest() |
| 135 : ui_thread_(ChromeThread::UI, &message_loop_), | 135 : ui_thread_(ChromeThread::UI, &message_loop_), |
| 136 db_thread_(ChromeThread::DB) { | 136 db_thread_(ChromeThread::DB) { |
| 137 } | 137 } |
| 138 | 138 |
| 139 virtual void SetUp() { | 139 virtual void SetUp() { |
| 140 web_data_service_ = new WebDataServiceFake(&web_database_); | 140 web_data_service_ = new WebDataServiceFake(&web_database_); |
| 141 personal_data_manager_.Init(&profile_); | 141 personal_data_manager_ = new PersonalDataManagerMock(); |
| 142 personal_data_manager_->Init(&profile_); |
| 142 db_thread_.Start(); | 143 db_thread_.Start(); |
| 143 | 144 |
| 144 notification_service_ = new ThreadNotificationService(&db_thread_); | 145 notification_service_ = new ThreadNotificationService(&db_thread_); |
| 145 notification_service_->Init(); | 146 notification_service_->Init(); |
| 146 } | 147 } |
| 147 | 148 |
| 148 virtual void TearDown() { | 149 virtual void TearDown() { |
| 149 service_.reset(); | 150 service_.reset(); |
| 150 notification_service_->TearDown(); | 151 notification_service_->TearDown(); |
| 151 db_thread_.Stop(); | 152 db_thread_.Stop(); |
| 152 MessageLoop::current()->RunAllPending(); | 153 MessageLoop::current()->RunAllPending(); |
| 153 } | 154 } |
| 154 | 155 |
| 155 void StartSyncService(Task* task) { | 156 void StartSyncService(Task* task) { |
| 156 if (!service_.get()) { | 157 if (!service_.get()) { |
| 157 service_.reset( | 158 service_.reset( |
| 158 new TestProfileSyncService(&factory_, &profile_, false, false)); | 159 new TestProfileSyncService(&factory_, &profile_, false, false)); |
| 159 service_->AddObserver(&observer_); | 160 service_->AddObserver(&observer_); |
| 160 AutofillDataTypeController* data_type_controller = | 161 AutofillDataTypeController* data_type_controller = |
| 161 new AutofillDataTypeController(&factory_, | 162 new AutofillDataTypeController(&factory_, |
| 162 &profile_, | 163 &profile_, |
| 163 service_.get()); | 164 service_.get()); |
| 164 | 165 |
| 165 EXPECT_CALL(factory_, CreateAutofillSyncComponents(_, _, _, _)). | 166 EXPECT_CALL(factory_, CreateAutofillSyncComponents(_, _, _, _)). |
| 166 WillOnce(MakeAutofillSyncComponents(service_.get(), | 167 WillOnce(MakeAutofillSyncComponents(service_.get(), |
| 167 &web_database_, | 168 &web_database_, |
| 168 &personal_data_manager_, | 169 personal_data_manager_.get(), |
| 169 data_type_controller)); | 170 data_type_controller)); |
| 170 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). | 171 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). |
| 171 WillOnce(MakeDataTypeManager(&backend_)); | 172 WillOnce(MakeDataTypeManager(&backend_)); |
| 172 | 173 |
| 173 EXPECT_CALL(profile_, GetWebDataService(_)). | 174 EXPECT_CALL(profile_, GetWebDataService(_)). |
| 174 WillOnce(Return(web_data_service_.get())); | 175 WillOnce(Return(web_data_service_.get())); |
| 175 | 176 |
| 176 EXPECT_CALL(profile_, GetPersonalDataManager()). | 177 EXPECT_CALL(profile_, GetPersonalDataManager()). |
| 177 WillRepeatedly(Return(&personal_data_manager_)); | 178 WillRepeatedly(Return(personal_data_manager_.get())); |
| 178 | 179 |
| 179 EXPECT_CALL(personal_data_manager_, IsDataLoaded()). | 180 EXPECT_CALL(*(personal_data_manager_.get()), IsDataLoaded()). |
| 180 WillRepeatedly(Return(true)); | 181 WillRepeatedly(Return(true)); |
| 181 | 182 |
| 182 // State changes once for the backend init and once for startup done. | 183 // State changes once for the backend init and once for startup done. |
| 183 EXPECT_CALL(observer_, OnStateChanged()). | 184 EXPECT_CALL(observer_, OnStateChanged()). |
| 184 WillOnce(InvokeTask(task)). | 185 WillOnce(InvokeTask(task)). |
| 185 WillOnce(Return()). | 186 WillOnce(Return()). |
| 186 WillOnce(QuitUIMessageLoop()); | 187 WillOnce(QuitUIMessageLoop()); |
| 187 service_->RegisterDataTypeController(data_type_controller); | 188 service_->RegisterDataTypeController(data_type_controller); |
| 188 service_->Initialize(); | 189 service_->Initialize(); |
| 189 MessageLoop::current()->Run(); | 190 MessageLoop::current()->Run(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 ChromeThread db_thread_; | 315 ChromeThread db_thread_; |
| 315 scoped_refptr<ThreadNotificationService> notification_service_; | 316 scoped_refptr<ThreadNotificationService> notification_service_; |
| 316 | 317 |
| 317 scoped_ptr<TestProfileSyncService> service_; | 318 scoped_ptr<TestProfileSyncService> service_; |
| 318 ProfileMock profile_; | 319 ProfileMock profile_; |
| 319 ProfileSyncFactoryMock factory_; | 320 ProfileSyncFactoryMock factory_; |
| 320 ProfileSyncServiceObserverMock observer_; | 321 ProfileSyncServiceObserverMock observer_; |
| 321 SyncBackendHostMock backend_; | 322 SyncBackendHostMock backend_; |
| 322 WebDatabaseMock web_database_; | 323 WebDatabaseMock web_database_; |
| 323 scoped_refptr<WebDataService> web_data_service_; | 324 scoped_refptr<WebDataService> web_data_service_; |
| 324 PersonalDataManagerMock personal_data_manager_; | 325 scoped_refptr<PersonalDataManagerMock> personal_data_manager_; |
| 325 | 326 |
| 326 TestIdFactory ids_; | 327 TestIdFactory ids_; |
| 327 }; | 328 }; |
| 328 | 329 |
| 329 class CreateAutofillRootTask : public Task { | 330 class CreateAutofillRootTask : public Task { |
| 330 public: | 331 public: |
| 331 explicit CreateAutofillRootTask(ProfileSyncServiceAutofillTest* test) | 332 explicit CreateAutofillRootTask(ProfileSyncServiceAutofillTest* test) |
| 332 : test_(test) { | 333 : test_(test) { |
| 333 } | 334 } |
| 334 | 335 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 // Owned by GetAutoFillProfiles caller. | 421 // Owned by GetAutoFillProfiles caller. |
| 421 AutoFillProfile* profile0 = new AutoFillProfile(string16(), 0); | 422 AutoFillProfile* profile0 = new AutoFillProfile(string16(), 0); |
| 422 autofill_unittest::SetProfileInfo(profile0, | 423 autofill_unittest::SetProfileInfo(profile0, |
| 423 "Billing", "Marion", "Mitchell", "Morrison", | 424 "Billing", "Marion", "Mitchell", "Morrison", |
| 424 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 425 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 425 "91601", "US", "12345678910", "01987654321"); | 426 "91601", "US", "12345678910", "01987654321"); |
| 426 profiles.push_back(profile0); | 427 profiles.push_back(profile0); |
| 427 expected_profiles.push_back(*profile0); | 428 expected_profiles.push_back(*profile0); |
| 428 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)). | 429 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)). |
| 429 WillOnce(DoAll(SetArgumentPointee<0>(profiles), Return(true))); | 430 WillOnce(DoAll(SetArgumentPointee<0>(profiles), Return(true))); |
| 430 EXPECT_CALL(personal_data_manager_, Refresh()); | 431 EXPECT_CALL(*(personal_data_manager_.get()), Refresh()); |
| 431 SetIdleChangeProcessorExpectations(); | 432 SetIdleChangeProcessorExpectations(); |
| 432 CreateAutofillRootTask task(this); | 433 CreateAutofillRootTask task(this); |
| 433 StartSyncService(&task); | 434 StartSyncService(&task); |
| 434 std::vector<AutofillEntry> sync_entries; | 435 std::vector<AutofillEntry> sync_entries; |
| 435 std::vector<AutoFillProfile> sync_profiles; | 436 std::vector<AutoFillProfile> sync_profiles; |
| 436 GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles); | 437 GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles); |
| 437 ASSERT_EQ(1U, entries.size()); | 438 ASSERT_EQ(1U, entries.size()); |
| 438 EXPECT_TRUE(entries[0] == sync_entries[0]); | 439 EXPECT_TRUE(entries[0] == sync_entries[0]); |
| 439 EXPECT_EQ(1U, sync_profiles.size()); | 440 EXPECT_EQ(1U, sync_profiles.size()); |
| 440 EXPECT_EQ(expected_profiles[0], sync_profiles[0]); | 441 EXPECT_EQ(expected_profiles[0], sync_profiles[0]); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 autofill_unittest::SetProfileInfo(profile1, | 482 autofill_unittest::SetProfileInfo(profile1, |
| 482 "Billing", "Same", "Label", "Morrison", | 483 "Billing", "Same", "Label", "Morrison", |
| 483 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 484 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 484 "91601", "US", "12345678910", "01987654321"); | 485 "91601", "US", "12345678910", "01987654321"); |
| 485 profiles.push_back(profile0); | 486 profiles.push_back(profile0); |
| 486 profiles.push_back(profile1); | 487 profiles.push_back(profile1); |
| 487 expected_profiles.push_back(*profile0); | 488 expected_profiles.push_back(*profile0); |
| 488 expected_profiles.push_back(*profile1); | 489 expected_profiles.push_back(*profile1); |
| 489 AutoFillProfile relabelled_profile; | 490 AutoFillProfile relabelled_profile; |
| 490 EXPECT_CALL(web_database_, GetAllAutofillEntries(_)).WillOnce(Return(true)); | 491 EXPECT_CALL(web_database_, GetAllAutofillEntries(_)).WillOnce(Return(true)); |
| 491 EXPECT_CALL(personal_data_manager_, Refresh()); | 492 EXPECT_CALL(*(personal_data_manager_.get()), Refresh()); |
| 492 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)). | 493 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)). |
| 493 WillOnce(DoAll(SetArgumentPointee<0>(profiles), Return(true))); | 494 WillOnce(DoAll(SetArgumentPointee<0>(profiles), Return(true))); |
| 494 EXPECT_CALL(web_database_, UpdateAutoFillProfile( | 495 EXPECT_CALL(web_database_, UpdateAutoFillProfile( |
| 495 ProfileMatchesExceptLabel(expected_profiles[1]))). | 496 ProfileMatchesExceptLabel(expected_profiles[1]))). |
| 496 WillOnce(DoAll(SaveArg<0>(&relabelled_profile), Return(true))); | 497 WillOnce(DoAll(SaveArg<0>(&relabelled_profile), Return(true))); |
| 497 | 498 |
| 498 SetIdleChangeProcessorExpectations(); | 499 SetIdleChangeProcessorExpectations(); |
| 499 CreateAutofillRootTask task(this); | 500 CreateAutofillRootTask task(this); |
| 500 StartSyncService(&task); | 501 StartSyncService(&task); |
| 501 std::vector<AutofillEntry> sync_entries; | 502 std::vector<AutofillEntry> sync_entries; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 std::vector<AutoFillProfile> sync_profiles; | 562 std::vector<AutoFillProfile> sync_profiles; |
| 562 sync_profiles.push_back(sync_profile); | 563 sync_profiles.push_back(sync_profile); |
| 563 AddAutofillEntriesTask task(this, sync_entries, sync_profiles); | 564 AddAutofillEntriesTask task(this, sync_entries, sync_profiles); |
| 564 | 565 |
| 565 AutoFillProfile to_be_added(sync_profile); | 566 AutoFillProfile to_be_added(sync_profile); |
| 566 to_be_added.set_unique_id(1); | 567 to_be_added.set_unique_id(1); |
| 567 EXPECT_CALL(web_database_, UpdateAutofillEntries(ElementsAre(sync_entry))). | 568 EXPECT_CALL(web_database_, UpdateAutofillEntries(ElementsAre(sync_entry))). |
| 568 WillOnce(Return(true)); | 569 WillOnce(Return(true)); |
| 569 EXPECT_CALL(web_database_, AddAutoFillProfile(Eq(to_be_added))). | 570 EXPECT_CALL(web_database_, AddAutoFillProfile(Eq(to_be_added))). |
| 570 WillOnce(Return(true)); | 571 WillOnce(Return(true)); |
| 571 EXPECT_CALL(personal_data_manager_, Refresh()); | 572 EXPECT_CALL(*(personal_data_manager_.get()), Refresh()); |
| 572 StartSyncService(&task); | 573 StartSyncService(&task); |
| 573 | 574 |
| 574 std::set<AutofillEntry> expected_entries; | 575 std::set<AutofillEntry> expected_entries; |
| 575 expected_entries.insert(native_entry); | 576 expected_entries.insert(native_entry); |
| 576 expected_entries.insert(sync_entry); | 577 expected_entries.insert(sync_entry); |
| 577 | 578 |
| 578 std::vector<AutofillEntry> new_sync_entries; | 579 std::vector<AutofillEntry> new_sync_entries; |
| 579 std::vector<AutoFillProfile> new_sync_profiles; | 580 std::vector<AutoFillProfile> new_sync_profiles; |
| 580 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles); | 581 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles); |
| 581 std::set<AutofillEntry> new_sync_entries_set(new_sync_entries.begin(), | 582 std::set<AutofillEntry> new_sync_entries_set(new_sync_entries.begin(), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)). | 634 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)). |
| 634 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); | 635 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); |
| 635 | 636 |
| 636 std::vector<AutofillEntry> sync_entries; | 637 std::vector<AutofillEntry> sync_entries; |
| 637 std::vector<AutoFillProfile> sync_profiles; | 638 std::vector<AutoFillProfile> sync_profiles; |
| 638 sync_profiles.push_back(sync_profile); | 639 sync_profiles.push_back(sync_profile); |
| 639 AddAutofillEntriesTask task(this, sync_entries, sync_profiles); | 640 AddAutofillEntriesTask task(this, sync_entries, sync_profiles); |
| 640 | 641 |
| 641 EXPECT_CALL(web_database_, UpdateAutoFillProfile(Eq(sync_profile))). | 642 EXPECT_CALL(web_database_, UpdateAutoFillProfile(Eq(sync_profile))). |
| 642 WillOnce(Return(true)); | 643 WillOnce(Return(true)); |
| 643 EXPECT_CALL(personal_data_manager_, Refresh()); | 644 EXPECT_CALL(*(personal_data_manager_.get()), Refresh()); |
| 644 StartSyncService(&task); | 645 StartSyncService(&task); |
| 645 | 646 |
| 646 std::vector<AutofillEntry> new_sync_entries; | 647 std::vector<AutofillEntry> new_sync_entries; |
| 647 std::vector<AutoFillProfile> new_sync_profiles; | 648 std::vector<AutoFillProfile> new_sync_profiles; |
| 648 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles); | 649 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles); |
| 649 ASSERT_EQ(1U, new_sync_profiles.size()); | 650 ASSERT_EQ(1U, new_sync_profiles.size()); |
| 650 EXPECT_TRUE(sync_profile == new_sync_profiles[0]); | 651 EXPECT_TRUE(sync_profile == new_sync_profiles[0]); |
| 651 } | 652 } |
| 652 | 653 |
| 653 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddEntry) { | 654 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddEntry) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 731 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
| 731 "32801", "US", "19482937549", "13502849239"); | 732 "32801", "US", "19482937549", "13502849239"); |
| 732 | 733 |
| 733 AutofillProfileChange change(AutofillProfileChange::ADD, | 734 AutofillProfileChange change(AutofillProfileChange::ADD, |
| 734 added_profile.Label(), &added_profile, string16()); | 735 added_profile.Label(), &added_profile, string16()); |
| 735 | 736 |
| 736 AutoFillProfile relabelled_profile; | 737 AutoFillProfile relabelled_profile; |
| 737 EXPECT_CALL(web_database_, UpdateAutoFillProfile( | 738 EXPECT_CALL(web_database_, UpdateAutoFillProfile( |
| 738 ProfileMatchesExceptLabel(added_profile))). | 739 ProfileMatchesExceptLabel(added_profile))). |
| 739 WillOnce(DoAll(SaveArg<0>(&relabelled_profile), Return(true))); | 740 WillOnce(DoAll(SaveArg<0>(&relabelled_profile), Return(true))); |
| 740 EXPECT_CALL(personal_data_manager_, Refresh()); | 741 EXPECT_CALL(*(personal_data_manager_.get()), Refresh()); |
| 741 | 742 |
| 742 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); | 743 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); |
| 743 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, | 744 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, |
| 744 Source<WebDataService>(web_data_service_.get()), | 745 Source<WebDataService>(web_data_service_.get()), |
| 745 Details<AutofillProfileChange>(&change)); | 746 Details<AutofillProfileChange>(&change)); |
| 746 | 747 |
| 747 std::vector<AutofillEntry> new_sync_entries; | 748 std::vector<AutofillEntry> new_sync_entries; |
| 748 std::vector<AutoFillProfile> new_sync_profiles; | 749 std::vector<AutoFillProfile> new_sync_profiles; |
| 749 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles); | 750 GetAutofillEntriesFromSyncDB(&new_sync_entries, &new_sync_profiles); |
| 750 ASSERT_EQ(2U, new_sync_profiles.size()); | 751 ASSERT_EQ(2U, new_sync_profiles.size()); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)). | 881 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)). |
| 881 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); | 882 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); |
| 882 CreateAutofillRootTask task(this); | 883 CreateAutofillRootTask task(this); |
| 883 StartSyncService(&task); | 884 StartSyncService(&task); |
| 884 | 885 |
| 885 josephine_update.set_label(ASCIIToUTF16("ExistingLabel")); | 886 josephine_update.set_label(ASCIIToUTF16("ExistingLabel")); |
| 886 AutoFillProfile relabelled_profile; | 887 AutoFillProfile relabelled_profile; |
| 887 EXPECT_CALL(web_database_, UpdateAutoFillProfile( | 888 EXPECT_CALL(web_database_, UpdateAutoFillProfile( |
| 888 ProfileMatchesExceptLabel(josephine_update))). | 889 ProfileMatchesExceptLabel(josephine_update))). |
| 889 WillOnce(DoAll(SaveArg<0>(&relabelled_profile), Return(true))); | 890 WillOnce(DoAll(SaveArg<0>(&relabelled_profile), Return(true))); |
| 890 EXPECT_CALL(personal_data_manager_, Refresh()); | 891 EXPECT_CALL(*(personal_data_manager_.get()), Refresh()); |
| 891 | 892 |
| 892 AutofillProfileChange change(AutofillProfileChange::UPDATE, | 893 AutofillProfileChange change(AutofillProfileChange::UPDATE, |
| 893 josephine_update.Label(), &josephine_update, | 894 josephine_update.Label(), &josephine_update, |
| 894 ASCIIToUTF16("Billing")); | 895 ASCIIToUTF16("Billing")); |
| 895 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); | 896 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); |
| 896 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, | 897 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, |
| 897 Source<WebDataService>(web_data_service_.get()), | 898 Source<WebDataService>(web_data_service_.get()), |
| 898 Details<AutofillProfileChange>(&change)); | 899 Details<AutofillProfileChange>(&change)); |
| 899 | 900 |
| 900 std::vector<AutofillEntry> new_sync_entries; | 901 std::vector<AutofillEntry> new_sync_entries; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 native_profiles.push_back(native_profile); | 950 native_profiles.push_back(native_profile); |
| 950 EXPECT_CALL(web_database_, GetAllAutofillEntries(_)). WillOnce(Return(true)); | 951 EXPECT_CALL(web_database_, GetAllAutofillEntries(_)). WillOnce(Return(true)); |
| 951 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)). | 952 EXPECT_CALL(web_database_, GetAutoFillProfiles(_)). |
| 952 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); | 953 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); |
| 953 | 954 |
| 954 std::vector<AutofillEntry> sync_entries; | 955 std::vector<AutofillEntry> sync_entries; |
| 955 std::vector<AutoFillProfile> sync_profiles; | 956 std::vector<AutoFillProfile> sync_profiles; |
| 956 sync_profiles.push_back(sync_profile); | 957 sync_profiles.push_back(sync_profile); |
| 957 AddAutofillEntriesTask task(this, sync_entries, sync_profiles); | 958 AddAutofillEntriesTask task(this, sync_entries, sync_profiles); |
| 958 | 959 |
| 959 EXPECT_CALL(personal_data_manager_, Refresh()); | 960 EXPECT_CALL(*(personal_data_manager_.get()), Refresh()); |
| 960 StartSyncService(&task); | 961 StartSyncService(&task); |
| 961 | 962 |
| 962 AutofillProfileChange change(AutofillProfileChange::REMOVE, | 963 AutofillProfileChange change(AutofillProfileChange::REMOVE, |
| 963 sync_profile.Label(), NULL, string16()); | 964 sync_profile.Label(), NULL, string16()); |
| 964 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); | 965 scoped_refptr<ThreadNotifier> notifier = new ThreadNotifier(&db_thread_); |
| 965 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, | 966 notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, |
| 966 Source<WebDataService>(web_data_service_.get()), | 967 Source<WebDataService>(web_data_service_.get()), |
| 967 Details<AutofillProfileChange>(&change)); | 968 Details<AutofillProfileChange>(&change)); |
| 968 | 969 |
| 969 std::vector<AutofillEntry> new_sync_entries; | 970 std::vector<AutofillEntry> new_sync_entries; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 994 // Wait for the PPS to shut everything down and signal us. | 995 // Wait for the PPS to shut everything down and signal us. |
| 995 EXPECT_CALL(observer_, OnStateChanged()).WillOnce(QuitUIMessageLoop()); | 996 EXPECT_CALL(observer_, OnStateChanged()).WillOnce(QuitUIMessageLoop()); |
| 996 MessageLoop::current()->Run(); | 997 MessageLoop::current()->Run(); |
| 997 EXPECT_TRUE(service_->unrecoverable_error_detected()); | 998 EXPECT_TRUE(service_->unrecoverable_error_detected()); |
| 998 | 999 |
| 999 // Ensure future autofill notifications don't crash. | 1000 // Ensure future autofill notifications don't crash. |
| 1000 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED, | 1001 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED, |
| 1001 Source<WebDataService>(web_data_service_.get()), | 1002 Source<WebDataService>(web_data_service_.get()), |
| 1002 Details<AutofillChangeList>(&changes)); | 1003 Details<AutofillChangeList>(&changes)); |
| 1003 } | 1004 } |
| OLD | NEW |