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

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

Issue 2165163002: Autofill cards at the bottom of the PaymentRequest UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Static comparator and faux-parameterized test 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/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() {}
- }
}

Powered by Google App Engine
This is Rietveld 408576698