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

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

Issue 2654033010: NQE: Record the number of RTT and throughput samples received (Closed)
Patch Set: 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
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 26 matching lines...) Expand all
37 #include "net/nqe/network_quality_observation.h" 37 #include "net/nqe/network_quality_observation.h"
38 #include "net/nqe/network_quality_observation_source.h" 38 #include "net/nqe/network_quality_observation_source.h"
39 #include "net/nqe/observation_buffer.h" 39 #include "net/nqe/observation_buffer.h"
40 #include "net/socket/socket_performance_watcher.h" 40 #include "net/socket/socket_performance_watcher.h"
41 #include "net/socket/socket_performance_watcher_factory.h" 41 #include "net/socket/socket_performance_watcher_factory.h"
42 #include "net/url_request/url_request.h" 42 #include "net/url_request/url_request.h"
43 #include "net/url_request/url_request_test_util.h" 43 #include "net/url_request/url_request_test_util.h"
44 #include "testing/gtest/include/gtest/gtest.h" 44 #include "testing/gtest/include/gtest/gtest.h"
45 #include "url/gurl.h" 45 #include "url/gurl.h"
46 46
47 namespace {
48
49 // Verifies that the number of samples in the bucket with minimum value
50 // |bucket_min| in |histogram| are at least |expected_min_count_samples|.
51 void VerifyBucketCountAtLeast(base::HistogramTester* histogram_tester,
RyanSturm 2017/01/31 19:57:57 I feel like this could be generalized in the Histo
tbansal1 2017/02/02 02:35:36 Done.
52 const std::string& histogram,
53 int32_t bucket_min,
54 int32_t expected_min_count_samples) {
55 std::vector<base::Bucket> buckets =
56 histogram_tester->GetAllSamples(histogram);
57 int actual_count_samples = 0;
58 for (const auto& bucket : buckets) {
59 if (bucket.min == bucket_min)
60 actual_count_samples += bucket.count;
61 }
62 EXPECT_LE(expected_min_count_samples, actual_count_samples);
63 }
64
65 } // namespace
66
47 namespace net { 67 namespace net {
48 68
49 namespace { 69 namespace {
50 70
51 class TestEffectiveConnectionTypeObserver 71 class TestEffectiveConnectionTypeObserver
52 : public NetworkQualityEstimator::EffectiveConnectionTypeObserver { 72 : public NetworkQualityEstimator::EffectiveConnectionTypeObserver {
53 public: 73 public:
54 std::vector<EffectiveConnectionType>& effective_connection_types() { 74 std::vector<EffectiveConnectionType>& effective_connection_types() {
55 return effective_connection_types_; 75 return effective_connection_types_;
56 } 76 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); 241 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
222 histogram_tester.ExpectUniqueSample( 242 histogram_tester.ExpectUniqueSample(
223 "NQE.MainFrame.EffectiveConnectionType.Unknown", 243 "NQE.MainFrame.EffectiveConnectionType.Unknown",
224 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); 244 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
225 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.RTT", 0, 245 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.RTT", 0,
226 1); 246 1);
227 histogram_tester.ExpectUniqueSample( 247 histogram_tester.ExpectUniqueSample(
228 "NQE.EstimateAvailable.MainFrame.TransportRTT", 0, 1); 248 "NQE.EstimateAvailable.MainFrame.TransportRTT", 0, 1);
229 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.Kbps", 0, 249 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.Kbps", 0,
230 1); 250 1);
251 histogram_tester.ExpectBucketCount(
252 "NQE.RTT.ObservationSource", NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP, 1);
253 histogram_tester.ExpectBucketCount(
254 "NQE.Kbps.ObservationSource", NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP, 1);
231 255
232 std::unique_ptr<URLRequest> request2(context.CreateRequest( 256 std::unique_ptr<URLRequest> request2(context.CreateRequest(
233 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 257 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
234 request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); 258 request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
235 request2->Start(); 259 request2->Start();
236 base::RunLoop().Run(); 260 base::RunLoop().Run();
237 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", 2); 261 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", 2);
238 histogram_tester.ExpectTotalCount( 262 histogram_tester.ExpectTotalCount(
239 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2); 263 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2);
240 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 1, 264 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 1,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 estimator.AddThroughputObserver(&throughput_observer); 395 estimator.AddThroughputObserver(&throughput_observer);
372 396
373 // |observer| should be notified as soon as it is added. 397 // |observer| should be notified as soon as it is added.
374 base::RunLoop().RunUntilIdle(); 398 base::RunLoop().RunUntilIdle();
375 EXPECT_EQ(1U, observer.effective_connection_types().size()); 399 EXPECT_EQ(1U, observer.effective_connection_types().size());
376 EXPECT_EQ( 400 EXPECT_EQ(
377 2, estimator.GetEntriesCount(NetLogEventType::NETWORK_QUALITY_CHANGED)); 401 2, estimator.GetEntriesCount(NetLogEventType::NETWORK_QUALITY_CHANGED));
378 402
379 estimator.SimulateNetworkChange( 403 estimator.SimulateNetworkChange(
380 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test"); 404 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test");
405 histogram_tester.ExpectBucketCount(
406 "NQE.RTT.ObservationSource",
407 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE, 1);
408 histogram_tester.ExpectBucketCount(
409 "NQE.Kbps.ObservationSource",
410 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE, 1);
381 411
382 // Verify the contents of the net log. 412 // Verify the contents of the net log.
383 EXPECT_LE( 413 EXPECT_LE(
384 3, estimator.GetEntriesCount(NetLogEventType::NETWORK_QUALITY_CHANGED)); 414 3, estimator.GetEntriesCount(NetLogEventType::NETWORK_QUALITY_CHANGED));
385 EXPECT_NE(-1, estimator.GetNetLogLastIntegerValue( 415 EXPECT_NE(-1, estimator.GetNetLogLastIntegerValue(
386 NetLogEventType::NETWORK_QUALITY_CHANGED, "http_rtt_ms")); 416 NetLogEventType::NETWORK_QUALITY_CHANGED, "http_rtt_ms"));
387 EXPECT_EQ(-1, 417 EXPECT_EQ(-1,
388 estimator.GetNetLogLastIntegerValue( 418 estimator.GetNetLogLastIntegerValue(
389 NetLogEventType::NETWORK_QUALITY_CHANGED, "transport_rtt_ms")); 419 NetLogEventType::NETWORK_QUALITY_CHANGED, "transport_rtt_ms"));
390 EXPECT_NE(-1, estimator.GetNetLogLastIntegerValue( 420 EXPECT_NE(-1, estimator.GetNetLogLastIntegerValue(
(...skipping 13 matching lines...) Expand all
404 // Verify that the cached network quality was read, and observers were 434 // Verify that the cached network quality was read, and observers were
405 // notified. |observer| must be notified once right after it was added, and 435 // notified. |observer| must be notified once right after it was added, and
406 // once again after the cached network quality was read. 436 // once again after the cached network quality was read.
407 EXPECT_LE(2U, observer.effective_connection_types().size()); 437 EXPECT_LE(2U, observer.effective_connection_types().size());
408 EXPECT_EQ(estimator.GetEffectiveConnectionType(), 438 EXPECT_EQ(estimator.GetEffectiveConnectionType(),
409 observer.effective_connection_types().back()); 439 observer.effective_connection_types().back());
410 EXPECT_EQ(1U, rtt_observer.observations().size()); 440 EXPECT_EQ(1U, rtt_observer.observations().size());
411 EXPECT_EQ(1U, throughput_observer.observations().size()); 441 EXPECT_EQ(1U, throughput_observer.observations().size());
412 } 442 }
413 443
444 TEST(NetworkQualityEstimatorTest, QuicObservations) {
445 base::HistogramTester histogram_tester;
446 TestNetworkQualityEstimator estimator;
447 estimator.OnUpdatedRTTAvailable(SocketPerformanceWatcherFactory::PROTOCOL_TCP,
448 base::TimeDelta::FromMilliseconds(10));
449 estimator.OnUpdatedRTTAvailable(
450 SocketPerformanceWatcherFactory::PROTOCOL_QUIC,
451 base::TimeDelta::FromMilliseconds(10));
452 histogram_tester.ExpectBucketCount("NQE.RTT.ObservationSource",
453 NETWORK_QUALITY_OBSERVATION_SOURCE_TCP, 1);
454 histogram_tester.ExpectBucketCount(
455 "NQE.RTT.ObservationSource", NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC, 1);
456 histogram_tester.ExpectTotalCount("NQE.RTT.ObservationSource", 2);
457 }
458
414 TEST(NetworkQualityEstimatorTest, StoreObservations) { 459 TEST(NetworkQualityEstimatorTest, StoreObservations) {
415 TestNetworkQualityEstimator estimator; 460 TestNetworkQualityEstimator estimator;
416 461
417 base::TimeDelta rtt; 462 base::TimeDelta rtt;
418 int32_t kbps; 463 int32_t kbps;
419 EXPECT_FALSE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); 464 EXPECT_FALSE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt));
420 EXPECT_FALSE( 465 EXPECT_FALSE(
421 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); 466 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
422 467
423 TestDelegate test_delegate; 468 TestDelegate test_delegate;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 base::TimeTicks(), i), 543 base::TimeTicks(), i),
499 estimator.GetRTTEstimateInternal(disallowed_observation_sources, 544 estimator.GetRTTEstimateInternal(disallowed_observation_sources,
500 base::TimeTicks(), i - 1)); 545 base::TimeTicks(), i - 1));
501 } 546 }
502 } 547 }
503 } 548 }
504 549
505 // Verifies that the observers receive the notifications when default estimates 550 // Verifies that the observers receive the notifications when default estimates
506 // are added to the observations. 551 // are added to the observations.
507 TEST(NetworkQualityEstimatorTest, DefaultObservations) { 552 TEST(NetworkQualityEstimatorTest, DefaultObservations) {
553 base::HistogramTester histogram_tester;
554
508 TestEffectiveConnectionTypeObserver effective_connection_type_observer; 555 TestEffectiveConnectionTypeObserver effective_connection_type_observer;
509 TestRTTAndThroughputEstimatesObserver rtt_throughput_estimates_observer; 556 TestRTTAndThroughputEstimatesObserver rtt_throughput_estimates_observer;
510 TestRTTObserver rtt_observer; 557 TestRTTObserver rtt_observer;
511 TestThroughputObserver throughput_observer; 558 TestThroughputObserver throughput_observer;
512 std::map<std::string, std::string> variation_params; 559 std::map<std::string, std::string> variation_params;
513 TestNetworkQualityEstimator estimator( 560 TestNetworkQualityEstimator estimator(
514 nullptr, variation_params, false, false, 561 nullptr, variation_params, false, false,
515 true /* add_default_platform_observations */, 562 true /* add_default_platform_observations */,
516 base::MakeUnique<BoundTestNetLog>()); 563 base::MakeUnique<BoundTestNetLog>());
564
565 histogram_tester.ExpectBucketCount(
566 "NQE.RTT.ObservationSource",
567 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_HTTP_FROM_PLATFORM, 1);
568 histogram_tester.ExpectBucketCount(
569 "NQE.RTT.ObservationSource",
570 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_TRANSPORT_FROM_PLATFORM, 1);
571 histogram_tester.ExpectBucketCount(
572 "NQE.Kbps.ObservationSource",
573 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_HTTP_FROM_PLATFORM, 1);
574 histogram_tester.ExpectTotalCount("NQE.RTT.ObservationSource", 2);
575 histogram_tester.ExpectTotalCount("NQE.Kbps.ObservationSource", 1);
576
517 base::TimeDelta rtt; 577 base::TimeDelta rtt;
518 int32_t kbps; 578 int32_t kbps;
519 579
520 // Default estimates should be available. 580 // Default estimates should be available.
521 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); 581 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt));
522 EXPECT_EQ(base::TimeDelta::FromMilliseconds(115), rtt); 582 EXPECT_EQ(base::TimeDelta::FromMilliseconds(115), rtt);
523 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); 583 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt));
524 EXPECT_EQ(base::TimeDelta::FromMilliseconds(55), rtt); 584 EXPECT_EQ(base::TimeDelta::FromMilliseconds(55), rtt);
525 EXPECT_TRUE( 585 EXPECT_TRUE(
526 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); 586 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 histogram_tester.ExpectBucketCount( 1461 histogram_tester.ExpectBucketCount(
1402 "NQE.ExternalEstimateProviderStatus", 1462 "NQE.ExternalEstimateProviderStatus",
1403 5 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE */, 1); 1463 5 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE */, 1);
1404 histogram_tester.ExpectBucketCount( 1464 histogram_tester.ExpectBucketCount(
1405 "NQE.ExternalEstimateProviderStatus", 1465 "NQE.ExternalEstimateProviderStatus",
1406 6 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE */, 1466 6 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE */,
1407 1); 1467 1);
1408 histogram_tester.ExpectUniqueSample("NQE.ExternalEstimateProvider.RTT", 1, 1); 1468 histogram_tester.ExpectUniqueSample("NQE.ExternalEstimateProvider.RTT", 1, 1);
1409 histogram_tester.ExpectUniqueSample( 1469 histogram_tester.ExpectUniqueSample(
1410 "NQE.ExternalEstimateProvider.DownlinkBandwidth", 100, 1); 1470 "NQE.ExternalEstimateProvider.DownlinkBandwidth", 100, 1);
1471 histogram_tester.ExpectBucketCount(
1472 "NQE.RTT.ObservationSource",
1473 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_EXTERNAL_ESTIMATE, 1);
1474 histogram_tester.ExpectBucketCount(
1475 "NQE.Kbps.ObservationSource",
1476 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_EXTERNAL_ESTIMATE, 1);
1411 1477
1412 EXPECT_EQ(1U, test_external_estimate_provider->update_count()); 1478 EXPECT_EQ(1U, test_external_estimate_provider->update_count());
1413 1479
1414 // Change network type to WiFi. Number of queries to External estimate 1480 // Change network type to WiFi. Number of queries to External estimate
1415 // provider must increment. 1481 // provider must increment.
1416 estimator.SimulateNetworkChange( 1482 estimator.SimulateNetworkChange(
1417 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); 1483 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1");
1418 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); 1484 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt));
1419 EXPECT_TRUE( 1485 EXPECT_TRUE(
1420 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); 1486 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 int32_t kbps; 1525 int32_t kbps;
1460 EXPECT_TRUE( 1526 EXPECT_TRUE(
1461 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); 1527 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
1462 EXPECT_EQ(external_estimate_provider_downstream_throughput, kbps); 1528 EXPECT_EQ(external_estimate_provider_downstream_throughput, kbps);
1463 1529
1464 TestDelegate test_delegate; 1530 TestDelegate test_delegate;
1465 TestURLRequestContext context(true); 1531 TestURLRequestContext context(true);
1466 context.set_network_quality_estimator(&estimator); 1532 context.set_network_quality_estimator(&estimator);
1467 context.Init(); 1533 context.Init();
1468 1534
1469 std::unique_ptr<URLRequest> request(context.CreateRequest( 1535 for (size_t i = 0; i < 2; ++i) {
1470 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1536 // Start 2 requests to ensure that the RTT estimate computed by the network
1471 request->Start(); 1537 // quality estimator takes into account the RTT observations from the
1472 base::RunLoop().Run(); 1538 // external estimate provider as well as organic observations.
1539 std::unique_ptr<URLRequest> request(context.CreateRequest(
1540 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1541 request->Start();
1542 base::RunLoop().Run();
1543 }
1473 1544
1474 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); 1545 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt));
1475 EXPECT_NE(external_estimate_provider_rtt, rtt); 1546 EXPECT_NE(external_estimate_provider_rtt, rtt);
1476 1547
1477 EXPECT_TRUE( 1548 EXPECT_TRUE(
1478 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); 1549 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
1479 EXPECT_NE(external_estimate_provider_downstream_throughput, kbps); 1550 EXPECT_NE(external_estimate_provider_downstream_throughput, kbps);
1480 } 1551 }
1481 1552
1482 // Tests if the throughput observation is taken correctly when local and network 1553 // Tests if the throughput observation is taken correctly when local and network
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 #define MAYBE_TestTCPSocketRTT TestTCPSocketRTT 2022 #define MAYBE_TestTCPSocketRTT TestTCPSocketRTT
1952 #else 2023 #else
1953 #define MAYBE_TestTCPSocketRTT DISABLED_TestTCPSocketRTT 2024 #define MAYBE_TestTCPSocketRTT DISABLED_TestTCPSocketRTT
1954 #endif 2025 #endif
1955 // Tests that the TCP socket notifies the Network Quality Estimator of TCP RTTs, 2026 // Tests that the TCP socket notifies the Network Quality Estimator of TCP RTTs,
1956 // which in turn notifies registered RTT observers. 2027 // which in turn notifies registered RTT observers.
1957 TEST(NetworkQualityEstimatorTest, MAYBE_TestTCPSocketRTT) { 2028 TEST(NetworkQualityEstimatorTest, MAYBE_TestTCPSocketRTT) {
1958 base::HistogramTester histogram_tester; 2029 base::HistogramTester histogram_tester;
1959 TestRTTObserver rtt_observer; 2030 TestRTTObserver rtt_observer;
1960 TestNetworkQualityEstimator estimator; 2031 TestNetworkQualityEstimator estimator;
2032 estimator.SimulateNetworkChange(
2033 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test");
2034
1961 estimator.AddRTTObserver(&rtt_observer); 2035 estimator.AddRTTObserver(&rtt_observer);
1962 2036
1963 TestDelegate test_delegate; 2037 TestDelegate test_delegate;
1964 TestURLRequestContext context(true); 2038 TestURLRequestContext context(true);
1965 context.set_network_quality_estimator(&estimator); 2039 context.set_network_quality_estimator(&estimator);
1966 2040
1967 std::unique_ptr<HttpNetworkSession::Params> params( 2041 std::unique_ptr<HttpNetworkSession::Params> params(
1968 new HttpNetworkSession::Params); 2042 new HttpNetworkSession::Params);
1969 // |estimator| should be notified of TCP RTT observations. 2043 // |estimator| should be notified of TCP RTT observations.
1970 params->socket_performance_watcher_factory = 2044 params->socket_performance_watcher_factory =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 // watcher. 2076 // watcher.
2003 EXPECT_LE(1U, after_count_tcp_rtt_observations - 2077 EXPECT_LE(1U, after_count_tcp_rtt_observations -
2004 before_count_tcp_rtt_observations) 2078 before_count_tcp_rtt_observations)
2005 << i; 2079 << i;
2006 } 2080 }
2007 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); 2081 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt));
2008 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); 2082 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt));
2009 2083
2010 estimator.SimulateNetworkChange( 2084 estimator.SimulateNetworkChange(
2011 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); 2085 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1");
2012 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); 2086 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.2G", 1);
2013 histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.Unknown", 2087 histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.2G",
2014 rtt.InMilliseconds(), 1); 2088 rtt.InMilliseconds(), 1);
2015 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.Unknown", 1); 2089 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.2G", 1);
2016 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); 2090 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.2G", 1);
2017 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.Unknown", 1); 2091 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.2G", 1);
2018 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.Unknown", 2092 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.2G", 1);
2019 1);
2020 2093
2021 // Verify that metrics are logged correctly on main-frame requests. 2094 // Verify that metrics are logged correctly on main-frame requests.
2022 histogram_tester.ExpectTotalCount("NQE.MainFrame.TransportRTT.Percentile50", 2095 histogram_tester.ExpectTotalCount("NQE.MainFrame.TransportRTT.Percentile50",
2023 num_requests); 2096 num_requests);
2024 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 0, 2097 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 0,
2025 1); 2098 1);
2026 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 1, 2099 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 1,
2027 num_requests - 1); 2100 num_requests - 1);
2028 histogram_tester.ExpectUniqueSample( 2101 histogram_tester.ExpectUniqueSample(
2029 "NQE.EstimateAvailable.MainFrame.TransportRTT", 1, num_requests); 2102 "NQE.EstimateAvailable.MainFrame.TransportRTT", 1, num_requests);
2030 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.Kbps", 0, 2103 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.Kbps", 0,
2031 1); 2104 1);
2032 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.Kbps", 1, 2105 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.Kbps", 1,
2033 num_requests - 1); 2106 num_requests - 1);
2034 2107
2035 histogram_tester.ExpectTotalCount( 2108 histogram_tester.ExpectTotalCount(
2036 "NQE.MainFrame.TransportRTT.Percentile50.Unknown", num_requests); 2109 "NQE.MainFrame.TransportRTT.Percentile50.2G", num_requests);
2037 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", 2110 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType",
2038 num_requests); 2111 num_requests);
2039 histogram_tester.ExpectTotalCount( 2112 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType.2G",
2040 "NQE.MainFrame.EffectiveConnectionType.Unknown", num_requests); 2113 num_requests);
2114 histogram_tester.ExpectBucketCount("NQE.MainFrame.EffectiveConnectionType.2G",
2115 EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
2116 VerifyBucketCountAtLeast(&histogram_tester, "NQE.RTT.ObservationSource",
2117 NETWORK_QUALITY_OBSERVATION_SOURCE_TCP, 1);
2118 VerifyBucketCountAtLeast(&histogram_tester, "NQE.Kbps.ObservationSource",
2119 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP, 1);
2041 histogram_tester.ExpectBucketCount( 2120 histogram_tester.ExpectBucketCount(
2042 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2121 "NQE.Kbps.ObservationSource",
2043 EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); 2122 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE, 0);
2123
2124 estimator.SimulateNetworkChange(
2125 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test");
2126 histogram_tester.ExpectBucketCount(
2127 "NQE.RTT.ObservationSource",
2128 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE, 1);
2044 } 2129 }
2045 2130
2046 #if defined(OS_IOS) 2131 #if defined(OS_IOS)
2047 // Flaky on iOS when |accuracy_recording_delay| is non-zero. 2132 // Flaky on iOS when |accuracy_recording_delay| is non-zero.
2048 #define MAYBE_RecordAccuracy DISABLED_RecordAccuracy 2133 #define MAYBE_RecordAccuracy DISABLED_RecordAccuracy
2049 #else 2134 #else
2050 #define MAYBE_RecordAccuracy RecordAccuracy 2135 #define MAYBE_RecordAccuracy RecordAccuracy
2051 #endif 2136 #endif
2052 // Tests if the NQE accuracy metrics are recorded properly. 2137 // Tests if the NQE accuracy metrics are recorded properly.
2053 TEST(NetworkQualityEstimatorTest, MAYBE_RecordAccuracy) { 2138 TEST(NetworkQualityEstimatorTest, MAYBE_RecordAccuracy) {
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 2842
2758 // Cleanup. 2843 // Cleanup.
2759 estimator.RemoveRTTObserver(&rtt_observer); 2844 estimator.RemoveRTTObserver(&rtt_observer);
2760 estimator.RemoveThroughputObserver(&throughput_observer); 2845 estimator.RemoveThroughputObserver(&throughput_observer);
2761 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); 2846 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer);
2762 estimator.RemoveEffectiveConnectionTypeObserver( 2847 estimator.RemoveEffectiveConnectionTypeObserver(
2763 &effective_connection_type_observer); 2848 &effective_connection_type_observer);
2764 } 2849 }
2765 2850
2766 } // namespace net 2851 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698