summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 15:52:24 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 15:52:24 +0000
commit023e18285f389eaef64ddd074b7bd704e3345c53 (patch)
tree090457b1a745dbce9a068b41e9270e2a7cdfb4a8
parentf96002266b393c92c388d1b9b34c2379f39a8778 (diff)
downloadchromium_src-023e18285f389eaef64ddd074b7bd704e3345c53.zip
chromium_src-023e18285f389eaef64ddd074b7bd704e3345c53.tar.gz
chromium_src-023e18285f389eaef64ddd074b7bd704e3345c53.tar.bz2
Revert 81421 - Looks to have broken unittest, see http://chromegw.corp.google.com/i/chromium/builders/Vista%20Tests%20%28dbg%29%281%29/builds/8263/steps/unit_tests/logs/TestLongSafePureFilenameRevert 81416 - Autofill extend profiles to include multi-valued fields, part 6 (Aggregation)Extends the Autofill aggregation logic to merge profiles with a common address into a single profile with multi-valued fields. Also, extends the web_database migration to include this new logic when migrating the web_database preferences.BUG=65625TEST=WebDatabaseMigrationTest.MigrateVersion32ToCurrent:AutofillMergeTest.DataDrivenMergeProfiles:AutofillProfileTest.*Review URL: http://codereview.chromium.org/6826059TBR=dhollowa@chromium.orgReview URL: http://codereview.chromium.org/6833026
TBR=siggi@chromium.org Review URL: http://codereview.chromium.org/6834028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81425 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autofill/autofill_merge_unittest.cc24
-rw-r--r--chrome/browser/autofill/autofill_profile.cc85
-rw-r--r--chrome/browser/autofill/autofill_profile.h7
-rw-r--r--chrome/browser/autofill/personal_data_manager.cc20
-rw-r--r--chrome/browser/autofill/personal_data_manager_unittest.cc116
-rw-r--r--chrome/browser/webdata/autofill_table.cc2
-rw-r--r--chrome/browser/webdata/autofill_table.h2
-rw-r--r--chrome/browser/webdata/web_database.cc18
-rw-r--r--chrome/browser/webdata/web_database_migration_unittest.cc36
-rw-r--r--chrome/test/data/autofill/merge/input/ambiguous.in21
-rw-r--r--chrome/test/data/autofill/merge/input/identical.in8
-rw-r--r--chrome/test/data/autofill/merge/input/multimerge.in28
-rw-r--r--chrome/test/data/autofill/merge/input/singlemerge.in28
-rw-r--r--chrome/test/data/autofill/merge/input/validation.in20
-rw-r--r--chrome/test/data/autofill/merge/output/ambiguous.out0
-rw-r--r--chrome/test/data/autofill/merge/output/identical.out4
-rw-r--r--chrome/test/data/autofill/merge/output/multimerge.out19
-rw-r--r--chrome/test/data/autofill/merge/output/singlemerge.out14
-rw-r--r--chrome/test/data/autofill/merge/output/validation.out4
19 files changed, 380 insertions, 76 deletions
diff --git a/chrome/browser/autofill/autofill_merge_unittest.cc b/chrome/browser/autofill/autofill_merge_unittest.cc
index cbd83d3..64ee661 100644
--- a/chrome/browser/autofill/autofill_merge_unittest.cc
+++ b/chrome/browser/autofill/autofill_merge_unittest.cc
@@ -39,8 +39,8 @@ const AutofillFieldType kProfileFieldTypes[] = {
ADDRESS_HOME_STATE,
ADDRESS_HOME_ZIP,
ADDRESS_HOME_COUNTRY,
- PHONE_HOME_NUMBER,
- PHONE_FAX_NUMBER,
+ PHONE_HOME_WHOLE_NUMBER,
+ PHONE_FAX_WHOLE_NUMBER,
};
// Serializes the |profiles| into a string.
@@ -51,10 +51,14 @@ std::string SerializeProfiles(const std::vector<AutofillProfile*>& profiles) {
result += "\n";
for (size_t j = 0; j < arraysize(kProfileFieldTypes); ++j) {
AutofillFieldType type = kProfileFieldTypes[j];
- result += AutofillType::FieldTypeToString(type);
- result += kFieldSeparator;
- result += UTF16ToUTF8(profiles[i]->GetInfo(type));
- result += "\n";
+ std::vector<string16> values;
+ profiles[i]->GetMultiInfo(type, &values);
+ for (size_t k = 0; k < values.size(); ++k) {
+ result += AutofillType::FieldTypeToString(type);
+ result += kFieldSeparator;
+ result += UTF16ToUTF8(values[k]);
+ result += "\n";
+ }
}
}
@@ -144,11 +148,6 @@ void AutofillMergeTest::SetUp() {
void AutofillMergeTest::GenerateResults(const std::string& input,
std::string* output) {
MergeProfiles(input, output);
-
- // Verify that the test is idempotent on the output profiles.
- std::string merged_output;
- MergeProfiles(*output, &merged_output);
- EXPECT_EQ(*output, merged_output);
}
void AutofillMergeTest::MergeProfiles(const std::string& profiles,
@@ -188,8 +187,7 @@ void AutofillMergeTest::MergeProfiles(const std::string& profiles,
// The first line is always a profile separator, and the last profile is not
// followed by an explicit separator.
- if ((i > 0 && line == kProfileSeparator) ||
- i == lines.size() - 1) {
+ if ((i > 0 && line == kProfileSeparator) || i == lines.size() - 1) {
// Reached the end of a profile. Try to import it.
FormStructure form_structure(form);
for (size_t i = 0; i < form_structure.field_count(); ++i) {
diff --git a/chrome/browser/autofill/autofill_profile.cc b/chrome/browser/autofill/autofill_profile.cc
index 7a526cc..d21c712 100644
--- a/chrome/browser/autofill/autofill_profile.cc
+++ b/chrome/browser/autofill/autofill_profile.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/autofill/autofill_profile.h"
+#include <algorithm>
#include <map>
#include <set>
@@ -134,6 +135,45 @@ void CopyItemsToValues(AutofillFieldType type,
(*values)[i] = form_group_items[i].GetInfo(type);
}
+// Collapse compound field types to their "full" type. I.e. First name
+// collapses to full name, area code collapses to full phone, etc.
+void CollapseCompoundFieldTypes(FieldTypeSet* type_set) {
+ FieldTypeSet collapsed_set;
+ for (FieldTypeSet::iterator iter = type_set->begin(); iter != type_set->end();
+ ++iter) {
+ switch (*iter) {
+ case NAME_FIRST:
+ case NAME_MIDDLE:
+ case NAME_LAST:
+ case NAME_MIDDLE_INITIAL:
+ case NAME_FULL:
+ case NAME_SUFFIX:
+ collapsed_set.insert(NAME_FULL);
+ break;
+
+ case PHONE_HOME_NUMBER:
+ case PHONE_HOME_CITY_CODE:
+ case PHONE_HOME_COUNTRY_CODE:
+ case PHONE_HOME_CITY_AND_NUMBER:
+ case PHONE_HOME_WHOLE_NUMBER:
+ collapsed_set.insert(PHONE_HOME_WHOLE_NUMBER);
+ break;
+
+ case PHONE_FAX_NUMBER:
+ case PHONE_FAX_CITY_CODE:
+ case PHONE_FAX_COUNTRY_CODE:
+ case PHONE_FAX_CITY_AND_NUMBER:
+ case PHONE_FAX_WHOLE_NUMBER:
+ collapsed_set.insert(PHONE_FAX_WHOLE_NUMBER);
+ break;
+
+ default:
+ collapsed_set.insert(*iter);
+ }
+ }
+ std::swap(*type_set, collapsed_set);
+}
+
} // namespace
AutofillProfile::AutofillProfile(const std::string& guid)
@@ -252,6 +292,15 @@ void AutofillProfile::GetMultiInfo(AutofillFieldType type,
}
}
+// static
+bool AutofillProfile::SupportsMultiValue(AutofillFieldType type) {
+ AutofillType::FieldTypeGroup group = AutofillType(type).group();
+ return group == AutofillType::NAME ||
+ group == AutofillType::EMAIL ||
+ group == AutofillType::PHONE_HOME ||
+ group == AutofillType::PHONE_FAX;
+}
+
const string16 AutofillProfile::Label() const {
return label_;
}
@@ -411,10 +460,38 @@ bool AutofillProfile::operator!=(const AutofillProfile& profile) const {
}
const string16 AutofillProfile::PrimaryValue() const {
- return GetInfo(NAME_FULL) +
- GetInfo(ADDRESS_HOME_LINE1) +
- GetInfo(ADDRESS_HOME_LINE2) +
- GetInfo(EMAIL_ADDRESS);
+ return GetInfo(ADDRESS_HOME_LINE1) +
+ GetInfo(ADDRESS_HOME_CITY);
+}
+
+void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile) {
+ FieldTypeSet field_types;
+ profile.GetAvailableFieldTypes(&field_types);
+
+ // Only transfer "full" types (e.g. full name) and not fragments (e.g.
+ // first name, last name).
+ CollapseCompoundFieldTypes(&field_types);
+
+ for (FieldTypeSet::const_iterator iter = field_types.begin();
+ iter != field_types.end(); ++iter) {
+ if (AutofillProfile::SupportsMultiValue(*iter)) {
+ std::vector<string16> new_values;
+ profile.GetMultiInfo(*iter, &new_values);
+ std::vector<string16> existing_values;
+ GetMultiInfo(*iter, &existing_values);
+ for (std::vector<string16>::iterator value_iter = new_values.begin();
+ value_iter != new_values.end(); ++value_iter) {
+ // Don't add duplicates.
+ if (std::find(existing_values.begin(), existing_values.end(),
+ *value_iter) == existing_values.end()) {
+ existing_values.insert(existing_values.end(), *value_iter);
+ }
+ }
+ SetMultiInfo(*iter, existing_values);
+ } else {
+ SetInfo(*iter, profile.GetInfo(*iter));
+ }
+ }
}
string16 AutofillProfile::ConstructInferredLabel(
diff --git a/chrome/browser/autofill/autofill_profile.h b/chrome/browser/autofill/autofill_profile.h
index ea301b7..4610482 100644
--- a/chrome/browser/autofill/autofill_profile.h
+++ b/chrome/browser/autofill/autofill_profile.h
@@ -49,6 +49,9 @@ class AutofillProfile : public FormGroup {
void GetMultiInfo(AutofillFieldType type,
std::vector<string16>* values) const;
+ // Returns |true| if |type| accepts multi-values.
+ static bool SupportsMultiValue(AutofillFieldType type);
+
// The user-visible label of the profile, generated in relation to other
// profiles. Shows at least 2 fields that differentiate profile from other
// profiles. See AdjustInferredLabels() further down for more description.
@@ -116,6 +119,10 @@ class AutofillProfile : public FormGroup {
// aid with correct aggregation of new data.
const string16 PrimaryValue() const;
+ // Overwrites the single-valued field data in |profile| with this
+ // Profile. Or, for multi-valued fields append the new values.
+ void OverwriteWithOrAddTo(const AutofillProfile& profile);
+
private:
typedef std::vector<const FormGroup*> FormGroupList;
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
index 46fee8a3..184b7a9 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -195,6 +195,10 @@ bool PersonalDataManager::ImportFormData(
// possible to import.
int importable_credit_card_fields = 0;
std::vector<const FormStructure*>::const_iterator iter;
+
+ // Detect and discard forms with multiple fields of the same type.
+ std::set<AutofillFieldType> types_seen;
+
for (iter = form_structures.begin(); iter != form_structures.end(); ++iter) {
const FormStructure* form = *iter;
for (size_t i = 0; i < form->field_count(); ++i) {
@@ -209,6 +213,20 @@ bool PersonalDataManager::ImportFormData(
AutofillFieldType field_type = field->type();
FieldTypeGroup group(AutofillType(field_type).group());
+ // Abandon the import if two fields of the same type are encountered.
+ // This indicates ambiguous data or miscategorization of types.
+ // Make an exception for PHONE_HOME_NUMBER however as both prefix and
+ // suffix are stored against this type.
+ if (types_seen.count(field_type) &&
+ field_type != PHONE_HOME_NUMBER &&
+ field_type != PHONE_FAX_NUMBER) {
+ imported_profile.reset();
+ local_imported_credit_card.reset();
+ break;
+ } else {
+ types_seen.insert(field_type);
+ }
+
if (group == AutofillType::CREDIT_CARD) {
// If the user has a password set, we have no way of setting credit
// card numbers.
@@ -713,7 +731,7 @@ bool PersonalDataManager::MergeProfile(
if (!profile.PrimaryValue().empty() &&
(*iter)->PrimaryValue() == profile.PrimaryValue()) {
merged = true;
- (*iter)->OverwriteWith(profile);
+ (*iter)->OverwriteWithOrAddTo(profile);
}
}
merged_profiles->push_back(**iter);
diff --git a/chrome/browser/autofill/personal_data_manager_unittest.cc b/chrome/browser/autofill/personal_data_manager_unittest.cc
index fa71c22..4c031b6 100644
--- a/chrome/browser/autofill/personal_data_manager_unittest.cc
+++ b/chrome/browser/autofill/personal_data_manager_unittest.cc
@@ -808,7 +808,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) {
"Email:", "email", "second@gmail.com", "text", &field);
form2.fields.push_back(field);
autofill_test::CreateTestFormField(
- "Address:", "address1", "21 Laussat St", "text", &field);
+ "Address:", "address1", "22 Laussat St", "text", &field);
form2.fields.push_back(field);
autofill_test::CreateTestFormField(
"City:", "city", "San Francisco", "text", &field);
@@ -837,13 +837,112 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) {
AutofillProfile expected2;
autofill_test::SetProfileInfo(&expected2, "John", NULL,
- "Adams", "second@gmail.com", NULL, "21 Laussat St", NULL,
+ "Adams", "second@gmail.com", NULL, "22 Laussat St", NULL,
"San Francisco", "California", "94102", NULL, NULL, NULL);
ASSERT_EQ(2U, results2.size());
EXPECT_EQ(0, expected.Compare(*results2[0]));
EXPECT_EQ(0, expected2.Compare(*results2[1]));
}
+TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) {
+ FormData form1;
+ webkit_glue::FormField field;
+ autofill_test::CreateTestFormField(
+ "First name:", "first_name", "George", "text", &field);
+ form1.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Last name:", "last_name", "Washington", "text", &field);
+ form1.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Email:", "email", "theprez@gmail.com", "text", &field);
+ form1.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Address:", "address1", "21 Laussat St", "text", &field);
+ form1.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "City:", "city", "San Francisco", "text", &field);
+ form1.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "State:", "state", "California", "text", &field);
+ form1.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Zip:", "zip", "94102", "text", &field);
+ form1.fields.push_back(field);
+
+ FormStructure form_structure1(form1);
+ form_structure1.DetermineHeuristicTypes();
+ std::vector<const FormStructure*> forms;
+ forms.push_back(&form_structure1);
+ const CreditCard* imported_credit_card;
+ EXPECT_TRUE(personal_data_->ImportFormData(forms, &imported_credit_card));
+ ASSERT_FALSE(imported_credit_card);
+
+ // Wait for the refresh.
+ EXPECT_CALL(personal_data_observer_,
+ OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop());
+
+ MessageLoop::current()->Run();
+
+ AutofillProfile expected;
+ autofill_test::SetProfileInfo(&expected, "George", NULL,
+ "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL,
+ "San Francisco", "California", "94102", NULL, NULL, NULL);
+ const std::vector<AutofillProfile*>& results1 = personal_data_->profiles();
+ ASSERT_EQ(1U, results1.size());
+ EXPECT_EQ(0, expected.Compare(*results1[0]));
+
+ // Now create a completely different profile.
+ FormData form2;
+ autofill_test::CreateTestFormField(
+ "First name:", "first_name", "John", "text", &field);
+ form2.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Last name:", "last_name", "Adams", "text", &field);
+ form2.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Email:", "email", "second@gmail.com", "text", &field);
+ form2.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Address:", "address1", "21 Laussat St", "text", &field);
+ form2.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "City:", "city", "San Francisco", "text", &field);
+ form2.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "State:", "state", "California", "text", &field);
+ form2.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Zip:", "zip", "94102", "text", &field);
+ form2.fields.push_back(field);
+
+ FormStructure form_structure2(form2);
+ form_structure2.DetermineHeuristicTypes();
+ forms.clear();
+ forms.push_back(&form_structure2);
+ EXPECT_TRUE(personal_data_->ImportFormData(forms, &imported_credit_card));
+ ASSERT_FALSE(imported_credit_card);
+
+ // Wait for the refresh.
+ EXPECT_CALL(personal_data_observer_,
+ OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop());
+
+ MessageLoop::current()->Run();
+
+ const std::vector<AutofillProfile*>& results2 = personal_data_->profiles();
+
+ // Modify expected to include multi-valued fields.
+ std::vector<string16> values;
+ expected.GetMultiInfo(NAME_FULL, &values);
+ values.push_back(ASCIIToUTF16("John Adams"));
+ expected.SetMultiInfo(NAME_FULL, values);
+ expected.GetMultiInfo(EMAIL_ADDRESS, &values);
+ values.push_back(ASCIIToUTF16("second@gmail.com"));
+ expected.SetMultiInfo(EMAIL_ADDRESS, values);
+
+ ASSERT_EQ(1U, results2.size());
+ EXPECT_EQ(0, expected.CompareMulti(*results2[0]));
+}
+
TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) {
FormData form1;
webkit_glue::FormField field;
@@ -949,13 +1048,14 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) {
const std::vector<AutofillProfile*>& results2 = personal_data_->profiles();
- AutofillProfile expected2;
- autofill_test::SetProfileInfo(&expected2, "George", NULL,
- "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue",
- "Suite A", "San Francisco", "California", "94102", "USA", "1231231234",
- NULL);
+ // Add multi-valued phone number to expectation. Also, country gets added.
+ std::vector<string16> values;
+ expected.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values);
+ values.push_back(ASCIIToUTF16("1231231234"));
+ expected.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, values);
+ expected.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States"));
ASSERT_EQ(1U, results2.size());
- EXPECT_EQ(0, expected2.Compare(*results2[0]));
+ EXPECT_EQ(0, expected.CompareMulti(*results2[0]));
}
TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) {
diff --git a/chrome/browser/webdata/autofill_table.cc b/chrome/browser/webdata/autofill_table.cc
index aca25f3..3a64c704 100644
--- a/chrome/browser/webdata/autofill_table.cc
+++ b/chrome/browser/webdata/autofill_table.cc
@@ -2051,7 +2051,7 @@ bool AutofillTable::MigrateToVersion35GreatBritainCountryCodes() {
}
// Merge and cull older profiles where possible.
-bool AutofillTable::MigrateToVersion36MergeAndCullOlderProfiles() {
+bool AutofillTable::MigrateToVersion37MergeAndCullOlderProfiles() {
sql::Statement s(db_->GetUniqueStatement(
"SELECT guid, date_modified FROM autofill_profiles"));
if (!s)
diff --git a/chrome/browser/webdata/autofill_table.h b/chrome/browser/webdata/autofill_table.h
index d86eb1c..38744e0 100644
--- a/chrome/browser/webdata/autofill_table.h
+++ b/chrome/browser/webdata/autofill_table.h
@@ -269,7 +269,7 @@ class AutofillTable : public WebDatabaseTable {
bool MigrateToVersion33ProfilesBasedOnFirstName();
bool MigrateToVersion34ProfilesBasedOnCountryCode();
bool MigrateToVersion35GreatBritainCountryCodes();
- bool MigrateToVersion36MergeAndCullOlderProfiles();
+ bool MigrateToVersion37MergeAndCullOlderProfiles();
private:
FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill);
diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc
index 6169be3..45a06a8 100644
--- a/chrome/browser/webdata/web_database.cc
+++ b/chrome/browser/webdata/web_database.cc
@@ -16,8 +16,8 @@ namespace {
// Current version number. Note: when changing the current version number,
// corresponding changes must happen in the unit tests, and new migration test
// added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|.
-const int kCurrentVersionNumber = 36;
-const int kCompatibleVersionNumber = 36;
+const int kCurrentVersionNumber = 37;
+const int kCompatibleVersionNumber = 37;
// Change the version number and possibly the compatibility version of
// |meta_table_|.
@@ -264,11 +264,19 @@ sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() {
ChangeVersion(&meta_table_, 35, true);
// FALL THROUGH
+ // Combine migrations 35 and 36. This is due to enhancements to the merge
+ // step when migrating profiles. The original migration from 35 to 36 did
+ // not merge profiles with identical addresses, but the migration from 36 to
+ // 37 does. The step from 35 to 36 should only happen on the Chrome 12 dev
+ // channel. Chrome 12 beta and release users will jump from 35 to 37
+ // directly getting the full benefits of the multi-valued merge as well as
+ // the culling of bad data.
case 35:
- if (!autofill_table_->MigrateToVersion36MergeAndCullOlderProfiles())
- return FailedMigrationTo(36);
+ case 36:
+ if (!autofill_table_->MigrateToVersion37MergeAndCullOlderProfiles())
+ return FailedMigrationTo(37);
- ChangeVersion(&meta_table_, 36, true);
+ ChangeVersion(&meta_table_, 37, true);
// FALL THROUGH
// Add successive versions here. Each should set the version number and
diff --git a/chrome/browser/webdata/web_database_migration_unittest.cc b/chrome/browser/webdata/web_database_migration_unittest.cc
index 0d2a365..c27abb9 100644
--- a/chrome/browser/webdata/web_database_migration_unittest.cc
+++ b/chrome/browser/webdata/web_database_migration_unittest.cc
@@ -212,7 +212,7 @@ class WebDatabaseMigrationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};
-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 36;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 37;
void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) {
std::string contents;
@@ -1055,16 +1055,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ(1297882100L, s1.ColumnInt64(8));
// John P. Doe.
- ASSERT_TRUE(s1.Step());
- EXPECT_EQ("589636FD-9037-3053-200C-80ABC97D7344", s1.ColumnString(0));
- EXPECT_EQ(ASCIIToUTF16("Doe Enterprises"), s1.ColumnString16(1));
- EXPECT_EQ(ASCIIToUTF16("1 Main St"), s1.ColumnString16(2));
- EXPECT_EQ(ASCIIToUTF16("Apt 1"), s1.ColumnString16(3));
- EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4));
- EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5));
- EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6));
- EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7));
- EXPECT_EQ(1297882100L, s1.ColumnInt64(8));
+ // Gets merged during migration from 35 to 37 due to multi-valued fields.
// Dave Smith.
ASSERT_TRUE(s1.Step());
@@ -1120,9 +1111,10 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ(ASCIIToUTF16(""), s2.ColumnString16(2));
EXPECT_EQ(ASCIIToUTF16("Doe"), s2.ColumnString16(3));
- // John P. Doe.
+ // John P. Doe. Note same guid as above due to merging of multi-valued
+ // fields.
ASSERT_TRUE(s2.Step());
- EXPECT_EQ("589636FD-9037-3053-200C-80ABC97D7344", s2.ColumnString(0));
+ EXPECT_EQ("00580526-FF81-EE2A-0546-1AC593A32E2F", s2.ColumnString(0));
EXPECT_EQ(ASCIIToUTF16("John"), s2.ColumnString16(1));
EXPECT_EQ(ASCIIToUTF16("P."), s2.ColumnString16(2));
EXPECT_EQ(ASCIIToUTF16("Doe"), s2.ColumnString16(3));
@@ -1165,9 +1157,8 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ(ASCIIToUTF16("john@doe.com"), s3.ColumnString16(1));
// John P. Doe.
- ASSERT_TRUE(s3.Step());
- EXPECT_EQ("589636FD-9037-3053-200C-80ABC97D7344", s3.ColumnString(0));
- EXPECT_EQ(ASCIIToUTF16("john@doe.com"), s3.ColumnString16(1));
+ // Gets culled during migration from 35 to 37 due to merging of John Doe and
+ // John P. Doe addresses.
// 2 Main Street.
ASSERT_TRUE(s3.Step());
@@ -1208,16 +1199,12 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ(ASCIIToUTF16("4153334444"), s4.ColumnString16(2));
// John P. Doe phone.
- ASSERT_TRUE(s4.Step());
- EXPECT_EQ("589636FD-9037-3053-200C-80ABC97D7344", s4.ColumnString(0));
- EXPECT_EQ(0, s4.ColumnInt(1)); // 0 means phone.
- EXPECT_EQ(ASCIIToUTF16("4151112222"), s4.ColumnString16(2));
+ // Gets culled during migration from 35 to 37 due to merging of John Doe and
+ // John P. Doe addresses.
// John P. Doe fax.
- ASSERT_TRUE(s4.Step());
- EXPECT_EQ("589636FD-9037-3053-200C-80ABC97D7344", s4.ColumnString(0));
- EXPECT_EQ(1, s4.ColumnInt(1)); // 1 means fax.
- EXPECT_EQ(ASCIIToUTF16("4153334444"), s4.ColumnString16(2));
+ // Gets culled during migration from 35 to 37 due to merging of John Doe and
+ // John P. Doe addresses.
// 2 Main Street phone.
ASSERT_TRUE(s4.Step());
@@ -1257,7 +1244,6 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ(1, s4.ColumnInt(1)); // 1 means fax.
EXPECT_EQ(ASCIIToUTF16(""), s4.ColumnString16(2));
-
// Should be all.
EXPECT_FALSE(s4.Step());
}
diff --git a/chrome/test/data/autofill/merge/input/ambiguous.in b/chrome/test/data/autofill/merge/input/ambiguous.in
new file mode 100644
index 0000000..afd96443
--- /dev/null
+++ b/chrome/test/data/autofill/merge/input/ambiguous.in
@@ -0,0 +1,21 @@
+---
+NAME_FIRST: John
+NAME_FIRST: James
+NAME_MIDDLE: Kilgore
+NAME_MIDDLE:
+NAME_LAST: Doe
+NAME_LAST:
+EMAIL_ADDRESS: john.doe@example.com
+EMAIL_ADDRESS: x.doe@example.com
+COMPANY_NAME: TestCo
+ADDRESS_HOME_LINE1: 1600 Amphitheatre Parkway
+ADDRESS_HOME_LINE2: (Bldg. 1950)
+ADDRESS_HOME_CITY: Mountain View
+ADDRESS_HOME_STATE: CA
+ADDRESS_HOME_ZIP: 94043
+ADDRESS_HOME_COUNTRY: United States
+PHONE_HOME_WHOLE_NUMBER: 6505558888
+PHONE_HOME_WHOLE_NUMBER: 6505559999
+PHONE_HOME_WHOLE_NUMBER: 6505559999
+PHONE_FAX_WHOLE_NUMBER: 6505556789
+PHONE_FAX_WHOLE_NUMBER: 6505551111
diff --git a/chrome/test/data/autofill/merge/input/identical.in b/chrome/test/data/autofill/merge/input/identical.in
index 0d45be4..6e1c6bc7 100644
--- a/chrome/test/data/autofill/merge/input/identical.in
+++ b/chrome/test/data/autofill/merge/input/identical.in
@@ -10,8 +10,8 @@ ADDRESS_HOME_CITY: Mountain View
ADDRESS_HOME_STATE: CA
ADDRESS_HOME_ZIP: 94043
ADDRESS_HOME_COUNTRY: United States
-PHONE_HOME_NUMBER: 6505558888
-PHONE_FAX_NUMBER: 6505556789
+PHONE_HOME_WHOLE_NUMBER: 6505558888
+PHONE_FAX_WHOLE_NUMBER: 6505556789
---
NAME_FIRST: John
NAME_MIDDLE: Kilgore
@@ -24,5 +24,5 @@ ADDRESS_HOME_CITY: Mountain View
ADDRESS_HOME_STATE: CA
ADDRESS_HOME_ZIP: 94043
ADDRESS_HOME_COUNTRY: United States
-PHONE_HOME_NUMBER: 6505558888
-PHONE_FAX_NUMBER: 6505556789
+PHONE_HOME_WHOLE_NUMBER: 6505558888
+PHONE_FAX_WHOLE_NUMBER: 6505556789
diff --git a/chrome/test/data/autofill/merge/input/multimerge.in b/chrome/test/data/autofill/merge/input/multimerge.in
new file mode 100644
index 0000000..9906c27
--- /dev/null
+++ b/chrome/test/data/autofill/merge/input/multimerge.in
@@ -0,0 +1,28 @@
+---
+NAME_FIRST: Alice
+NAME_MIDDLE: Anne
+NAME_LAST: Akins
+EMAIL_ADDRESS: aa@a.com
+COMPANY_NAME: Acme
+ADDRESS_HOME_LINE1: 1 Main Street
+ADDRESS_HOME_LINE2: Apt 1
+ADDRESS_HOME_CITY: San Francisco
+ADDRESS_HOME_STATE: CA
+ADDRESS_HOME_ZIP: 94102
+ADDRESS_HOME_COUNTRY: United States
+PHONE_HOME_WHOLE_NUMBER: 1110001111
+PHONE_FAX_WHOLE_NUMBER: 8880008888
+---
+NAME_FIRST: Billy
+NAME_MIDDLE: Bob
+NAME_LAST: Bruner
+EMAIL_ADDRESS: bb@b.com
+COMPANY_NAME: Acme
+ADDRESS_HOME_LINE1: 1 Main Street
+ADDRESS_HOME_LINE2: Apt 1
+ADDRESS_HOME_CITY: San Francisco
+ADDRESS_HOME_STATE: CA
+ADDRESS_HOME_ZIP: 94102
+ADDRESS_HOME_COUNTRY: United States
+PHONE_HOME_WHOLE_NUMBER: 2220003333
+PHONE_FAX_WHOLE_NUMBER: 8880008888
diff --git a/chrome/test/data/autofill/merge/input/singlemerge.in b/chrome/test/data/autofill/merge/input/singlemerge.in
new file mode 100644
index 0000000..f264015
--- /dev/null
+++ b/chrome/test/data/autofill/merge/input/singlemerge.in
@@ -0,0 +1,28 @@
+---
+NAME_FIRST: Alice
+NAME_MIDDLE: Anne
+NAME_LAST: Akins
+EMAIL_ADDRESS: aa@a.com
+COMPANY_NAME: Acme
+ADDRESS_HOME_LINE1: 1 Main Street
+ADDRESS_HOME_LINE2: Apt 1
+ADDRESS_HOME_CITY: San Francisco
+ADDRESS_HOME_STATE: CA
+ADDRESS_HOME_ZIP: 94102
+ADDRESS_HOME_COUNTRY: United States
+PHONE_HOME_WHOLE_NUMBER: 1110001111
+PHONE_FAX_WHOLE_NUMBER: 8880008888
+---
+NAME_FIRST: Alice
+NAME_MIDDLE: Anne
+NAME_LAST: Akins
+EMAIL_ADDRESS: aa@a.com
+COMPANY_NAME: Box Co
+ADDRESS_HOME_LINE1: 1 Main Street
+ADDRESS_HOME_LINE2: Apt 2
+ADDRESS_HOME_CITY: San Francisco
+ADDRESS_HOME_STATE: NY
+ADDRESS_HOME_ZIP: 11001
+ADDRESS_HOME_COUNTRY: Canada
+PHONE_HOME_WHOLE_NUMBER: 1110001111
+PHONE_FAX_WHOLE_NUMBER: 8880008888
diff --git a/chrome/test/data/autofill/merge/input/validation.in b/chrome/test/data/autofill/merge/input/validation.in
index 32ed1a8..f148032 100644
--- a/chrome/test/data/autofill/merge/input/validation.in
+++ b/chrome/test/data/autofill/merge/input/validation.in
@@ -9,8 +9,8 @@ ADDRESS_HOME_CITY: Mountain View
ADDRESS_HOME_STATE: CA
ADDRESS_HOME_ZIP: 94043
ADDRESS_HOME_COUNTRY: United States
-PHONE_HOME_NUMBER: 6505558888
-PHONE_FAX_NUMBER: 6505556789
+PHONE_HOME_WHOLE_NUMBER: 6505558888
+PHONE_FAX_WHOLE_NUMBER: 6505556789
---
NAME_FIRST: John
NAME_LAST: Doe
@@ -20,8 +20,8 @@ ADDRESS_HOME_CITY: Mountain View
ADDRESS_HOME_STATE: CA
ADDRESS_HOME_ZIP: 94043
ADDRESS_HOME_COUNTRY: United States
-PHONE_HOME_NUMBER: 6505558888
-PHONE_FAX_NUMBER: 6505556789
+PHONE_HOME_WHOLE_NUMBER: 6505558888
+PHONE_FAX_WHOLE_NUMBER: 6505556789
---
NAME_FIRST: Jim
NAME_LAST: Smith
@@ -49,8 +49,8 @@ ADDRESS_HOME_CITY: Mountain View
ADDRESS_HOME_STATE: CA
ADDRESS_HOME_ZIP: 94043
ADDRESS_HOME_COUNTRY: Bad Country
-PHONE_HOME_NUMBER: 6505558888
-PHONE_FAX_NUMBER: 6505556789
+PHONE_HOME_WHOLE_NUMBER: 6505558888
+PHONE_FAX_WHOLE_NUMBER: 6505556789
---
NAME_FIRST: Joe
NAME_LAST: Jones
@@ -61,8 +61,8 @@ ADDRESS_HOME_CITY: Mountain View
ADDRESS_HOME_STATE: BadState
ADDRESS_HOME_ZIP: 94043
ADDRESS_HOME_COUNTRY: United States
-PHONE_HOME_NUMBER: 6505558888
-PHONE_FAX_NUMBER: 6505556789
+PHONE_HOME_WHOLE_NUMBER: 6505558888
+PHONE_FAX_WHOLE_NUMBER: 6505556789
---
NAME_FIRST: Jim
NAME_LAST: Jones
@@ -73,5 +73,5 @@ ADDRESS_HOME_CITY: Mountain View
ADDRESS_HOME_STATE: CA
ADDRESS_HOME_ZIP: bogus
ADDRESS_HOME_COUNTRY: United States
-PHONE_HOME_NUMBER: 6505558888
-PHONE_FAX_NUMBER: 6505556789
+PHONE_HOME_WHOLE_NUMBER: 6505558888
+PHONE_FAX_WHOLE_NUMBER: 6505556789
diff --git a/chrome/test/data/autofill/merge/output/ambiguous.out b/chrome/test/data/autofill/merge/output/ambiguous.out
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/chrome/test/data/autofill/merge/output/ambiguous.out
diff --git a/chrome/test/data/autofill/merge/output/identical.out b/chrome/test/data/autofill/merge/output/identical.out
index 5ddb88c..8c6fb81 100644
--- a/chrome/test/data/autofill/merge/output/identical.out
+++ b/chrome/test/data/autofill/merge/output/identical.out
@@ -10,5 +10,5 @@ ADDRESS_HOME_CITY: Mountain View
ADDRESS_HOME_STATE: CA
ADDRESS_HOME_ZIP: 94043
ADDRESS_HOME_COUNTRY: United States
-PHONE_HOME_NUMBER: 6505558888
-PHONE_FAX_NUMBER: 6505556789
+PHONE_HOME_WHOLE_NUMBER: 6505558888
+PHONE_FAX_WHOLE_NUMBER: 6505556789
diff --git a/chrome/test/data/autofill/merge/output/multimerge.out b/chrome/test/data/autofill/merge/output/multimerge.out
new file mode 100644
index 0000000..260f8bb
--- /dev/null
+++ b/chrome/test/data/autofill/merge/output/multimerge.out
@@ -0,0 +1,19 @@
+---
+NAME_FIRST: Alice
+NAME_FIRST: Billy
+NAME_MIDDLE: Anne
+NAME_MIDDLE: Bob
+NAME_LAST: Akins
+NAME_LAST: Bruner
+EMAIL_ADDRESS: aa@a.com
+EMAIL_ADDRESS: bb@b.com
+COMPANY_NAME: Acme
+ADDRESS_HOME_LINE1: 1 Main Street
+ADDRESS_HOME_LINE2: Apt 1
+ADDRESS_HOME_CITY: San Francisco
+ADDRESS_HOME_STATE: CA
+ADDRESS_HOME_ZIP: 94102
+ADDRESS_HOME_COUNTRY: United States
+PHONE_HOME_WHOLE_NUMBER: 1110001111
+PHONE_HOME_WHOLE_NUMBER: 2220003333
+PHONE_FAX_WHOLE_NUMBER: 8880008888
diff --git a/chrome/test/data/autofill/merge/output/singlemerge.out b/chrome/test/data/autofill/merge/output/singlemerge.out
new file mode 100644
index 0000000..3181458
--- /dev/null
+++ b/chrome/test/data/autofill/merge/output/singlemerge.out
@@ -0,0 +1,14 @@
+---
+NAME_FIRST: Alice
+NAME_MIDDLE: Anne
+NAME_LAST: Akins
+EMAIL_ADDRESS: aa@a.com
+COMPANY_NAME: Box Co
+ADDRESS_HOME_LINE1: 1 Main Street
+ADDRESS_HOME_LINE2: Apt 2
+ADDRESS_HOME_CITY: San Francisco
+ADDRESS_HOME_STATE: NY
+ADDRESS_HOME_ZIP: 11001
+ADDRESS_HOME_COUNTRY: Canada
+PHONE_HOME_WHOLE_NUMBER: 1110001111
+PHONE_FAX_WHOLE_NUMBER: 8880008888
diff --git a/chrome/test/data/autofill/merge/output/validation.out b/chrome/test/data/autofill/merge/output/validation.out
index cc3c080..2925154 100644
--- a/chrome/test/data/autofill/merge/output/validation.out
+++ b/chrome/test/data/autofill/merge/output/validation.out
@@ -10,5 +10,5 @@ ADDRESS_HOME_CITY: Mountain View
ADDRESS_HOME_STATE: CA
ADDRESS_HOME_ZIP: 94043
ADDRESS_HOME_COUNTRY: United States
-PHONE_HOME_NUMBER: 6505558888
-PHONE_FAX_NUMBER: 6505556789
+PHONE_HOME_WHOLE_NUMBER: 6505558888
+PHONE_FAX_WHOLE_NUMBER: 6505556789