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

Side by Side Diff: components/metrics/net/network_metrics_provider_unittest.cc

Issue 2661563004: Mark ECT as ambiguous if there is a change in the connection type. (Closed)
Patch Set: ps Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « components/metrics/net/network_metrics_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "components/metrics/net/network_metrics_provider.h" 5 #include "components/metrics/net/network_metrics_provider.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 system_profile.network().effective_connection_type()); 104 system_profile.network().effective_connection_type());
105 105
106 // Getting the system profile again should return the actual effective 106 // Getting the system profile again should return the actual effective
107 // connection type since the effective connection type did not change during 107 // connection type since the effective connection type did not change during
108 // the lifetime of the log. 108 // the lifetime of the log.
109 network_metrics_provider.ProvideSystemProfileMetrics(&system_profile); 109 network_metrics_provider.ProvideSystemProfileMetrics(&system_profile);
110 EXPECT_EQ(SystemProfileProto::Network::EFFECTIVE_CONNECTION_TYPE_SLOW_2G, 110 EXPECT_EQ(SystemProfileProto::Network::EFFECTIVE_CONNECTION_TYPE_SLOW_2G,
111 system_profile.network().effective_connection_type()); 111 system_profile.network().effective_connection_type());
112 } 112 }
113 113
114 // Verifies that the effective connection type is set to AMBIGUOUS when there is
115 // a change in the connection type.
116 TEST(NetworkMetricsProviderTest, ECTAmbiguousOnConnectionTypeChange) {
117 base::MessageLoop loop(base::MessageLoop::TYPE_IO);
118
119 #if defined(OS_CHROMEOS)
120 chromeos::DBusThreadManager::Initialize();
121 chromeos::NetworkHandler::Initialize();
122 #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.
123
124 net::TestNetworkQualityEstimator estimator;
125 std::unique_ptr<NetworkMetricsProvider::NetworkQualityEstimatorProvider>
126 estimator_provider(base::WrapUnique(
127 new TestNetworkQualityEstimatorProvider(&estimator)));
128 SystemProfileProto system_profile;
129 NetworkMetricsProvider network_metrics_provider(
130 std::move(estimator_provider), base::ThreadTaskRunnerHandle::Get().get());
131
132 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN,
133 network_metrics_provider.effective_connection_type_);
134 EXPECT_FALSE(
135 network_metrics_provider.effective_connection_type_is_ambiguous_);
136
137 network_metrics_provider.OnConnectionTypeChanged(
138 net::NetworkChangeNotifier::CONNECTION_2G);
139 EXPECT_TRUE(network_metrics_provider.effective_connection_type_is_ambiguous_);
140 network_metrics_provider.ProvideSystemProfileMetrics(&system_profile);
141 EXPECT_EQ(SystemProfileProto::Network::EFFECTIVE_CONNECTION_TYPE_AMBIGUOUS,
142 system_profile.network().effective_connection_type());
143 }
144
114 } // namespace metrics 145 } // namespace metrics
OLDNEW
« 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