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

Side by Side Diff: android_webview/embeddedtestserver/java/src/org/chromium/net/test/AwEmbeddedTestServer.java

Issue 2687573002: [Android Webview] Refactor LoadUrlTest and work on embedded_test_server custom handler (Closed)
Patch Set: ready 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.net.test;
jbudorick 2017/03/09 02:00:47 Everything in this directory should be in org.chro
shenghuazhang 2017/03/13 18:48:15 Done.
6
7 import android.content.Context;
8 import android.content.Intent;
9
10 /** A simple file server for java android webview tests which extends
11 * from class EmbeddedTestServer. It is able to add custom handlers
12 * which registers with net::test_server::EmbeddedTestServer native code.
13 *
14 * An example use:
15 * AwEmbeddedTestServer s = new AwEmbeddedTestServer();
16 * s = AwEmbeddedTestServer.createAndStartServer(context);
17 *
18 * // serve requests...
19 * s.getURL("/foo/bar.txt");
20 *
21 * s.stopAndDestroyServer();
22 *
23 * Note that this runs net::test_server::EmbeddedTestServer in a service in a se parate APK.
24 */
25 public class AwEmbeddedTestServer extends EmbeddedTestServer {
26 @Override
27 protected void setIntentClassName(Intent intent) {
28 intent.setClassName("org.chromium.net.test.awsupport",
29 "org.chromium.net.test.AwEmbeddedTestServerService");
30 }
31 /** Create and initialize a server with the default handlers.
32 *
33 * This handles native object initialization, server configuration, and ser ver initialization.
34 * On returning, the server is ready for use.
35 *
36 * @param context The context in which the server will run.
37 * @return The created server.
38 */
39 public static AwEmbeddedTestServer createAndStartServer(Context context)
jbudorick 2017/03/09 02:00:47 hmm, this logic is almost the same as the Embedded
shenghuazhang 2017/03/13 18:48:15 Yeah. Separated the common steps into a new method
40 throws InterruptedException {
41 AwEmbeddedTestServer server = new AwEmbeddedTestServer();
42 server.initializeNative(context);
43 server.addDefaultHandlers("");
44 if (!server.start()) {
45 throw new EmbeddedTestServerFailure(
46 "Failed to start serving using default and custom handlers." );
47 }
48 return server;
49 }
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698