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

Unified Diff: components/metrics/net/network_metrics_provider_unittest.cc

Issue 2663023002: Mark ECT as ambiguous if there is a change in the connection type. (Closed)
Patch Set: Created 3 years, 11 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 | « components/metrics/net/network_metrics_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/net/network_metrics_provider_unittest.cc
diff --git a/components/metrics/net/network_metrics_provider_unittest.cc b/components/metrics/net/network_metrics_provider_unittest.cc
index a8b2c2ab04e4c8302ae58590e023f6a3845b3ac6..7006ee146be7d119c112bd279780317c79a858b2 100644
--- a/components/metrics/net/network_metrics_provider_unittest.cc
+++ b/components/metrics/net/network_metrics_provider_unittest.cc
@@ -47,15 +47,21 @@ class TestNetworkQualityEstimatorProvider
} // namespace
-// Verifies that the effective connection type is correctly set.
-TEST(NetworkMetricsProviderTest, EffectiveConnectionType) {
- base::MessageLoop loop(base::MessageLoop::TYPE_IO);
-
+class NetworkMetricsProviderTest : public testing::Test {
+ protected:
+ NetworkMetricsProviderTest() : loop_(base::MessageLoop::TYPE_IO) {
#if defined(OS_CHROMEOS)
- chromeos::DBusThreadManager::Initialize();
- chromeos::NetworkHandler::Initialize();
+ chromeos::DBusThreadManager::Initialize();
+ chromeos::NetworkHandler::Initialize();
#endif // OS_CHROMEOS
+ }
+
+ private:
+ base::MessageLoop loop_;
+};
+// Verifies that the effective connection type is correctly set.
+TEST_F(NetworkMetricsProviderTest, EffectiveConnectionType) {
net::TestNetworkQualityEstimator estimator;
std::unique_ptr<NetworkMetricsProvider::NetworkQualityEstimatorProvider>
estimator_provider(base::WrapUnique(
@@ -111,4 +117,28 @@ TEST(NetworkMetricsProviderTest, EffectiveConnectionType) {
system_profile.network().effective_connection_type());
}
+// Verifies that the effective connection type is set to AMBIGUOUS when there is
+// a change in the connection type.
+TEST_F(NetworkMetricsProviderTest, ECTAmbiguousOnConnectionTypeChange) {
+ net::TestNetworkQualityEstimator estimator;
+ std::unique_ptr<NetworkMetricsProvider::NetworkQualityEstimatorProvider>
+ estimator_provider(base::WrapUnique(
+ new TestNetworkQualityEstimatorProvider(&estimator)));
+ SystemProfileProto system_profile;
+ NetworkMetricsProvider network_metrics_provider(
+ std::move(estimator_provider), base::ThreadTaskRunnerHandle::Get().get());
+
+ EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN,
+ network_metrics_provider.effective_connection_type_);
+ EXPECT_FALSE(
+ network_metrics_provider.effective_connection_type_is_ambiguous_);
+
+ network_metrics_provider.OnConnectionTypeChanged(
+ net::NetworkChangeNotifier::CONNECTION_2G);
+ EXPECT_TRUE(network_metrics_provider.effective_connection_type_is_ambiguous_);
+ network_metrics_provider.ProvideSystemProfileMetrics(&system_profile);
+ EXPECT_EQ(SystemProfileProto::Network::EFFECTIVE_CONNECTION_TYPE_AMBIGUOUS,
+ system_profile.network().effective_connection_type());
+}
+
} // namespace metrics
« no previous file with comments | « components/metrics/net/network_metrics_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698