Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 static org.chromium.base.CollectionUtil.newHashSet; | 7 import static org.chromium.base.CollectionUtil.newHashSet; |
| 8 | 8 |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.ContextWrapper; | 10 import android.content.ContextWrapper; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 // TODO(xunjieli): Remove annotation after crbug.com/539519 is fixed. | 275 // TODO(xunjieli): Remove annotation after crbug.com/539519 is fixed. |
| 276 @SuppressWarnings("deprecation") | 276 @SuppressWarnings("deprecation") |
| 277 public void testRealTimeNetworkQualityObservations() throws Exception { | 277 public void testRealTimeNetworkQualityObservations() throws Exception { |
| 278 mTestFramework = startCronetTestFramework(); | 278 mTestFramework = startCronetTestFramework(); |
| 279 TestExecutor testExecutor = new TestExecutor(); | 279 TestExecutor testExecutor = new TestExecutor(); |
| 280 TestNetworkQualityListener networkQualityListener = new TestNetworkQuali tyListener(); | 280 TestNetworkQualityListener networkQualityListener = new TestNetworkQuali tyListener(); |
| 281 mTestFramework.mCronetEngine.enableNetworkQualityEstimatorForTesting( | 281 mTestFramework.mCronetEngine.enableNetworkQualityEstimatorForTesting( |
| 282 true, true, testExecutor); | 282 true, true, testExecutor); |
| 283 mTestFramework.mCronetEngine.addRttListener(networkQualityListener); | 283 mTestFramework.mCronetEngine.addRttListener(networkQualityListener); |
| 284 mTestFramework.mCronetEngine.addThroughputListener(networkQualityListene r); | 284 mTestFramework.mCronetEngine.addThroughputListener(networkQualityListene r); |
| 285 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 285 |
| 286 UrlRequest urlRequest = | 286 // Throughput observation is posted to network quality estimator, and ru nning two requests |
|
xunjieli
2016/05/24 01:54:43
The comment is a little vague, and I don't quite u
tbansal1
2016/05/24 16:57:08
I updated the comment. Let me know if it is still
| |
| 287 mTestFramework.mCronetEngine.createRequest(mUrl, callback, callb ack.getExecutor()); | 287 // ensures that the observation corresponding to the first request is po sted in time. |
| 288 urlRequest.start(); | 288 for (int i = 0; i < 2; ++i) { |
| 289 callback.blockForDone(); | 289 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
| 290 testExecutor.runAllTasks(); | 290 UrlRequest urlRequest = mTestFramework.mCronetEngine.createRequest( |
| 291 mUrl, callback, callback.getExecutor()); | |
| 292 urlRequest.start(); | |
| 293 callback.blockForDone(); | |
| 294 testExecutor.runAllTasks(); | |
| 295 } | |
| 296 | |
| 291 assertTrue(networkQualityListener.rttObservationCount() > 0); | 297 assertTrue(networkQualityListener.rttObservationCount() > 0); |
| 292 assertTrue(networkQualityListener.throughputObservationCount() > 0); | 298 assertTrue(networkQualityListener.throughputObservationCount() > 0); |
| 293 mTestFramework.mCronetEngine.shutdown(); | 299 mTestFramework.mCronetEngine.shutdown(); |
| 294 } | 300 } |
| 295 | 301 |
| 296 private static class TestRequestFinishedListener | 302 private static class TestRequestFinishedListener |
| 297 implements CronetEngine.RequestFinishedListener { | 303 implements CronetEngine.RequestFinishedListener { |
| 298 private UrlRequestInfo mRequestInfo = null; | 304 private UrlRequestInfo mRequestInfo = null; |
| 299 | 305 |
| 300 @Override | 306 @Override |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1146 } | 1152 } |
| 1147 }.start(); | 1153 }.start(); |
| 1148 otherThreadDone.block(); | 1154 otherThreadDone.block(); |
| 1149 builder.build().shutdown(); | 1155 builder.build().shutdown(); |
| 1150 uiThreadDone.open(); | 1156 uiThreadDone.open(); |
| 1151 } | 1157 } |
| 1152 }); | 1158 }); |
| 1153 assertTrue(uiThreadDone.block(1000)); | 1159 assertTrue(uiThreadDone.block(1000)); |
| 1154 } | 1160 } |
| 1155 } | 1161 } |
| OLD | NEW |