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.content.DialogInterface; | 7 import android.content.DialogInterface; |
8 import android.test.suitebuilder.annotation.MediumTest; | 8 import android.test.suitebuilder.annotation.MediumTest; |
9 | 9 |
10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
11 import org.chromium.base.metrics.RecordHistogram; | 11 import org.chromium.base.metrics.RecordHistogram; |
12 import org.chromium.base.test.util.Feature; | 12 import org.chromium.base.test.util.Feature; |
13 import org.chromium.chrome.R; | 13 import org.chromium.chrome.R; |
14 import org.chromium.chrome.browser.autofill.AutofillTestHelper; | 14 import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
15 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 15 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
16 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; | 16 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
17 | 17 |
18 import java.util.concurrent.ExecutionException; | 18 import java.util.concurrent.ExecutionException; |
19 import java.util.concurrent.TimeoutException; | 19 import java.util.concurrent.TimeoutException; |
20 | 20 |
21 /** | 21 /** |
22 * A payment integration test for a merchant that requests contact details. | 22 * A payment integration test for a merchant that requests contact details. |
23 */ | 23 */ |
24 public class PaymentRequestContactDetailsTest extends PaymentRequestTestBase { | 24 public class PaymentRequestContactDetailsTest extends PaymentRequestTestBase { |
25 public PaymentRequestContactDetailsTest() { | 25 public PaymentRequestContactDetailsTest() { |
26 // The merchant requests both a phone number and an email address. | 26 // The merchant requests a payer name, a phone number and an email addre
ss. |
27 super("payment_request_contact_details_test.html"); | 27 super("payment_request_contact_details_test.html"); |
28 } | 28 } |
29 | 29 |
30 @Override | 30 @Override |
31 public void onMainActivityStarted() | 31 public void onMainActivityStarted() |
32 throws InterruptedException, ExecutionException, TimeoutException { | 32 throws InterruptedException, ExecutionException, TimeoutException { |
33 AutofillTestHelper helper = new AutofillTestHelper(); | 33 AutofillTestHelper helper = new AutofillTestHelper(); |
34 // The user has valid phone number and email address on disk. | 34 // The user has valid payer name, phone number and email address on disk
. |
35 String billingAddressId = helper.setProfile(new AutofillProfile("", "htt
ps://example.com", | 35 String billingAddressId = helper.setProfile(new AutofillProfile("", "htt
ps://example.com", |
36 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "
", "90291", "", | 36 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "
", "90291", "", |
37 "US", "555-555-5555", "jon.doe@google.com", "en-US")); | 37 "US", "555-555-5555", "jon.doe@google.com", "en-US")); |
38 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", | 38 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", |
39 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, | 39 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, |
40 billingAddressId, "" /* serverId */)); | 40 billingAddressId, "" /* serverId */)); |
41 } | 41 } |
42 | 42 |
43 /** Provide the existing valid phone number and email address to the merchan
t. */ | 43 /** Provide the existing valid payer name, phone number and email address to
the merchant. */ |
44 @MediumTest | 44 @MediumTest |
45 @Feature({"Payments"}) | 45 @Feature({"Payments"}) |
46 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { | 46 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { |
47 triggerUIAndWait(mReadyToPay); | 47 triggerUIAndWait(mReadyToPay); |
48 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 48 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
49 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 49 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
50 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 50 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
51 expectResultContains(new String[] {"555-555-5555", "jon.doe@google.com"}
); | 51 expectResultContains(new String[] {"Jon Doe", "555-555-5555", "jon.doe@g
oogle.com"}); |
52 } | 52 } |
53 | 53 |
54 /** Attempt to add invalid phone number and email address and cancel the tra
nsaction. */ | 54 /** Attempt to add invalid contact information and cancel the transaction. *
/ |
55 @MediumTest | 55 @MediumTest |
56 @Feature({"Payments"}) | 56 @Feature({"Payments"}) |
57 public void testAddInvalidContactAndCancel() | 57 public void testAddInvalidContactAndCancel() |
58 throws InterruptedException, ExecutionException, TimeoutException { | 58 throws InterruptedException, ExecutionException, TimeoutException { |
59 triggerUIAndWait(mReadyToPay); | 59 triggerUIAndWait(mReadyToPay); |
60 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); | 60 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
61 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit)
; | 61 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit)
; |
62 setTextInEditorAndWait(new String[] {"+++", "jane.jones"}, mEditorTextUp
date); | 62 setTextInEditorAndWait(new String[] {"", "+++", "jane.jones"}, mEditorTe
xtUpdate); |
63 clickInEditorAndWait(R.id.payments_edit_done_button, mEditorValidationEr
ror); | 63 clickInEditorAndWait(R.id.payments_edit_done_button, mEditorValidationEr
ror); |
64 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput); | 64 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput); |
65 clickAndWait(R.id.close_button, mDismissed); | 65 clickAndWait(R.id.close_button, mDismissed); |
66 expectResultContains(new String[] {"Request cancelled"}); | 66 expectResultContains(new String[] {"Request cancelled"}); |
67 } | 67 } |
68 | 68 |
69 /** Add new phone number and email address and provide that to the merchant.
*/ | 69 /** Add new payer name, phone number and email address and provide that to t
he merchant. */ |
70 @MediumTest | 70 @MediumTest |
71 @Feature({"Payments"}) | 71 @Feature({"Payments"}) |
72 public void testAddContactAndPay() | 72 public void testAddContactAndPay() |
73 throws InterruptedException, ExecutionException, TimeoutException { | 73 throws InterruptedException, ExecutionException, TimeoutException { |
74 triggerUIAndWait(mReadyToPay); | 74 triggerUIAndWait(mReadyToPay); |
75 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); | 75 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
76 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit)
; | 76 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit)
; |
77 setTextInEditorAndWait(new String[] {"999-999-9999", "jane.jones@google.
com"}, | 77 setTextInEditorAndWait(new String[] {"Jane Jones", "999-999-9999", "jane
.jones@google.com"}, |
78 mEditorTextUpdate); | 78 mEditorTextUpdate); |
79 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); | 79 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
80 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 80 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
81 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 81 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
82 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 82 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
83 expectResultContains(new String[] {"999-999-9999", "jane.jones@google.co
m"}); | 83 expectResultContains(new String[] {"Jane Jones", "999-999-9999", "jane.j
ones@google.com"}); |
84 } | 84 } |
85 | 85 |
86 /** Quickly pressing on "add contact info" and then [X] should not crash. */ | 86 /** Quickly pressing on "add contact info" and then [X] should not crash. */ |
87 @MediumTest | 87 @MediumTest |
88 @Feature({"Payments"}) | 88 @Feature({"Payments"}) |
89 public void testQuickAddContactAndCloseShouldNotCrash() | 89 public void testQuickAddContactAndCloseShouldNotCrash() |
90 throws InterruptedException, ExecutionException, TimeoutException { | 90 throws InterruptedException, ExecutionException, TimeoutException { |
91 triggerUIAndWait(mReadyToPay); | 91 triggerUIAndWait(mReadyToPay); |
92 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); | 92 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
93 | 93 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 // Make sure that only the appropriate enum value was logged. | 194 // Make sure that only the appropriate enum value was logged. |
195 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i
) { | 195 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i
) { |
196 assertEquals((i == (PaymentRequestMetrics.REQUESTED_INFORMATION_EMAI
L | 196 assertEquals((i == (PaymentRequestMetrics.REQUESTED_INFORMATION_EMAI
L |
197 | PaymentRequestMetrics.REQUESTED_INFORMATION_PHONE) ? 1 : 0
), | 197 | PaymentRequestMetrics.REQUESTED_INFORMATION_PHONE) ? 1 : 0
), |
198 RecordHistogram.getHistogramValueCountForTesting( | 198 RecordHistogram.getHistogramValueCountForTesting( |
199 "PaymentRequest.RequestedInformation", i)); | 199 "PaymentRequest.RequestedInformation", i)); |
200 } | 200 } |
201 } | 201 } |
202 } | 202 } |
OLD | NEW |