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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 UrlRequest urlRequest = | 263 UrlRequest urlRequest = |
| 264 mTestFramework.mCronetEngine.createRequest(mUrl, callback, callb ack.getExecutor()); | 264 mTestFramework.mCronetEngine.createRequest(mUrl, callback, callb ack.getExecutor()); |
| 265 urlRequest.start(); | 265 urlRequest.start(); |
| 266 callback.blockForDone(); | 266 callback.blockForDone(); |
| 267 testExecutor.runAllTasks(); | 267 testExecutor.runAllTasks(); |
| 268 assertEquals(0, networkQualityListener.rttObservationCount()); | 268 assertEquals(0, networkQualityListener.rttObservationCount()); |
| 269 assertEquals(0, networkQualityListener.throughputObservationCount()); | 269 assertEquals(0, networkQualityListener.throughputObservationCount()); |
| 270 mTestFramework.mCronetEngine.shutdown(); | 270 mTestFramework.mCronetEngine.shutdown(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 /* | |
| 274 @SmallTest | 273 @SmallTest |
| 275 @Feature({"Cronet"}) | 274 @Feature({"Cronet"}) |
| 276 // TODO(xunjieli): Remove annotation after crbug.com/539519 is fixed. | 275 // TODO(xunjieli): Remove annotation after crbug.com/539519 is fixed. |
|
xunjieli
2016/05/24 18:26:38
Since you are here, do you mind getting rid of thi
tbansal1
2016/05/26 18:02:59
Done.
| |
| 277 @SuppressWarnings("deprecation") | 276 @SuppressWarnings("deprecation") |
| 278 */ | |
| 279 @FlakyTest(message = "http://crbug.com/614227") | |
| 280 public void testRealTimeNetworkQualityObservations() throws Exception { | 277 public void testRealTimeNetworkQualityObservations() throws Exception { |
| 281 mTestFramework = startCronetTestFramework(); | 278 mTestFramework = startCronetTestFramework(); |
| 282 TestExecutor testExecutor = new TestExecutor(); | 279 TestExecutor testExecutor = new TestExecutor(); |
| 283 TestNetworkQualityListener networkQualityListener = new TestNetworkQuali tyListener(); | 280 TestNetworkQualityListener networkQualityListener = new TestNetworkQuali tyListener(); |
| 284 mTestFramework.mCronetEngine.enableNetworkQualityEstimatorForTesting( | 281 mTestFramework.mCronetEngine.enableNetworkQualityEstimatorForTesting( |
| 285 true, true, testExecutor); | 282 true, true, testExecutor); |
| 286 mTestFramework.mCronetEngine.addRttListener(networkQualityListener); | 283 mTestFramework.mCronetEngine.addRttListener(networkQualityListener); |
| 287 mTestFramework.mCronetEngine.addThroughputListener(networkQualityListene r); | 284 mTestFramework.mCronetEngine.addThroughputListener(networkQualityListene r); |
| 288 TestUrlRequestCallback callback = new TestUrlRequestCallback(); | 285 |
| 289 UrlRequest urlRequest = | 286 // Throughput observation is posted to the network quality estimator and its observers |
| 290 mTestFramework.mCronetEngine.createRequest(mUrl, callback, callb ack.getExecutor()); | 287 // after the UrlRequest is destroyed. Throughput observation correspondi ng to the first |
| 291 urlRequest.start(); | 288 // UrlRequest would post before the second UrlRequest starts. |
|
xunjieli
2016/05/24 18:26:39
I don't quite understand the threading model. The
tbansal1
2016/05/25 00:02:22
Context on how NQE works: After the request comple
xunjieli
2016/05/25 20:37:50
I thought opening the conditional variable in onTh
tbansal1
2016/05/25 21:04:13
You are right, it makes sure that IO is completed.
xunjieli
2016/05/26 13:54:47
Ah, I see. I didn't realize TestExecutor runs task
tbansal1
2016/05/26 18:02:59
Acknowledged.
| |
| 292 callback.blockForDone(); | 289 for (int i = 0; i < 2; ++i) { |
| 293 testExecutor.runAllTasks(); | 290 TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
| 291 UrlRequest urlRequest = mTestFramework.mCronetEngine.createRequest( | |
| 292 mUrl, callback, callback.getExecutor()); | |
| 293 urlRequest.start(); | |
| 294 callback.blockForDone(); | |
| 295 testExecutor.runAllTasks(); | |
| 296 } | |
| 297 | |
| 294 assertTrue(networkQualityListener.rttObservationCount() > 0); | 298 assertTrue(networkQualityListener.rttObservationCount() > 0); |
| 295 assertTrue(networkQualityListener.throughputObservationCount() > 0); | 299 assertTrue(networkQualityListener.throughputObservationCount() > 0); |
| 296 mTestFramework.mCronetEngine.shutdown(); | 300 mTestFramework.mCronetEngine.shutdown(); |
| 297 } | 301 } |
| 298 | 302 |
| 299 private static class TestRequestFinishedListener | 303 private static class TestRequestFinishedListener |
| 300 implements CronetEngine.RequestFinishedListener { | 304 implements CronetEngine.RequestFinishedListener { |
| 301 private UrlRequestInfo mRequestInfo = null; | 305 private UrlRequestInfo mRequestInfo = null; |
| 302 | 306 |
| 303 @Override | 307 @Override |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1149 } | 1153 } |
| 1150 }.start(); | 1154 }.start(); |
| 1151 otherThreadDone.block(); | 1155 otherThreadDone.block(); |
| 1152 builder.build().shutdown(); | 1156 builder.build().shutdown(); |
| 1153 uiThreadDone.open(); | 1157 uiThreadDone.open(); |
| 1154 } | 1158 } |
| 1155 }); | 1159 }); |
| 1156 assertTrue(uiThreadDone.block(1000)); | 1160 assertTrue(uiThreadDone.block(1000)); |
| 1157 } | 1161 } |
| 1158 } | 1162 } |
| OLD | NEW |