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