OLD | NEW |
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); | 217 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); |
218 request->Start(); | 218 request->Start(); |
219 base::RunLoop().Run(); | 219 base::RunLoop().Run(); |
220 | 220 |
221 // Both RTT and downstream throughput should be updated. | 221 // Both RTT and downstream throughput should be updated. |
222 base::TimeDelta http_rtt; | 222 base::TimeDelta http_rtt; |
223 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &http_rtt)); | 223 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &http_rtt)); |
224 EXPECT_TRUE( | 224 EXPECT_TRUE( |
225 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); | 225 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); |
226 base::TimeDelta transport_rtt; | 226 base::TimeDelta transport_rtt; |
| 227 EXPECT_FALSE(estimator.GetTransportRTT()); |
227 EXPECT_FALSE( | 228 EXPECT_FALSE( |
228 estimator.GetRecentTransportRTT(base::TimeTicks(), &transport_rtt)); | 229 estimator.GetRecentTransportRTT(base::TimeTicks(), &transport_rtt)); |
229 | 230 |
230 // Verify the contents of the net log. | 231 // Verify the contents of the net log. |
231 EXPECT_LE( | 232 EXPECT_LE( |
232 2, estimator.GetEntriesCount(NetLogEventType::NETWORK_QUALITY_CHANGED)); | 233 2, estimator.GetEntriesCount(NetLogEventType::NETWORK_QUALITY_CHANGED)); |
233 EXPECT_EQ(http_rtt.InMilliseconds(), | 234 EXPECT_EQ(http_rtt.InMilliseconds(), |
234 estimator.GetNetLogLastIntegerValue( | 235 estimator.GetNetLogLastIntegerValue( |
235 NetLogEventType::NETWORK_QUALITY_CHANGED, "http_rtt_ms")); | 236 NetLogEventType::NETWORK_QUALITY_CHANGED, "http_rtt_ms")); |
236 EXPECT_EQ(-1, | 237 EXPECT_EQ(-1, |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 395 |
395 base::RunLoop().RunUntilIdle(); | 396 base::RunLoop().RunUntilIdle(); |
396 | 397 |
397 // Both RTT and downstream throughput should be updated. | 398 // Both RTT and downstream throughput should be updated. |
398 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 399 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
399 EXPECT_TRUE( | 400 EXPECT_TRUE( |
400 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); | 401 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); |
401 EXPECT_NE(EFFECTIVE_CONNECTION_TYPE_UNKNOWN, | 402 EXPECT_NE(EFFECTIVE_CONNECTION_TYPE_UNKNOWN, |
402 estimator.GetEffectiveConnectionType()); | 403 estimator.GetEffectiveConnectionType()); |
403 EXPECT_FALSE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 404 EXPECT_FALSE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
| 405 EXPECT_FALSE(estimator.GetTransportRTT()); |
404 | 406 |
405 histogram_tester.ExpectBucketCount("NQE.CachedNetworkQualityAvailable", false, | 407 histogram_tester.ExpectBucketCount("NQE.CachedNetworkQualityAvailable", false, |
406 1); | 408 1); |
407 | 409 |
408 // Add the observers before changing the network type. | 410 // Add the observers before changing the network type. |
409 TestEffectiveConnectionTypeObserver observer; | 411 TestEffectiveConnectionTypeObserver observer; |
410 estimator.AddEffectiveConnectionTypeObserver(&observer); | 412 estimator.AddEffectiveConnectionTypeObserver(&observer); |
411 TestRTTObserver rtt_observer; | 413 TestRTTObserver rtt_observer; |
412 estimator.AddRTTObserver(&rtt_observer); | 414 estimator.AddRTTObserver(&rtt_observer); |
413 TestThroughputObserver throughput_observer; | 415 TestThroughputObserver throughput_observer; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 | 502 |
501 base::RunLoop().RunUntilIdle(); | 503 base::RunLoop().RunUntilIdle(); |
502 | 504 |
503 // Both RTT and downstream throughput should be updated. | 505 // Both RTT and downstream throughput should be updated. |
504 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 506 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
505 EXPECT_TRUE( | 507 EXPECT_TRUE( |
506 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); | 508 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); |
507 EXPECT_NE(EFFECTIVE_CONNECTION_TYPE_UNKNOWN, | 509 EXPECT_NE(EFFECTIVE_CONNECTION_TYPE_UNKNOWN, |
508 estimator.GetEffectiveConnectionType()); | 510 estimator.GetEffectiveConnectionType()); |
509 EXPECT_FALSE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 511 EXPECT_FALSE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
| 512 EXPECT_FALSE(estimator.GetTransportRTT()); |
510 | 513 |
511 histogram_tester.ExpectTotalCount("NQE.CachedNetworkQualityAvailable", 0); | 514 histogram_tester.ExpectTotalCount("NQE.CachedNetworkQualityAvailable", 0); |
512 | 515 |
513 // Add the observers before changing the network type. | 516 // Add the observers before changing the network type. |
514 TestRTTObserver rtt_observer; | 517 TestRTTObserver rtt_observer; |
515 estimator.AddRTTObserver(&rtt_observer); | 518 estimator.AddRTTObserver(&rtt_observer); |
516 TestThroughputObserver throughput_observer; | 519 TestThroughputObserver throughput_observer; |
517 estimator.AddThroughputObserver(&throughput_observer); | 520 estimator.AddThroughputObserver(&throughput_observer); |
518 | 521 |
519 estimator.SimulateNetworkChange( | 522 estimator.SimulateNetworkChange( |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 histogram_tester.ExpectTotalCount("NQE.Kbps.ObservationSource", 1); | 687 histogram_tester.ExpectTotalCount("NQE.Kbps.ObservationSource", 1); |
685 | 688 |
686 base::TimeDelta rtt; | 689 base::TimeDelta rtt; |
687 int32_t kbps; | 690 int32_t kbps; |
688 | 691 |
689 // Default estimates should be available. | 692 // Default estimates should be available. |
690 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 693 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
691 EXPECT_EQ(base::TimeDelta::FromMilliseconds(115), rtt); | 694 EXPECT_EQ(base::TimeDelta::FromMilliseconds(115), rtt); |
692 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 695 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
693 EXPECT_EQ(base::TimeDelta::FromMilliseconds(55), rtt); | 696 EXPECT_EQ(base::TimeDelta::FromMilliseconds(55), rtt); |
| 697 EXPECT_EQ(rtt, estimator.GetTransportRTT().value()); |
694 EXPECT_TRUE( | 698 EXPECT_TRUE( |
695 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); | 699 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); |
696 EXPECT_EQ(1961, kbps); | 700 EXPECT_EQ(1961, kbps); |
697 | 701 |
698 estimator.AddEffectiveConnectionTypeObserver( | 702 estimator.AddEffectiveConnectionTypeObserver( |
699 &effective_connection_type_observer); | 703 &effective_connection_type_observer); |
700 estimator.AddRTTAndThroughputEstimatesObserver( | 704 estimator.AddRTTAndThroughputEstimatesObserver( |
701 &rtt_throughput_estimates_observer); | 705 &rtt_throughput_estimates_observer); |
702 estimator.AddRTTObserver(&rtt_observer); | 706 estimator.AddRTTObserver(&rtt_observer); |
703 estimator.AddThroughputObserver(&throughput_observer); | 707 estimator.AddThroughputObserver(&throughput_observer); |
704 | 708 |
705 // Simulate network change to 3G. Default estimates should be available. | 709 // Simulate network change to 3G. Default estimates should be available. |
706 estimator.SimulateNetworkChange( | 710 estimator.SimulateNetworkChange( |
707 NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-3"); | 711 NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-3"); |
708 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 712 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
709 // Taken from network_quality_estimator_params.cc. | 713 // Taken from network_quality_estimator_params.cc. |
710 EXPECT_EQ(base::TimeDelta::FromMilliseconds(272), rtt); | 714 EXPECT_EQ(base::TimeDelta::FromMilliseconds(272), rtt); |
711 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 715 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
712 EXPECT_EQ(base::TimeDelta::FromMilliseconds(209), rtt); | 716 EXPECT_EQ(base::TimeDelta::FromMilliseconds(209), rtt); |
| 717 EXPECT_EQ(rtt, estimator.GetTransportRTT()); |
713 EXPECT_TRUE( | 718 EXPECT_TRUE( |
714 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); | 719 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); |
715 EXPECT_EQ(749, kbps); | 720 EXPECT_EQ(749, kbps); |
716 | 721 |
717 EXPECT_NE(EFFECTIVE_CONNECTION_TYPE_UNKNOWN, | 722 EXPECT_NE(EFFECTIVE_CONNECTION_TYPE_UNKNOWN, |
718 estimator.GetEffectiveConnectionType()); | 723 estimator.GetEffectiveConnectionType()); |
719 EXPECT_EQ( | 724 EXPECT_EQ( |
720 1U, | 725 1U, |
721 effective_connection_type_observer.effective_connection_types().size()); | 726 effective_connection_type_observer.effective_connection_types().size()); |
722 EXPECT_NE( | 727 EXPECT_NE( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 true /* add_default_platform_observations */, | 783 true /* add_default_platform_observations */, |
779 base::MakeUnique<BoundTestNetLog>()); | 784 base::MakeUnique<BoundTestNetLog>()); |
780 | 785 |
781 base::TimeDelta rtt; | 786 base::TimeDelta rtt; |
782 int32_t kbps; | 787 int32_t kbps; |
783 | 788 |
784 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 789 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
785 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1000), rtt); | 790 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1000), rtt); |
786 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 791 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
787 EXPECT_EQ(base::TimeDelta::FromMilliseconds(500), rtt); | 792 EXPECT_EQ(base::TimeDelta::FromMilliseconds(500), rtt); |
| 793 EXPECT_EQ(rtt, estimator.GetTransportRTT().value()); |
788 EXPECT_TRUE( | 794 EXPECT_TRUE( |
789 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); | 795 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); |
790 EXPECT_EQ(100, kbps); | 796 EXPECT_EQ(100, kbps); |
791 | 797 |
792 // Simulate network change to Wi-Fi. | 798 // Simulate network change to Wi-Fi. |
793 estimator.SimulateNetworkChange( | 799 estimator.SimulateNetworkChange( |
794 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); | 800 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); |
795 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 801 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
796 EXPECT_EQ(base::TimeDelta::FromMilliseconds(2000), rtt); | 802 EXPECT_EQ(base::TimeDelta::FromMilliseconds(2000), rtt); |
797 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 803 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
798 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1000), rtt); | 804 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1000), rtt); |
| 805 EXPECT_EQ(rtt, estimator.GetTransportRTT().value()); |
799 EXPECT_TRUE( | 806 EXPECT_TRUE( |
800 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); | 807 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); |
801 EXPECT_EQ(200, kbps); | 808 EXPECT_EQ(200, kbps); |
802 | 809 |
803 // Peak network quality should not be affected by the network quality | 810 // Peak network quality should not be affected by the network quality |
804 // estimator field trial. | 811 // estimator field trial. |
805 EXPECT_EQ(nqe::internal::InvalidRTT(), | 812 EXPECT_EQ(nqe::internal::InvalidRTT(), |
806 estimator.peak_network_quality_.http_rtt()); | 813 estimator.peak_network_quality_.http_rtt()); |
807 EXPECT_EQ(nqe::internal::kInvalidThroughput, | 814 EXPECT_EQ(nqe::internal::kInvalidThroughput, |
808 estimator.peak_network_quality_.downstream_throughput_kbps()); | 815 estimator.peak_network_quality_.downstream_throughput_kbps()); |
809 | 816 |
810 // Simulate network change to 2G. Only the Kbps default estimate should be | 817 // Simulate network change to 2G. Only the Kbps default estimate should be |
811 // available. | 818 // available. |
812 estimator.SimulateNetworkChange( | 819 estimator.SimulateNetworkChange( |
813 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-2"); | 820 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-2"); |
814 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 821 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
815 // Taken from network_quality_estimator_params.cc. | 822 // Taken from network_quality_estimator_params.cc. |
816 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1726), rtt); | 823 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1726), rtt); |
817 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 824 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
818 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1531), rtt); | 825 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1531), rtt); |
| 826 EXPECT_EQ(rtt, estimator.GetTransportRTT().value()); |
819 EXPECT_TRUE( | 827 EXPECT_TRUE( |
820 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); | 828 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); |
821 EXPECT_EQ(300, kbps); | 829 EXPECT_EQ(300, kbps); |
822 | 830 |
823 // Simulate network change to 3G. Default estimates should be available. | 831 // Simulate network change to 3G. Default estimates should be available. |
824 estimator.SimulateNetworkChange( | 832 estimator.SimulateNetworkChange( |
825 NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-3"); | 833 NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-3"); |
826 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 834 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
827 EXPECT_EQ(base::TimeDelta::FromMilliseconds(272), rtt); | 835 EXPECT_EQ(base::TimeDelta::FromMilliseconds(272), rtt); |
828 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 836 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
829 EXPECT_EQ(base::TimeDelta::FromMilliseconds(209), rtt); | 837 EXPECT_EQ(base::TimeDelta::FromMilliseconds(209), rtt); |
| 838 EXPECT_EQ(rtt, estimator.GetTransportRTT().value()); |
830 EXPECT_TRUE( | 839 EXPECT_TRUE( |
831 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); | 840 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); |
832 EXPECT_EQ(749, kbps); | 841 EXPECT_EQ(749, kbps); |
833 } | 842 } |
834 | 843 |
835 TEST(NetworkQualityEstimatorTest, ObtainAlgorithmToUseFromParams) { | 844 TEST(NetworkQualityEstimatorTest, ObtainAlgorithmToUseFromParams) { |
836 const struct { | 845 const struct { |
837 bool set_variation_param; | 846 bool set_variation_param; |
838 std::string algorithm; | 847 std::string algorithm; |
839 NetworkQualityEstimator::EffectiveConnectionTypeAlgorithm | 848 NetworkQualityEstimator::EffectiveConnectionTypeAlgorithm |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 std::unique_ptr<ExternalEstimateProvider> external_estimate_provider( | 1527 std::unique_ptr<ExternalEstimateProvider> external_estimate_provider( |
1519 test_external_estimate_provider); | 1528 test_external_estimate_provider); |
1520 TestNetworkQualityEstimator estimator(std::map<std::string, std::string>(), | 1529 TestNetworkQualityEstimator estimator(std::map<std::string, std::string>(), |
1521 std::move(external_estimate_provider)); | 1530 std::move(external_estimate_provider)); |
1522 estimator.SimulateNetworkChange(net::NetworkChangeNotifier::CONNECTION_WIFI, | 1531 estimator.SimulateNetworkChange(net::NetworkChangeNotifier::CONNECTION_WIFI, |
1523 "test"); | 1532 "test"); |
1524 base::TimeDelta rtt; | 1533 base::TimeDelta rtt; |
1525 int32_t kbps; | 1534 int32_t kbps; |
1526 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 1535 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
1527 EXPECT_FALSE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 1536 EXPECT_FALSE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
| 1537 EXPECT_FALSE(estimator.GetTransportRTT()); |
1528 EXPECT_TRUE( | 1538 EXPECT_TRUE( |
1529 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); | 1539 estimator.GetRecentDownlinkThroughputKbps(base::TimeTicks(), &kbps)); |
1530 | 1540 |
1531 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 5); | 1541 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 5); |
1532 | 1542 |
1533 histogram_tester.ExpectBucketCount( | 1543 histogram_tester.ExpectBucketCount( |
1534 "NQE.ExternalEstimateProviderStatus", | 1544 "NQE.ExternalEstimateProviderStatus", |
1535 1 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE */, 1); | 1545 1 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE */, 1); |
1536 histogram_tester.ExpectBucketCount( | 1546 histogram_tester.ExpectBucketCount( |
1537 "NQE.ExternalEstimateProviderStatus", | 1547 "NQE.ExternalEstimateProviderStatus", |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2152 // |estimator| should be notified of TCP RTT observations. | 2162 // |estimator| should be notified of TCP RTT observations. |
2153 params->socket_performance_watcher_factory = | 2163 params->socket_performance_watcher_factory = |
2154 estimator.GetSocketPerformanceWatcherFactory(); | 2164 estimator.GetSocketPerformanceWatcherFactory(); |
2155 context.set_http_network_session_params(std::move(params)); | 2165 context.set_http_network_session_params(std::move(params)); |
2156 context.Init(); | 2166 context.Init(); |
2157 | 2167 |
2158 EXPECT_EQ(0U, rtt_observer.observations().size()); | 2168 EXPECT_EQ(0U, rtt_observer.observations().size()); |
2159 base::TimeDelta rtt; | 2169 base::TimeDelta rtt; |
2160 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 2170 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
2161 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 2171 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
| 2172 EXPECT_EQ(rtt, estimator.GetTransportRTT().value()); |
2162 | 2173 |
2163 // Send two requests. Verify that the completion of each request generates at | 2174 // Send two requests. Verify that the completion of each request generates at |
2164 // least one TCP RTT observation. | 2175 // least one TCP RTT observation. |
2165 const size_t num_requests = 2; | 2176 const size_t num_requests = 2; |
2166 for (size_t i = 0; i < num_requests; ++i) { | 2177 for (size_t i = 0; i < num_requests; ++i) { |
2167 size_t before_count_tcp_rtt_observations = 0; | 2178 size_t before_count_tcp_rtt_observations = 0; |
2168 for (const auto& observation : rtt_observer.observations()) { | 2179 for (const auto& observation : rtt_observer.observations()) { |
2169 if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP) | 2180 if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP) |
2170 ++before_count_tcp_rtt_observations; | 2181 ++before_count_tcp_rtt_observations; |
2171 } | 2182 } |
(...skipping 11 matching lines...) Expand all Loading... |
2183 ++after_count_tcp_rtt_observations; | 2194 ++after_count_tcp_rtt_observations; |
2184 } | 2195 } |
2185 // At least one notification should be received per socket performance | 2196 // At least one notification should be received per socket performance |
2186 // watcher. | 2197 // watcher. |
2187 EXPECT_LE(1U, after_count_tcp_rtt_observations - | 2198 EXPECT_LE(1U, after_count_tcp_rtt_observations - |
2188 before_count_tcp_rtt_observations) | 2199 before_count_tcp_rtt_observations) |
2189 << i; | 2200 << i; |
2190 } | 2201 } |
2191 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); | 2202 EXPECT_TRUE(estimator.GetRecentHttpRTT(base::TimeTicks(), &rtt)); |
2192 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); | 2203 EXPECT_TRUE(estimator.GetRecentTransportRTT(base::TimeTicks(), &rtt)); |
| 2204 EXPECT_EQ(rtt, estimator.GetTransportRTT().value()); |
2193 | 2205 |
2194 estimator.SimulateNetworkChange( | 2206 estimator.SimulateNetworkChange( |
2195 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); | 2207 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); |
2196 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.2G", 1); | 2208 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.2G", 1); |
2197 histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.2G", | 2209 histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.2G", |
2198 rtt.InMilliseconds(), 1); | 2210 rtt.InMilliseconds(), 1); |
2199 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.2G", 1); | 2211 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.2G", 1); |
2200 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.2G", 1); | 2212 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.2G", 1); |
2201 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.2G", 1); | 2213 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.2G", 1); |
2202 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.2G", 1); | 2214 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.2G", 1); |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3079 | 3091 |
3080 // Cleanup. | 3092 // Cleanup. |
3081 estimator.RemoveRTTObserver(&rtt_observer); | 3093 estimator.RemoveRTTObserver(&rtt_observer); |
3082 estimator.RemoveThroughputObserver(&throughput_observer); | 3094 estimator.RemoveThroughputObserver(&throughput_observer); |
3083 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); | 3095 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); |
3084 estimator.RemoveEffectiveConnectionTypeObserver( | 3096 estimator.RemoveEffectiveConnectionTypeObserver( |
3085 &effective_connection_type_observer); | 3097 &effective_connection_type_observer); |
3086 } | 3098 } |
3087 | 3099 |
3088 } // namespace net | 3100 } // namespace net |
OLD | NEW |