| Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMultipleContactDetailsTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMultipleContactDetailsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMultipleContactDetailsTest.java
|
| index d6c235b015854711a1bd52f9bbec27c014c4dbbb..ad534500e3385b1759922bc4429c0fde19e57854 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMultipleContactDetailsTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMultipleContactDetailsTest.java
|
| @@ -21,36 +21,69 @@ import java.util.concurrent.TimeoutException;
|
| */
|
| public class PaymentRequestMultipleContactDetailsTest extends PaymentRequestTestBase {
|
| private static final AutofillProfile[] AUTOFILL_PROFILES = {
|
| - // Incomplete (no phone) profile.
|
| + // 0 - Incomplete (no phone) profile.
|
| new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| "Bart Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| "90210", "", "US", "", "bart@simpson.com", ""),
|
|
|
| - // Incomplete (no email) profile.
|
| + // 1 - Incomplete (no email) profile.
|
| new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| "Homer Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| "90210", "", "US", "555 123-4567", "", ""),
|
|
|
| - // Complete profile.
|
| + // 2 - Complete profile.
|
| new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| "Lisa Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| "90210", "", "US", "555 123-4567", "lisa@simpson.com", ""),
|
|
|
| - // Complete profile.
|
| + // 3 - Complete profile.
|
| new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| "Maggie Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| "90210", "", "US", "555 123-4567", "maggie@simpson.com", ""),
|
|
|
| - // Incomplete (no phone and email) profile.
|
| + // 4 - Incomplete (no phone and email) profile.
|
| new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| "Marge Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| "90210", "", "US", "", "", ""),
|
|
|
| - // Incomplete (no name) profile.
|
| + // 5 - Incomplete (no name) profile.
|
| new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */, "",
|
| "Acme Inc.", "123 Main", "California", "Los Angeles", "", "90210", "", "US",
|
| "555 123-4567", "marge@simpson.com", ""),
|
|
|
| + // These profiles are used to test the dedupe of subset suggestions. They are based on
|
| + // The Lisa Simpson profile.
|
| +
|
| + // 6 - Same as original, but with no name.
|
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| + "" /* name */, "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| + "90210", "", "US", "555 123-4567", "lisa@simpson.com", ""),
|
| +
|
| + // 7 - Same as original, but with no phone.
|
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| + "Lisa Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| + "90210", "", "US", "" /* phoneNumber */, "lisa@simpson.com", ""),
|
| +
|
| + // 8 - Same as original, but with no email.
|
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| + "Lisa Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| + "90210", "", "US", "555 123-4567", "" /* emailAddress */, ""),
|
| +
|
| + // 9 - Same as original, but with no phone and no email.
|
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| + "Lisa Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| + "90210", "", "US", "" /* phoneNumber */, "" /* emailAddress */, ""),
|
| +
|
| + // 10 - Has an email address that is a superset of the original profile's email.
|
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| + "Lisa Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| + "90210", "", "US", "555 123-4567", "fakelisa@simpson.com", ""),
|
| +
|
| + // 11 - Has the same name as the original but with no capitalization in the name.
|
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| + "lisa simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
|
| + "90210", "", "US", "555 123-4567", "lisa@simpson.com", ""),
|
| +
|
| };
|
|
|
| private AutofillProfile[] mProfilesToAdd;
|
| @@ -131,9 +164,80 @@ public class PaymentRequestMultipleContactDetailsTest extends PaymentRequestTest
|
| getContactDetailsSuggestionLabel(0));
|
| assertEquals(
|
| "Homer Simpson\n555 123-4567\nEmail required", getContactDetailsSuggestionLabel(1));
|
| - assertEquals(
|
| - "Marge Simpson\nMore information required", getContactDetailsSuggestionLabel(2));
|
| assertEquals("555 123-4567\nmarge@simpson.com\nName required",
|
| - getContactDetailsSuggestionLabel(3));
|
| + getContactDetailsSuggestionLabel(2));
|
| + assertEquals(
|
| + "Marge Simpson\nMore information required", getContactDetailsSuggestionLabel(3));
|
| + }
|
| +
|
| + /**
|
| + * Makes sure that suggestions that are subsets of other fields (empty values) are deduped.
|
| + */
|
| + @MediumTest
|
| + @Feature({"Payments"})
|
| + public void testContactDetailsDedupe_EmptyFields()
|
| + throws InterruptedException, ExecutionException, TimeoutException {
|
| + // Add the original profile and a bunch of similar profiles with missing fields.
|
| + // Make sure the original profile is suggested last, to test that the suggestions are
|
| + // sorted by completeness.
|
| + mProfilesToAdd = new AutofillProfile[] {
|
| + AUTOFILL_PROFILES[2], AUTOFILL_PROFILES[6], AUTOFILL_PROFILES[7],
|
| + AUTOFILL_PROFILES[8], AUTOFILL_PROFILES[9],
|
| + };
|
| + mCountsToSet = new int[] {1, 20, 15, 10, 5};
|
| + mDatesToSet = new int[] {1000, 4000, 3000, 2000, 1000};
|
| +
|
| + triggerUIAndWait(mReadyForInput);
|
| + clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
|
| +
|
| + // Only the original profile with all the fields should be suggested.
|
| + assertEquals(1, getNumberOfContactDetailSuggestions());
|
| + assertEquals("Lisa Simpson\n555 123-4567\nlisa@simpson.com",
|
| + getContactDetailsSuggestionLabel(0));
|
| + }
|
| +
|
| + /**
|
| + * Makes sure that suggestions where some fields values are equal but with different case are
|
| + * deduped.
|
| + */
|
| + @MediumTest
|
| + @Feature({"Payments"})
|
| + public void testContactDetailsDedupe_Capitalization()
|
| + throws InterruptedException, ExecutionException, TimeoutException {
|
| + // Add the original profile and the one where the the name is not capitalized.
|
| + // Make sure the original profile is suggested first (no particular reason).
|
| + mProfilesToAdd = new AutofillProfile[] {AUTOFILL_PROFILES[2], AUTOFILL_PROFILES[11]};
|
| + mCountsToSet = new int[] {15, 5};
|
| + mDatesToSet = new int[] {5000, 2000};
|
| +
|
| + triggerUIAndWait(mReadyForInput);
|
| + clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
|
| + assertEquals(1, getNumberOfContactDetailSuggestions());
|
| + assertEquals("Lisa Simpson\n555 123-4567\nlisa@simpson.com",
|
| + getContactDetailsSuggestionLabel(0));
|
| + }
|
| +
|
| + /**
|
| + * Makes sure that suggestions where some fields values are subsets of the other are not
|
| + * deduped.
|
| + */
|
| + @MediumTest
|
| + @Feature({"Payments"})
|
| + public void testContactDetailsDontDedupe_FieldSubset()
|
| + throws InterruptedException, ExecutionException, TimeoutException {
|
| + // Add the original profile and the one where the email is a superset of the original.
|
| + // Make sure the one with the superset is suggested first, because to test the subset one
|
| + // needs to be added after.
|
| + mProfilesToAdd = new AutofillProfile[] {AUTOFILL_PROFILES[2], AUTOFILL_PROFILES[10]};
|
| + mCountsToSet = new int[] {15, 25};
|
| + mDatesToSet = new int[] {5000, 7000};
|
| +
|
| + triggerUIAndWait(mReadyForInput);
|
| + clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
|
| + assertEquals(2, getNumberOfContactDetailSuggestions());
|
| + assertEquals("Lisa Simpson\n555 123-4567\nfakelisa@simpson.com",
|
| + getContactDetailsSuggestionLabel(0));
|
| + assertEquals("Lisa Simpson\n555 123-4567\nlisa@simpson.com",
|
| + getContactDetailsSuggestionLabel(1));
|
| }
|
| }
|
|
|