| 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 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; |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // NETWORK_QUALITY_OBSERVATION_SOURCE_TCP | 319 // NETWORK_QUALITY_OBSERVATION_SOURCE_TCP |
| 320 assertTrue(rttListener.rttObservationCount(1) > 0); | 320 assertTrue(rttListener.rttObservationCount(1) > 0); |
| 321 | 321 |
| 322 // NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC | 322 // NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC |
| 323 assertEquals(0, rttListener.rttObservationCount(2)); | 323 assertEquals(0, rttListener.rttObservationCount(2)); |
| 324 | 324 |
| 325 // Verify that the listeners were notified on the expected thread. | 325 // Verify that the listeners were notified on the expected thread. |
| 326 assertEquals(mNetworkQualityThread, rttListener.getThread()); | 326 assertEquals(mNetworkQualityThread, rttListener.getThread()); |
| 327 assertEquals(mNetworkQualityThread, throughputListener.getThread()); | 327 assertEquals(mNetworkQualityThread, throughputListener.getThread()); |
| 328 | 328 |
| 329 // Verify that effective connection type callback is received and |
| 330 // effective connection type is correctly set. |
| 331 assertTrue(mTestFramework.mCronetEngine.getEffectiveConnectionType() |
| 332 != EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_UNKNOWN); |
| 333 |
| 329 mTestFramework.mCronetEngine.shutdown(); | 334 mTestFramework.mCronetEngine.shutdown(); |
| 330 } | 335 } |
| 331 | 336 |
| 332 | 337 @SmallTest |
| 338 @Feature({"Cronet"}) |
| 339 public void testEffectiveConnectionTypeEquivalence() throws Exception { |
| 340 assertEquals(EffectiveConnectionType.getEffectiveConnectionType( |
| 341 NetworkEffectiveConnectionType.EFFECTIVE_CONNECTION
_TYPE_UNKNOWN), |
| 342 EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_UNKNOWN); |
| 343 assertEquals(EffectiveConnectionType.getEffectiveConnectionType( |
| 344 NetworkEffectiveConnectionType.EFFECTIVE_CONNECTION
_TYPE_OFFLINE), |
| 345 EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_OFFLINE); |
| 346 assertEquals(EffectiveConnectionType.getEffectiveConnectionType( |
| 347 NetworkEffectiveConnectionType.EFFECTIVE_CONNECTION
_TYPE_SLOW_2G), |
| 348 EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_SLOW_2G); |
| 349 assertEquals(EffectiveConnectionType.getEffectiveConnectionType( |
| 350 NetworkEffectiveConnectionType.EFFECTIVE_CONNECTION
_TYPE_2G), |
| 351 EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_2G); |
| 352 assertEquals(EffectiveConnectionType.getEffectiveConnectionType( |
| 353 NetworkEffectiveConnectionType.EFFECTIVE_CONNECTION
_TYPE_3G), |
| 354 EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_3G); |
| 355 assertEquals(EffectiveConnectionType.getEffectiveConnectionType( |
| 356 NetworkEffectiveConnectionType.EFFECTIVE_CONNECTION
_TYPE_4G), |
| 357 EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_4G); |
| 358 assertEquals(EffectiveConnectionType.getEffectiveConnectionType( |
| 359 NetworkEffectiveConnectionType.EFFECTIVE_CONNECTION
_TYPE_BROADBAND), |
| 360 EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_BROADBAND); |
| 361 assertEquals(EffectiveConnectionType.getEffectiveConnectionType( |
| 362 NetworkEffectiveConnectionType.EFFECTIVE_CONNECTION
_TYPE_LAST), |
| 363 EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_LAST); |
| 364 } |
| 333 | 365 |
| 334 /** | 366 /** |
| 335 @SmallTest | 367 @SmallTest |
| 336 @Feature({"Cronet"}) | 368 @Feature({"Cronet"}) |
| 337 https://crbug.com/596929 | 369 https://crbug.com/596929 |
| 338 */ | 370 */ |
| 339 @FlakyTest | 371 @FlakyTest |
| 340 public void testShutdown() throws Exception { | 372 public void testShutdown() throws Exception { |
| 341 mTestFramework = startCronetTestFramework(); | 373 mTestFramework = startCronetTestFramework(); |
| 342 TestUrlRequestCallback callback = new ShutdownTestUrlRequestCallback(); | 374 TestUrlRequestCallback callback = new ShutdownTestUrlRequestCallback(); |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 } | 1145 } |
| 1114 }.start(); | 1146 }.start(); |
| 1115 otherThreadDone.block(); | 1147 otherThreadDone.block(); |
| 1116 builder.build().shutdown(); | 1148 builder.build().shutdown(); |
| 1117 uiThreadDone.open(); | 1149 uiThreadDone.open(); |
| 1118 } | 1150 } |
| 1119 }); | 1151 }); |
| 1120 assertTrue(uiThreadDone.block(1000)); | 1152 assertTrue(uiThreadDone.block(1000)); |
| 1121 } | 1153 } |
| 1122 } | 1154 } |
| OLD | NEW |