| Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestServiceWorkerPaymentAppTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestServiceWorkerPaymentAppTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestServiceWorkerPaymentAppTest.java
|
| index 458c1d660847063850c0cbc9702e4b2227373d7e..adcea851dc061ed31d54be92dd5279d5f15e4893 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestServiceWorkerPaymentAppTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestServiceWorkerPaymentAppTest.java
|
| @@ -17,10 +17,6 @@ import org.chromium.chrome.test.ChromeActivityTestRule;
|
| import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
| import org.chromium.content_public.browser.WebContents;
|
|
|
| -import java.util.ArrayList;
|
| -import java.util.Arrays;
|
| -import java.util.HashSet;
|
| -import java.util.List;
|
| import java.util.Set;
|
| import java.util.concurrent.ExecutionException;
|
| import java.util.concurrent.TimeoutException;
|
| @@ -38,49 +34,22 @@ public class PaymentRequestServiceWorkerPaymentAppTest {
|
| public PaymentRequestTestRule mPaymentRequestTestRule =
|
| new PaymentRequestTestRule("payment_request_bobpay_test.html");
|
|
|
| - /** Flag for installing a service worker payment app without any payment options. */
|
| - private static final int NO_OPTIONS = 0;
|
| -
|
| - /** Flag for installing a service worker payment app with one payment option. */
|
| - private static final int ONE_OPTION = 1;
|
| -
|
| - /** Flag for installing a service worker payment app with two options. */
|
| - private static final int TWO_OPTIONS = 2;
|
| -
|
| /**
|
| * Installs a mock service worker based payment app for testing.
|
| *
|
| - * @param instrumentPresence Whether the manifest has any payment options. Either NO_OPTIONS
|
| - * ONE_OPTION or TWO_OPTIONS
|
| + * @param hasSupportedMethods Whether the mock payment app has supported payment methods.
|
| */
|
| - private void installMockServiceWorkerPaymentApp(final int instrumentPresence) {
|
| + private void installMockServiceWorkerPaymentApp(final boolean hasSupportedMethods) {
|
| PaymentAppFactory.getInstance().addAdditionalFactory(
|
| new PaymentAppFactory.PaymentAppFactoryAddition() {
|
| @Override
|
| public void create(WebContents webContents, Set<String> methodNames,
|
| PaymentAppFactory.PaymentAppCreatedCallback callback) {
|
| - List<PaymentInstrument> instruments = new ArrayList<PaymentInstrument>();
|
| -
|
| - if (instrumentPresence != NO_OPTIONS) {
|
| - instruments.add(new ServiceWorkerPaymentInstrument(webContents,
|
| - 0 /* swRegistrationId */, "new" /* instrumentId */,
|
| - "Create BobPay account" /* label */,
|
| - new HashSet<String>(Arrays.asList(
|
| - "https://bobpay.com", "basic-card")) /* methodNames */,
|
| - null /* icon*/));
|
| - }
|
| -
|
| - if (instrumentPresence == TWO_OPTIONS) {
|
| - instruments.add(new ServiceWorkerPaymentInstrument(webContents,
|
| - 0 /* swRegistrationId */, "existing" /* instrumentId */,
|
| - "Existing BobPay account" /* label */,
|
| - new HashSet<String>(Arrays.asList(
|
| - "https://bobpay.com", "basic-card")) /* methodNames */,
|
| - null /* icon */));
|
| - }
|
| -
|
| - callback.onPaymentAppCreated(
|
| - new ServiceWorkerPaymentApp(webContents, instruments));
|
| + String[] supportedMethodNames = {"https://bobpay.com", "basic-card"};
|
| + callback.onPaymentAppCreated(new ServiceWorkerPaymentApp(webContents,
|
| + 0 /* registrationId */, "BobPay" /* label */, null /* icon */,
|
| + hasSupportedMethods ? supportedMethodNames
|
| + : new String[0] /* methodNames */));
|
| callback.onAllPaymentAppsCreated();
|
| }
|
| });
|
| @@ -89,8 +58,9 @@ public class PaymentRequestServiceWorkerPaymentAppTest {
|
| @Test
|
| @MediumTest
|
| @Feature({"Payments"})
|
| - public void testNoOptions() throws InterruptedException, ExecutionException, TimeoutException {
|
| - installMockServiceWorkerPaymentApp(NO_OPTIONS);
|
| + public void testNoSupportedPaymentMethods()
|
| + throws InterruptedException, ExecutionException, TimeoutException {
|
| + installMockServiceWorkerPaymentApp(false);
|
| mPaymentRequestTestRule.openPageAndClickBuyAndWait(mPaymentRequestTestRule.getShowFailed());
|
| mPaymentRequestTestRule.expectResultContains(
|
| new String[] {"show() rejected", "The payment method is not supported"});
|
| @@ -99,18 +69,9 @@ public class PaymentRequestServiceWorkerPaymentAppTest {
|
| @Test
|
| @MediumTest
|
| @Feature({"Payments"})
|
| - public void testOneOption() throws InterruptedException, ExecutionException, TimeoutException {
|
| - installMockServiceWorkerPaymentApp(ONE_OPTION);
|
| - mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getReadyForInput());
|
| - // TODO(tommyt): crbug.com/669876. Expand this test as we implement more
|
| - // service worker based payment app functionality.
|
| - }
|
| -
|
| - @Test
|
| - @MediumTest
|
| - @Feature({"Payments"})
|
| - public void testTwoOptions() throws InterruptedException, ExecutionException, TimeoutException {
|
| - installMockServiceWorkerPaymentApp(TWO_OPTIONS);
|
| + public void testHasSupportedPaymentMethods()
|
| + throws InterruptedException, ExecutionException, TimeoutException {
|
| + installMockServiceWorkerPaymentApp(true);
|
| mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getReadyForInput());
|
| // TODO(tommyt): crbug.com/669876. Expand this test as we implement more
|
| // service worker based payment app functionality.
|
|
|