OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.h" | 5 #include "net/nqe/network_quality_estimator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 test.downlink_throughput_kbps); | 1246 test.downlink_throughput_kbps); |
1247 estimator.set_recent_downlink_throughput_kbps( | 1247 estimator.set_recent_downlink_throughput_kbps( |
1248 test.downlink_throughput_kbps); | 1248 test.downlink_throughput_kbps); |
1249 // Run one main frame request to force recomputation of effective connection | 1249 // Run one main frame request to force recomputation of effective connection |
1250 // type. | 1250 // type. |
1251 estimator.RunOneRequest(); | 1251 estimator.RunOneRequest(); |
1252 EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); | 1252 EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); |
1253 } | 1253 } |
1254 } | 1254 } |
1255 | 1255 |
1256 // Tests if |weight_multiplier_per_second_| is set to correct value for various | |
1257 // values of half life parameter. | |
1258 TEST(NetworkQualityEstimatorTest, HalfLifeParam) { | |
1259 std::map<std::string, std::string> variation_params; | |
1260 | |
1261 const struct { | |
1262 std::string description; | |
1263 std::string variation_params_value; | |
1264 double expected_weight_multiplier; | |
1265 } tests[] = { | |
1266 {"Half life parameter is not set, default value should be used", | |
1267 std::string(), 0.988}, | |
1268 {"Half life parameter is set to negative, default value should be used", | |
1269 "-100", 0.988}, | |
1270 {"Half life parameter is set to zero, default value should be used", "0", | |
1271 0.988}, | |
1272 {"Half life parameter is set correctly", "10", 0.933}, | |
1273 }; | |
1274 | |
1275 for (const auto& test : tests) { | |
1276 variation_params["HalfLifeSeconds"] = test.variation_params_value; | |
1277 TestNetworkQualityEstimator estimator(variation_params); | |
1278 EXPECT_NEAR(test.expected_weight_multiplier, | |
1279 estimator.weight_multiplier_per_second_, 0.001) | |
1280 << test.description; | |
1281 } | |
1282 } | |
1283 | |
1284 TEST(NetworkQualityEstimatorTest, TestGetMetricsSince) { | 1256 TEST(NetworkQualityEstimatorTest, TestGetMetricsSince) { |
1285 std::map<std::string, std::string> variation_params; | 1257 std::map<std::string, std::string> variation_params; |
1286 | 1258 |
1287 const base::TimeDelta rtt_threshold_3g = | 1259 const base::TimeDelta rtt_threshold_3g = |
1288 base::TimeDelta::FromMilliseconds(30); | 1260 base::TimeDelta::FromMilliseconds(30); |
1289 const base::TimeDelta rtt_threshold_4g = base::TimeDelta::FromMilliseconds(1); | 1261 const base::TimeDelta rtt_threshold_4g = base::TimeDelta::FromMilliseconds(1); |
1290 | 1262 |
1291 variation_params["3G.ThresholdMedianHttpRTTMsec"] = | 1263 variation_params["3G.ThresholdMedianHttpRTTMsec"] = |
1292 base::IntToString(rtt_threshold_3g.InMilliseconds()); | 1264 base::IntToString(rtt_threshold_3g.InMilliseconds()); |
1293 variation_params["HalfLifeSeconds"] = "300000"; | 1265 variation_params["HalfLifeSeconds"] = "300000"; |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3140 | 3112 |
3141 // Cleanup. | 3113 // Cleanup. |
3142 estimator.RemoveRTTObserver(&rtt_observer); | 3114 estimator.RemoveRTTObserver(&rtt_observer); |
3143 estimator.RemoveThroughputObserver(&throughput_observer); | 3115 estimator.RemoveThroughputObserver(&throughput_observer); |
3144 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); | 3116 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); |
3145 estimator.RemoveEffectiveConnectionTypeObserver( | 3117 estimator.RemoveEffectiveConnectionTypeObserver( |
3146 &effective_connection_type_observer); | 3118 &effective_connection_type_observer); |
3147 } | 3119 } |
3148 | 3120 |
3149 } // namespace net | 3121 } // namespace net |
OLD | NEW |