Chromium Code Reviews| 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..b1d57f8b557e728dcdf326df38b31148406ec7bc 100644 |
| --- a/components/metrics/net/network_metrics_provider_unittest.cc |
| +++ b/components/metrics/net/network_metrics_provider_unittest.cc |
| @@ -111,4 +111,35 @@ 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(NetworkMetricsProviderTest, ECTAmbiguousOnConnectionTypeChange) { |
| + base::MessageLoop loop(base::MessageLoop::TYPE_IO); |
| + |
| +#if defined(OS_CHROMEOS) |
| + chromeos::DBusThreadManager::Initialize(); |
| + chromeos::NetworkHandler::Initialize(); |
| +#endif // OS_CHROMEOS |
|
Alexei Svitkine (slow)
2017/01/27 22:01:40
Nit: Can this goop go into the test harness ctor?
tbansal1
2017/01/29 07:12:27
Done.
|
| + |
| + 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 |