Commit 20a99a11 authored by estade@chromium.org's avatar estade@chromium.org

Fix profile comparison re: address lines.

BUG=375545
TEST=try to edit an address to add address line 3 in chrome://settings

Review URL: https://codereview.chromium.org/332213004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278044 0039d316-1c4b-4281-b951-d872f2087c98
parent a6ba6a64
...@@ -193,14 +193,14 @@ public class PersonalDataManagerTest extends ChromeShellTestBase { ...@@ -193,14 +193,14 @@ public class PersonalDataManagerTest extends ChromeShellTestBase {
final String streetAddress2 = streetAddress1 + "\n" final String streetAddress2 = streetAddress1 + "\n"
+ "Fourth floor\n" + "Fourth floor\n"
+ "The red bell"; + "The red bell";
AutofillProfile profile1 = new AutofillProfile( AutofillProfile profile = new AutofillProfile(
"" /* guid */, "https://www.example.com" /* origin */, "" /* guid */, "https://www.example.com" /* origin */,
"Monsieur Jean DELHOURME", "Acme Inc.", "Monsieur Jean DELHOURME", "Acme Inc.",
streetAddress1, streetAddress1,
"Tahiti", "Mahina", "Orofara", "Tahiti", "Mahina", "Orofara",
"98709", "CEDEX 98703", "98709", "CEDEX 98703",
"French Polynesia", "50.71.53", "john@acme.inc", ""); "French Polynesia", "50.71.53", "john@acme.inc", "");
String profileGuid1 = mHelper.setProfile(profile1); String profileGuid1 = mHelper.setProfile(profile);
assertEquals(1, mHelper.getNumberOfProfiles()); assertEquals(1, mHelper.getNumberOfProfiles());
AutofillProfile storedProfile1 = mHelper.getProfile(profileGuid1); AutofillProfile storedProfile1 = mHelper.getProfile(profileGuid1);
assertEquals("PF", storedProfile1.getCountryCode()); assertEquals("PF", storedProfile1.getCountryCode());
...@@ -214,12 +214,10 @@ public class PersonalDataManagerTest extends ChromeShellTestBase { ...@@ -214,12 +214,10 @@ public class PersonalDataManagerTest extends ChromeShellTestBase {
assertEquals("50.71.53", storedProfile1.getPhoneNumber()); assertEquals("50.71.53", storedProfile1.getPhoneNumber());
assertEquals("john@acme.inc", storedProfile1.getEmailAddress()); assertEquals("john@acme.inc", storedProfile1.getEmailAddress());
profile1.setStreetAddress(streetAddress2); profile.setStreetAddress(streetAddress2);
mHelper.setProfile(profile1); String profileGuid2 = mHelper.setProfile(profile);
assertEquals(1, mHelper.getNumberOfProfiles()); assertEquals(2, mHelper.getNumberOfProfiles());
storedProfile1 = mHelper.getProfile(profileGuid1); AutofillProfile storedProfile2 = mHelper.getProfile(profileGuid2);
assertEquals(streetAddress2, storedProfile2.getStreetAddress());
// TODO(estade): http://crbug.com/375545.
// assertEquals(streetAddress2, storedProfile1.getStreetAddress());
} }
} }
...@@ -418,8 +418,7 @@ bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const { ...@@ -418,8 +418,7 @@ bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const {
int AutofillProfile::Compare(const AutofillProfile& profile) const { int AutofillProfile::Compare(const AutofillProfile& profile) const {
const ServerFieldType single_value_types[] = { const ServerFieldType single_value_types[] = {
COMPANY_NAME, COMPANY_NAME,
ADDRESS_HOME_LINE1, ADDRESS_HOME_STREET_ADDRESS,
ADDRESS_HOME_LINE2,
ADDRESS_HOME_DEPENDENT_LOCALITY, ADDRESS_HOME_DEPENDENT_LOCALITY,
ADDRESS_HOME_CITY, ADDRESS_HOME_CITY,
ADDRESS_HOME_STATE, ADDRESS_HOME_STATE,
......
...@@ -654,6 +654,18 @@ TEST(AutofillProfileTest, Compare) { ...@@ -654,6 +654,18 @@ TEST(AutofillProfileTest, Compare) {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, "408.555.4321"); NULL, NULL, NULL, NULL, NULL, NULL, NULL, "408.555.4321");
EXPECT_GT(0, a.Compare(b)); EXPECT_GT(0, a.Compare(b));
EXPECT_LT(0, b.Compare(a)); EXPECT_LT(0, b.Compare(a));
// Addresses are compared in full. Regression test for http://crbug.com/375545
test::SetProfileInfo(&a, "John", NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
a.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
ASCIIToUTF16("line one\nline two"));
test::SetProfileInfo(&b, "John", NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
b.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS,
ASCIIToUTF16("line one\nline two\nline three"));
EXPECT_GT(0, a.Compare(b));
EXPECT_LT(0, b.Compare(a));
} }
TEST(AutofillProfileTest, MultiValueNames) { TEST(AutofillProfileTest, MultiValueNames) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment