Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1217)

Unified Diff: net/nqe/network_quality_estimator_unittest.cc

Issue 2172403002: Provide default thresholds for effective connection types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bengr comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/nqe/network_quality_estimator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/nqe/network_quality_estimator_unittest.cc
diff --git a/net/nqe/network_quality_estimator_unittest.cc b/net/nqe/network_quality_estimator_unittest.cc
index b381ce84649b52b55c8e071d1c1e47816f1a3f5b..c61d5b772f0310fc6f8665010e4e81e794d22f40 100644
--- a/net/nqe/network_quality_estimator_unittest.cc
+++ b/net/nqe/network_quality_estimator_unittest.cc
@@ -691,36 +691,6 @@ TEST(NetworkQualityEstimatorTest, ObtainAlgorithmToUseFromParams) {
}
}
-// Tests that |GetEffectiveConnectionType| returns correct connection type when
-// no variation params are specified.
-TEST(NetworkQualityEstimatorTest, ObtainThresholdsNone) {
- std::map<std::string, std::string> variation_params;
-
- TestNetworkQualityEstimator estimator(variation_params);
-
- // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType
- // does not return Offline if the device is offline.
- estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI,
- "test");
-
- const struct {
- int32_t rtt_msec;
- NetworkQualityEstimator::EffectiveConnectionType expected_conn_type;
- } tests[] = {
- {5000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND},
- {20, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND},
- };
-
- for (const auto& test : tests) {
- estimator.set_http_rtt(base::TimeDelta::FromMilliseconds(test.rtt_msec));
- estimator.set_recent_http_rtt(
- base::TimeDelta::FromMilliseconds(test.rtt_msec));
- estimator.set_downlink_throughput_kbps(INT32_MAX);
- estimator.set_recent_downlink_throughput_kbps(INT32_MAX);
- EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType());
- }
-}
-
// Tests that |GetEffectiveConnectionType| returns
// EFFECTIVE_CONNECTION_TYPE_OFFLINE when the device is currently offline.
TEST(NetworkQualityEstimatorTest, Offline) {
@@ -794,6 +764,114 @@ TEST(NetworkQualityEstimatorTest, ObtainThresholdsOnlyRTT) {
}
}
+// Tests that default transport RTT thresholds for different effective
+// connection types are correctly set.
+TEST(NetworkQualityEstimatorTest, DefaultTransportRTTBasedThresholds) {
+ const struct {
+ bool override_defaults_using_variation_params;
+ int32_t transport_rtt_msec;
+ NetworkQualityEstimator::EffectiveConnectionType expected_conn_type;
+ } tests[] = {
+ // When the variation params do not override connection thresholds,
+ // default values should be used.
+ {false, 5000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {false, 4000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {false, 3000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {false, 2000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {false, 1500, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G},
+ {false, 1000,
+ NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND},
+ {false, 20, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND},
+ // Override default thresholds using variation params.
+ {true, 5000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_OFFLINE},
+ {true, 4000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_OFFLINE},
+ {true, 3000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {true, 2000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {true, 1500, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G},
+ {true, 1000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G},
+ {true, 20, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND},
+ };
+
+ for (const auto& test : tests) {
+ std::map<std::string, std::string> variation_params;
+ variation_params["effective_connection_type_algorithm"] =
+ "TransportRTTOrDownstreamThroughput";
+ if (test.override_defaults_using_variation_params) {
+ variation_params["Offline.ThresholdMedianTransportRTTMsec"] = "4000";
+ variation_params["Slow2G.ThresholdMedianTransportRTTMsec"] = "2000";
+ variation_params["2G.ThresholdMedianTransportRTTMsec"] = "1000";
+ }
+
+ TestNetworkQualityEstimator estimator(variation_params);
+
+ // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType
+ // does not return Offline if the device is offline.
+ estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI,
+ "test");
+
+ estimator.set_transport_rtt(
+ base::TimeDelta::FromMilliseconds(test.transport_rtt_msec));
+ estimator.set_recent_transport_rtt(
+ base::TimeDelta::FromMilliseconds(test.transport_rtt_msec));
+ estimator.set_downlink_throughput_kbps(INT32_MAX);
+ estimator.set_recent_downlink_throughput_kbps(INT32_MAX);
+ EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType());
+ }
+}
+
+// Tests that default HTTP RTT thresholds for different effective
+// connection types are correctly set.
+TEST(NetworkQualityEstimatorTest, DefaultHttpRTTBasedThresholds) {
+ const struct {
+ bool override_defaults_using_variation_params;
+ int32_t http_rtt_msec;
+ NetworkQualityEstimator::EffectiveConnectionType expected_conn_type;
+ } tests[] = {
+ // When the variation params do not override connection thresholds,
+ // default values should be used.
+ {false, 5000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {false, 4000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {false, 3000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {false, 2000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G},
+ {false, 1500, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G},
+ {false, 1000,
+ NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND},
+ {false, 20, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND},
+ // Override default thresholds using variation params.
+ {true, 5000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_OFFLINE},
+ {true, 4000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_OFFLINE},
+ {true, 3000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {true, 2000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_SLOW_2G},
+ {true, 1500, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G},
+ {true, 1000, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_2G},
+ {true, 20, NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_BROADBAND},
+ };
+
+ for (const auto& test : tests) {
+ std::map<std::string, std::string> variation_params;
+ if (test.override_defaults_using_variation_params) {
+ variation_params["Offline.ThresholdMedianHttpRTTMsec"] = "4000";
+ variation_params["Slow2G.ThresholdMedianHttpRTTMsec"] = "2000";
+ variation_params["2G.ThresholdMedianHttpRTTMsec"] = "1000";
+ }
+
+ TestNetworkQualityEstimator estimator(variation_params);
+
+ // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType
+ // does not return Offline if the device is offline.
+ estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI,
+ "test");
+
+ estimator.set_http_rtt(
+ base::TimeDelta::FromMilliseconds(test.http_rtt_msec));
+ estimator.set_recent_http_rtt(
+ base::TimeDelta::FromMilliseconds(test.http_rtt_msec));
+ estimator.set_downlink_throughput_kbps(INT32_MAX);
+ estimator.set_recent_downlink_throughput_kbps(INT32_MAX);
+ EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType());
+ }
+}
+
// Tests that |GetEffectiveConnectionType| returns correct connection type when
// only transport RTT thresholds are specified in the variation params.
TEST(NetworkQualityEstimatorTest, ObtainThresholdsOnlyTransportRTT) {
« no previous file with comments | « net/nqe/network_quality_estimator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698