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

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

Issue 2433923005: Revert of Expose RTT and throughput estimates from Cronet (Closed)
Patch Set: Created 4 years, 2 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 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;
11 import android.os.Looper; 11 import android.os.Looper;
12 import android.os.StrictMode; 12 import android.os.StrictMode;
13 import android.test.suitebuilder.annotation.SmallTest; 13 import android.test.suitebuilder.annotation.SmallTest;
14 14
15 import org.json.JSONObject;
16
17 import org.chromium.base.FileUtils; 15 import org.chromium.base.FileUtils;
18 import org.chromium.base.PathUtils; 16 import org.chromium.base.PathUtils;
19 import org.chromium.base.annotations.JNINamespace; 17 import org.chromium.base.annotations.JNINamespace;
20 import org.chromium.base.test.util.Feature; 18 import org.chromium.base.test.util.Feature;
21 import org.chromium.net.MetricsTestUtil.TestExecutor; 19 import org.chromium.net.MetricsTestUtil.TestExecutor;
22 import org.chromium.net.TestUrlRequestCallback.ResponseStep; 20 import org.chromium.net.TestUrlRequestCallback.ResponseStep;
23 import org.chromium.net.impl.CronetLibraryLoader; 21 import org.chromium.net.impl.CronetLibraryLoader;
24 import org.chromium.net.impl.CronetUrlRequestContext; 22 import org.chromium.net.impl.CronetUrlRequestContext;
25 import org.chromium.net.test.EmbeddedTestServer; 23 import org.chromium.net.test.EmbeddedTestServer;
24 import org.json.JSONObject;
26 25
27 import java.io.BufferedReader; 26 import java.io.BufferedReader;
28 import java.io.File; 27 import java.io.File;
29 import java.io.FileReader; 28 import java.io.FileReader;
30 import java.net.URL; 29 import java.net.URL;
31 import java.util.Arrays; 30 import java.util.Arrays;
32 import java.util.concurrent.Executor; 31 import java.util.concurrent.Executor;
33 import java.util.concurrent.Executors; 32 import java.util.concurrent.Executors;
34 import java.util.concurrent.ThreadFactory; 33 import java.util.concurrent.ThreadFactory;
35 import java.util.concurrent.atomic.AtomicReference; 34 import java.util.concurrent.atomic.AtomicReference;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 callback.blockForDone(); 273 callback.blockForDone();
275 networkQualityExecutor.runAllTasks(); 274 networkQualityExecutor.runAllTasks();
276 assertEquals(0, rttListener.rttObservationCount()); 275 assertEquals(0, rttListener.rttObservationCount());
277 testFramework.mCronetEngine.shutdown(); 276 testFramework.mCronetEngine.shutdown();
278 } 277 }
279 278
280 @SmallTest 279 @SmallTest
281 @Feature({"Cronet"}) 280 @Feature({"Cronet"})
282 public void testRealTimeNetworkQualityObservationsQuicDisabled() throws Exce ption { 281 public void testRealTimeNetworkQualityObservationsQuicDisabled() throws Exce ption {
283 CronetEngine.Builder mCronetEngineBuilder = new CronetEngine.Builder(get Context()); 282 CronetEngine.Builder mCronetEngineBuilder = new CronetEngine.Builder(get Context());
284 assert RttThroughputValues.INVALID_RTT_THROUGHPUT < 0;
285
286 Executor listenersExecutor = Executors.newSingleThreadExecutor(new Execu torThreadFactory()); 283 Executor listenersExecutor = Executors.newSingleThreadExecutor(new Execu torThreadFactory());
287 ConditionVariable waitForThroughput = new ConditionVariable(); 284 ConditionVariable waitForThroughput = new ConditionVariable();
288 TestNetworkQualityRttListener rttListener = 285 TestNetworkQualityRttListener rttListener =
289 new TestNetworkQualityRttListener(listenersExecutor); 286 new TestNetworkQualityRttListener(listenersExecutor);
290 TestNetworkQualityThroughputListener throughputListener = 287 TestNetworkQualityThroughputListener throughputListener =
291 new TestNetworkQualityThroughputListener(listenersExecutor, wait ForThroughput); 288 new TestNetworkQualityThroughputListener(listenersExecutor, wait ForThroughput);
292 mCronetEngineBuilder.enableHttp2(true).enableQuic(false).enableNetworkQu alityEstimator( 289 mCronetEngineBuilder.enableHttp2(true).enableQuic(false).enableNetworkQu alityEstimator(
293 true); 290 true);
294 final CronetTestFramework testFramework = 291 final CronetTestFramework testFramework =
295 startCronetTestFrameworkWithUrlAndCronetEngineBuilder(null, mCro netEngineBuilder); 292 startCronetTestFrameworkWithUrlAndCronetEngineBuilder(null, mCro netEngineBuilder);
(...skipping 30 matching lines...) Expand all
326 323
327 // Verify that the listeners were notified on the expected thread. 324 // Verify that the listeners were notified on the expected thread.
328 assertEquals(mNetworkQualityThread, rttListener.getThread()); 325 assertEquals(mNetworkQualityThread, rttListener.getThread());
329 assertEquals(mNetworkQualityThread, throughputListener.getThread()); 326 assertEquals(mNetworkQualityThread, throughputListener.getThread());
330 327
331 // Verify that effective connection type callback is received and 328 // Verify that effective connection type callback is received and
332 // effective connection type is correctly set. 329 // effective connection type is correctly set.
333 assertTrue(testFramework.mCronetEngine.getEffectiveConnectionType() 330 assertTrue(testFramework.mCronetEngine.getEffectiveConnectionType()
334 != EffectiveConnectionType.TYPE_UNKNOWN); 331 != EffectiveConnectionType.TYPE_UNKNOWN);
335 332
336 // Verify that the HTTP RTT, transport RTT and downstream throughput
337 // estimates are available.
338 if (testFramework.mCronetEngine.getEffectiveConnectionType()
339 != EffectiveConnectionType.TYPE_OFFLINE) {
340 assertTrue(testFramework.mCronetEngine.getHttpRttMs() > 0);
341 assertTrue(testFramework.mCronetEngine.getTransportRttMs() > 0);
342 assertTrue(testFramework.mCronetEngine.getDownstreamThroughputKbps() > 0);
343 } else {
344 assertEquals(RttThroughputValues.INVALID_RTT_THROUGHPUT,
345 testFramework.mCronetEngine.getHttpRttMs());
346 assertEquals(RttThroughputValues.INVALID_RTT_THROUGHPUT,
347 testFramework.mCronetEngine.getTransportRttMs());
348 assertEquals(RttThroughputValues.INVALID_RTT_THROUGHPUT,
349 testFramework.mCronetEngine.getDownstreamThroughputKbps());
350 }
351
352 testFramework.mCronetEngine.shutdown(); 333 testFramework.mCronetEngine.shutdown();
353 } 334 }
354 335
355 @SmallTest 336 @SmallTest
356 @Feature({"Cronet"}) 337 @Feature({"Cronet"})
357 // TODO: Remove the annotation after fixing http://crbug.com/637979 & http:/ /crbug.com/637972 338 // TODO: Remove the annotation after fixing http://crbug.com/637979 & http:/ /crbug.com/637972
358 @OnlyRunNativeCronet 339 @OnlyRunNativeCronet
359 public void testShutdown() throws Exception { 340 public void testShutdown() throws Exception {
360 final CronetTestFramework testFramework = startCronetTestFramework(); 341 final CronetTestFramework testFramework = startCronetTestFramework();
361 ShutdownTestUrlRequestCallback callback = 342 ShutdownTestUrlRequestCallback callback =
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 TestUrlRequestCallback callback = new TestUrlRequestCallback(); 1447 TestUrlRequestCallback callback = new TestUrlRequestCallback();
1467 URL requestUrl = 1448 URL requestUrl =
1468 new URL("http", resolverTestHostname, testUrl.getPort(), testUrl .getFile()); 1449 new URL("http", resolverTestHostname, testUrl.getPort(), testUrl .getFile());
1469 UrlRequest.Builder urlRequestBuilder = new UrlRequest.Builder(requestUrl .toString(), 1450 UrlRequest.Builder urlRequestBuilder = new UrlRequest.Builder(requestUrl .toString(),
1470 callback, callback.getExecutor(), testFramework.mCronetEngine); 1451 callback, callback.getExecutor(), testFramework.mCronetEngine);
1471 urlRequestBuilder.build().start(); 1452 urlRequestBuilder.build().start();
1472 callback.blockForDone(); 1453 callback.blockForDone();
1473 assertEquals(200, callback.mResponseInfo.getHttpStatusCode()); 1454 assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
1474 } 1455 }
1475 } 1456 }
OLDNEW
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java ('k') | net/nqe/network_quality.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698