summaryrefslogtreecommitdiffstats
path: root/net/test
diff options
context:
space:
mode:
authorjbudorick <jbudorick@chromium.org>2016-02-04 11:36:10 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-04 19:37:18 +0000
commit91bb9b3d4964cb8611231722a4538afccbd9fd09 (patch)
treeae05901a1ff614a26a6c38ee7185f791f668ac8f /net/test
parent5c52f6eb47d0215df28f589bd5c9a5f14a44383f (diff)
downloadchromium_src-91bb9b3d4964cb8611231722a4538afccbd9fd09.zip
chromium_src-91bb9b3d4964cb8611231722a4538afccbd9fd09.tar.gz
chromium_src-91bb9b3d4964cb8611231722a4538afccbd9fd09.tar.bz2
[Android] Convert TabsTest and InfoBarTest to EmbeddedTestServer.
BUG=488195 TBR=maruel@chromium.org Review URL: https://codereview.chromium.org/1639253010 Cr-Commit-Position: refs/heads/master@{#373588}
Diffstat (limited to 'net/test')
-rw-r--r--net/test/android/javatests/src/org/chromium/net/test/EmbeddedTestServer.java26
1 files changed, 16 insertions, 10 deletions
diff --git a/net/test/android/javatests/src/org/chromium/net/test/EmbeddedTestServer.java b/net/test/android/javatests/src/org/chromium/net/test/EmbeddedTestServer.java
index 06ed7e2..149dc88 100644
--- a/net/test/android/javatests/src/org/chromium/net/test/EmbeddedTestServer.java
+++ b/net/test/android/javatests/src/org/chromium/net/test/EmbeddedTestServer.java
@@ -59,6 +59,7 @@ public class EmbeddedTestServer {
}
};
+ private Context mContext;
private final Object mImplMonitor = new Object();
/**
@@ -74,11 +75,18 @@ public class EmbeddedTestServer {
}
}
+ /** Bind the service that will run the native server object.
+ *
+ * @param context The context to use to bind the service. This will also be used to unbind
+ # the service at server destruction time.
+ */
public void initializeNative(Context context) throws InterruptedException {
+ mContext = context;
+
Intent intent = new Intent(EMBEDDED_TEST_SERVER_SERVICE);
intent.setClassName(
"org.chromium.net.test.support", "org.chromium.net.test.EmbeddedTestServerService");
- if (!context.bindService(intent, mConn, Context.BIND_AUTO_CREATE)) {
+ if (!mContext.bindService(intent, mConn, Context.BIND_AUTO_CREATE)) {
throw new EmbeddedTestServerFailure(
"Unable to bind to the EmbeddedTestServer service.");
}
@@ -156,7 +164,7 @@ public class EmbeddedTestServer {
* 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 is being started.
+ * @param context The context in which the server will run.
* @param directory The directory from which files should be served.
* @return The created server.
*/
@@ -204,7 +212,7 @@ public class EmbeddedTestServer {
}
/** Destroy the native EmbeddedTestServer object. */
- public void destroy(Context context) {
+ public void destroy() {
try {
synchronized (mImplMonitor) {
checkServiceLocked();
@@ -213,20 +221,18 @@ public class EmbeddedTestServer {
} catch (RemoteException e) {
throw new EmbeddedTestServerFailure("Failed to destroy native server.", e);
} finally {
- context.unbindService(mConn);
+ mContext.unbindService(mConn);
}
}
- /** Stop and destroy the provided server.
+ /** Stop and destroy the server.
*
* This handles stopping the server and destroying the native object.
- *
- * @param server The server to stop and destroy.
*/
- public static void stopAndDestroyServer(EmbeddedTestServer server, Context context) {
- if (!server.shutdownAndWaitUntilComplete()) {
+ public void stopAndDestroyServer() {
+ if (!shutdownAndWaitUntilComplete()) {
throw new EmbeddedTestServerFailure("Failed to stop server.");
}
- server.destroy(context);
+ destroy();
}
}