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

Side by Side Diff: net/nqe/network_quality_estimator_unittest.cc

Issue 2443293002: Record main frame UMA without breaking down by the connection type. (Closed)
Patch Set: Created 4 years, 1 month 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 | « net/nqe/network_quality_estimator.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "net/nqe/network_quality_estimator.h" 5 #include "net/nqe/network_quality_estimator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 // Both RTT and downstream throughput should be updated. 179 // Both RTT and downstream throughput should be updated.
180 EXPECT_TRUE(estimator.GetHttpRTT(&rtt)); 180 EXPECT_TRUE(estimator.GetHttpRTT(&rtt));
181 EXPECT_TRUE(estimator.GetDownlinkThroughputKbps(&kbps)); 181 EXPECT_TRUE(estimator.GetDownlinkThroughputKbps(&kbps));
182 EXPECT_FALSE(estimator.GetTransportRTT(&rtt)); 182 EXPECT_FALSE(estimator.GetTransportRTT(&rtt));
183 183
184 // Check UMA histograms. 184 // Check UMA histograms.
185 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 0); 185 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 0);
186 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 0); 186 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 0);
187 histogram_tester.ExpectUniqueSample( 187 histogram_tester.ExpectUniqueSample(
188 "NQE.MainFrame.EffectiveConnectionType",
189 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
190 histogram_tester.ExpectUniqueSample(
188 "NQE.MainFrame.EffectiveConnectionType.Unknown", 191 "NQE.MainFrame.EffectiveConnectionType.Unknown",
189 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); 192 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
190 193
191 std::unique_ptr<URLRequest> request2(context.CreateRequest( 194 std::unique_ptr<URLRequest> request2(context.CreateRequest(
192 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 195 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
193 request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); 196 request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
194 request2->Start(); 197 request2->Start();
195 base::RunLoop().Run(); 198 base::RunLoop().Run();
199 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", 2);
196 histogram_tester.ExpectTotalCount( 200 histogram_tester.ExpectTotalCount(
197 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2); 201 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2);
198 202
199 estimator.SimulateNetworkChange( 203 estimator.SimulateNetworkChange(
200 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); 204 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1");
201 histogram_tester.ExpectUniqueSample("NQE.CachedNetworkQualityAvailable", 205 histogram_tester.ExpectUniqueSample("NQE.CachedNetworkQualityAvailable",
202 false, 2); 206 false, 2);
203 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1); 207 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1);
204 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1); 208 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1);
205 209
206 histogram_tester.ExpectTotalCount("NQE.RatioMedianRTT.WiFi", 0); 210 histogram_tester.ExpectTotalCount("NQE.RatioMedianRTT.WiFi", 0);
207 211
208 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile0.Unknown", 1); 212 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile0.Unknown", 1);
209 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile10.Unknown", 1); 213 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile10.Unknown", 1);
210 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile50.Unknown", 1); 214 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile50.Unknown", 1);
211 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile90.Unknown", 1); 215 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile90.Unknown", 1);
212 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile100.Unknown", 1); 216 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile100.Unknown", 1);
213 217
214 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 0); 218 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 0);
215 219
216 EXPECT_FALSE(estimator.GetHttpRTT(&rtt)); 220 EXPECT_FALSE(estimator.GetHttpRTT(&rtt));
217 EXPECT_FALSE(estimator.GetDownlinkThroughputKbps(&kbps)); 221 EXPECT_FALSE(estimator.GetDownlinkThroughputKbps(&kbps));
218 222
219 // Verify that metrics are logged correctly on main-frame requests. 223 // Verify that metrics are logged correctly on main-frame requests.
224 histogram_tester.ExpectTotalCount("NQE.MainFrame.RTT.Percentile50", 1);
220 histogram_tester.ExpectTotalCount("NQE.MainFrame.RTT.Percentile50.Unknown", 225 histogram_tester.ExpectTotalCount("NQE.MainFrame.RTT.Percentile50.Unknown",
221 1); 226 1);
227 histogram_tester.ExpectTotalCount("NQE.MainFrame.TransportRTT.Percentile50",
228 0);
222 histogram_tester.ExpectTotalCount( 229 histogram_tester.ExpectTotalCount(
223 "NQE.MainFrame.TransportRTT.Percentile50.Unknown", 0); 230 "NQE.MainFrame.TransportRTT.Percentile50.Unknown", 0);
231 histogram_tester.ExpectTotalCount("NQE.MainFrame.Kbps.Percentile50", 1);
224 histogram_tester.ExpectTotalCount("NQE.MainFrame.Kbps.Percentile50.Unknown", 232 histogram_tester.ExpectTotalCount("NQE.MainFrame.Kbps.Percentile50.Unknown",
225 1); 233 1);
226 234
227 estimator.SimulateNetworkChange( 235 estimator.SimulateNetworkChange(
228 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, std::string()); 236 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, std::string());
229 histogram_tester.ExpectUniqueSample("NQE.CachedNetworkQualityAvailable", 237 histogram_tester.ExpectUniqueSample("NQE.CachedNetworkQualityAvailable",
230 false, 3); 238 false, 3);
231 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1); 239 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1);
232 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1); 240 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1);
233 241
234 EXPECT_FALSE(estimator.GetHttpRTT(&rtt)); 242 EXPECT_FALSE(estimator.GetHttpRTT(&rtt));
235 EXPECT_FALSE(estimator.GetDownlinkThroughputKbps(&kbps)); 243 EXPECT_FALSE(estimator.GetDownlinkThroughputKbps(&kbps));
236 244
237 std::unique_ptr<URLRequest> request3(context.CreateRequest( 245 std::unique_ptr<URLRequest> request3(context.CreateRequest(
238 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 246 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
239 request3->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); 247 request3->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
240 request3->Start(); 248 request3->Start();
241 base::RunLoop().Run(); 249 base::RunLoop().Run();
242 histogram_tester.ExpectUniqueSample( 250 histogram_tester.ExpectUniqueSample(
243 "NQE.MainFrame.EffectiveConnectionType.WiFi", 251 "NQE.MainFrame.EffectiveConnectionType.WiFi",
244 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); 252 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
253 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", 3);
245 254
246 estimator.SimulateNetworkChange( 255 estimator.SimulateNetworkChange(
247 NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN, "test"); 256 NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN, "test");
248 histogram_tester.ExpectBucketCount("NQE.CachedNetworkQualityAvailable", false, 257 histogram_tester.ExpectBucketCount("NQE.CachedNetworkQualityAvailable", false,
249 3); 258 3);
250 histogram_tester.ExpectBucketCount("NQE.CachedNetworkQualityAvailable", true, 259 histogram_tester.ExpectBucketCount("NQE.CachedNetworkQualityAvailable", true,
251 1); 260 1);
252 } 261 }
253 262
254 // Tests that the network quality estimator writes and reads network quality 263 // Tests that the network quality estimator writes and reads network quality
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 1348
1340 estimator.set_recent_effective_connection_type(EFFECTIVE_CONNECTION_TYPE_2G); 1349 estimator.set_recent_effective_connection_type(EFFECTIVE_CONNECTION_TYPE_2G);
1341 tick_clock_ptr->Advance(base::TimeDelta::FromMinutes(60)); 1350 tick_clock_ptr->Advance(base::TimeDelta::FromMinutes(60));
1342 1351
1343 std::unique_ptr<URLRequest> request(context.CreateRequest( 1352 std::unique_ptr<URLRequest> request(context.CreateRequest(
1344 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1353 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1345 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); 1354 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1346 request->Start(); 1355 request->Start();
1347 base::RunLoop().Run(); 1356 base::RunLoop().Run();
1348 EXPECT_EQ(1U, observer.effective_connection_types().size()); 1357 EXPECT_EQ(1U, observer.effective_connection_types().size());
1358 histogram_tester.ExpectUniqueSample("NQE.MainFrame.EffectiveConnectionType",
1359 EFFECTIVE_CONNECTION_TYPE_2G, 1);
1349 histogram_tester.ExpectUniqueSample( 1360 histogram_tester.ExpectUniqueSample(
1350 "NQE.MainFrame.EffectiveConnectionType.Unknown", 1361 "NQE.MainFrame.EffectiveConnectionType.Unknown",
1351 EFFECTIVE_CONNECTION_TYPE_2G, 1); 1362 EFFECTIVE_CONNECTION_TYPE_2G, 1);
1352 1363
1353 // Next request should not trigger recomputation of effective connection type 1364 // Next request should not trigger recomputation of effective connection type
1354 // since there has been no change in the clock. 1365 // since there has been no change in the clock.
1355 std::unique_ptr<URLRequest> request2(context.CreateRequest( 1366 std::unique_ptr<URLRequest> request2(context.CreateRequest(
1356 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1367 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1357 request2->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); 1368 request2->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1358 request2->Start(); 1369 request2->Start();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 1523
1513 estimator.set_recent_effective_connection_type(EFFECTIVE_CONNECTION_TYPE_2G); 1524 estimator.set_recent_effective_connection_type(EFFECTIVE_CONNECTION_TYPE_2G);
1514 tick_clock_ptr->Advance(base::TimeDelta::FromMinutes(60)); 1525 tick_clock_ptr->Advance(base::TimeDelta::FromMinutes(60));
1515 1526
1516 std::unique_ptr<URLRequest> request(context.CreateRequest( 1527 std::unique_ptr<URLRequest> request(context.CreateRequest(
1517 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1528 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1518 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); 1529 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1519 request->Start(); 1530 request->Start();
1520 base::RunLoop().Run(); 1531 base::RunLoop().Run();
1521 EXPECT_EQ(1U, observer.effective_connection_types().size()); 1532 EXPECT_EQ(1U, observer.effective_connection_types().size());
1533 histogram_tester.ExpectUniqueSample("NQE.MainFrame.EffectiveConnectionType",
1534 EFFECTIVE_CONNECTION_TYPE_2G, 1);
1522 histogram_tester.ExpectUniqueSample( 1535 histogram_tester.ExpectUniqueSample(
1523 "NQE.MainFrame.EffectiveConnectionType.WiFi", 1536 "NQE.MainFrame.EffectiveConnectionType.WiFi",
1524 EFFECTIVE_CONNECTION_TYPE_2G, 1); 1537 EFFECTIVE_CONNECTION_TYPE_2G, 1);
1525 1538
1526 size_t expected_effective_connection_type_notifications = 1; 1539 size_t expected_effective_connection_type_notifications = 1;
1527 EXPECT_EQ(expected_effective_connection_type_notifications, 1540 EXPECT_EQ(expected_effective_connection_type_notifications,
1528 observer.effective_connection_types().size()); 1541 observer.effective_connection_types().size());
1529 1542
1530 EXPECT_EQ(expected_effective_connection_type_notifications, 1543 EXPECT_EQ(expected_effective_connection_type_notifications,
1531 estimator.rtt_observations_.Size()); 1544 estimator.rtt_observations_.Size());
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); 1732 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1);
1720 histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.Unknown", 1733 histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.Unknown",
1721 rtt.InMilliseconds(), 1); 1734 rtt.InMilliseconds(), 1);
1722 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.Unknown", 1); 1735 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.Unknown", 1);
1723 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); 1736 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1);
1724 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.Unknown", 1); 1737 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.Unknown", 1);
1725 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.Unknown", 1738 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.Unknown",
1726 1); 1739 1);
1727 1740
1728 // Verify that metrics are logged correctly on main-frame requests. 1741 // Verify that metrics are logged correctly on main-frame requests.
1742 histogram_tester.ExpectTotalCount("NQE.MainFrame.TransportRTT.Percentile50",
1743 num_requests);
1729 histogram_tester.ExpectTotalCount( 1744 histogram_tester.ExpectTotalCount(
1730 "NQE.MainFrame.TransportRTT.Percentile50.Unknown", num_requests); 1745 "NQE.MainFrame.TransportRTT.Percentile50.Unknown", num_requests);
1746 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType",
1747 num_requests);
1731 histogram_tester.ExpectTotalCount( 1748 histogram_tester.ExpectTotalCount(
1732 "NQE.MainFrame.EffectiveConnectionType.Unknown", num_requests); 1749 "NQE.MainFrame.EffectiveConnectionType.Unknown", num_requests);
1733 histogram_tester.ExpectBucketCount( 1750 histogram_tester.ExpectBucketCount(
1734 "NQE.MainFrame.EffectiveConnectionType.Unknown", 1751 "NQE.MainFrame.EffectiveConnectionType.Unknown",
1735 EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); 1752 EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
1736 } 1753 }
1737 1754
1738 #if defined(OS_IOS) 1755 #if defined(OS_IOS)
1739 // Flaky on iOS when |accuracy_recording_delay| is non-zero. 1756 // Flaky on iOS when |accuracy_recording_delay| is non-zero.
1740 #define MAYBE_RecordAccuracy DISABLED_RecordAccuracy 1757 #define MAYBE_RecordAccuracy DISABLED_RecordAccuracy
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 if (expected_count == 1) { 2205 if (expected_count == 1) {
2189 EffectiveConnectionType last_notified_type = 2206 EffectiveConnectionType last_notified_type =
2190 observer.effective_connection_types().at( 2207 observer.effective_connection_types().at(
2191 observer.effective_connection_types().size() - 1); 2208 observer.effective_connection_types().size() - 1);
2192 EXPECT_EQ(i, last_notified_type); 2209 EXPECT_EQ(i, last_notified_type);
2193 } 2210 }
2194 } 2211 }
2195 } 2212 }
2196 2213
2197 } // namespace net 2214 } // namespace net
OLDNEW
« 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