Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ed7af553ba3ff61c903ff1687fbb57cf524781f9 |
| --- /dev/null |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMultipleContactDetailsTest.java |
| @@ -0,0 +1,96 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.payments; |
| + |
| +import android.test.suitebuilder.annotation.MediumTest; |
| + |
| +import org.chromium.chrome.R; |
| +import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
| +import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| +import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
| + |
| +import java.util.concurrent.ExecutionException; |
| +import java.util.concurrent.TimeoutException; |
| + |
| +/** |
| + * A payment integration test for a merchant that requests contact details and a user that has |
| + * multiple contact detail options. |
|
please use gerrit instead
2016/07/07 13:59:36
Replace "multiple" with "5".
sebsg
2016/07/08 07:54:52
Done.
|
| + */ |
| +public class PaymentRequestMultipleContactDetailsTest extends PaymentRequestTestBase { |
| + public PaymentRequestMultipleContactDetailsTest() { |
| + // The merchant requests both a phone number and an email address. |
| + super("payment_request_contact_details_test.html"); |
| + } |
| + |
| + @Override |
| + public void onMainActivityStarted() |
| + throws InterruptedException, ExecutionException, TimeoutException { |
| + AutofillTestHelper helper = new AutofillTestHelper(); |
| + // Create an incomplete (no phone) profile with the highest frecency score. |
| + AutofillProfile profile1 = |
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */, |
| + "Homer Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "", |
| + "90210", "", "US", "", "homer@simpson.com", ""); |
| + String guid1 = helper.setProfile(profile1); |
| + |
| + // Create an incomplete (no phone) profile with a the second highest frecency score. |
| + AutofillProfile profile2 = |
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */, |
| + "Marge Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "", |
| + "90210", "", "US", "", "marge@simpson.com", ""); |
| + String guid2 = helper.setProfile(profile2); |
| + |
| + // Create a complete profile with a middle frecency score. |
| + AutofillProfile profile3 = |
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */, |
| + "Bart Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "", |
| + "90210", "", "US", "555 123-4567", "bart@simpson.com", ""); |
| + String guid3 = helper.setProfile(profile3); |
| + |
| + // Create a complete profile with the second lowest frecency score. |
| + AutofillProfile profile4 = |
| + 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", ""); |
| + String guid4 = helper.setProfile(profile4); |
| + |
| + // Create an incomplete profile with the lowest frecency score. |
| + AutofillProfile profile5 = |
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */, |
| + "Maggie Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "", |
| + "90210", "", "US", "", "maggie@simpson.com", ""); |
| + String guid5 = helper.setProfile(profile5); |
| + |
| + // Create a credit card associated with the fourth profile. |
| + helper.setCreditCard(new CreditCard("", "https://example.com", true, true, "Jon Doe", |
| + "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_visa, |
| + guid4)); |
| + |
| + // Set the use stats so that profile1 has the highest frecency score, profile2 the second |
| + // highest, profile 3 the third lowest, profile4 the second lowest and profile 5 the lowest. |
| + helper.setProfileUseStatsForTesting(guid1, 20, 5000); |
| + helper.setProfileUseStatsForTesting(guid2, 15, 5000); |
| + helper.setProfileUseStatsForTesting(guid3, 10, 5000); |
| + helper.setProfileUseStatsForTesting(guid4, 5, 5000); |
| + helper.setProfileUseStatsForTesting(guid5, 1, 1); |
| + } |
| + |
| + /** |
| + * Make sure the contact details suggestions are in the correct order and that only the top 4 |
| + * are shown. They should be ordered by frecency and complete contact details should be |
| + * suggested first. |
| + */ |
| + @MediumTest |
| + public void testContactDetailsSuggestionOrdering() |
| + throws InterruptedException, ExecutionException, TimeoutException { |
| + triggerUIAndWait(mReadyToPay); |
| + clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
| + assertEquals("555 123-4567\nbart@simpson.com", getContactDetailsSuggestionLabel(0)); |
| + assertEquals("555 123-4567\nlisa@simpson.com", getContactDetailsSuggestionLabel(1)); |
| + assertEquals("homer@simpson.com", getContactDetailsSuggestionLabel(2)); |
| + assertEquals("marge@simpson.com", getContactDetailsSuggestionLabel(3)); |
| + assertEquals(null, getContactDetailsSuggestionLabel(4)); |
| + } |
| +} |