OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
6 | 6 |
7 import android.test.suitebuilder.annotation.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
8 | 8 |
9 import org.chromium.base.test.util.Feature; | 9 import org.chromium.base.test.util.Feature; |
10 import org.chromium.chrome.R; | 10 import org.chromium.chrome.R; |
11 import org.chromium.chrome.browser.autofill.AutofillTestHelper; | 11 import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
12 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 12 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
13 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; | 13 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
14 | 14 |
15 import java.util.concurrent.ExecutionException; | 15 import java.util.concurrent.ExecutionException; |
16 import java.util.concurrent.TimeoutException; | 16 import java.util.concurrent.TimeoutException; |
17 | 17 |
18 /** | 18 /** |
19 * A payment integration test for a merchant that requests contact details and a
user that has | 19 * A payment integration test for a merchant that requests payer information det
ails and a user that |
20 * 5 contact detail options. | 20 * has 5 payer information detail options. |
21 */ | 21 */ |
22 public class PaymentRequestMultipleContactDetailsTest extends PaymentRequestTest
Base { | 22 public class PaymentRequestMultiplePayerInfoDetailsTest extends PaymentRequestTe
stBase { |
23 public PaymentRequestMultipleContactDetailsTest() { | 23 public PaymentRequestMultiplePayerInfoDetailsTest() { |
24 // The merchant requests both a phone number and an email address. | 24 // The merchant requests payer information. |
25 super("payment_request_contact_details_test.html"); | 25 super("payment_request_payer_info_details_test.html"); |
26 } | 26 } |
27 | 27 |
28 @Override | 28 @Override |
29 public void onMainActivityStarted() | 29 public void onMainActivityStarted() |
30 throws InterruptedException, ExecutionException, TimeoutException { | 30 throws InterruptedException, ExecutionException, TimeoutException { |
31 AutofillTestHelper helper = new AutofillTestHelper(); | 31 AutofillTestHelper helper = new AutofillTestHelper(); |
32 // Create an incomplete (no phone) profile with the highest frecency sco
re. | 32 // Create an incomplete (no phone) profile with the highest frecency sco
re. |
33 String guid1 = helper.setProfile( | 33 String guid1 = helper.setProfile( |
34 new AutofillProfile("" /* guid */, "https://www.example.com" /*
origin */, | 34 new AutofillProfile("" /* guid */, "https://www.example.com" /*
origin */, |
35 "Bart Simpson", "Acme Inc.", "123 Main", "California", "
Los Angeles", "", | 35 "Bart Simpson", "Acme Inc.", "123 Main", "California", "
Los Angeles", "", |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // Set the use stats so that profile1 has the highest frecency score, pr
ofile2 the second | 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. | 68 // highest, profile 3 the third lowest, profile4 the second lowest and p
rofile 5 the lowest. |
69 helper.setProfileUseStatsForTesting(guid1, 20, 5000); | 69 helper.setProfileUseStatsForTesting(guid1, 20, 5000); |
70 helper.setProfileUseStatsForTesting(guid2, 15, 5000); | 70 helper.setProfileUseStatsForTesting(guid2, 15, 5000); |
71 helper.setProfileUseStatsForTesting(guid3, 10, 5000); | 71 helper.setProfileUseStatsForTesting(guid3, 10, 5000); |
72 helper.setProfileUseStatsForTesting(guid4, 5, 5000); | 72 helper.setProfileUseStatsForTesting(guid4, 5, 5000); |
73 helper.setProfileUseStatsForTesting(guid5, 1, 1); | 73 helper.setProfileUseStatsForTesting(guid5, 1, 1); |
74 } | 74 } |
75 | 75 |
76 /** | 76 /** |
77 * Make sure the contact details suggestions are in the correct order and th
at only the top 4 | 77 * Make sure the payer information details suggestions are in the correct or
der and that only |
78 * are shown. They should be ordered by frecency and complete contact detail
s should be | 78 * the top 4 are shown. They should be ordered by frecency and complete paye
r information |
79 * suggested first. | 79 * details should be suggested first. |
80 */ | 80 */ |
81 @MediumTest | 81 @MediumTest |
82 @Feature({"Payments"}) | 82 @Feature({"Payments"}) |
83 public void testContactDetailsSuggestionOrdering() | 83 public void testPayerInfoDetailsSuggestionOrdering() |
84 throws InterruptedException, ExecutionException, TimeoutException { | 84 throws InterruptedException, ExecutionException, TimeoutException { |
85 triggerUIAndWait(mReadyToPay); | 85 triggerUIAndWait(mReadyToPay); |
86 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); | 86 clickInPayerInfoAndWait(R.id.payments_section, mReadyForInput); |
87 assertEquals(4, getNumberOfContactDetailSuggestions()); | 87 assertEquals(4, getNumberOfPayerInfoDetailSuggestions()); |
88 assertEquals("555 123-4567\nlisa@simpson.com", getContactDetailsSuggesti
onLabel(0)); | 88 assertEquals("Lisa Simpson\n555 123-4567\nlisa@simpson.com", |
89 assertEquals("555 123-4567\nmaggie@simpson.com", getContactDetailsSugges
tionLabel(1)); | 89 getPayerInfoDetailsSuggestionLabel(0)); |
90 assertEquals("bart@simpson.com", getContactDetailsSuggestionLabel(2)); | 90 assertEquals("Maggie Simpson\n555 123-4567\nmaggie@simpson.com", |
91 assertEquals("homer@simpson.com", getContactDetailsSuggestionLabel(3)); | 91 getPayerInfoDetailsSuggestionLabel(1)); |
| 92 assertEquals("Bart Simpson\nbart@simpson.com", getPayerInfoDetailsSugges
tionLabel(2)); |
| 93 assertEquals("Homer Simpson\nhomer@simpson.com", getPayerInfoDetailsSugg
estionLabel(3)); |
92 } | 94 } |
93 } | 95 } |
OLD | NEW |