Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestDynamicShippingMultipleAddressesTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestDynamicShippingMultipleAddressesTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestDynamicShippingMultipleAddressesTest.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..527b53d3d222222dcbac4a9d3bd0cf8bd518e69a |
| --- /dev/null |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestDynamicShippingMultipleAddressesTest.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 requires shipping address to calculate shipping |
| + * and user that has multiple addresses stored in autofill settings. |
|
please use gerrit instead
2016/07/07 13:59:36
Replace "multiple" with "5", because that's critic
sebsg
2016/07/08 07:54:52
Done.
|
| + */ |
| +public class PaymentRequestDynamicShippingMultipleAddressesTest extends PaymentRequestTestBase { |
| + public PaymentRequestDynamicShippingMultipleAddressesTest() { |
| + // This merchant requests the shipping address first before providing any shipping options. |
| + super("payment_request_dynamic_shipping_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", "", |
|
please use gerrit instead
2016/07/07 13:59:36
Please add the profiles in alphabetic order, so th
sebsg
2016/07/08 07:54:52
Done.
|
| + "90210", "", "US", "", "homer@simpson.com", ""); |
| + String guid1 = helper.setProfile(profile1); |
|
please use gerrit instead
2016/07/07 13:59:36
No need to create "profileX" variables that you're
sebsg
2016/07/08 07:54:52
Done.
|
| + |
| + // 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 the second lowest 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 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 witht 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 second lowest and profile4 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 address suggestions are in the correct order and that only the top 4 |
| + * suggestions are shown. They should be ordered by frecency and complete addresses should be |
| + * suggested first. |
| + */ |
| + @MediumTest |
| + public void testShippingAddressSuggestionOrdering() |
| + throws InterruptedException, ExecutionException, TimeoutException { |
| + triggerUIAndWait(mReadyForInput); |
| + clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput); |
| + assertTrue(getShippingAddressSuggestionLabel(0).contains("Bart Simpson")); |
| + assertTrue(getShippingAddressSuggestionLabel(1).contains("Lisa Simpson")); |
| + assertTrue(getShippingAddressSuggestionLabel(2).contains("Homer Simpson")); |
| + assertTrue(getShippingAddressSuggestionLabel(3).contains("Marge Simpson")); |
| + assertEquals(null, getShippingAddressSuggestionLabel(4)); |
| + } |
| +} |