| 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 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 }, | 1689 }, |
| 1690 }; | 1690 }; |
| 1691 | 1691 |
| 1692 for (const auto& accuracy_recording_delay : accuracy_recording_delays) { | 1692 for (const auto& accuracy_recording_delay : accuracy_recording_delays) { |
| 1693 for (const auto& test : tests) { | 1693 for (const auto& test : tests) { |
| 1694 std::unique_ptr<base::SimpleTestTickClock> tick_clock( | 1694 std::unique_ptr<base::SimpleTestTickClock> tick_clock( |
| 1695 new base::SimpleTestTickClock()); | 1695 new base::SimpleTestTickClock()); |
| 1696 base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get(); | 1696 base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get(); |
| 1697 tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1)); | 1697 tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1)); |
| 1698 | 1698 |
| 1699 std::unique_ptr<ExternalEstimateProvider> external_estimate_provider( |
| 1700 new TestExternalEstimateProvider(test.rtt, 0)); |
| 1701 |
| 1699 std::map<std::string, std::string> variation_params; | 1702 std::map<std::string, std::string> variation_params; |
| 1700 TestNetworkQualityEstimator estimator(variation_params); | 1703 TestNetworkQualityEstimator estimator( |
| 1704 variation_params, std::move(external_estimate_provider)); |
| 1705 |
| 1701 estimator.SetTickClockForTesting(std::move(tick_clock)); | 1706 estimator.SetTickClockForTesting(std::move(tick_clock)); |
| 1702 estimator.SimulateNetworkChangeTo( | 1707 estimator.SimulateNetworkChangeTo( |
| 1703 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); | 1708 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); |
| 1704 tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1)); | 1709 tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1)); |
| 1705 | 1710 |
| 1706 std::vector<base::TimeDelta> accuracy_recording_intervals; | 1711 std::vector<base::TimeDelta> accuracy_recording_intervals; |
| 1707 accuracy_recording_intervals.push_back(accuracy_recording_delay); | 1712 accuracy_recording_intervals.push_back(accuracy_recording_delay); |
| 1708 estimator.SetAccuracyRecordingIntervals(accuracy_recording_intervals); | 1713 estimator.SetAccuracyRecordingIntervals(accuracy_recording_intervals); |
| 1709 | 1714 |
| 1710 // RTT is higher than threshold. Network is slow. | 1715 // RTT is higher than threshold. Network is slow. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1783 sign_suffix_with_zero_samples + "." + interval_value + ".60_140", | 1788 sign_suffix_with_zero_samples + "." + interval_value + ".60_140", |
| 1784 0); | 1789 0); |
| 1785 histogram_tester.ExpectUniqueSample( | 1790 histogram_tester.ExpectUniqueSample( |
| 1786 "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." + | 1791 "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." + |
| 1787 sign_suffix_with_one_sample + "." + interval_value + ".60_140", | 1792 sign_suffix_with_one_sample + "." + interval_value + ".60_140", |
| 1788 diff, 1); | 1793 diff, 1); |
| 1789 histogram_tester.ExpectTotalCount( | 1794 histogram_tester.ExpectTotalCount( |
| 1790 "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." + | 1795 "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." + |
| 1791 sign_suffix_with_zero_samples + "." + interval_value + ".60_140", | 1796 sign_suffix_with_zero_samples + "." + interval_value + ".60_140", |
| 1792 0); | 1797 0); |
| 1798 |
| 1799 histogram_tester.ExpectUniqueSample( |
| 1800 "NQE.ExternalEstimateProvider.RTT.Accuracy.EstimatedObservedDiff." + |
| 1801 sign_suffix_with_one_sample + "." + interval_value + ".60_140", |
| 1802 diff, 1); |
| 1803 histogram_tester.ExpectTotalCount( |
| 1804 "NQE.ExternalEstimateProvider.RTT.Accuracy.EstimatedObservedDiff." + |
| 1805 sign_suffix_with_zero_samples + "." + interval_value + ".60_140", |
| 1806 0); |
| 1793 } | 1807 } |
| 1794 } | 1808 } |
| 1795 } | 1809 } |
| 1796 | 1810 |
| 1797 // Tests that the effective connection type is converted correctly to a | 1811 // Tests that the effective connection type is converted correctly to a |
| 1798 // descriptive string name, and vice-versa. | 1812 // descriptive string name, and vice-versa. |
| 1799 TEST(NetworkQualityEstimatorTest, NameConnectionTypeConversion) { | 1813 TEST(NetworkQualityEstimatorTest, NameConnectionTypeConversion) { |
| 1800 for (size_t i = 0; | 1814 for (size_t i = 0; |
| 1801 i < NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_LAST; ++i) { | 1815 i < NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_LAST; ++i) { |
| 1802 const NetworkQualityEstimator::EffectiveConnectionType | 1816 const NetworkQualityEstimator::EffectiveConnectionType |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1979 | 1993 |
| 1980 // Get the bits at index 18-24 which contain the resource fetch time. | 1994 // Get the bits at index 18-24 which contain the resource fetch time. |
| 1981 EXPECT_LE(0, (buckets.at(0).min >> kBitsPerMetric) % 128); | 1995 EXPECT_LE(0, (buckets.at(0).min >> kBitsPerMetric) % 128); |
| 1982 | 1996 |
| 1983 // Get the bits at index 25-31 which contain the resource load size. | 1997 // Get the bits at index 25-31 which contain the resource load size. |
| 1984 EXPECT_LE(0, (buckets.at(0).min) % 128); | 1998 EXPECT_LE(0, (buckets.at(0).min) % 128); |
| 1985 } | 1999 } |
| 1986 } | 2000 } |
| 1987 | 2001 |
| 1988 } // namespace net | 2002 } // namespace net |
| OLD | NEW |