diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 02:23:26 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 02:23:26 +0000 |
commit | ce78c1f9270ebcafb41dd90632716a639ff444a0 (patch) | |
tree | 7116cdce183071ee070d9d497804f500f4429f1b /chrome | |
parent | 8f6e658a45d2b3b8ac488eca254507e541aaaef6 (diff) | |
download | chromium_src-ce78c1f9270ebcafb41dd90632716a639ff444a0.zip chromium_src-ce78c1f9270ebcafb41dd90632716a639ff444a0.tar.gz chromium_src-ce78c1f9270ebcafb41dd90632716a639ff444a0.tar.bz2 |
Fix for autofill profile setup through infobar where the "imported" profile would
not get persisted. The problem was ImportFormData was assigning ID, which was causing
SetProfile to think it was an update, rather than an Add, and the update would then fail.
BUG=40297
TEST=PersonalDataManagerTest.ImportFormData (added)
Review URL: http://codereview.chromium.org/1589025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44045 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autofill/personal_data_manager.cc | 3 | ||||
-rw-r--r-- | chrome/browser/autofill/personal_data_manager_unittest.cc | 22 |
2 files changed, 23 insertions, 2 deletions
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc index a3affd7..8a711cd 100644 --- a/chrome/browser/autofill/personal_data_manager.cc +++ b/chrome/browser/autofill/personal_data_manager.cc @@ -126,8 +126,7 @@ bool PersonalDataManager::ImportFormData( // possible to import. int importable_fields = 0; int importable_credit_card_fields = 0; - imported_profile_.reset(new AutoFillProfile( - string16(), CreateNextUniqueID(&unique_profile_ids_))); + imported_profile_.reset(new AutoFillProfile(string16(), 0)); // TODO(jhawkins): Use a hash of the CC# instead of a list of unique IDs? imported_credit_card_.reset(new CreditCard(string16(), 0)); diff --git a/chrome/browser/autofill/personal_data_manager_unittest.cc b/chrome/browser/autofill/personal_data_manager_unittest.cc index ecce104..10d43a3 100644 --- a/chrome/browser/autofill/personal_data_manager_unittest.cc +++ b/chrome/browser/autofill/personal_data_manager_unittest.cc @@ -7,6 +7,7 @@ #include "base/scoped_ptr.h" #include "chrome/browser/autofill/autofill_common_unittest.h" #include "chrome/browser/autofill/autofill_profile.h" +#include "chrome/browser/autofill/form_structure.h" #include "chrome/browser/autofill/personal_data_manager.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/pref_service.h" @@ -17,6 +18,7 @@ #include "chrome/common/notification_type.h" #include "chrome/common/pref_names.h" #include "chrome/test/testing_profile.h" +#include "webkit/glue/form_data.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -343,6 +345,26 @@ TEST_F(PersonalDataManagerTest, Refresh) { EXPECT_EQ(profile0, *results2.at(0)); } +TEST_F(PersonalDataManagerTest, ImportFormData) { + webkit_glue::FormData form; + FormStructure form_structure(form); + std::vector<FormStructure*> forms; + forms.push_back(&form_structure); + personal_data_->ImportFormData(forms, NULL); + personal_data_->SaveImportedFormData(); + + // And wait for the refresh. + EXPECT_CALL(personal_data_observer_, + OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); + + MessageLoop::current()->Run(); + + AutoFillProfile expected(ASCIIToUTF16("Unlabeled"), 1); + const std::vector<AutoFillProfile*>& results = personal_data_->profiles(); + ASSERT_EQ(1U, results.size()); + ASSERT_EQ(expected, *results[0]); +} + TEST_F(PersonalDataManagerTest, DefaultProfiles) { AutoFillProfile profile0(string16(), 0); autofill_unittest::SetProfileInfo(&profile0, |