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(); |