| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "net/nqe/network_quality_estimator_test_util.h" | 5 #include "net/nqe/network_quality_estimator_test_util.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 false, | 43 false, |
| 44 base::MakeUnique<BoundTestNetLog>()) {} | 44 base::MakeUnique<BoundTestNetLog>()) {} |
| 45 | 45 |
| 46 TestNetworkQualityEstimator::TestNetworkQualityEstimator( | 46 TestNetworkQualityEstimator::TestNetworkQualityEstimator( |
| 47 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider, | 47 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider, |
| 48 const std::map<std::string, std::string>& variation_params, | 48 const std::map<std::string, std::string>& variation_params, |
| 49 bool allow_local_host_requests_for_tests, | 49 bool allow_local_host_requests_for_tests, |
| 50 bool allow_smaller_responses_for_tests, | 50 bool allow_smaller_responses_for_tests, |
| 51 bool add_default_platform_observations, | 51 bool add_default_platform_observations, |
| 52 std::unique_ptr<BoundTestNetLog> net_log) | 52 std::unique_ptr<BoundTestNetLog> net_log) |
| 53 : TestNetworkQualityEstimator(std::move(external_estimate_provider), | |
| 54 variation_params, | |
| 55 allow_local_host_requests_for_tests, | |
| 56 allow_smaller_responses_for_tests, | |
| 57 add_default_platform_observations, | |
| 58 false, | |
| 59 std::move(net_log)) {} | |
| 60 | |
| 61 TestNetworkQualityEstimator::TestNetworkQualityEstimator( | |
| 62 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider, | |
| 63 const std::map<std::string, std::string>& variation_params, | |
| 64 bool allow_local_host_requests_for_tests, | |
| 65 bool allow_smaller_responses_for_tests, | |
| 66 bool add_default_platform_observations, | |
| 67 bool suppress_notifications_for_testing, | |
| 68 std::unique_ptr<BoundTestNetLog> net_log) | |
| 69 : NetworkQualityEstimator(std::move(external_estimate_provider), | 53 : NetworkQualityEstimator(std::move(external_estimate_provider), |
| 70 variation_params, | 54 variation_params, |
| 71 allow_local_host_requests_for_tests, | 55 allow_local_host_requests_for_tests, |
| 72 allow_smaller_responses_for_tests, | 56 allow_smaller_responses_for_tests, |
| 73 add_default_platform_observations, | 57 add_default_platform_observations, |
| 74 net_log->bound()), | 58 net_log->bound()), |
| 75 current_network_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN), | 59 current_network_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN), |
| 76 accuracy_recording_intervals_set_(false), | 60 accuracy_recording_intervals_set_(false), |
| 77 rand_double_(0.0), | 61 rand_double_(0.0), |
| 78 embedded_test_server_(base::FilePath(kTestFilePath)), | 62 embedded_test_server_(base::FilePath(kTestFilePath)), |
| 79 suppress_notifications_for_testing_(suppress_notifications_for_testing), | 63 suppress_notifications_for_testing_(false), |
| 80 net_log_(std::move(net_log)) { | 64 net_log_(std::move(net_log)) { |
| 81 // Set up the embedded test server. | 65 // Set up the embedded test server. |
| 82 EXPECT_TRUE(embedded_test_server_.Start()); | 66 EXPECT_TRUE(embedded_test_server_.Start()); |
| 83 } | 67 } |
| 84 | 68 |
| 85 TestNetworkQualityEstimator::~TestNetworkQualityEstimator() {} | 69 TestNetworkQualityEstimator::~TestNetworkQualityEstimator() {} |
| 86 | 70 |
| 87 void TestNetworkQualityEstimator::RunOneRequest() { | 71 void TestNetworkQualityEstimator::RunOneRequest() { |
| 88 TestDelegate test_delegate; | 72 TestDelegate test_delegate; |
| 89 TestURLRequestContext context(true); | 73 TestURLRequestContext context(true); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 EffectiveConnectionType type) { | 273 EffectiveConnectionType type) { |
| 290 for (auto& observer : effective_connection_type_observer_list_) | 274 for (auto& observer : effective_connection_type_observer_list_) |
| 291 observer.OnEffectiveConnectionTypeChanged(type); | 275 observer.OnEffectiveConnectionTypeChanged(type); |
| 292 } | 276 } |
| 293 | 277 |
| 294 nqe::internal::NetworkID TestNetworkQualityEstimator::GetCurrentNetworkID() | 278 nqe::internal::NetworkID TestNetworkQualityEstimator::GetCurrentNetworkID() |
| 295 const { | 279 const { |
| 296 return nqe::internal::NetworkID(current_network_type_, current_network_id_); | 280 return nqe::internal::NetworkID(current_network_type_, current_network_id_); |
| 297 } | 281 } |
| 298 | 282 |
| 283 void TestNetworkQualityEstimator::SetSuppressNotificationsForTesting( |
| 284 bool suppress_notifications_for_testing) { |
| 285 suppress_notifications_for_testing_ = suppress_notifications_for_testing; |
| 286 } |
| 287 |
| 299 TestNetworkQualityEstimator::LocalHttpTestServer::LocalHttpTestServer( | 288 TestNetworkQualityEstimator::LocalHttpTestServer::LocalHttpTestServer( |
| 300 const base::FilePath& document_root) { | 289 const base::FilePath& document_root) { |
| 301 AddDefaultHandlers(document_root); | 290 AddDefaultHandlers(document_root); |
| 302 } | 291 } |
| 303 | 292 |
| 304 void TestNetworkQualityEstimator::NotifyObserversOfRTTOrThroughputComputed() | 293 void TestNetworkQualityEstimator::NotifyObserversOfRTTOrThroughputComputed() |
| 305 const { | 294 const { |
| 306 if (suppress_notifications_for_testing_) | 295 if (suppress_notifications_for_testing_) |
| 307 return; | 296 return; |
| 308 | 297 |
| 309 NetworkQualityEstimator::NotifyObserversOfRTTOrThroughputComputed(); | 298 NetworkQualityEstimator::NotifyObserversOfRTTOrThroughputComputed(); |
| 310 } | 299 } |
| 311 | 300 |
| 312 void TestNetworkQualityEstimator:: | 301 void TestNetworkQualityEstimator:: |
| 313 NotifyRTTAndThroughputEstimatesObserverIfPresent( | 302 NotifyRTTAndThroughputEstimatesObserverIfPresent( |
| 314 RTTAndThroughputEstimatesObserver* observer) const { | 303 RTTAndThroughputEstimatesObserver* observer) const { |
| 315 if (suppress_notifications_for_testing_) | 304 if (suppress_notifications_for_testing_) |
| 316 return; | 305 return; |
| 317 | 306 |
| 318 NetworkQualityEstimator::NotifyRTTAndThroughputEstimatesObserverIfPresent( | 307 NetworkQualityEstimator::NotifyRTTAndThroughputEstimatesObserverIfPresent( |
| 319 observer); | 308 observer); |
| 320 } | 309 } |
| 321 | 310 |
| 322 } // namespace net | 311 } // namespace net |
| OLD | NEW |