| 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 #ifndef NET_NQE_NETWORK_QUALITY_ESTIMATOR_TEST_UTIL_H_ | 5 #ifndef NET_NQE_NETWORK_QUALITY_ESTIMATOR_TEST_UTIL_H_ |
| 6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_TEST_UTIL_H_ | 6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 external_estimate_provider); | 41 external_estimate_provider); |
| 42 | 42 |
| 43 TestNetworkQualityEstimator( | 43 TestNetworkQualityEstimator( |
| 44 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider, | 44 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider, |
| 45 const std::map<std::string, std::string>& variation_params, | 45 const std::map<std::string, std::string>& variation_params, |
| 46 bool allow_local_host_requests_for_tests, | 46 bool allow_local_host_requests_for_tests, |
| 47 bool allow_smaller_responses_for_tests, | 47 bool allow_smaller_responses_for_tests, |
| 48 bool add_default_platform_observations, | 48 bool add_default_platform_observations, |
| 49 std::unique_ptr<BoundTestNetLog> net_log); | 49 std::unique_ptr<BoundTestNetLog> net_log); |
| 50 | 50 |
| 51 TestNetworkQualityEstimator( | |
| 52 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider, | |
| 53 const std::map<std::string, std::string>& variation_params, | |
| 54 bool allow_local_host_requests_for_tests, | |
| 55 bool allow_smaller_responses_for_tests, | |
| 56 bool add_default_platform_observations, | |
| 57 bool suppress_notifications_for_testing, | |
| 58 std::unique_ptr<BoundTestNetLog> net_log); | |
| 59 | |
| 60 ~TestNetworkQualityEstimator() override; | 51 ~TestNetworkQualityEstimator() override; |
| 61 | 52 |
| 62 // Runs one URL request to completion. | 53 // Runs one URL request to completion. |
| 63 void RunOneRequest(); | 54 void RunOneRequest(); |
| 64 | 55 |
| 65 // Overrides the current network type and id. | 56 // Overrides the current network type and id. |
| 66 // Notifies network quality estimator of a change in connection. | 57 // Notifies network quality estimator of a change in connection. |
| 67 void SimulateNetworkChange( | 58 void SimulateNetworkChange( |
| 68 NetworkChangeNotifier::ConnectionType new_connection_type, | 59 NetworkChangeNotifier::ConnectionType new_connection_type, |
| 69 const std::string& network_id); | 60 const std::string& network_id); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 210 |
| 220 // Notifies the registered observers that the network quality estimate has | 211 // Notifies the registered observers that the network quality estimate has |
| 221 // changed to |network_quality|. | 212 // changed to |network_quality|. |
| 222 void NotifyObserversOfRTTOrThroughputEstimatesComputed( | 213 void NotifyObserversOfRTTOrThroughputEstimatesComputed( |
| 223 const net::nqe::internal::NetworkQuality& network_quality); | 214 const net::nqe::internal::NetworkQuality& network_quality); |
| 224 | 215 |
| 225 // Notifies the registered observers that the network quality estimate has | 216 // Notifies the registered observers that the network quality estimate has |
| 226 // changed to |network_quality|. | 217 // changed to |network_quality|. |
| 227 void NotifyObserversOfEffectiveConnectionType(EffectiveConnectionType type); | 218 void NotifyObserversOfEffectiveConnectionType(EffectiveConnectionType type); |
| 228 | 219 |
| 220 void SetSuppressNotificationsForTesting( |
| 221 bool suppress_notifications_for_testing); |
| 222 |
| 229 using NetworkQualityEstimator::SetTickClockForTesting; | 223 using NetworkQualityEstimator::SetTickClockForTesting; |
| 230 using NetworkQualityEstimator::OnConnectionTypeChanged; | 224 using NetworkQualityEstimator::OnConnectionTypeChanged; |
| 231 using NetworkQualityEstimator::OnUpdatedRTTAvailable; | 225 using NetworkQualityEstimator::OnUpdatedRTTAvailable; |
| 232 | 226 |
| 233 private: | 227 private: |
| 234 class LocalHttpTestServer : public EmbeddedTestServer { | 228 class LocalHttpTestServer : public EmbeddedTestServer { |
| 235 public: | 229 public: |
| 236 explicit LocalHttpTestServer(const base::FilePath& document_root); | 230 explicit LocalHttpTestServer(const base::FilePath& document_root); |
| 237 }; | 231 }; |
| 238 | 232 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 base::Optional<int32_t> recent_downlink_throughput_kbps_; | 266 base::Optional<int32_t> recent_downlink_throughput_kbps_; |
| 273 | 267 |
| 274 // If set, GetRTTEstimateInternal() would return the set value. | 268 // If set, GetRTTEstimateInternal() would return the set value. |
| 275 base::Optional<base::TimeDelta> rtt_estimate_internal_; | 269 base::Optional<base::TimeDelta> rtt_estimate_internal_; |
| 276 | 270 |
| 277 double rand_double_; | 271 double rand_double_; |
| 278 | 272 |
| 279 LocalHttpTestServer embedded_test_server_; | 273 LocalHttpTestServer embedded_test_server_; |
| 280 | 274 |
| 281 // If true, notifications are not sent to any of the observers. | 275 // If true, notifications are not sent to any of the observers. |
| 282 const bool suppress_notifications_for_testing_; | 276 bool suppress_notifications_for_testing_; |
| 283 | 277 |
| 284 // Net log provided to network quality estimator. | 278 // Net log provided to network quality estimator. |
| 285 std::unique_ptr<net::BoundTestNetLog> net_log_; | 279 std::unique_ptr<net::BoundTestNetLog> net_log_; |
| 286 | 280 |
| 287 DISALLOW_COPY_AND_ASSIGN(TestNetworkQualityEstimator); | 281 DISALLOW_COPY_AND_ASSIGN(TestNetworkQualityEstimator); |
| 288 }; | 282 }; |
| 289 | 283 |
| 290 } // namespace net | 284 } // namespace net |
| 291 | 285 |
| 292 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_TEST_UTIL_H_ | 286 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_TEST_UTIL_H_ |
| OLD | NEW |