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

Unified Diff: android_webview/test/embeddedtestserver/java/src/org/chromium/android_webview/test/AwEmbeddedTestServerImpl.java

Issue 2687573002: [Android Webview] Refactor LoadUrlTest and work on embedded_test_server custom handler (Closed)
Patch Set: John comment & url encode Created 3 years, 9 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/test/embeddedtestserver/java/src/org/chromium/android_webview/test/AwEmbeddedTestServerImpl.java
diff --git a/android_webview/test/embeddedtestserver/java/src/org/chromium/android_webview/test/AwEmbeddedTestServerImpl.java b/android_webview/test/embeddedtestserver/java/src/org/chromium/android_webview/test/AwEmbeddedTestServerImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..50f3b67cbcf950a3248414dc99d6e02a6c400ca7
--- /dev/null
+++ b/android_webview/test/embeddedtestserver/java/src/org/chromium/android_webview/test/AwEmbeddedTestServerImpl.java
@@ -0,0 +1,48 @@
+// Copyright 2017 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 android.content.Context;
+
+import org.chromium.base.annotations.JNINamespace;
+import org.chromium.net.test.EmbeddedTestServerImpl;
+
+import java.util.concurrent.Callable;
+
+/**
+ * Java bindings for running a net::test_server::EmbeddedTestServer.
+ *
+ * This should not be used directly. Use {@link EmbeddedTestServer} instead.
+ */
+@JNINamespace("android_webview::test")
+public class AwEmbeddedTestServerImpl extends EmbeddedTestServerImpl {
+ /** Create an uninitialized EmbeddedTestServer. */
+ public AwEmbeddedTestServerImpl(Context context) {
+ super(context);
+ }
+
+ /** Add the default handlers and serve files from the provided directory relative to the
+ * external storage directory.
+ *
+ * @param directoryPath The path of the directory from which files should be served, relative
+ * to the external storage directory.
+ */
+ @Override
+ public void addDefaultHandlers(final String directoryPath) {
+ runOnHandlerThread(new Callable<Void>() {
+ @Override
+ public Void call() {
+ callAddDefaultHandlers(directoryPath);
jbudorick 2017/03/13 23:32:54 can this just call super.addDefaultHandlers(direct
shenghuazhang 2017/03/17 01:07:15 Done.
+ long[] handlers = nativeGetHandlers();
+ for (long handler : handlers) {
+ callRegisterRequestHandler(handler);
jbudorick 2017/03/13 23:32:54 similarly, can this call registerRequestHandler(ha
shenghuazhang 2017/03/17 01:07:15 Done.
+ }
+ return null;
+ }
+ });
+ }
+
+ private native long[] nativeGetHandlers();
jbudorick 2017/03/13 23:32:54 I think this should be private static native -- we
shenghuazhang 2017/03/17 01:07:15 Oh right! The native method GetHandlers was with p
+}

Powered by Google App Engine
This is Rietveld 408576698