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

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

Issue 2145613003: NQE: Add accuracy histogram for external estimate provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed bengr comments Created 4 years, 5 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 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 }, 1826 },
1827 }; 1827 };
1828 1828
1829 for (const auto& accuracy_recording_delay : accuracy_recording_delays) { 1829 for (const auto& accuracy_recording_delay : accuracy_recording_delays) {
1830 for (const auto& test : tests) { 1830 for (const auto& test : tests) {
1831 std::unique_ptr<base::SimpleTestTickClock> tick_clock( 1831 std::unique_ptr<base::SimpleTestTickClock> tick_clock(
1832 new base::SimpleTestTickClock()); 1832 new base::SimpleTestTickClock());
1833 base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get(); 1833 base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get();
1834 tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1)); 1834 tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1));
1835 1835
1836 std::unique_ptr<ExternalEstimateProvider> external_estimate_provider(
1837 new TestExternalEstimateProvider(test.rtt, 0));
1838
1836 std::map<std::string, std::string> variation_params; 1839 std::map<std::string, std::string> variation_params;
1837 TestNetworkQualityEstimator estimator(variation_params); 1840 TestNetworkQualityEstimator estimator(
1841 variation_params, std::move(external_estimate_provider));
1842
1838 estimator.SetTickClockForTesting(std::move(tick_clock)); 1843 estimator.SetTickClockForTesting(std::move(tick_clock));
1839 estimator.SimulateNetworkChangeTo( 1844 estimator.SimulateNetworkChangeTo(
1840 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); 1845 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1");
1841 tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1)); 1846 tick_clock_ptr->Advance(base::TimeDelta::FromSeconds(1));
1842 1847
1843 std::vector<base::TimeDelta> accuracy_recording_intervals; 1848 std::vector<base::TimeDelta> accuracy_recording_intervals;
1844 accuracy_recording_intervals.push_back(accuracy_recording_delay); 1849 accuracy_recording_intervals.push_back(accuracy_recording_delay);
1845 estimator.SetAccuracyRecordingIntervals(accuracy_recording_intervals); 1850 estimator.SetAccuracyRecordingIntervals(accuracy_recording_intervals);
1846 1851
1847 // RTT is higher than threshold. Network is slow. 1852 // RTT is higher than threshold. Network is slow.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 sign_suffix_with_zero_samples + "." + interval_value + ".60_140", 1925 sign_suffix_with_zero_samples + "." + interval_value + ".60_140",
1921 0); 1926 0);
1922 histogram_tester.ExpectUniqueSample( 1927 histogram_tester.ExpectUniqueSample(
1923 "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." + 1928 "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." +
1924 sign_suffix_with_one_sample + "." + interval_value + ".60_140", 1929 sign_suffix_with_one_sample + "." + interval_value + ".60_140",
1925 diff, 1); 1930 diff, 1);
1926 histogram_tester.ExpectTotalCount( 1931 histogram_tester.ExpectTotalCount(
1927 "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." + 1932 "NQE.Accuracy.TransportRTT.EstimatedObservedDiff." +
1928 sign_suffix_with_zero_samples + "." + interval_value + ".60_140", 1933 sign_suffix_with_zero_samples + "." + interval_value + ".60_140",
1929 0); 1934 0);
1935
1936 histogram_tester.ExpectUniqueSample(
1937 "NQE.ExternalEstimateProvider.RTT.Accuracy.EstimatedObservedDiff." +
1938 sign_suffix_with_one_sample + "." + interval_value + ".60_140",
1939 diff, 1);
1940 histogram_tester.ExpectTotalCount(
1941 "NQE.ExternalEstimateProvider.RTT.Accuracy.EstimatedObservedDiff." +
1942 sign_suffix_with_zero_samples + "." + interval_value + ".60_140",
1943 0);
1930 } 1944 }
1931 } 1945 }
1932 } 1946 }
1933 1947
1934 // Tests that the effective connection type is converted correctly to a 1948 // Tests that the effective connection type is converted correctly to a
1935 // descriptive string name, and vice-versa. 1949 // descriptive string name, and vice-versa.
1936 TEST(NetworkQualityEstimatorTest, NameConnectionTypeConversion) { 1950 TEST(NetworkQualityEstimatorTest, NameConnectionTypeConversion) {
1937 for (size_t i = 0; 1951 for (size_t i = 0;
1938 i < NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_LAST; ++i) { 1952 i < NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_LAST; ++i) {
1939 const NetworkQualityEstimator::EffectiveConnectionType 1953 const NetworkQualityEstimator::EffectiveConnectionType
1940 effective_connection_type = 1954 effective_connection_type =
1941 static_cast<NetworkQualityEstimator::EffectiveConnectionType>(i); 1955 static_cast<NetworkQualityEstimator::EffectiveConnectionType>(i);
1942 std::string connection_type_name = 1956 std::string connection_type_name =
1943 std::string(NetworkQualityEstimator::GetNameForEffectiveConnectionType( 1957 std::string(NetworkQualityEstimator::GetNameForEffectiveConnectionType(
1944 effective_connection_type)); 1958 effective_connection_type));
1945 EXPECT_FALSE(connection_type_name.empty()); 1959 EXPECT_FALSE(connection_type_name.empty());
1946 EXPECT_EQ(effective_connection_type, 1960 EXPECT_EQ(effective_connection_type,
1947 NetworkQualityEstimator::GetEffectiveConnectionTypeForName( 1961 NetworkQualityEstimator::GetEffectiveConnectionTypeForName(
1948 connection_type_name)); 1962 connection_type_name));
1949 } 1963 }
1950 } 1964 }
1951 1965
1952 } // namespace net 1966 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698