| Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPaymentAppTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPaymentAppTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPaymentAppTest.java
|
| index 63ad47f7d136117fa08499b1df42ba6a1e7d657f..8c17d1279688435f01f6492a3e07b951bbd87942 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPaymentAppTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPaymentAppTest.java
|
| @@ -4,20 +4,10 @@
|
|
|
| package org.chromium.chrome.browser.payments;
|
|
|
| -import android.os.Handler;
|
| import android.test.suitebuilder.annotation.MediumTest;
|
|
|
| -import org.chromium.base.ThreadUtils;
|
| import org.chromium.chrome.R;
|
| -import org.chromium.chrome.browser.payments.PaymentAppFactory.PaymentAppFactoryAddition;
|
| -import org.chromium.content_public.browser.WebContents;
|
| -import org.chromium.mojom.payments.PaymentItem;
|
| -import org.json.JSONObject;
|
|
|
| -import java.util.ArrayList;
|
| -import java.util.HashSet;
|
| -import java.util.List;
|
| -import java.util.Set;
|
| import java.util.concurrent.ExecutionException;
|
| import java.util.concurrent.TimeoutException;
|
|
|
| @@ -25,12 +15,6 @@ import java.util.concurrent.TimeoutException;
|
| * A payment integration test for a merchant that requests payment via Bob Pay.
|
| */
|
| public class PaymentRequestPaymentAppTest extends PaymentRequestTestBase {
|
| - private static final int NO_INSTRUMENTS = 0;
|
| - private static final int HAVE_INSTRUMENTS = 1;
|
| -
|
| - private static final int IMMEDIATE_RESPONSE = 0;
|
| - private static final int DELAYED_RESPONSE = 1;
|
| -
|
| public PaymentRequestPaymentAppTest() {
|
| super("payment_request_bobpay_test.html");
|
| }
|
| @@ -55,7 +39,7 @@ public class PaymentRequestPaymentAppTest extends PaymentRequestTestBase {
|
| @MediumTest
|
| public void testNoInstrumentsInFastBobPay() throws InterruptedException, ExecutionException,
|
| TimeoutException {
|
| - installBobPay(NO_INSTRUMENTS, IMMEDIATE_RESPONSE);
|
| + installPaymentApp(NO_INSTRUMENTS, IMMEDIATE_RESPONSE);
|
| triggerUIAndWait(mShowFailed);
|
| expectResultContains(
|
| new String[]{"show() rejected", "The payment method is not supported"});
|
| @@ -68,7 +52,7 @@ public class PaymentRequestPaymentAppTest extends PaymentRequestTestBase {
|
| @MediumTest
|
| public void testNoInstrumentsInSlowBobPay() throws InterruptedException, ExecutionException,
|
| TimeoutException {
|
| - installBobPay(NO_INSTRUMENTS, DELAYED_RESPONSE);
|
| + installPaymentApp(NO_INSTRUMENTS, DELAYED_RESPONSE);
|
| triggerUIAndWait(mShowFailed);
|
| expectResultContains(
|
| new String[]{"show() rejected", "The payment method is not supported"});
|
| @@ -81,7 +65,7 @@ public class PaymentRequestPaymentAppTest extends PaymentRequestTestBase {
|
| @MediumTest
|
| public void testPayViaFastBobPay() throws InterruptedException, ExecutionException,
|
| TimeoutException {
|
| - installBobPay(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE);
|
| + installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE);
|
| triggerUIAndWait(mReadyToPay);
|
| clickAndWait(R.id.button_primary, mDismissed);
|
| expectResultContains(new String[]{"https://bobpay.com", "\"transaction\"", "1337"});
|
| @@ -94,92 +78,9 @@ public class PaymentRequestPaymentAppTest extends PaymentRequestTestBase {
|
| @MediumTest
|
| public void testPayViaSlowBobPay() throws InterruptedException, ExecutionException,
|
| TimeoutException {
|
| - installBobPay(HAVE_INSTRUMENTS, DELAYED_RESPONSE);
|
| + installPaymentApp(HAVE_INSTRUMENTS, DELAYED_RESPONSE);
|
| triggerUIAndWait(mReadyToPay);
|
| clickAndWait(R.id.button_primary, mDismissed);
|
| expectResultContains(new String[]{"https://bobpay.com", "\"transaction\"", "1337"});
|
| }
|
| -
|
| - /**
|
| - * Installs a payment app for testing.
|
| - *
|
| - * @param instrumentPresence Whether Bob Pay has any payment instruments. Either NO_INSTRUMENTS
|
| - * or HAVE_INSTRUMENTS.
|
| - * @param responseSpeed How quickly Bob Pay will respond to "get instruments" query. Either
|
| - * IMMEDIATE_RESPONSE or DELAYED_RESPONSE.
|
| - */
|
| - private void installBobPay(final int instrumentPresence, final int responseSpeed) {
|
| - PaymentAppFactory.setAdditionalFactory(new PaymentAppFactoryAddition() {
|
| - @Override
|
| - public List<PaymentApp> create(WebContents webContents) {
|
| - List<PaymentApp> additionalApps = new ArrayList<>();
|
| - additionalApps.add(new BobPay(instrumentPresence, responseSpeed));
|
| - return additionalApps;
|
| - }
|
| - });
|
| - }
|
| -
|
| - /** A payment app implementation for test. */
|
| - private static class BobPay implements PaymentApp {
|
| - private final int mInstrumentPresence;
|
| - private final int mResponseSpeed;
|
| -
|
| - BobPay(int instrumentPresence, int responseSpeed) {
|
| - mInstrumentPresence = instrumentPresence;
|
| - mResponseSpeed = responseSpeed;
|
| - }
|
| -
|
| - @Override
|
| - public void getInstruments(JSONObject details, final InstrumentsCallback
|
| - instrumentsCallback) {
|
| - final List<PaymentInstrument> instruments = new ArrayList<>();
|
| - if (mInstrumentPresence == HAVE_INSTRUMENTS) instruments.add(new BobPayInstrument());
|
| - Runnable instrumentsReady = new Runnable() {
|
| - @Override
|
| - public void run() {
|
| - ThreadUtils.assertOnUiThread();
|
| - instrumentsCallback.onInstrumentsReady(BobPay.this, instruments);
|
| - }
|
| - };
|
| - if (mResponseSpeed == IMMEDIATE_RESPONSE) {
|
| - instrumentsReady.run();
|
| - } else {
|
| - new Handler().postDelayed(instrumentsReady, 100);
|
| - }
|
| - }
|
| -
|
| - @Override
|
| - public Set<String> getSupportedMethodNames() {
|
| - Set<String> methodNames = new HashSet<>();
|
| - methodNames.add("https://bobpay.com");
|
| - return methodNames;
|
| - }
|
| -
|
| - @Override
|
| - public String getIdentifier() {
|
| - return "https://bobpay.com";
|
| - }
|
| - }
|
| -
|
| - /** A payment instrument implementation for test. */
|
| - private static class BobPayInstrument extends PaymentInstrument {
|
| - BobPayInstrument() {
|
| - super("https://bobpay.com", "Bob Pay", null, NO_ICON);
|
| - }
|
| -
|
| - @Override
|
| - public String getMethodName() {
|
| - return "https://bobpay.com";
|
| - }
|
| -
|
| - @Override
|
| - public void getDetails(String merchantName, String origin, PaymentItem total,
|
| - List<PaymentItem> cart, JSONObject details, DetailsCallback detailsCallback) {
|
| - detailsCallback.onInstrumentDetailsReady(
|
| - "https://bobpay.com", "{\"transaction\": 1337}");
|
| - }
|
| -
|
| - @Override
|
| - public void dismiss() {}
|
| - }
|
| }
|
|
|