| OLD | NEW |
| 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.content.DialogInterface; | 8 import android.content.DialogInterface; |
| 9 import android.support.test.filters.MediumTest; | 9 import android.support.test.filters.MediumTest; |
| 10 | 10 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 // Simulate an abort by the merchant. | 177 // Simulate an abort by the merchant. |
| 178 clickNodeAndWait("abort", mDismissed); | 178 clickNodeAndWait("abort", mDismissed); |
| 179 expectResultContains(new String[] {"Abort"}); | 179 expectResultContains(new String[] {"Abort"}); |
| 180 | 180 |
| 181 assertOnlySpecificAbortMetricLogged( | 181 assertOnlySpecificAbortMetricLogged( |
| 182 PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_MERCHANT); | 182 PaymentRequestMetrics.ABORT_REASON_ABORTED_BY_MERCHANT); |
| 183 } | 183 } |
| 184 | 184 |
| 185 /** | 185 /** |
| 186 * Expect only the ABORT_REASON_NO_MATCHING_PAYMENT_METHOD enum value gets l
ogged when a Payment | 186 * Expect no abort metrics to be logged even if there are no matching paymen
t methods because |
| 187 * Request gets cancelled because the user does not have any of the payment
methods accepted by | 187 * the Payment Request was not shown to the user (a Payment Request gets can
celled because the |
| 188 * the merchant and the merchant does not accept credit cards. | 188 * user does not have any of the payment methods accepted by the merchant an
d the merchant does |
| 189 * not accept credit cards). It should instead be logged as a reason why the
Payment Request was |
| 190 * not shown to the user. |
| 189 */ | 191 */ |
| 190 @MediumTest | 192 @MediumTest |
| 191 @Feature({"Payments"}) | 193 @Feature({"Payments"}) |
| 192 public void testAbortMetrics_NoMatchingPaymentMethod() throws InterruptedExc
eption, | 194 public void testMetrics_NoMatchingPaymentMethod() |
| 193 ExecutionException, TimeoutException { | 195 throws InterruptedException, ExecutionException, TimeoutException { |
| 194 // Android Pay is supported but no instruments are present. | 196 // Android Pay is supported but no instruments are present. |
| 195 installPaymentApp("https://android.com/pay", NO_INSTRUMENTS, DELAYED_RES
PONSE); | 197 installPaymentApp("https://android.com/pay", NO_INSTRUMENTS, DELAYED_RES
PONSE); |
| 196 openPageAndClickNodeAndWait("androidPayBuy", mShowFailed); | 198 openPageAndClickNodeAndWait("androidPayBuy", mShowFailed); |
| 197 expectResultContains(new String[] {"The payment method is not supported"
}); | 199 expectResultContains(new String[] {"The payment method is not supported"
}); |
| 198 | 200 |
| 199 assertOnlySpecificAbortMetricLogged( | 201 // Make sure that it is not logged as an abort. |
| 200 PaymentRequestMetrics.ABORT_REASON_NO_MATCHING_PAYMENT_METHOD); | 202 assertOnlySpecificAbortMetricLogged(-1 /* none */); |
| 203 // Make sure that it was logged as a reason why the Payment Request was
not shown. |
| 204 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( |
| 205 "PaymentRequest.CheckoutFunnel.NoShow", |
| 206 PaymentRequestMetrics.NO_SHOW_NO_MATCHING_PAYMEN
T_METHOD)); |
| 201 } | 207 } |
| 202 | 208 |
| 203 /** | 209 /** |
| 204 * Expect only the ABORT_REASON_NO_SUPPORTED_PAYMENT_METHOD enum value gets
logged when a | 210 * Expect no abort metrics to be logged even if there are no matching paymen
t methods because |
| 205 * Payment Request gets cancelled because the merchant only accepts payment
methods we don't | 211 * the Payment Request was not shown to the user (a Payment Request gets can
celled because the |
| 206 * support. | 212 * merchant only accepts payment methods we don't support. It should instead
be logged as a |
| 213 * reason why the Payment Request was not shown to the user. |
| 207 */ | 214 */ |
| 208 @MediumTest | 215 @MediumTest |
| 209 @Feature({"Payments"}) | 216 @Feature({"Payments"}) |
| 210 public void testAbortMetrics_NoSupportedPaymentMethod() throws InterruptedEx
ception, | 217 public void testMetrics_NoSupportedPaymentMethod() |
| 211 ExecutionException, TimeoutException { | 218 throws InterruptedException, ExecutionException, TimeoutException { |
| 212 openPageAndClickNodeAndWait("noSupported", mShowFailed); | 219 openPageAndClickNodeAndWait("noSupported", mShowFailed); |
| 213 expectResultContains(new String[] {"The payment method is not supported"
}); | 220 expectResultContains(new String[] {"The payment method is not supported"
}); |
| 214 | 221 |
| 215 assertOnlySpecificAbortMetricLogged( | 222 // Make sure that it is not logged as an abort. |
| 216 PaymentRequestMetrics.ABORT_REASON_NO_SUPPORTED_PAYMENT_METHOD); | 223 assertOnlySpecificAbortMetricLogged(-1 /* none */); |
| 224 // Make sure that it was logged as a reason why the Payment Request was
not shown. |
| 225 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( |
| 226 "PaymentRequest.CheckoutFunnel.NoShow", |
| 227 PaymentRequestMetrics.NO_SHOW_NO_SUPPORTED_PAYME
NT_METHOD)); |
| 217 } | 228 } |
| 218 | 229 |
| 219 /** | 230 /** |
| 220 * Expect only the SELECTED_METHOD_CREDIT_CARD enum value to be logged for t
he | 231 * Expect only the SELECTED_METHOD_CREDIT_CARD enum value to be logged for t
he |
| 221 * "SelectedPaymentMethod" histogram when completing a Payment Request with
a credit card. | 232 * "SelectedPaymentMethod" histogram when completing a Payment Request with
a credit card. |
| 222 */ | 233 */ |
| 223 @MediumTest | 234 @MediumTest |
| 224 @Feature({"Payments"}) | 235 @Feature({"Payments"}) |
| 225 public void testSelectedPaymentMethod_CreditCard() throws InterruptedExcepti
on, | 236 public void testSelectedPaymentMethod_CreditCard() throws InterruptedExcepti
on, |
| 226 ExecutionException, TimeoutException { | 237 ExecutionException, TimeoutException { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 * have a record. | 285 * have a record. |
| 275 */ | 286 */ |
| 276 private void assertOnlySpecificSelectedPaymentMethodMetricLogged(int payment
Method) { | 287 private void assertOnlySpecificSelectedPaymentMethodMetricLogged(int payment
Method) { |
| 277 for (int i = 0; i < PaymentRequestMetrics.SELECTED_METHOD_MAX; ++i) { | 288 for (int i = 0; i < PaymentRequestMetrics.SELECTED_METHOD_MAX; ++i) { |
| 278 assertEquals((i == paymentMethod ? 1 : 0), | 289 assertEquals((i == paymentMethod ? 1 : 0), |
| 279 RecordHistogram.getHistogramValueCountForTesting( | 290 RecordHistogram.getHistogramValueCountForTesting( |
| 280 "PaymentRequest.SelectedPaymentMethod", i)); | 291 "PaymentRequest.SelectedPaymentMethod", i)); |
| 281 } | 292 } |
| 282 } | 293 } |
| 283 } | 294 } |
| OLD | NEW |