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

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

Issue 2872593002: [Cronet] Regression test for DCHECK when histograms read on another thread (Closed)
Patch Set: cleanup Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.content.ContextWrapper; 8 import android.content.ContextWrapper;
9 import android.os.ConditionVariable; 9 import android.os.ConditionVariable;
10 import android.os.Handler; 10 import android.os.Handler;
(...skipping 13 matching lines...) Expand all
24 import org.chromium.net.impl.CronetEngineBuilderImpl; 24 import org.chromium.net.impl.CronetEngineBuilderImpl;
25 import org.chromium.net.impl.CronetLibraryLoader; 25 import org.chromium.net.impl.CronetLibraryLoader;
26 import org.chromium.net.impl.CronetUrlRequestContext; 26 import org.chromium.net.impl.CronetUrlRequestContext;
27 import org.chromium.net.test.EmbeddedTestServer; 27 import org.chromium.net.test.EmbeddedTestServer;
28 28
29 import java.io.BufferedReader; 29 import java.io.BufferedReader;
30 import java.io.File; 30 import java.io.File;
31 import java.io.FileReader; 31 import java.io.FileReader;
32 import java.net.URL; 32 import java.net.URL;
33 import java.util.Arrays; 33 import java.util.Arrays;
34 import java.util.concurrent.Callable;
34 import java.util.concurrent.Executor; 35 import java.util.concurrent.Executor;
36 import java.util.concurrent.FutureTask;
35 import java.util.concurrent.atomic.AtomicReference; 37 import java.util.concurrent.atomic.AtomicReference;
36 38
37 /** 39 /**
38 * Test CronetEngine. 40 * Test CronetEngine.
39 */ 41 */
40 @JNINamespace("cronet") 42 @JNINamespace("cronet")
41 public class CronetUrlRequestContextTest extends CronetTestBase { 43 public class CronetUrlRequestContextTest extends CronetTestBase {
42 private static final String TAG = CronetUrlRequestContextTest.class.getSimpl eName(); 44 private static final String TAG = CronetUrlRequestContextTest.class.getSimpl eName();
43 45
44 // URLs used for tests. 46 // URLs used for tests.
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 public void testGetGlobalMetricsDeltas() throws Exception { 1147 public void testGetGlobalMetricsDeltas() throws Exception {
1146 final CronetTestFramework testFramework = startCronetTestFramework(); 1148 final CronetTestFramework testFramework = startCronetTestFramework();
1147 1149
1148 byte delta1[] = testFramework.mCronetEngine.getGlobalMetricsDeltas(); 1150 byte delta1[] = testFramework.mCronetEngine.getGlobalMetricsDeltas();
1149 1151
1150 TestUrlRequestCallback callback = new TestUrlRequestCallback(); 1152 TestUrlRequestCallback callback = new TestUrlRequestCallback();
1151 UrlRequest.Builder builder = testFramework.mCronetEngine.newUrlRequestBu ilder( 1153 UrlRequest.Builder builder = testFramework.mCronetEngine.newUrlRequestBu ilder(
1152 mUrl, callback, callback.getExecutor()); 1154 mUrl, callback, callback.getExecutor());
1153 builder.build().start(); 1155 builder.build().start();
1154 callback.blockForDone(); 1156 callback.blockForDone();
1155 byte delta2[] = testFramework.mCronetEngine.getGlobalMetricsDeltas(); 1157 // Fetch deltas on a different thread the second time to make sure this is permitted.
1158 // See crbug.com/719448
1159 FutureTask<byte[]> task = new FutureTask<byte[]>(new Callable<byte[]>() {
1160 public byte[] call() {
1161 return testFramework.mCronetEngine.getGlobalMetricsDeltas();
1162 }
1163 });
1164 new Thread(task).start();
1165 byte delta2[] = task.get();
1156 assertTrue(delta2.length != 0); 1166 assertTrue(delta2.length != 0);
1157 assertFalse(Arrays.equals(delta1, delta2)); 1167 assertFalse(Arrays.equals(delta1, delta2));
1158 } 1168 }
1159 1169
1160 @SmallTest 1170 @SmallTest
1161 @Feature({"Cronet"}) 1171 @Feature({"Cronet"})
1162 public void testCronetEngineBuilderConfig() throws Exception { 1172 public void testCronetEngineBuilderConfig() throws Exception {
1163 // This is to prompt load of native library. 1173 // This is to prompt load of native library.
1164 startCronetTestFramework(); 1174 startCronetTestFramework();
1165 // Verify CronetEngine.Builder config is passed down accurately to nativ e code. 1175 // Verify CronetEngine.Builder config is passed down accurately to nativ e code.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 TestUrlRequestCallback callback = new TestUrlRequestCallback(); 1270 TestUrlRequestCallback callback = new TestUrlRequestCallback();
1261 URL requestUrl = 1271 URL requestUrl =
1262 new URL("http", resolverTestHostname, testUrl.getPort(), testUrl .getFile()); 1272 new URL("http", resolverTestHostname, testUrl.getPort(), testUrl .getFile());
1263 UrlRequest.Builder urlRequestBuilder = testFramework.mCronetEngine.newUr lRequestBuilder( 1273 UrlRequest.Builder urlRequestBuilder = testFramework.mCronetEngine.newUr lRequestBuilder(
1264 requestUrl.toString(), callback, callback.getExecutor()); 1274 requestUrl.toString(), callback, callback.getExecutor());
1265 urlRequestBuilder.build().start(); 1275 urlRequestBuilder.build().start();
1266 callback.blockForDone(); 1276 callback.blockForDone();
1267 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); 1277 assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
1268 } 1278 }
1269 } 1279 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698