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

Unified Diff: net/nqe/network_quality_estimator_unittest.cc

Issue 1991933002: Return E_C_T_OFFLINE when the device is offline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 f3a4962e11ee14296925ad4e49a70e241c76d075..f0a102081ab3aed7886a641901fa0ddfc2fab8ca 100644
--- a/net/nqe/network_quality_estimator_unittest.cc
+++ b/net/nqe/network_quality_estimator_unittest.cc
@@ -75,7 +75,7 @@ class TestNetworkQualityEstimator : public NetworkQualityEstimator {
// Overrides the current network type and id.
// Notifies network quality estimator of change in connection.
void SimulateNetworkChangeTo(NetworkChangeNotifier::ConnectionType type,
- std::string network_id) {
+ const std::string& network_id) {
current_network_type_ = type;
current_network_id_ = network_id;
OnConnectionTypeChanged(type);
@@ -431,6 +431,32 @@ TEST(NetworkQualityEstimatorTest, ObtainThresholdsNone) {
}
}
+// Tests that |GetEffectiveConnectionType| returns
+// EFFECTIVE_CONNECTION_TYPE_OFFLINE when the device is currently offline.
+TEST(NetworkQualityEstimatorTest, Offline) {
+ std::map<std::string, std::string> variation_params;
+
+ TestNetworkQualityEstimator estimator(variation_params);
+
+ const struct {
+ NetworkChangeNotifier::ConnectionType connection_type;
+ NetworkQualityEstimator::EffectiveConnectionType expected_connection_type;
+ } tests[] = {
+ {NetworkChangeNotifier::CONNECTION_2G,
+ NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_UNKNOWN},
+ {NetworkChangeNotifier::CONNECTION_NONE,
+ NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_OFFLINE},
+ {NetworkChangeNotifier::CONNECTION_3G,
+ NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_UNKNOWN},
+ };
+
+ for (const auto& test : tests) {
+ estimator.SimulateNetworkChangeTo(test.connection_type, "test");
+ EXPECT_EQ(test.expected_connection_type,
+ estimator.GetEffectiveConnectionType());
+ }
+}
+
// Tests that |GetEffectiveConnectionType| returns correct connection type when
// only RTT thresholds are specified in the variation params.
TEST(NetworkQualityEstimatorTest, ObtainThresholdsOnlyRTT) {
« 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