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

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: Fix test 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 | « net/nqe/network_quality_estimator_test_util.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | 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 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 ExpectBucketCountAtLeast(base::HistogramTester* histogram_tester,
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 1); 248 1);
229 histogram_tester.ExpectUniqueSample( 249 histogram_tester.ExpectUniqueSample(
230 "NQE.EstimateAvailable.MainFrame.TransportRTT", 0, 1); 250 "NQE.EstimateAvailable.MainFrame.TransportRTT", 0, 1);
231 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.Kbps", 0, 251 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.Kbps", 0,
232 1); 252 1);
233 EXPECT_LE(1u, 253 EXPECT_LE(1u,
234 histogram_tester.GetAllSamples("NQE.RTT.OnECTComputation").size()); 254 histogram_tester.GetAllSamples("NQE.RTT.OnECTComputation").size());
235 EXPECT_LE(1u, 255 EXPECT_LE(1u,
236 histogram_tester.GetAllSamples("NQE.Kbps.OnECTComputation").size()); 256 histogram_tester.GetAllSamples("NQE.Kbps.OnECTComputation").size());
237 257
258 histogram_tester.ExpectBucketCount(
259 "NQE.RTT.ObservationSource", NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP, 1);
260 histogram_tester.ExpectBucketCount(
261 "NQE.Kbps.ObservationSource", NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP, 1);
262
238 std::unique_ptr<URLRequest> request2(context.CreateRequest( 263 std::unique_ptr<URLRequest> request2(context.CreateRequest(
239 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 264 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
240 request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); 265 request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
241 request2->Start(); 266 request2->Start();
242 base::RunLoop().Run(); 267 base::RunLoop().Run();
243 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", 2); 268 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", 2);
244 histogram_tester.ExpectTotalCount( 269 histogram_tester.ExpectTotalCount(
245 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2); 270 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2);
246 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 1, 271 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 1,
247 1); 272 1);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 estimator.AddThroughputObserver(&throughput_observer); 404 estimator.AddThroughputObserver(&throughput_observer);
380 405
381 // |observer| should be notified as soon as it is added. 406 // |observer| should be notified as soon as it is added.
382 base::RunLoop().RunUntilIdle(); 407 base::RunLoop().RunUntilIdle();
383 EXPECT_EQ(1U, observer.effective_connection_types().size()); 408 EXPECT_EQ(1U, observer.effective_connection_types().size());
384 EXPECT_EQ( 409 EXPECT_EQ(
385 2, estimator.GetEntriesCount(NetLogEventType::NETWORK_QUALITY_CHANGED)); 410 2, estimator.GetEntriesCount(NetLogEventType::NETWORK_QUALITY_CHANGED));
386 411
387 estimator.SimulateNetworkChange( 412 estimator.SimulateNetworkChange(
388 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test"); 413 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test");
414 histogram_tester.ExpectBucketCount(
415 "NQE.RTT.ObservationSource",
416 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE, 1);
417 histogram_tester.ExpectBucketCount(
418 "NQE.Kbps.ObservationSource",
419 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE, 1);
389 420
390 // Verify the contents of the net log. 421 // Verify the contents of the net log.
391 EXPECT_LE( 422 EXPECT_LE(
392 3, estimator.GetEntriesCount(NetLogEventType::NETWORK_QUALITY_CHANGED)); 423 3, estimator.GetEntriesCount(NetLogEventType::NETWORK_QUALITY_CHANGED));
393 EXPECT_NE(-1, estimator.GetNetLogLastIntegerValue( 424 EXPECT_NE(-1, estimator.GetNetLogLastIntegerValue(
394 NetLogEventType::NETWORK_QUALITY_CHANGED, "http_rtt_ms")); 425 NetLogEventType::NETWORK_QUALITY_CHANGED, "http_rtt_ms"));
395 EXPECT_EQ(-1, 426 EXPECT_EQ(-1,
396 estimator.GetNetLogLastIntegerValue( 427 estimator.GetNetLogLastIntegerValue(
397 NetLogEventType::NETWORK_QUALITY_CHANGED, "transport_rtt_ms")); 428 NetLogEventType::NETWORK_QUALITY_CHANGED, "transport_rtt_ms"));
398 EXPECT_NE(-1, estimator.GetNetLogLastIntegerValue( 429 EXPECT_NE(-1, estimator.GetNetLogLastIntegerValue(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 histogram_tester.ExpectTotalCount("NQE.CachedNetworkQualityAvailable", 0); 508 histogram_tester.ExpectTotalCount("NQE.CachedNetworkQualityAvailable", 0);
478 base::RunLoop().RunUntilIdle(); 509 base::RunLoop().RunUntilIdle();
479 510
480 // Verify that the cached network quality was read, and observers were 511 // Verify that the cached network quality was read, and observers were
481 // notified. |observer| must be notified once right after it was added, and 512 // notified. |observer| must be notified once right after it was added, and
482 // once again after the cached network quality was read. 513 // once again after the cached network quality was read.
483 EXPECT_EQ(0U, rtt_observer.observations().size()); 514 EXPECT_EQ(0U, rtt_observer.observations().size());
484 EXPECT_EQ(0U, throughput_observer.observations().size()); 515 EXPECT_EQ(0U, throughput_observer.observations().size());
485 } 516 }
486 517
518 TEST(NetworkQualityEstimatorTest, QuicObservations) {
519 base::HistogramTester histogram_tester;
520 TestNetworkQualityEstimator estimator;
521 estimator.OnUpdatedRTTAvailable(SocketPerformanceWatcherFactory::PROTOCOL_TCP,
522 base::TimeDelta::FromMilliseconds(10));
523 estimator.OnUpdatedRTTAvailable(
524 SocketPerformanceWatcherFactory::PROTOCOL_QUIC,
525 base::TimeDelta::FromMilliseconds(10));
526 histogram_tester.ExpectBucketCount("NQE.RTT.ObservationSource",
527 NETWORK_QUALITY_OBSERVATION_SOURCE_TCP, 1);
528 histogram_tester.ExpectBucketCount(
529 "NQE.RTT.ObservationSource", NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC, 1);
530 histogram_tester.ExpectTotalCount("NQE.RTT.ObservationSource", 2);
531 }
532
487 TEST(NetworkQualityEstimatorTest, StoreObservations) { 533 TEST(NetworkQualityEstimatorTest, StoreObservations) {
488 TestNetworkQualityEstimator estimator; 534 TestNetworkQualityEstimator estimator;
489 535
490 base::TimeDelta rtt; 536 base::TimeDelta rtt;
491 int32_t kbps; 537 int32_t kbps;
492 EXPECT_FALSE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); 538 EXPECT_FALSE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt));
493 EXPECT_FALSE( 539 EXPECT_FALSE(
494 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); 540 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
495 541
496 TestDelegate test_delegate; 542 TestDelegate test_delegate;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 base::TimeTicks(), i), 617 base::TimeTicks(), i),
572 estimator.GetRTTEstimateInternal(disallowed_observation_sources, 618 estimator.GetRTTEstimateInternal(disallowed_observation_sources,
573 base::TimeTicks(), i - 1)); 619 base::TimeTicks(), i - 1));
574 } 620 }
575 } 621 }
576 } 622 }
577 623
578 // Verifies that the observers receive the notifications when default estimates 624 // Verifies that the observers receive the notifications when default estimates
579 // are added to the observations. 625 // are added to the observations.
580 TEST(NetworkQualityEstimatorTest, DefaultObservations) { 626 TEST(NetworkQualityEstimatorTest, DefaultObservations) {
627 base::HistogramTester histogram_tester;
628
581 TestEffectiveConnectionTypeObserver effective_connection_type_observer; 629 TestEffectiveConnectionTypeObserver effective_connection_type_observer;
582 TestRTTAndThroughputEstimatesObserver rtt_throughput_estimates_observer; 630 TestRTTAndThroughputEstimatesObserver rtt_throughput_estimates_observer;
583 TestRTTObserver rtt_observer; 631 TestRTTObserver rtt_observer;
584 TestThroughputObserver throughput_observer; 632 TestThroughputObserver throughput_observer;
585 std::map<std::string, std::string> variation_params; 633 std::map<std::string, std::string> variation_params;
586 TestNetworkQualityEstimator estimator( 634 TestNetworkQualityEstimator estimator(
587 nullptr, variation_params, false, false, 635 nullptr, variation_params, false, false,
588 true /* add_default_platform_observations */, 636 true /* add_default_platform_observations */,
589 base::MakeUnique<BoundTestNetLog>()); 637 base::MakeUnique<BoundTestNetLog>());
638
639 histogram_tester.ExpectBucketCount(
640 "NQE.RTT.ObservationSource",
641 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_HTTP_FROM_PLATFORM, 1);
642 histogram_tester.ExpectBucketCount(
643 "NQE.RTT.ObservationSource",
644 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_TRANSPORT_FROM_PLATFORM, 1);
645 histogram_tester.ExpectBucketCount(
646 "NQE.Kbps.ObservationSource",
647 NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_HTTP_FROM_PLATFORM, 1);
648 histogram_tester.ExpectTotalCount("NQE.RTT.ObservationSource", 2);
649 histogram_tester.ExpectTotalCount("NQE.Kbps.ObservationSource", 1);
650
590 base::TimeDelta rtt; 651 base::TimeDelta rtt;
591 int32_t kbps; 652 int32_t kbps;
592 653
593 // Default estimates should be available. 654 // Default estimates should be available.
594 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); 655 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt));
595 EXPECT_EQ(base::TimeDelta::FromMilliseconds(115), rtt); 656 EXPECT_EQ(base::TimeDelta::FromMilliseconds(115), rtt);
596 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); 657 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt));
597 EXPECT_EQ(base::TimeDelta::FromMilliseconds(55), rtt); 658 EXPECT_EQ(base::TimeDelta::FromMilliseconds(55), rtt);
598 EXPECT_TRUE( 659 EXPECT_TRUE(
599 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); 660 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 histogram_tester.ExpectBucketCount( 1535 histogram_tester.ExpectBucketCount(
1475 "NQE.ExternalEstimateProviderStatus", 1536 "NQE.ExternalEstimateProviderStatus",
1476 5 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE */, 1); 1537 5 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE */, 1);
1477 histogram_tester.ExpectBucketCount( 1538 histogram_tester.ExpectBucketCount(
1478 "NQE.ExternalEstimateProviderStatus", 1539 "NQE.ExternalEstimateProviderStatus",
1479 6 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE */, 1540 6 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE */,
1480 1); 1541 1);
1481 histogram_tester.ExpectUniqueSample("NQE.ExternalEstimateProvider.RTT", 1, 1); 1542 histogram_tester.ExpectUniqueSample("NQE.ExternalEstimateProvider.RTT", 1, 1);
1482 histogram_tester.ExpectUniqueSample( 1543 histogram_tester.ExpectUniqueSample(
1483 "NQE.ExternalEstimateProvider.DownlinkBandwidth", 100, 1); 1544 "NQE.ExternalEstimateProvider.DownlinkBandwidth", 100, 1);
1545 histogram_tester.ExpectBucketCount(
1546 "NQE.RTT.ObservationSource",
1547 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_EXTERNAL_ESTIMATE, 1);
1548 histogram_tester.ExpectBucketCount(
1549 "NQE.Kbps.ObservationSource",
1550 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_EXTERNAL_ESTIMATE, 1);
1484 1551
1485 EXPECT_EQ(1U, test_external_estimate_provider->update_count()); 1552 EXPECT_EQ(1U, test_external_estimate_provider->update_count());
1486 1553
1487 // Change network type to WiFi. Number of queries to External estimate 1554 // Change network type to WiFi. Number of queries to External estimate
1488 // provider must increment. 1555 // provider must increment.
1489 estimator.SimulateNetworkChange( 1556 estimator.SimulateNetworkChange(
1490 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); 1557 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1");
1491 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); 1558 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt));
1492 EXPECT_TRUE( 1559 EXPECT_TRUE(
1493 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); 1560 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 int32_t kbps; 1599 int32_t kbps;
1533 EXPECT_TRUE( 1600 EXPECT_TRUE(
1534 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); 1601 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
1535 EXPECT_EQ(external_estimate_provider_downstream_throughput, kbps); 1602 EXPECT_EQ(external_estimate_provider_downstream_throughput, kbps);
1536 1603
1537 TestDelegate test_delegate; 1604 TestDelegate test_delegate;
1538 TestURLRequestContext context(true); 1605 TestURLRequestContext context(true);
1539 context.set_network_quality_estimator(&estimator); 1606 context.set_network_quality_estimator(&estimator);
1540 context.Init(); 1607 context.Init();
1541 1608
1542 std::unique_ptr<URLRequest> request(context.CreateRequest( 1609 for (size_t i = 0; i < 2; ++i) {
1543 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1610 // Start 2 requests to ensure that the RTT estimate computed by the network
1544 request->Start(); 1611 // quality estimator takes into account the RTT observations from the
1545 base::RunLoop().Run(); 1612 // external estimate provider as well as organic observations.
1613 std::unique_ptr<URLRequest> request(context.CreateRequest(
1614 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1615 request->Start();
1616 base::RunLoop().Run();
1617 }
1546 1618
1547 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); 1619 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt));
1548 EXPECT_NE(external_estimate_provider_rtt, rtt); 1620 EXPECT_NE(external_estimate_provider_rtt, rtt);
1549 1621
1550 EXPECT_TRUE( 1622 EXPECT_TRUE(
1551 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); 1623 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps));
1552 EXPECT_NE(external_estimate_provider_downstream_throughput, kbps); 1624 EXPECT_NE(external_estimate_provider_downstream_throughput, kbps);
1553 } 1625 }
1554 1626
1555 // Tests if the throughput observation is taken correctly when local and network 1627 // Tests if the throughput observation is taken correctly when local and network
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 #if defined(TCP_INFO) || defined(OS_LINUX) 2099 #if defined(TCP_INFO) || defined(OS_LINUX)
2028 #define MAYBE_TestTCPSocketRTT TestTCPSocketRTT 2100 #define MAYBE_TestTCPSocketRTT TestTCPSocketRTT
2029 #else 2101 #else
2030 #define MAYBE_TestTCPSocketRTT DISABLED_TestTCPSocketRTT 2102 #define MAYBE_TestTCPSocketRTT DISABLED_TestTCPSocketRTT
2031 #endif 2103 #endif
2032 // Tests that the TCP socket notifies the Network Quality Estimator of TCP RTTs, 2104 // Tests that the TCP socket notifies the Network Quality Estimator of TCP RTTs,
2033 // which in turn notifies registered RTT observers. 2105 // which in turn notifies registered RTT observers.
2034 TEST(NetworkQualityEstimatorTest, MAYBE_TestTCPSocketRTT) { 2106 TEST(NetworkQualityEstimatorTest, MAYBE_TestTCPSocketRTT) {
2035 base::HistogramTester histogram_tester; 2107 base::HistogramTester histogram_tester;
2036 TestRTTObserver rtt_observer; 2108 TestRTTObserver rtt_observer;
2037 TestNetworkQualityEstimator estimator; 2109
2110 std::map<std::string, std::string> variation_params;
2111 variation_params["persistent_cache_reading_enabled"] = "true";
2112 TestNetworkQualityEstimator estimator(variation_params);
2113 estimator.SimulateNetworkChange(
2114 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test");
2115
2038 estimator.AddRTTObserver(&rtt_observer); 2116 estimator.AddRTTObserver(&rtt_observer);
2039 2117
2040 TestDelegate test_delegate; 2118 TestDelegate test_delegate;
2041 TestURLRequestContext context(true); 2119 TestURLRequestContext context(true);
2042 context.set_network_quality_estimator(&estimator); 2120 context.set_network_quality_estimator(&estimator);
2043 2121
2044 std::unique_ptr<HttpNetworkSession::Params> params( 2122 std::unique_ptr<HttpNetworkSession::Params> params(
2045 new HttpNetworkSession::Params); 2123 new HttpNetworkSession::Params);
2046 // |estimator| should be notified of TCP RTT observations. 2124 // |estimator| should be notified of TCP RTT observations.
2047 params->socket_performance_watcher_factory = 2125 params->socket_performance_watcher_factory =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 // watcher. 2157 // watcher.
2080 EXPECT_LE(1U, after_count_tcp_rtt_observations - 2158 EXPECT_LE(1U, after_count_tcp_rtt_observations -
2081 before_count_tcp_rtt_observations) 2159 before_count_tcp_rtt_observations)
2082 << i; 2160 << i;
2083 } 2161 }
2084 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); 2162 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt));
2085 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); 2163 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt));
2086 2164
2087 estimator.SimulateNetworkChange( 2165 estimator.SimulateNetworkChange(
2088 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); 2166 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1");
2089 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); 2167 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.2G", 1);
2090 histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.Unknown", 2168 histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.2G",
2091 rtt.InMilliseconds(), 1); 2169 rtt.InMilliseconds(), 1);
2092 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.Unknown", 1); 2170 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.2G", 1);
2093 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); 2171 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.2G", 1);
2094 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.Unknown", 1); 2172 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.2G", 1);
2095 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.Unknown", 2173 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.2G", 1);
2096 1);
2097 2174
2098 // Verify that metrics are logged correctly on main-frame requests. 2175 // Verify that metrics are logged correctly on main-frame requests.
2099 histogram_tester.ExpectTotalCount("NQE.MainFrame.TransportRTT.Percentile50", 2176 histogram_tester.ExpectTotalCount("NQE.MainFrame.TransportRTT.Percentile50",
2100 num_requests); 2177 num_requests);
2101 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 0, 2178 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 0,
2102 1); 2179 1);
2103 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 1, 2180 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 1,
2104 num_requests - 1); 2181 num_requests - 1);
2105 histogram_tester.ExpectUniqueSample( 2182 histogram_tester.ExpectUniqueSample(
2106 "NQE.EstimateAvailable.MainFrame.TransportRTT", 1, num_requests); 2183 "NQE.EstimateAvailable.MainFrame.TransportRTT", 1, num_requests);
2107 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.Kbps", 0, 2184 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.Kbps", 0,
2108 1); 2185 1);
2109 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.Kbps", 1, 2186 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.Kbps", 1,
2110 num_requests - 1); 2187 num_requests - 1);
2111 2188
2112 histogram_tester.ExpectTotalCount( 2189 histogram_tester.ExpectTotalCount(
2113 "NQE.MainFrame.TransportRTT.Percentile50.Unknown", num_requests); 2190 "NQE.MainFrame.TransportRTT.Percentile50.2G", num_requests);
2114 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", 2191 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType",
2115 num_requests); 2192 num_requests);
2116 histogram_tester.ExpectTotalCount( 2193 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType.2G",
2117 "NQE.MainFrame.EffectiveConnectionType.Unknown", num_requests); 2194 num_requests);
2118 histogram_tester.ExpectBucketCount( 2195 histogram_tester.ExpectBucketCount("NQE.MainFrame.EffectiveConnectionType.2G",
2119 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2196 EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
2120 EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); 2197 ExpectBucketCountAtLeast(&histogram_tester, "NQE.RTT.ObservationSource",
2198 NETWORK_QUALITY_OBSERVATION_SOURCE_TCP, 1);
2199 ExpectBucketCountAtLeast(&histogram_tester, "NQE.Kbps.ObservationSource",
2200 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP, 1);
2201 histogram_tester.ExpectBucketCount("NQE.MainFrame.EffectiveConnectionType.2G",
2202 EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
2121 EXPECT_LE(1u, 2203 EXPECT_LE(1u,
2122 histogram_tester 2204 histogram_tester
2123 .GetAllSamples("NQE.EffectiveConnectionType.OnECTComputation") 2205 .GetAllSamples("NQE.EffectiveConnectionType.OnECTComputation")
2124 .size()); 2206 .size());
2125 EXPECT_LE(1u, 2207 EXPECT_LE(1u,
2126 histogram_tester.GetAllSamples("NQE.TransportRTT.OnECTComputation") 2208 histogram_tester.GetAllSamples("NQE.TransportRTT.OnECTComputation")
2127 .size()); 2209 .size());
2128 EXPECT_LE(1u, 2210 EXPECT_LE(1u,
2129 histogram_tester.GetAllSamples("NQE.RTT.OnECTComputation").size()); 2211 histogram_tester.GetAllSamples("NQE.RTT.OnECTComputation").size());
2212
2213 histogram_tester.ExpectBucketCount(
2214 "NQE.Kbps.ObservationSource",
2215 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE, 0);
2216
2217 estimator.SimulateNetworkChange(
2218 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test");
2219 histogram_tester.ExpectBucketCount(
2220 "NQE.RTT.ObservationSource",
2221 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE, 1);
2130 } 2222 }
2131 2223
2132 #if defined(OS_IOS) 2224 #if defined(OS_IOS)
2133 // Flaky on iOS when |accuracy_recording_delay| is non-zero. 2225 // Flaky on iOS when |accuracy_recording_delay| is non-zero.
2134 #define MAYBE_RecordAccuracy DISABLED_RecordAccuracy 2226 #define MAYBE_RecordAccuracy DISABLED_RecordAccuracy
2135 #else 2227 #else
2136 #define MAYBE_RecordAccuracy RecordAccuracy 2228 #define MAYBE_RecordAccuracy RecordAccuracy
2137 #endif 2229 #endif
2138 // Tests if the NQE accuracy metrics are recorded properly. 2230 // Tests if the NQE accuracy metrics are recorded properly.
2139 TEST(NetworkQualityEstimatorTest, MAYBE_RecordAccuracy) { 2231 TEST(NetworkQualityEstimatorTest, MAYBE_RecordAccuracy) {
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 3071
2980 // Cleanup. 3072 // Cleanup.
2981 estimator.RemoveRTTObserver(&rtt_observer); 3073 estimator.RemoveRTTObserver(&rtt_observer);
2982 estimator.RemoveThroughputObserver(&throughput_observer); 3074 estimator.RemoveThroughputObserver(&throughput_observer);
2983 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); 3075 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer);
2984 estimator.RemoveEffectiveConnectionTypeObserver( 3076 estimator.RemoveEffectiveConnectionTypeObserver(
2985 &effective_connection_type_observer); 3077 &effective_connection_type_observer);
2986 } 3078 }
2987 3079
2988 } // namespace net 3080 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator_test_util.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698