OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.payments; |
| 6 |
| 7 import android.test.suitebuilder.annotation.MediumTest; |
| 8 |
| 9 import org.chromium.chrome.R; |
| 10 import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
| 11 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| 12 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
| 13 |
| 14 import java.util.concurrent.ExecutionException; |
| 15 import java.util.concurrent.TimeoutException; |
| 16 |
| 17 /** |
| 18 * A payment integration test for a merchant that requests contact details and a
user that has |
| 19 * 5 contact detail options. |
| 20 */ |
| 21 public class PaymentRequestMultipleContactDetailsTest extends PaymentRequestTest
Base { |
| 22 public PaymentRequestMultipleContactDetailsTest() { |
| 23 // The merchant requests both a phone number and an email address. |
| 24 super("payment_request_contact_details_test.html"); |
| 25 } |
| 26 |
| 27 @Override |
| 28 public void onMainActivityStarted() |
| 29 throws InterruptedException, ExecutionException, TimeoutException { |
| 30 AutofillTestHelper helper = new AutofillTestHelper(); |
| 31 // Create an incomplete (no phone) profile with the highest frecency sco
re. |
| 32 String guid1 = helper.setProfile( |
| 33 new AutofillProfile("" /* guid */, "https://www.example.com" /*
origin */, |
| 34 "Bart Simpson", "Acme Inc.", "123 Main", "California", "
Los Angeles", "", |
| 35 "90210", "", "US", "", "bart@simpson.com", "")); |
| 36 |
| 37 // Create an incomplete (no phone) profile with a the second highest fre
cency score. |
| 38 String guid2 = helper.setProfile( |
| 39 new AutofillProfile("" /* guid */, "https://www.example.com" /*
origin */, |
| 40 "Homer Simpson", "Acme Inc.", "123 Main", "California",
"Los Angeles", "", |
| 41 "90210", "", "US", "", "homer@simpson.com", "")); |
| 42 |
| 43 // Create a complete profile with a middle frecency score. |
| 44 String guid3 = helper.setProfile( |
| 45 new AutofillProfile("" /* guid */, "https://www.example.com" /*
origin */, |
| 46 "Lisa Simpson", "Acme Inc.", "123 Main", "California", "
Los Angeles", "", |
| 47 "90210", "", "US", "555 123-4567", "lisa@simpson.com", "
")); |
| 48 |
| 49 // Create a complete profile with the second lowest frecency score. |
| 50 String guid4 = helper.setProfile( |
| 51 new AutofillProfile("" /* guid */, "https://www.example.com" /*
origin */, |
| 52 "Maggie Simpson", "Acme Inc.", "123 Main", "California",
"Los Angeles", "", |
| 53 "90210", "", "US", "555 123-4567", "maggie@simpson.com",
"")); |
| 54 |
| 55 // Create an incomplete profile with the lowest frecency score. |
| 56 String guid5 = helper.setProfile( |
| 57 new AutofillProfile("" /* guid */, "https://www.example.com" /*
origin */, |
| 58 "Marge Simpson", "Acme Inc.", "123 Main", "California",
"Los Angeles", "", |
| 59 "90210", "", "US", "", "marge@simpson.com", "")); |
| 60 |
| 61 // Create a credit card associated with the fourth profile. |
| 62 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", |
| 63 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, |
| 64 guid4)); |
| 65 |
| 66 // Set the use stats so that profile1 has the highest frecency score, pr
ofile2 the second |
| 67 // highest, profile 3 the third lowest, profile4 the second lowest and p
rofile 5 the lowest. |
| 68 helper.setProfileUseStatsForTesting(guid1, 20, 5000); |
| 69 helper.setProfileUseStatsForTesting(guid2, 15, 5000); |
| 70 helper.setProfileUseStatsForTesting(guid3, 10, 5000); |
| 71 helper.setProfileUseStatsForTesting(guid4, 5, 5000); |
| 72 helper.setProfileUseStatsForTesting(guid5, 1, 1); |
| 73 } |
| 74 |
| 75 /** |
| 76 * Make sure the contact details suggestions are in the correct order and th
at only the top 4 |
| 77 * are shown. They should be ordered by frecency and complete contact detail
s should be |
| 78 * suggested first. |
| 79 */ |
| 80 @MediumTest |
| 81 public void testContactDetailsSuggestionOrdering() |
| 82 throws InterruptedException, ExecutionException, TimeoutException { |
| 83 triggerUIAndWait(mReadyToPay); |
| 84 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
| 85 assertEquals("555 123-4567\nlisa@simpson.com", getContactDetailsSuggesti
onLabel(0)); |
| 86 assertEquals("555 123-4567\nmaggie@simpson.com", getContactDetailsSugges
tionLabel(1)); |
| 87 assertEquals("bart@simpson.com", getContactDetailsSuggestionLabel(2)); |
| 88 assertEquals("homer@simpson.com", getContactDetailsSuggestionLabel(3)); |
| 89 assertEquals(null, getContactDetailsSuggestionLabel(4)); |
| 90 } |
| 91 } |
OLD | NEW |