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

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

Issue 2526293003: PaymentApp: Add classes for supporting Web Based Payment Apps (Closed)
Patch Set: Make the service worker unittests work even with the feature flag off Created 4 years 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
« no previous file with comments | « chrome/android/java_sources.gni ('k') | chrome/browser/android/chrome_feature_list.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..26f9cb5661e0296368170dc1e859225ef583e012
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestServiceWorkerPaymentAppTest.java
@@ -0,0 +1,107 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.payments;
+
+import android.test.suitebuilder.annotation.MediumTest;
+
+import org.chromium.base.test.util.Feature;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * A payment integration test for service worker based payment apps.
+ */
+public class PaymentRequestServiceWorkerPaymentAppTest extends PaymentRequestTestBase {
+ /** 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;
+
+ public PaymentRequestServiceWorkerPaymentAppTest() {
+ super("payment_request_bobpay_test.html");
+ }
+
+ /**
+ * Installs a service worker based payment app for testing.
+ *
+ * @param optionPresence Whether the manifest has any payment options. Either NO_OPTIONS
+ * ONE_OPTION or TWO_OPTIONS
+ */
+ private void installServiceWorkerPaymentApp(final int instrumentPresence) {
+ PaymentAppFactory.setServiceWorkerPaymentAppBridgeForTest(
+ new ServiceWorkerPaymentAppBridge() {
+ @Override
+ public List<Manifest> getAllAppManifests() {
+ ServiceWorkerPaymentAppBridge.Manifest testManifest =
+ new ServiceWorkerPaymentAppBridge.Manifest();
+ testManifest.scopeUrl = "https://bobpay.com/app";
+ testManifest.label = "BobPay";
+
+ if (instrumentPresence != NO_OPTIONS) {
+ ServiceWorkerPaymentAppBridge.Option testOption =
+ new ServiceWorkerPaymentAppBridge.Option();
+ testOption.id = "new";
+ testOption.label = "Create BobPay account";
+ testOption.enabledMethods =
+ Arrays.asList("https://bobpay.com", "basic-card");
+ testManifest.options.add(testOption);
+ }
+
+ if (instrumentPresence == TWO_OPTIONS) {
+ ServiceWorkerPaymentAppBridge.Option testOption =
+ new ServiceWorkerPaymentAppBridge.Option();
+ testOption.id = "existing";
+ testOption.label = "Existing BobPay account";
+ testOption.enabledMethods =
+ Arrays.asList("https://bobpay.com", "basic-card");
+ testManifest.options.add(testOption);
+ }
+
+ return Arrays.asList(testManifest);
+ }
+ });
+ }
+
+ @Override
+ public void onMainActivityStarted() throws InterruptedException, ExecutionException,
+ TimeoutException {}
+
+ @MediumTest
+ @Feature({"Payments"})
+ public void testNoOptions() throws InterruptedException, ExecutionException,
+ TimeoutException {
+ installServiceWorkerPaymentApp(NO_OPTIONS);
+ openPageAndClickBuyAndWait(mShowFailed);
+ expectResultContains(
+ new String[]{"show() rejected", "The payment method is not supported"});
+ }
+
+ @MediumTest
+ @Feature({"Payments"})
+ public void testOneOption() throws InterruptedException, ExecutionException,
+ TimeoutException {
+ installServiceWorkerPaymentApp(ONE_OPTION);
+ triggerUIAndWait(mReadyForInput);
+ // TODO(tommyt): crbug.com/669876. Expand this test as we implement more
+ // service worker based payment app functionality.
+ }
+
+ @MediumTest
+ @Feature({"Payments"})
+ public void testTwoOptions() throws InterruptedException, ExecutionException,
+ TimeoutException {
+ installServiceWorkerPaymentApp(TWO_OPTIONS);
+ triggerUIAndWait(mReadyForInput);
+ // TODO(tommyt): crbug.com/669876. Expand this test as we implement more
+ // service worker based payment app functionality.
+ }
+}
« no previous file with comments | « chrome/android/java_sources.gni ('k') | chrome/browser/android/chrome_feature_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698