| 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/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "net/base/load_flags.h" | 9 #include "net/base/load_flags.h" |
| 10 #include "net/test/embedded_test_server/http_response.h" | 10 #include "net/test/embedded_test_server/http_response.h" |
| 11 #include "net/url_request/url_request.h" | 11 #include "net/url_request/url_request.h" |
| 12 #include "net/url_request/url_request_test_util.h" | 12 #include "net/url_request/url_request_test_util.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 const base::FilePath::CharType kTestFilePath[] = | 16 const base::FilePath::CharType kTestFilePath[] = |
| 17 FILE_PATH_LITERAL("net/data/url_request_unittest"); | 17 FILE_PATH_LITERAL("net/data/url_request_unittest"); |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 TestNetworkQualityEstimator::TestNetworkQualityEstimator() |
| 24 : TestNetworkQualityEstimator(std::map<std::string, std::string>()) {} |
| 25 |
| 26 TestNetworkQualityEstimator::TestNetworkQualityEstimator( |
| 27 const std::map<std::string, std::string>& variation_params) |
| 28 : TestNetworkQualityEstimator(variation_params, |
| 29 std::unique_ptr<ExternalEstimateProvider>()) { |
| 30 } |
| 31 |
| 23 TestNetworkQualityEstimator::TestNetworkQualityEstimator( | 32 TestNetworkQualityEstimator::TestNetworkQualityEstimator( |
| 24 const std::map<std::string, std::string>& variation_params, | 33 const std::map<std::string, std::string>& variation_params, |
| 25 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider) | 34 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider) |
| 26 : TestNetworkQualityEstimator(std::move(external_estimate_provider), | 35 : TestNetworkQualityEstimator(std::move(external_estimate_provider), |
| 27 variation_params, | 36 variation_params, |
| 28 true, | 37 true, |
| 29 true, | 38 true, |
| 30 false) {} | 39 false) {} |
| 31 | 40 |
| 32 TestNetworkQualityEstimator::TestNetworkQualityEstimator( | 41 TestNetworkQualityEstimator::TestNetworkQualityEstimator( |
| 33 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider, | 42 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider, |
| 34 const std::map<std::string, std::string>& variation_params, | 43 const std::map<std::string, std::string>& variation_params, |
| 35 bool allow_local_host_requests_for_tests, | 44 bool allow_local_host_requests_for_tests, |
| 36 bool allow_smaller_responses_for_tests, | 45 bool allow_smaller_responses_for_tests, |
| 37 bool add_default_platform_observations) | 46 bool add_default_platform_observations) |
| 38 : NetworkQualityEstimator(std::move(external_estimate_provider), | 47 : NetworkQualityEstimator(std::move(external_estimate_provider), |
| 39 variation_params, | 48 variation_params, |
| 40 allow_local_host_requests_for_tests, | 49 allow_local_host_requests_for_tests, |
| 41 allow_smaller_responses_for_tests, | 50 allow_smaller_responses_for_tests, |
| 42 add_default_platform_observations), | 51 add_default_platform_observations), |
| 43 current_network_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN), | 52 current_network_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN), |
| 44 accuracy_recording_intervals_set_(false), | 53 accuracy_recording_intervals_set_(false), |
| 45 rand_double_(0.0), | 54 rand_double_(0.0), |
| 46 embedded_test_server_(base::FilePath(kTestFilePath)) { | 55 embedded_test_server_(base::FilePath(kTestFilePath)) { |
| 47 // Set up the embedded test server. | 56 // Set up the embedded test server. |
| 48 EXPECT_TRUE(embedded_test_server_.Start()); | 57 EXPECT_TRUE(embedded_test_server_.Start()); |
| 49 } | 58 } |
| 50 | 59 |
| 51 TestNetworkQualityEstimator::TestNetworkQualityEstimator( | |
| 52 const std::map<std::string, std::string>& variation_params) | |
| 53 : TestNetworkQualityEstimator(variation_params, | |
| 54 std::unique_ptr<ExternalEstimateProvider>()) { | |
| 55 } | |
| 56 | |
| 57 TestNetworkQualityEstimator::~TestNetworkQualityEstimator() {} | 60 TestNetworkQualityEstimator::~TestNetworkQualityEstimator() {} |
| 58 | 61 |
| 59 void TestNetworkQualityEstimator::RunOneRequest() { | 62 void TestNetworkQualityEstimator::RunOneRequest() { |
| 60 TestDelegate test_delegate; | 63 TestDelegate test_delegate; |
| 61 TestURLRequestContext context(true); | 64 TestURLRequestContext context(true); |
| 62 context.set_network_quality_estimator(this); | 65 context.set_network_quality_estimator(this); |
| 63 context.Init(); | 66 context.Init(); |
| 64 std::unique_ptr<URLRequest> request( | 67 std::unique_ptr<URLRequest> request( |
| 65 context.CreateRequest(GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); | 68 context.CreateRequest(GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); |
| 66 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); | 69 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 const { | 196 const { |
| 194 return nqe::internal::NetworkID(current_network_type_, current_network_id_); | 197 return nqe::internal::NetworkID(current_network_type_, current_network_id_); |
| 195 } | 198 } |
| 196 | 199 |
| 197 TestNetworkQualityEstimator::LocalHttpTestServer::LocalHttpTestServer( | 200 TestNetworkQualityEstimator::LocalHttpTestServer::LocalHttpTestServer( |
| 198 const base::FilePath& document_root) { | 201 const base::FilePath& document_root) { |
| 199 AddDefaultHandlers(document_root); | 202 AddDefaultHandlers(document_root); |
| 200 } | 203 } |
| 201 | 204 |
| 202 } // namespace net | 205 } // namespace net |
| OLD | NEW |