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

Side by Side Diff: components/cronet/android/test/src/org/chromium/net/QuicTestServer.java

Issue 2043803003: 👔 Reland #2: Move side-loaded test data /sdcard -> /sdcard/gtestdata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase atop https://codereview.chromium.org/2041723006 Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.ConditionVariable; 8 import android.os.ConditionVariable;
9 9
10 import org.chromium.base.Log; 10 import org.chromium.base.Log;
11 import org.chromium.base.annotations.CalledByNative; 11 import org.chromium.base.annotations.CalledByNative;
12 import org.chromium.base.annotations.JNINamespace; 12 import org.chromium.base.annotations.JNINamespace;
13 import org.chromium.base.test.util.UrlUtils;
13 14
14 /** 15 /**
15 * Wrapper class to start a Quic test server. 16 * Wrapper class to start a Quic test server.
16 */ 17 */
17 @JNINamespace("cronet") 18 @JNINamespace("cronet")
18 public final class QuicTestServer { 19 public final class QuicTestServer {
19 private static final ConditionVariable sBlock = new ConditionVariable(); 20 private static final ConditionVariable sBlock = new ConditionVariable();
20 private static final String TAG = "cr.QuicTestServer"; 21 private static final String TAG = "cr.QuicTestServer";
21 22
22 private static final String CERT_USED = "quic_test.example.com.crt"; 23 private static final String CERT_USED = "quic_test.example.com.crt";
23 private static final String KEY_USED = "quic_test.example.com.key"; 24 private static final String KEY_USED = "quic_test.example.com.key";
24 private static final String[] CERTS_USED = {CERT_USED}; 25 private static final String[] CERTS_USED = {CERT_USED};
25 26
26 private static boolean sServerRunning = false; 27 private static boolean sServerRunning = false;
27 28
28 /* 29 /*
29 * Starts the server. 30 * Starts the server.
30 */ 31 */
31 public static void startQuicTestServer(Context context) { 32 public static void startQuicTestServer(Context context) {
32 if (sServerRunning) { 33 if (sServerRunning) {
33 throw new IllegalStateException("Quic server is already running"); 34 throw new IllegalStateException("Quic server is already running");
34 } 35 }
35 TestFilesInstaller.installIfNeeded(context); 36 TestFilesInstaller.installIfNeeded(context);
36 nativeStartQuicTestServer(TestFilesInstaller.getInstalledPath(context)); 37 nativeStartQuicTestServer(
38 TestFilesInstaller.getInstalledPath(context), UrlUtils.getIsolat edTestRoot());
37 sBlock.block(); 39 sBlock.block();
38 sBlock.close(); 40 sBlock.close();
39 sServerRunning = true; 41 sServerRunning = true;
40 } 42 }
41 43
42 /** 44 /**
43 * Shuts down the server. No-op if the server is already shut down. 45 * Shuts down the server. No-op if the server is already shut down.
44 */ 46 */
45 public static void shutdownQuicTestServer() { 47 public static void shutdownQuicTestServer() {
46 if (!sServerRunning) { 48 if (!sServerRunning) {
(...skipping 26 matching lines...) Expand all
73 public static long createMockCertVerifier() { 75 public static long createMockCertVerifier() {
74 return MockCertVerifier.createMockCertVerifier(CERTS_USED); 76 return MockCertVerifier.createMockCertVerifier(CERTS_USED);
75 } 77 }
76 78
77 @CalledByNative 79 @CalledByNative
78 private static void onServerStarted() { 80 private static void onServerStarted() {
79 Log.i(TAG, "Quic server started."); 81 Log.i(TAG, "Quic server started.");
80 sBlock.open(); 82 sBlock.open();
81 } 83 }
82 84
83 private static native void nativeStartQuicTestServer(String filePath); 85 private static native void nativeStartQuicTestServer(String filePath, String testDataDir);
84 private static native void nativeShutdownQuicTestServer(); 86 private static native void nativeShutdownQuicTestServer();
85 private static native String nativeGetServerHost(); 87 private static native String nativeGetServerHost();
86 private static native int nativeGetServerPort(); 88 private static native int nativeGetServerPort();
87 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698