| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); | 221 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); |
| 222 histogram_tester.ExpectUniqueSample( | 222 histogram_tester.ExpectUniqueSample( |
| 223 "NQE.MainFrame.EffectiveConnectionType.Unknown", | 223 "NQE.MainFrame.EffectiveConnectionType.Unknown", |
| 224 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); | 224 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); |
| 225 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.RTT", 0, | 225 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.RTT", 0, |
| 226 1); | 226 1); |
| 227 histogram_tester.ExpectUniqueSample( | 227 histogram_tester.ExpectUniqueSample( |
| 228 "NQE.EstimateAvailable.MainFrame.TransportRTT", 0, 1); | 228 "NQE.EstimateAvailable.MainFrame.TransportRTT", 0, 1); |
| 229 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.Kbps", 0, | 229 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.Kbps", 0, |
| 230 1); | 230 1); |
| 231 EXPECT_LE(1u, |
| 232 histogram_tester.GetAllSamples("NQE.RTT.OnECTComputation").size()); |
| 233 EXPECT_LE(1u, |
| 234 histogram_tester.GetAllSamples("NQE.Kbps.OnECTComputation").size()); |
| 231 | 235 |
| 232 std::unique_ptr<URLRequest> request2(context.CreateRequest( | 236 std::unique_ptr<URLRequest> request2(context.CreateRequest( |
| 233 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); | 237 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); |
| 234 request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); | 238 request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); |
| 235 request2->Start(); | 239 request2->Start(); |
| 236 base::RunLoop().Run(); | 240 base::RunLoop().Run(); |
| 237 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", 2); | 241 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", 2); |
| 238 histogram_tester.ExpectTotalCount( | 242 histogram_tester.ExpectTotalCount( |
| 239 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2); | 243 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2); |
| 240 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 1, | 244 histogram_tester.ExpectBucketCount("NQE.EstimateAvailable.MainFrame.RTT", 1, |
| (...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 EFFECTIVE_CONNECTION_TYPE_2G, 1); | 1815 EFFECTIVE_CONNECTION_TYPE_2G, 1); |
| 1812 histogram_tester.ExpectUniqueSample( | 1816 histogram_tester.ExpectUniqueSample( |
| 1813 "NQE.MainFrame.EffectiveConnectionType.WiFi", | 1817 "NQE.MainFrame.EffectiveConnectionType.WiFi", |
| 1814 EFFECTIVE_CONNECTION_TYPE_2G, 1); | 1818 EFFECTIVE_CONNECTION_TYPE_2G, 1); |
| 1815 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.RTT", 0, | 1819 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.RTT", 0, |
| 1816 1); | 1820 1); |
| 1817 histogram_tester.ExpectUniqueSample( | 1821 histogram_tester.ExpectUniqueSample( |
| 1818 "NQE.EstimateAvailable.MainFrame.TransportRTT", 0, 1); | 1822 "NQE.EstimateAvailable.MainFrame.TransportRTT", 0, 1); |
| 1819 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.Kbps", 0, | 1823 histogram_tester.ExpectUniqueSample("NQE.EstimateAvailable.MainFrame.Kbps", 0, |
| 1820 1); | 1824 1); |
| 1825 EXPECT_LE(1u, |
| 1826 histogram_tester |
| 1827 .GetAllSamples("NQE.EffectiveConnectionType.OnECTComputation") |
| 1828 .size()); |
| 1821 | 1829 |
| 1822 size_t expected_effective_connection_type_notifications = 1; | 1830 size_t expected_effective_connection_type_notifications = 1; |
| 1823 EXPECT_EQ(expected_effective_connection_type_notifications, | 1831 EXPECT_EQ(expected_effective_connection_type_notifications, |
| 1824 observer.effective_connection_types().size()); | 1832 observer.effective_connection_types().size()); |
| 1825 | 1833 |
| 1826 EXPECT_EQ(expected_effective_connection_type_notifications, | 1834 EXPECT_EQ(expected_effective_connection_type_notifications, |
| 1827 estimator.rtt_observations_.Size()); | 1835 estimator.rtt_observations_.Size()); |
| 1828 | 1836 |
| 1829 // Increase the number of RTT observations. Every time the number of RTT | 1837 // Increase the number of RTT observations. Every time the number of RTT |
| 1830 // observations is more than doubled, effective connection type must be | 1838 // observations is more than doubled, effective connection type must be |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 | 2042 |
| 2035 histogram_tester.ExpectTotalCount( | 2043 histogram_tester.ExpectTotalCount( |
| 2036 "NQE.MainFrame.TransportRTT.Percentile50.Unknown", num_requests); | 2044 "NQE.MainFrame.TransportRTT.Percentile50.Unknown", num_requests); |
| 2037 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", | 2045 histogram_tester.ExpectTotalCount("NQE.MainFrame.EffectiveConnectionType", |
| 2038 num_requests); | 2046 num_requests); |
| 2039 histogram_tester.ExpectTotalCount( | 2047 histogram_tester.ExpectTotalCount( |
| 2040 "NQE.MainFrame.EffectiveConnectionType.Unknown", num_requests); | 2048 "NQE.MainFrame.EffectiveConnectionType.Unknown", num_requests); |
| 2041 histogram_tester.ExpectBucketCount( | 2049 histogram_tester.ExpectBucketCount( |
| 2042 "NQE.MainFrame.EffectiveConnectionType.Unknown", | 2050 "NQE.MainFrame.EffectiveConnectionType.Unknown", |
| 2043 EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); | 2051 EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); |
| 2052 EXPECT_LE(1u, |
| 2053 histogram_tester |
| 2054 .GetAllSamples("NQE.EffectiveConnectionType.OnECTComputation") |
| 2055 .size()); |
| 2056 EXPECT_LE(1u, |
| 2057 histogram_tester.GetAllSamples("NQE.TransportRTT.OnECTComputation") |
| 2058 .size()); |
| 2059 EXPECT_LE(1u, |
| 2060 histogram_tester.GetAllSamples("NQE.RTT.OnECTComputation").size()); |
| 2044 } | 2061 } |
| 2045 | 2062 |
| 2046 #if defined(OS_IOS) | 2063 #if defined(OS_IOS) |
| 2047 // Flaky on iOS when |accuracy_recording_delay| is non-zero. | 2064 // Flaky on iOS when |accuracy_recording_delay| is non-zero. |
| 2048 #define MAYBE_RecordAccuracy DISABLED_RecordAccuracy | 2065 #define MAYBE_RecordAccuracy DISABLED_RecordAccuracy |
| 2049 #else | 2066 #else |
| 2050 #define MAYBE_RecordAccuracy RecordAccuracy | 2067 #define MAYBE_RecordAccuracy RecordAccuracy |
| 2051 #endif | 2068 #endif |
| 2052 // Tests if the NQE accuracy metrics are recorded properly. | 2069 // Tests if the NQE accuracy metrics are recorded properly. |
| 2053 TEST(NetworkQualityEstimatorTest, MAYBE_RecordAccuracy) { | 2070 TEST(NetworkQualityEstimatorTest, MAYBE_RecordAccuracy) { |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2757 | 2774 |
| 2758 // Cleanup. | 2775 // Cleanup. |
| 2759 estimator.RemoveRTTObserver(&rtt_observer); | 2776 estimator.RemoveRTTObserver(&rtt_observer); |
| 2760 estimator.RemoveThroughputObserver(&throughput_observer); | 2777 estimator.RemoveThroughputObserver(&throughput_observer); |
| 2761 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); | 2778 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); |
| 2762 estimator.RemoveEffectiveConnectionTypeObserver( | 2779 estimator.RemoveEffectiveConnectionTypeObserver( |
| 2763 &effective_connection_type_observer); | 2780 &effective_connection_type_observer); |
| 2764 } | 2781 } |
| 2765 | 2782 |
| 2766 } // namespace net | 2783 } // namespace net |
| OLD | NEW |