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

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

Issue 2182123003: [Payments] Add information requested by merchant metrics to PR. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored and added integration tests Created 4 years, 4 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.metrics.RecordHistogram;
11 import org.chromium.chrome.R;
12 import org.chromium.chrome.browser.autofill.AutofillTestHelper;
13 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
14 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
15
16 import java.util.concurrent.ExecutionException;
17 import java.util.concurrent.TimeoutException;
18
19 /**
20 * A payment integration test for a merchant that requires and email address and provides free
21 * shipping regardless of address.
22 */
23 public class PaymentRequestEmailAndFreeShippingTest extends PaymentRequestTestBa se {
24 public PaymentRequestEmailAndFreeShippingTest() {
25 // This merchant requests and email address and provides free shipping w orldwide.
26 super("payment_request_email_and_free_shipping_test.html");
27 }
28
29 @Override
30 public void onMainActivityStarted()
31 throws InterruptedException, ExecutionException, TimeoutException {
32 AutofillTestHelper helper = new AutofillTestHelper();
33 // The user has a shipping address with a valid email on disk.
34 String billingAddressId = helper.setProfile(new AutofillProfile("", "htt ps://example.com",
35 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", " ", "90291", "",
36 "US", "555-555-5555", "jon.doe@google.com", "en-US"));
37 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru e, "Jon Doe",
38 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_ visa,
39 billingAddressId));
40 }
41
42 /** Submit the email and the shipping address to the merchant when the user clicks "Pay." */
43 @MediumTest
44 public void testPay() throws InterruptedException, ExecutionException, Timeo utException {
45 triggerUIAndWait(mReadyToPay);
46 clickAndWait(R.id.button_primary, mReadyForUnmaskInput);
47 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo Unmask);
48 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed );
49 expectResultContains(new String[] {"jon.doe@google.com", "Jon Doe", "411 1111111111111",
50 "12", "2050", "visa", "123", "Google", "340 Main St", "CA", "Los Angeles", "90291",
51 "US", "en", "freeShippingOption"});
52 }
53
54 /**
55 * Test that starting a payment request that requires and email address and a shipping address
56 * results in the appropriate metric being logged in the PaymentRequest.Requ estedInformation
57 * histogram.
58 */
59 @MediumTest
60 public void testRequestedInformationMetric() throws InterruptedException, Ex ecutionException,
61 TimeoutException {
62 // Start the Payment Request.
63 triggerUIAndWait(mReadyToPay);
64
65 // Make sure that only the appropriate enum value was logged.
66 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i ) {
67 if (i == PaymentRequestMetrics.REQUESTED_INFORMATION_EMAIL_SHIPPING) {
68 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting (
69 "PaymentRequest.RequestedInformation", i));
70 } else {
71 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting (
72 "PaymentRequest.RequestedInformation", i));
73 }
74 }
75 }
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698