Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPayerInfoDetailsTest.java

Issue 2413833002: PaymentRequest: Rename ContactInfo to PayerInfo.
Patch Set: test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 payer information det ails.
23 */ 23 */
24 public class PaymentRequestContactDetailsTest extends PaymentRequestTestBase { 24 public class PaymentRequestPayerInfoDetailsTest extends PaymentRequestTestBase {
25 public PaymentRequestContactDetailsTest() { 25 public PaymentRequestPayerInfoDetailsTest() {
26 // The merchant requests both a phone number and an email address. 26 // The merchant requests payer information.
27 super("payment_request_contact_details_test.html"); 27 super("payment_request_payer_info_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 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 phone number and email address to the merchan t. */
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[] {"555-555-5555", "jon.doe@google.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 payer information and cancel the transaction. */
55 @MediumTest 55 @MediumTest
56 @Feature({"Payments"}) 56 @Feature({"Payments"})
57 public void testAddInvalidContactAndCancel() 57 public void testAddInvalidPayerInfoAndCancel()
58 throws InterruptedException, ExecutionException, TimeoutException { 58 throws InterruptedException, ExecutionException, TimeoutException {
59 triggerUIAndWait(mReadyToPay); 59 triggerUIAndWait(mReadyToPay);
60 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); 60 clickInPayerInfoAndWait(R.id.payments_section, mReadyForInput);
61 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit) ; 61 clickInPayerInfoAndWait(R.id.payments_add_option_button, mReadyToEdit);
62 setTextInEditorAndWait(new String[] {"+++", "jane.jones"}, mEditorTextUp date); 62 setTextInEditorAndWait(new String[] {"+++", "jane.jones"}, mEditorTextUp date);
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 phone number and email address and provide that to the merchant. */
70 @MediumTest 70 @MediumTest
71 @Feature({"Payments"}) 71 @Feature({"Payments"})
72 public void testAddContactAndPay() 72 public void testAddPayerInfoAndPay()
73 throws InterruptedException, ExecutionException, TimeoutException { 73 throws InterruptedException, ExecutionException, TimeoutException {
74 triggerUIAndWait(mReadyToPay); 74 triggerUIAndWait(mReadyToPay);
75 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); 75 clickInPayerInfoAndWait(R.id.payments_section, mReadyForInput);
76 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit) ; 76 clickInPayerInfoAndWait(R.id.payments_add_option_button, mReadyToEdit);
77 setTextInEditorAndWait(new String[] {"999-999-9999", "jane.jones@google. com"}, 77 setTextInEditorAndWait(new String[] {"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[] {"999-999-9999", "jane.jones@google.co m"});
84 } 84 }
85 85
86 /** Quickly pressing on "add contact info" and then [X] should not crash. */ 86 /** Quickly pressing on "add payer info" and then [X] should not crash. */
87 @MediumTest 87 @MediumTest
88 @Feature({"Payments"}) 88 @Feature({"Payments"})
89 public void testQuickAddContactAndCloseShouldNotCrash() 89 public void testQuickAddPayerInfoAndCloseShouldNotCrash()
90 throws InterruptedException, ExecutionException, TimeoutException { 90 throws InterruptedException, ExecutionException, TimeoutException {
91 triggerUIAndWait(mReadyToPay); 91 triggerUIAndWait(mReadyToPay);
92 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); 92 clickInPayerInfoAndWait(R.id.payments_section, mReadyForInput);
93 93
94 // Quickly press on "add contact info" and then [X]. 94 // Quickly press on "add payer info" and then [X].
95 int callCount = mReadyToEdit.getCallCount(); 95 int callCount = mReadyToEdit.getCallCount();
96 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 96 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
97 @Override 97 @Override
98 public void run() { 98 public void run() {
99 mUI.getContactDetailsSectionForTest().findViewById( 99 mUI.getPayerInfoDetailsSectionForTest().findViewById(
100 R.id.payments_add_option_button).performClick(); 100 R.id.payments_add_option_button).performClick();
101 mUI.getDialogForTest().findViewById(R.id.close_button).performCl ick(); 101 mUI.getDialogForTest().findViewById(R.id.close_button).performCl ick();
102 } 102 }
103 }); 103 });
104 mReadyToEdit.waitForCallback(callCount); 104 mReadyToEdit.waitForCallback(callCount);
105 105
106 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput); 106 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput);
107 clickAndWait(R.id.close_button, mDismissed); 107 clickAndWait(R.id.close_button, mDismissed);
108 expectResultContains(new String[] {"Request cancelled"}); 108 expectResultContains(new String[] {"Request cancelled"});
109 } 109 }
110 110
111 /** Quickly pressing on [X] and then "add contact info" should not crash. */ 111 /** Quickly pressing on [X] and then "add payer info" should not crash. */
112 @MediumTest 112 @MediumTest
113 @Feature({"Payments"}) 113 @Feature({"Payments"})
114 public void testQuickCloseAndAddContactShouldNotCrash() 114 public void testQuickCloseAndAddPayerInfoShouldNotCrash()
115 throws InterruptedException, ExecutionException, TimeoutException { 115 throws InterruptedException, ExecutionException, TimeoutException {
116 triggerUIAndWait(mReadyToPay); 116 triggerUIAndWait(mReadyToPay);
117 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); 117 clickInPayerInfoAndWait(R.id.payments_section, mReadyForInput);
118 118
119 // Quickly press on [X] and then "add contact info." 119 // Quickly press on [X] and then "add payer info."
120 int callCount = mDismissed.getCallCount(); 120 int callCount = mDismissed.getCallCount();
121 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 121 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
122 @Override 122 @Override
123 public void run() { 123 public void run() {
124 mUI.getDialogForTest().findViewById(R.id.close_button).performCl ick(); 124 mUI.getDialogForTest().findViewById(R.id.close_button).performCl ick();
125 mUI.getContactDetailsSectionForTest().findViewById( 125 mUI.getPayerInfoDetailsSectionForTest().findViewById(
126 R.id.payments_add_option_button).performClick(); 126 R.id.payments_add_option_button).performClick();
127 } 127 }
128 }); 128 });
129 mDismissed.waitForCallback(callCount); 129 mDismissed.waitForCallback(callCount);
130 130
131 expectResultContains(new String[] {"Request cancelled"}); 131 expectResultContains(new String[] {"Request cancelled"});
132 } 132 }
133 133
134 /** Quickly pressing on "add contact info" and then "cancel" should not cras h. */ 134 /** Quickly pressing on "add payer info" and then "cancel" should not crash. */
135 @MediumTest 135 @MediumTest
136 @Feature({"Payments"}) 136 @Feature({"Payments"})
137 public void testQuickAddContactAndCancelShouldNotCrash() 137 public void testQuickAddPayerInfoAndCancelShouldNotCrash()
138 throws InterruptedException, ExecutionException, TimeoutException { 138 throws InterruptedException, ExecutionException, TimeoutException {
139 triggerUIAndWait(mReadyToPay); 139 triggerUIAndWait(mReadyToPay);
140 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); 140 clickInPayerInfoAndWait(R.id.payments_section, mReadyForInput);
141 141
142 // Quickly press on "add contact info" and then "cancel." 142 // Quickly press on "add payer info" and then "cancel."
143 int callCount = mReadyToEdit.getCallCount(); 143 int callCount = mReadyToEdit.getCallCount();
144 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 144 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
145 @Override 145 @Override
146 public void run() { 146 public void run() {
147 mUI.getContactDetailsSectionForTest().findViewById( 147 mUI.getPayerInfoDetailsSectionForTest().findViewById(
148 R.id.payments_add_option_button).performClick(); 148 R.id.payments_add_option_button).performClick();
149 mUI.getDialogForTest().findViewById(R.id.button_secondary).perfo rmClick(); 149 mUI.getDialogForTest().findViewById(R.id.button_secondary).perfo rmClick();
150 } 150 }
151 }); 151 });
152 mReadyToEdit.waitForCallback(callCount); 152 mReadyToEdit.waitForCallback(callCount);
153 153
154 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput); 154 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput);
155 clickAndWait(R.id.close_button, mDismissed); 155 clickAndWait(R.id.close_button, mDismissed);
156 expectResultContains(new String[] {"Request cancelled"}); 156 expectResultContains(new String[] {"Request cancelled"});
157 } 157 }
158 158
159 /** Quickly pressing on "cancel" and then "add contact info" should not cras h. */ 159 /** Quickly pressing on "cancel" and then "add payer info" should not crash. */
160 @MediumTest 160 @MediumTest
161 @Feature({"Payments"}) 161 @Feature({"Payments"})
162 public void testQuickCancelAndAddContactShouldNotCrash() 162 public void testQuickCancelAndAddPayerInfoShouldNotCrash()
163 throws InterruptedException, ExecutionException, TimeoutException { 163 throws InterruptedException, ExecutionException, TimeoutException {
164 triggerUIAndWait(mReadyToPay); 164 triggerUIAndWait(mReadyToPay);
165 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); 165 clickInPayerInfoAndWait(R.id.payments_section, mReadyForInput);
166 166
167 // Quickly press on "cancel" and then "add contact info." 167 // Quickly press on "cancel" and then "add payer info."
168 int callCount = mDismissed.getCallCount(); 168 int callCount = mDismissed.getCallCount();
169 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 169 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
170 @Override 170 @Override
171 public void run() { 171 public void run() {
172 mUI.getDialogForTest().findViewById(R.id.button_secondary).perfo rmClick(); 172 mUI.getDialogForTest().findViewById(R.id.button_secondary).perfo rmClick();
173 mUI.getContactDetailsSectionForTest().findViewById( 173 mUI.getPayerInfoDetailsSectionForTest().findViewById(
174 R.id.payments_add_option_button).performClick(); 174 R.id.payments_add_option_button).performClick();
175 } 175 }
176 }); 176 });
177 mDismissed.waitForCallback(callCount); 177 mDismissed.waitForCallback(callCount);
178 178
179 expectResultContains(new String[] {"Request cancelled"}); 179 expectResultContains(new String[] {"Request cancelled"});
180 } 180 }
181 181
182 /** 182 /**
183 * Test that starting a payment request that requires the user's email addre ss and phone number 183 * Test that starting a payment request that requires the user's email addre ss and phone number
184 * results in the appropriate metric being logged in the PaymentRequest.Requ estedInformation 184 * results in the appropriate metric being logged in the PaymentRequest.Requ estedInformation
185 * histogram. 185 * histogram.
186 */ 186 */
187 @MediumTest 187 @MediumTest
188 @Feature({"Payments"}) 188 @Feature({"Payments"})
189 public void testRequestedInformationMetric() throws InterruptedException, Ex ecutionException, 189 public void testRequestedInformationMetric() throws InterruptedException, Ex ecutionException,
190 TimeoutException { 190 TimeoutException {
191 // Start the Payment Request. 191 // Start the Payment Request.
192 triggerUIAndWait(mReadyToPay); 192 triggerUIAndWait(mReadyToPay);
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698