OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.smoke; | 5 package org.chromium.net.smoke; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 | 8 |
9 import org.json.JSONObject; | 9 import org.json.JSONObject; |
10 | 10 |
11 import org.chromium.base.Log; | 11 import org.chromium.base.Log; |
12 import org.chromium.net.CronetTestUtil; | 12 import org.chromium.net.CronetTestUtil; |
13 import org.chromium.net.ExperimentalCronetEngine; | 13 import org.chromium.net.ExperimentalCronetEngine; |
14 | 14 |
15 /** | 15 /** |
16 * Provides support for tests that depend on QUIC and HTTP2 servers. | 16 * Provides support for tests that depend on QUIC and HTTP2 servers. |
17 */ | 17 */ |
18 class ChromiumNativeTestSupport extends ChromiumPlatformOnlyTestSupport { | 18 class ChromiumNativeTestSupport extends ChromiumPlatformOnlyTestSupport { |
19 private static final String TAG = ChromiumNativeTestSupport.class.getSimpleN
ame(); | 19 private static final String TAG = ChromiumNativeTestSupport.class.getSimpleN
ame(); |
20 | 20 |
| 21 /** |
| 22 * Name of the file that contains the test server certificate in PEM format. |
| 23 */ |
| 24 private static final String SERVER_CERT_PEM = "quic_test.example.com.crt"; |
| 25 |
| 26 /** |
| 27 * Name of the file that contains the test server private key in PKCS8 PEM f
ormat. |
| 28 */ |
| 29 private static final String SERVER_KEY_PKCS8_PEM = "quic_test.example.com.ke
y.pkcs8.pem"; |
| 30 |
21 @Override | 31 @Override |
22 public TestServer createTestServer(Context context, Protocol protocol) { | 32 public TestServer createTestServer(Context context, Protocol protocol) { |
23 switch (protocol) { | 33 switch (protocol) { |
24 case QUIC: | 34 case QUIC: |
25 return new QuicTestServer(context); | 35 return new QuicTestServer(context); |
26 case HTTP2: | 36 case HTTP2: |
27 return new Http2TestServer(context); | 37 return new Http2TestServer(context); |
28 case HTTP1: | 38 case HTTP1: |
29 return super.createTestServer(context, protocol); | 39 return super.createTestServer(context, protocol); |
30 default: | 40 default: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 private static class Http2TestServer implements TestServer { | 90 private static class Http2TestServer implements TestServer { |
81 private final Context mContext; | 91 private final Context mContext; |
82 | 92 |
83 Http2TestServer(Context context) { | 93 Http2TestServer(Context context) { |
84 mContext = context; | 94 mContext = context; |
85 } | 95 } |
86 | 96 |
87 @Override | 97 @Override |
88 public boolean start() { | 98 public boolean start() { |
89 try { | 99 try { |
90 return org.chromium.net.Http2TestServer.startHttp2TestServer(mCo
ntext, | 100 return org.chromium.net.Http2TestServer.startHttp2TestServer( |
91 org.chromium.net.QuicTestServer.getServerCert(), | 101 mContext, SERVER_CERT_PEM, SERVER_KEY_PKCS8_PEM); |
92 org.chromium.net.QuicTestServer.getServerCertKey()); | |
93 } catch (Exception e) { | 102 } catch (Exception e) { |
94 Log.e(TAG, "Exception during Http2TestServer start", e); | 103 Log.e(TAG, "Exception during Http2TestServer start", e); |
95 return false; | 104 return false; |
96 } | 105 } |
97 } | 106 } |
98 | 107 |
99 @Override | 108 @Override |
100 public void shutdown() { | 109 public void shutdown() { |
101 try { | 110 try { |
102 org.chromium.net.Http2TestServer.shutdownHttp2TestServer(); | 111 org.chromium.net.Http2TestServer.shutdownHttp2TestServer(); |
103 } catch (Exception e) { | 112 } catch (Exception e) { |
104 Log.e(TAG, "Exception during Http2TestServer shutdown", e); | 113 Log.e(TAG, "Exception during Http2TestServer shutdown", e); |
105 } | 114 } |
106 } | 115 } |
107 | 116 |
108 @Override | 117 @Override |
109 public String getSuccessURL() { | 118 public String getSuccessURL() { |
110 return org.chromium.net.Http2TestServer.getEchoMethodUrl(); | 119 return org.chromium.net.Http2TestServer.getEchoMethodUrl(); |
111 } | 120 } |
112 } | 121 } |
113 } | 122 } |
OLD | NEW |