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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestContactDetailsTest.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
(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.content.DialogInterface;
8 import android.test.suitebuilder.annotation.MediumTest;
9
10 import org.chromium.base.ThreadUtils;
11 import org.chromium.base.metrics.RecordHistogram;
12 import org.chromium.base.test.util.Feature;
13 import org.chromium.chrome.R;
14 import org.chromium.chrome.browser.autofill.AutofillTestHelper;
15 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
16 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
17
18 import java.util.concurrent.ExecutionException;
19 import java.util.concurrent.TimeoutException;
20
21 /**
22 * A payment integration test for a merchant that requests contact details.
23 */
24 public class PaymentRequestContactDetailsTest extends PaymentRequestTestBase {
25 public PaymentRequestContactDetailsTest() {
26 // The merchant requests both a phone number and an email address.
27 super("payment_request_contact_details_test.html");
28 }
29
30 @Override
31 public void onMainActivityStarted()
32 throws InterruptedException, ExecutionException, TimeoutException {
33 AutofillTestHelper helper = new AutofillTestHelper();
34 // The user has valid phone number and email address on disk.
35 String billingAddressId = helper.setProfile(new AutofillProfile("", "htt ps://example.com",
36 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", " ", "90291", "",
37 "US", "555-555-5555", "jon.doe@google.com", "en-US"));
38 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru e, "Jon Doe",
39 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_ visa,
40 billingAddressId, "" /* serverId */));
41 }
42
43 /** Provide the existing valid phone number and email address to the merchan t. */
44 @MediumTest
45 @Feature({"Payments"})
46 public void testPay() throws InterruptedException, ExecutionException, Timeo utException {
47 triggerUIAndWait(mReadyToPay);
48 clickAndWait(R.id.button_primary, mReadyForUnmaskInput);
49 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo Unmask);
50 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed );
51 expectResultContains(new String[] {"555-555-5555", "jon.doe@google.com"} );
52 }
53
54 /** Attempt to add invalid phone number and email address and cancel the tra nsaction. */
55 @MediumTest
56 @Feature({"Payments"})
57 public void testAddInvalidContactAndCancel()
58 throws InterruptedException, ExecutionException, TimeoutException {
59 triggerUIAndWait(mReadyToPay);
60 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
61 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit) ;
62 setTextInEditorAndWait(new String[] {"+++", "jane.jones"}, mEditorTextUp date);
63 clickInEditorAndWait(R.id.payments_edit_done_button, mEditorValidationEr ror);
64 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput);
65 clickAndWait(R.id.close_button, mDismissed);
66 expectResultContains(new String[] {"Request cancelled"});
67 }
68
69 /** Add new phone number and email address and provide that to the merchant. */
70 @MediumTest
71 @Feature({"Payments"})
72 public void testAddContactAndPay()
73 throws InterruptedException, ExecutionException, TimeoutException {
74 triggerUIAndWait(mReadyToPay);
75 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
76 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit) ;
77 setTextInEditorAndWait(new String[] {"999-999-9999", "jane.jones@google. com"},
78 mEditorTextUpdate);
79 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay);
80 clickAndWait(R.id.button_primary, mReadyForUnmaskInput);
81 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo Unmask);
82 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed );
83 expectResultContains(new String[] {"999-999-9999", "jane.jones@google.co m"});
84 }
85
86 /** Quickly pressing on "add contact info" and then [X] should not crash. */
87 @MediumTest
88 @Feature({"Payments"})
89 public void testQuickAddContactAndCloseShouldNotCrash()
90 throws InterruptedException, ExecutionException, TimeoutException {
91 triggerUIAndWait(mReadyToPay);
92 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
93
94 // Quickly press on "add contact info" and then [X].
95 int callCount = mReadyToEdit.getCallCount();
96 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
97 @Override
98 public void run() {
99 mUI.getContactDetailsSectionForTest().findViewById(
100 R.id.payments_add_option_button).performClick();
101 mUI.getDialogForTest().findViewById(R.id.close_button).performCl ick();
102 }
103 });
104 mReadyToEdit.waitForCallback(callCount);
105
106 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput);
107 clickAndWait(R.id.close_button, mDismissed);
108 expectResultContains(new String[] {"Request cancelled"});
109 }
110
111 /** Quickly pressing on [X] and then "add contact info" should not crash. */
112 @MediumTest
113 @Feature({"Payments"})
114 public void testQuickCloseAndAddContactShouldNotCrash()
115 throws InterruptedException, ExecutionException, TimeoutException {
116 triggerUIAndWait(mReadyToPay);
117 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
118
119 // Quickly press on [X] and then "add contact info."
120 int callCount = mDismissed.getCallCount();
121 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
122 @Override
123 public void run() {
124 mUI.getDialogForTest().findViewById(R.id.close_button).performCl ick();
125 mUI.getContactDetailsSectionForTest().findViewById(
126 R.id.payments_add_option_button).performClick();
127 }
128 });
129 mDismissed.waitForCallback(callCount);
130
131 expectResultContains(new String[] {"Request cancelled"});
132 }
133
134 /** Quickly pressing on "add contact info" and then "cancel" should not cras h. */
135 @MediumTest
136 @Feature({"Payments"})
137 public void testQuickAddContactAndCancelShouldNotCrash()
138 throws InterruptedException, ExecutionException, TimeoutException {
139 triggerUIAndWait(mReadyToPay);
140 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
141
142 // Quickly press on "add contact info" and then "cancel."
143 int callCount = mReadyToEdit.getCallCount();
144 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
145 @Override
146 public void run() {
147 mUI.getContactDetailsSectionForTest().findViewById(
148 R.id.payments_add_option_button).performClick();
149 mUI.getDialogForTest().findViewById(R.id.button_secondary).perfo rmClick();
150 }
151 });
152 mReadyToEdit.waitForCallback(callCount);
153
154 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput);
155 clickAndWait(R.id.close_button, mDismissed);
156 expectResultContains(new String[] {"Request cancelled"});
157 }
158
159 /** Quickly pressing on "cancel" and then "add contact info" should not cras h. */
160 @MediumTest
161 @Feature({"Payments"})
162 public void testQuickCancelAndAddContactShouldNotCrash()
163 throws InterruptedException, ExecutionException, TimeoutException {
164 triggerUIAndWait(mReadyToPay);
165 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
166
167 // Quickly press on "cancel" and then "add contact info."
168 int callCount = mDismissed.getCallCount();
169 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
170 @Override
171 public void run() {
172 mUI.getDialogForTest().findViewById(R.id.button_secondary).perfo rmClick();
173 mUI.getContactDetailsSectionForTest().findViewById(
174 R.id.payments_add_option_button).performClick();
175 }
176 });
177 mDismissed.waitForCallback(callCount);
178
179 expectResultContains(new String[] {"Request cancelled"});
180 }
181
182 /**
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
185 * histogram.
186 */
187 @MediumTest
188 @Feature({"Payments"})
189 public void testRequestedInformationMetric() throws InterruptedException, Ex ecutionException,
190 TimeoutException {
191 // Start the Payment Request.
192 triggerUIAndWait(mReadyToPay);
193
194 // Make sure that only the appropriate enum value was logged.
195 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i ) {
196 assertEquals((i == (PaymentRequestMetrics.REQUESTED_INFORMATION_EMAI L
197 | PaymentRequestMetrics.REQUESTED_INFORMATION_PHONE) ? 1 : 0 ),
198 RecordHistogram.getHistogramValueCountForTesting(
199 "PaymentRequest.RequestedInformation", i));
200 }
201 }
202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698