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

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

Issue 2583593002: [Payments] Dedupe subsets in contact detail suggestions. (Closed)
Patch Set: Addressed Comments Created 3 years, 11 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.support.test.filters.MediumTest; 7 import android.support.test.filters.MediumTest;
8 8
9 import org.chromium.base.ThreadUtils; 9 import org.chromium.base.ThreadUtils;
10 import org.chromium.base.metrics.RecordHistogram; 10 import org.chromium.base.metrics.RecordHistogram;
(...skipping 16 matching lines...) Expand all
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 // The user has valid payer name, phone number and email address on disk . 32 // The user has valid payer name, phone number and email address on disk .
33 helper.setProfile(new AutofillProfile("", "https://example.com", true, " Jon Doe", "Google", 33 helper.setProfile(new AutofillProfile("", "https://example.com", true, " Jon Doe", "Google",
34 "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555- 555-5555", 34 "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555- 555-5555",
35 "jon.doe@google.com", "en-US")); 35 "jon.doe@google.com", "en-US"));
36 36
37 // Add the same profile but with a different address.
38 helper.setProfile(new AutofillProfile("", "https://example.com", true, " ", "Google",
39 "999 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555- 555-5555",
40 "jon.doe@google.com", "en-US"));
41
42 // Add the same profile but without a phone number.
43 helper.setProfile(new AutofillProfile("", "https://example.com", true, " Jon Doe", "Google",
44 "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "" /* phone_number */,
45 "jon.doe@google.com", "en-US"));
46
47 // Add the same profile but without an email.
48 helper.setProfile(new AutofillProfile("", "https://example.com", true, " Jon Doe", "Google",
49 "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555- 555-5555",
50 "" /* emailAddress */, "en-US"));
51
52 // Add the same profile but without a name.
53 helper.setProfile(new AutofillProfile("" /* name */, "https://example.co m", true, "",
54 "Google", "340 Main St", "CA", "Los Angeles", "", "90291", "", " US", "555-555-5555",
55 "jon.doe@google.com", "en-US"));
56
37 installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE); 57 installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE);
38 } 58 }
39 59
40 /** Provide the existing valid payer name, phone number and email address to the merchant. */ 60 /** Provide the existing valid payer name, phone number and email address to the merchant. */
41 @MediumTest 61 @MediumTest
42 @Feature({"Payments"}) 62 @Feature({"Payments"})
43 public void testPay() throws InterruptedException, ExecutionException, Timeo utException { 63 public void testPay() throws InterruptedException, ExecutionException, Timeo utException {
44 triggerUIAndWait(mReadyToPay); 64 triggerUIAndWait(mReadyToPay);
45 clickAndWait(R.id.button_primary, mDismissed); 65 clickAndWait(R.id.button_primary, mDismissed);
46 expectResultContains(new String[] {"Jon Doe", "555-555-5555", "jon.doe@g oogle.com"}); 66 expectResultContains(new String[] {"Jon Doe", "555-555-5555", "jon.doe@g oogle.com"});
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 mUI.getContactDetailsSectionForTest().findViewById( 221 mUI.getContactDetailsSectionForTest().findViewById(
202 R.id.payments_add_option_button).performClick(); 222 R.id.payments_add_option_button).performClick();
203 } 223 }
204 }); 224 });
205 mDismissed.waitForCallback(callCount); 225 mDismissed.waitForCallback(callCount);
206 226
207 expectResultContains(new String[] {"Request cancelled"}); 227 expectResultContains(new String[] {"Request cancelled"});
208 } 228 }
209 229
210 /** 230 /**
231 * Makes sure that suggestions that are equal to or subsets of other suggest ions are not shown
232 * to the user.
233 */
234 @MediumTest
235 @Feature({"Payments"})
236 public void testSuggestionsDeduped()
237 throws InterruptedException, ExecutionException, TimeoutException {
238 triggerUIAndWait(mReadyToPay);
239 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
240 assertEquals(1, getNumberOfContactDetailSuggestions());
241 }
242
243 /**
211 * Test that starting a payment request that requires the user's email addre ss, phone number and 244 * Test that starting a payment request that requires the user's email addre ss, phone number and
212 * name results in the appropriate metric being logged in the 245 * name results in the appropriate metric being logged in the
213 * PaymentRequest.RequestedInformation histogram. 246 * PaymentRequest.RequestedInformation histogram.
214 */ 247 */
215 @MediumTest 248 @MediumTest
216 @Feature({"Payments"}) 249 @Feature({"Payments"})
217 public void testRequestedInformationMetric() throws InterruptedException, Ex ecutionException, 250 public void testRequestedInformationMetric() throws InterruptedException, Ex ecutionException,
218 TimeoutException { 251 TimeoutException {
219 // Start the Payment Request. 252 // Start the Payment Request.
220 triggerUIAndWait(mReadyToPay); 253 triggerUIAndWait(mReadyToPay);
221 254
222 // Make sure that only the appropriate enum value was logged. 255 // Make sure that only the appropriate enum value was logged.
223 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i ) { 256 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i ) {
224 assertEquals((i == (PaymentRequestMetrics.REQUESTED_INFORMATION_EMAI L 257 assertEquals((i == (PaymentRequestMetrics.REQUESTED_INFORMATION_EMAI L
225 | PaymentRequestMetrics.REQUESTED_INFORMATION_PHONE 258 | PaymentRequestMetrics.REQUESTED_INFORMATION_PHONE
226 | PaymentRequestMetrics.REQUESTED_INFORMATION_NAME) ? 1 : 0) , 259 | PaymentRequestMetrics.REQUESTED_INFORMATION_NAME) ? 1 : 0) ,
227 RecordHistogram.getHistogramValueCountForTesting( 260 RecordHistogram.getHistogramValueCountForTesting(
228 "PaymentRequest.RequestedInformation", i)); 261 "PaymentRequest.RequestedInformation", i));
229 } 262 }
230 } 263 }
231 } 264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698