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

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

Issue 1273173002: Added Network Quality Estimator Real-time interface to Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
index d9cc5578e7169c741dd1b7ec1095a251996df6bc..4990762751bfd6b5de617c91d5412f6f17c85e14 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
@@ -79,6 +79,28 @@ public class CronetUrlRequestContextTest extends CronetTestBase {
}
}
+ static class TestNetworkQualityObserver
+ implements NetworkQualityRTTObserver, NetworkQualityThroughputObserver {
+ int mRTTObservationCount;
+ int mThroughputObservationCount;
+
+ public void onRTTObservation(int rttMs, int when, int source) {
+ mRTTObservationCount++;
+ }
+
+ public void onThroughputObservation(int throughputKbps, int when, int source) {
+ mThroughputObservationCount++;
+ }
+
+ public int rttObservationCount() {
+ return mRTTObservationCount;
+ }
+
+ public int throughputObservationCount() {
+ return mThroughputObservationCount;
+ }
+ }
+
@SmallTest
@Feature({"Cronet"})
public void testConfigUserAgent() throws Exception {
@@ -154,6 +176,23 @@ public class CronetUrlRequestContextTest extends CronetTestBase {
@SmallTest
@Feature({"Cronet"})
+ public void testRealTimeNetworkQualityObservations() throws Exception {
+ mActivity = launchCronetTestApp();
+ TestNetworkQualityObserver networkQualityObserver = new TestNetworkQualityObserver();
+ mActivity.mUrlRequestContext.enableNetworkQualityEstimator(true, true);
+ mActivity.mUrlRequestContext.addRTTObserver(networkQualityObserver);
+ mActivity.mUrlRequestContext.addThroughputObserver(networkQualityObserver);
+ TestUrlRequestListener listener = new TestUrlRequestListener();
+ UrlRequest urlRequest = mActivity.mUrlRequestContext.createRequest(
+ TEST_URL, listener, listener.getExecutor());
+ urlRequest.start();
+ listener.blockForDone();
+ assertTrue(networkQualityObserver.rttObservationCount() > 0);
+ assertTrue(networkQualityObserver.throughputObservationCount() > 0);
+ }
+
+ @SmallTest
+ @Feature({"Cronet"})
public void testShutdown() throws Exception {
mActivity = launchCronetTestApp();
TestUrlRequestListener listener = new ShutdownTestUrlRequestListener();

Powered by Google App Engine
This is Rietveld 408576698