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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/TestAwServiceWorkerClient.java

Issue 1544863002: [Android WebView] Implement initial settings and callback support for Service Workers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 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: android_webview/javatests/src/org/chromium/android_webview/test/TestAwServiceWorkerClient.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/TestAwServiceWorkerClient.java b/android_webview/javatests/src/org/chromium/android_webview/test/TestAwServiceWorkerClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..7b65982c9b24bf807d2610d70d77cce4d616fde0
--- /dev/null
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/TestAwServiceWorkerClient.java
@@ -0,0 +1,52 @@
+// 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.android_webview.test;
+
+import org.chromium.android_webview.AwContentsClient.AwWebResourceRequest;
+import org.chromium.android_webview.AwServiceWorkerClient;
+import org.chromium.android_webview.AwWebResourceResponse;
+import org.chromium.content.browser.test.util.CallbackHelper;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AwServiceWorkerClient subclass used for testing.
+ */
+public class TestAwServiceWorkerClient extends AwServiceWorkerClient {
+
+ /**
+ * Helper class to wait for callbacks on the TestAwServiceWorkerClient.
+ */
+ public static class ShouldInterceptRequestHelper extends CallbackHelper {
+ private List<AwWebResourceRequest> mInterceptedRequests =
+ new ArrayList<AwWebResourceRequest>();
+
+ public void notifyCalled(AwWebResourceRequest request) {
+ mInterceptedRequests.add(request);
+ notifyCalled();
+ }
+
+ public List<AwWebResourceRequest> getAwWebResourceRequests() {
+ return mInterceptedRequests;
+ }
+ }
+
+ private ShouldInterceptRequestHelper mShouldInterceptRequestHelper;
+
+ public ShouldInterceptRequestHelper getShouldInterceptRequestHelper() {
+ return mShouldInterceptRequestHelper;
+ }
+
+ public TestAwServiceWorkerClient() {
+ mShouldInterceptRequestHelper = new ShouldInterceptRequestHelper();
+ }
+
+ @Override
+ public AwWebResourceResponse shouldInterceptRequest(AwWebResourceRequest request) {
+ mShouldInterceptRequestHelper.notifyCalled(request);
+ return null;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698