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

Unified Diff: android_webview/test/embedded_test_server/java/src/org/chromium/android_webview/test/AwEmbeddedTestServer.java

Issue 2687573002: [Android Webview] Refactor LoadUrlTest and work on embedded_test_server custom handler (Closed)
Patch Set: Change AwETS intent class name Created 3 years, 6 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/embedded_test_server/java/src/org/chromium/android_webview/test/AwEmbeddedTestServer.java
diff --git a/android_webview/test/embedded_test_server/java/src/org/chromium/android_webview/test/AwEmbeddedTestServer.java b/android_webview/test/embedded_test_server/java/src/org/chromium/android_webview/test/AwEmbeddedTestServer.java
new file mode 100644
index 0000000000000000000000000000000000000000..0cb2dbbbe12d5af87f856a01bce5550ad6b1f3f9
--- /dev/null
+++ b/android_webview/test/embedded_test_server/java/src/org/chromium/android_webview/test/AwEmbeddedTestServer.java
@@ -0,0 +1,49 @@
+// 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 android.content.Intent;
+
+import org.chromium.net.test.EmbeddedTestServer;
+
+/** A simple file server for java android webview tests which extends
+ * from class EmbeddedTestServer. It is able to add custom handlers
+ * which registers with net::test_server::EmbeddedTestServer native code.
+ *
+ * An example use:
+ * AwEmbeddedTestServer s = AwEmbeddedTestServer.createAndStartServer(context);
+ *
+ * // serve requests...
+ * s.getURL("/foo/bar.txt");
+ *
+ * s.stopAndDestroyServer();
+ *
+ * Note that this runs net::test_server::EmbeddedTestServer in a service in a separate APK.
+ */
+public class AwEmbeddedTestServer extends EmbeddedTestServer {
+ /** Set intent package and class name that will pass to the service.
+ *
+ * @param intent The intent to use to pass into the service.
+ */
+ @Override
+ protected void setIntentClassName(Intent intent) {
+ intent.setClassName("org.chromium.android_webview.test.support",
+ "org.chromium.android_webview.test.AwEmbeddedTestServerService");
+ }
+
+ /** Create and initialize a server with the default and custom handlers.
+ *
+ * This handles native object initialization, server configuration, and server initialization.
+ * On returning, the server is ready for use.
+ *
+ * @param context The context in which the server will run.
+ * @return The created server.
+ */
+ public static AwEmbeddedTestServer createAndStartServer(Context context)
+ throws InterruptedException {
+ return initializeAndStartServer(new AwEmbeddedTestServer(), context);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698