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

Unified 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: Rebase Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailAndFreeShippingTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailAndFreeShippingTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailAndFreeShippingTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..6df03efc38e0aa6cdca2525bb9d5ea2239b11b32
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailAndFreeShippingTest.java
@@ -0,0 +1,73 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.payments;
+
+import android.content.DialogInterface;
+import android.test.suitebuilder.annotation.MediumTest;
+
+import org.chromium.base.metrics.RecordHistogram;
+import org.chromium.chrome.R;
+import org.chromium.chrome.browser.autofill.AutofillTestHelper;
+import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
+import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * A payment integration test for a merchant that requires and email address and provides free
+ * shipping regardless of address.
+ */
+public class PaymentRequestEmailAndFreeShippingTest extends PaymentRequestTestBase {
+ public PaymentRequestEmailAndFreeShippingTest() {
+ // This merchant requests and email address and provides free shipping worldwide.
+ super("payment_request_email_and_free_shipping_test.html");
+ }
+
+ @Override
+ public void onMainActivityStarted()
+ throws InterruptedException, ExecutionException, TimeoutException {
+ AutofillTestHelper helper = new AutofillTestHelper();
+ // The user has a shipping address with a valid email on disk.
+ String billingAddressId = helper.setProfile(new AutofillProfile("", "https://example.com",
+ true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "90291", "",
+ "US", "555-555-5555", "jon.doe@google.com", "en-US"));
+ helper.setCreditCard(new CreditCard("", "https://example.com", true, true, "Jon Doe",
+ "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_visa,
+ billingAddressId, "" /* serverId */));
+ }
+
+ /** Submit the email and the shipping address to the merchant when the user clicks "Pay." */
+ @MediumTest
+ public void testPay() throws InterruptedException, ExecutionException, TimeoutException {
+ triggerUIAndWait(mReadyToPay);
+ clickAndWait(R.id.button_primary, mReadyForUnmaskInput);
+ setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyToUnmask);
+ clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed);
+ expectResultContains(new String[] {"jon.doe@google.com", "Jon Doe", "4111111111111111",
+ "12", "2050", "visa", "123", "Google", "340 Main St", "CA", "Los Angeles", "90291",
+ "US", "en", "freeShippingOption"});
+ }
+
+ /**
+ * Test that starting a payment request that requires and email address and a shipping address
+ * results in the appropriate metric being logged in the PaymentRequest.RequestedInformation
+ * histogram.
+ */
+ @MediumTest
+ public void testRequestedInformationMetric() throws InterruptedException, ExecutionException,
+ TimeoutException {
+ // Start the Payment Request.
+ triggerUIAndWait(mReadyToPay);
+
+ // Make sure that only the appropriate enum value was logged.
+ for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i) {
+ assertEquals((i == (PaymentRequestMetrics.REQUESTED_INFORMATION_EMAIL
+ | PaymentRequestMetrics.REQUESTED_INFORMATION_SHIPPING) ? 1 : 0),
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.RequestedInformation", i));
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698