| 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.content.DialogInterface; | 7 import android.content.DialogInterface; |
| 8 import android.test.suitebuilder.annotation.MediumTest; | 8 import android.test.suitebuilder.annotation.MediumTest; |
| 9 | 9 |
| 10 import org.chromium.base.metrics.RecordHistogram; | 10 import org.chromium.base.metrics.RecordHistogram; |
| 11 import org.chromium.base.test.util.Feature; |
| 11 import org.chromium.chrome.R; | 12 import org.chromium.chrome.R; |
| 12 import org.chromium.chrome.browser.autofill.AutofillTestHelper; | 13 import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
| 13 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 14 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| 14 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; | 15 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
| 15 | 16 |
| 16 import java.util.concurrent.ExecutionException; | 17 import java.util.concurrent.ExecutionException; |
| 17 import java.util.concurrent.TimeoutException; | 18 import java.util.concurrent.TimeoutException; |
| 18 | 19 |
| 19 /** | 20 /** |
| 20 * A payment integration test for a merchant that requests an email address and
a phone number and | 21 * A payment integration test for a merchant that requests an email address and
a phone number and |
| (...skipping 18 matching lines...) Expand all Loading... |
| 39 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", | 40 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", |
| 40 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, | 41 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, |
| 41 billingAddressId, "" /* serverId */)); | 42 billingAddressId, "" /* serverId */)); |
| 42 } | 43 } |
| 43 | 44 |
| 44 /** | 45 /** |
| 45 * Submit the email address, phone number and shipping address to the mercha
nt when the user | 46 * Submit the email address, phone number and shipping address to the mercha
nt when the user |
| 46 * clicks "Pay." | 47 * clicks "Pay." |
| 47 */ | 48 */ |
| 48 @MediumTest | 49 @MediumTest |
| 50 @Feature({"Payments"}) |
| 49 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { | 51 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { |
| 50 triggerUIAndWait(mReadyToPay); | 52 triggerUIAndWait(mReadyToPay); |
| 51 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 53 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 52 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 54 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
| 53 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 55 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
| 54 expectResultContains(new String[] {"jon.doe@google.com", "555-555-5555",
"Jon Doe", | 56 expectResultContains(new String[] {"jon.doe@google.com", "555-555-5555",
"Jon Doe", |
| 55 "4111111111111111", "12", "2050", "visa", "123", "Google", "340
Main St", "CA", | 57 "4111111111111111", "12", "2050", "visa", "123", "Google", "340
Main St", "CA", |
| 56 "Los Angeles", "90291", "US", "en", "freeShippingOption"}); | 58 "Los Angeles", "90291", "US", "en", "freeShippingOption"}); |
| 57 } | 59 } |
| 58 | 60 |
| 59 /** | 61 /** |
| 60 * Test that starting a payment request that requires an email address, a ph
one number and a | 62 * Test that starting a payment request that requires an email address, a ph
one number and a |
| 61 * shipping address results in the appropriate metric being logged in the | 63 * shipping address results in the appropriate metric being logged in the |
| 62 * PaymentRequest.RequestedInformation histogram. | 64 * PaymentRequest.RequestedInformation histogram. |
| 63 */ | 65 */ |
| 64 @MediumTest | 66 @MediumTest |
| 67 @Feature({"Payments"}) |
| 65 public void testRequestedInformationMetric() throws InterruptedException, Ex
ecutionException, | 68 public void testRequestedInformationMetric() throws InterruptedException, Ex
ecutionException, |
| 66 TimeoutException { | 69 TimeoutException { |
| 67 // Start the Payment Request. | 70 // Start the Payment Request. |
| 68 triggerUIAndWait(mReadyToPay); | 71 triggerUIAndWait(mReadyToPay); |
| 69 | 72 |
| 70 // Make sure that only the appropriate enum value was logged. | 73 // Make sure that only the appropriate enum value was logged. |
| 71 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i
) { | 74 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i
) { |
| 72 assertEquals((i == (PaymentRequestMetrics.REQUESTED_INFORMATION_EMAI
L | 75 assertEquals((i == (PaymentRequestMetrics.REQUESTED_INFORMATION_EMAI
L |
| 73 | PaymentRequestMetrics.REQUESTED_INFORMATION_PHONE | 76 | PaymentRequestMetrics.REQUESTED_INFORMATION_PHONE |
| 74 | PaymentRequestMetrics.REQUESTED_INFORMATION_SHIPPING) ? 1
: 0), | 77 | PaymentRequestMetrics.REQUESTED_INFORMATION_SHIPPING) ? 1
: 0), |
| 75 RecordHistogram.getHistogramValueCountForTesting( | 78 RecordHistogram.getHistogramValueCountForTesting( |
| 76 "PaymentRequest.RequestedInformation", i)); | 79 "PaymentRequest.RequestedInformation", i)); |
| 77 } | 80 } |
| 78 } | 81 } |
| 79 } | 82 } |
| OLD | NEW |