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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMetricsTest.java

Issue 2220713002: [Payments] Add Payment Request metrics for selected payment method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMetricsTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMetricsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMetricsTest.java
index 207d3bd149fd8f04ea00241ca892f4d6caded730..3d779d5a97f8f46cbaeb8bc1abb73f943119db5a 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMetricsTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMetricsTest.java
@@ -46,7 +46,7 @@ public class PaymentRequestMetricsTest extends PaymentRequestTestBase {
public void testSuccessCheckoutFunnel() throws InterruptedException, ExecutionException,
TimeoutException {
// Initiate a payment request.
- triggerUIAndWait(mReadyToPay);
+ triggerUIAndWait("ccBuy", mReadyToPay);
// Make sure sure that the "Initiated" and "Shown" events were logged.
assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
@@ -79,7 +79,7 @@ public class PaymentRequestMetricsTest extends PaymentRequestTestBase {
@MediumTest
public void testAbortMetrics_AbortedByUser_CancelButton() throws InterruptedException,
ExecutionException, TimeoutException {
- triggerUIAndWait(mReadyToPay);
+ triggerUIAndWait("ccBuy", mReadyToPay);
clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput);
// Cancel the Payment Request.
@@ -104,7 +104,7 @@ public class PaymentRequestMetricsTest extends PaymentRequestTestBase {
@MediumTest
public void testAbortMetrics_AbortedByUser_XButton() throws InterruptedException,
ExecutionException, TimeoutException {
- triggerUIAndWait(mReadyToPay);
+ triggerUIAndWait("ccBuy", mReadyToPay);
clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput);
// Press the [X] button.
@@ -122,7 +122,7 @@ public class PaymentRequestMetricsTest extends PaymentRequestTestBase {
@MediumTest
public void testAbortMetrics_AbortedByUser_BackButton() throws InterruptedException,
ExecutionException, TimeoutException {
- triggerUIAndWait(mReadyToPay);
+ triggerUIAndWait("ccBuy", mReadyToPay);
clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput);
// Press the back button.
@@ -147,7 +147,7 @@ public class PaymentRequestMetricsTest extends PaymentRequestTestBase {
@MediumTest
public void testAbortMetrics_AbortedByUser_TabClosed() throws InterruptedException,
ExecutionException, TimeoutException {
- triggerUIAndWait(mReadyToPay);
+ triggerUIAndWait("ccBuy", mReadyToPay);
clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput);
// Press the back button.
@@ -164,7 +164,7 @@ public class PaymentRequestMetricsTest extends PaymentRequestTestBase {
@MediumTest
public void testAbortMetrics_AbortedByMerchant() throws InterruptedException,
ExecutionException, TimeoutException {
- triggerUIAndWait(mReadyToPay);
+ triggerUIAndWait("ccBuy", mReadyToPay);
// Simulate an abort by the merchant.
clickNodeAndWait("abort", mDismissed);
@@ -184,7 +184,7 @@ public class PaymentRequestMetricsTest extends PaymentRequestTestBase {
ExecutionException, TimeoutException {
// Bob pay is supported but no instruments are present.
installPaymentApp(NO_INSTRUMENTS, DELAYED_RESPONSE);
- triggerUIAndWait("noMatching", mShowFailed);
+ triggerUIAndWait("bobPayBuy", mShowFailed);
expectResultContains(new String[] {"The payment method is not supported"});
assertOnlySpecificAbortMetricLogged(
@@ -207,6 +207,42 @@ public class PaymentRequestMetricsTest extends PaymentRequestTestBase {
}
/**
+ * Expect only the SELECTED_METHOD_CREDIT_CARD enum value to be logged for the
+ * "SelectedPaymentMethod" histogram when completing a Payment Request with a credit card.
+ */
+ @MediumTest
+ public void testSelectedPaymentMethod_CreditCard() throws InterruptedException,
+ ExecutionException, TimeoutException {
+ // Complete a Payment Request with a credit card.
+ triggerUIAndWait("ccBuy", mReadyToPay);
+ clickAndWait(R.id.button_primary, mReadyForUnmaskInput);
+ setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyToUnmask);
+ clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed);
+
+ assertOnlySpecificSelectedPaymentMethodMetricLogged(
+ PaymentRequestMetrics.SELECTED_METHOD_CREDIT_CARD);
+ }
+
+ /**
+ * Expect only the SELECTED_METHOD_ANDROID_PAY enum value to be logged for the
+ * "SelectedPaymentMethod" histogram when completing a Payment Request with Android Pay.
+ */
+ @MediumTest
+ public void testSelectedPaymentMethod_BobPay() throws InterruptedException, ExecutionException,
+ TimeoutException {
+ // Set the test name for Android Pay (BobPay).
+ PaymentRequestMetrics.setAndroidPayMethodNameForTest();
+
+ // Complete a Payment Request with BobPay.
+ installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE);
+ triggerUIAndWait("bobPayBuy", mReadyToPay);
+ clickAndWait(R.id.button_primary, mDismissed);
+
+ assertOnlySpecificSelectedPaymentMethodMetricLogged(
+ PaymentRequestMetrics.SELECTED_METHOD_ANDROID_PAY);
+ }
+
+ /**
* Asserts that only the specified reason for abort is logged.
*
* @param abortReason The only bucket in the abort histogram that should have a record.
@@ -218,4 +254,18 @@ public class PaymentRequestMetricsTest extends PaymentRequestTestBase {
"PaymentRequest.CheckoutFunnel.Aborted", i));
}
}
+
+ /**
+ * Asserts that only the specified selected payment method is logged.
+ *
+ * @param paymentMethod The only bucket in the selected payment method histogram that should
+ * have a record.
+ */
+ private void assertOnlySpecificSelectedPaymentMethodMetricLogged(int paymentMethod) {
+ for (int i = 0; i < PaymentRequestMetrics.SELECTED_METHOD_MAX; ++i) {
+ assertEquals((i == paymentMethod ? 1 : 0),
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.SelectedPaymentMethod", i));
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698