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

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

Issue 1897903002: Record how frequently EEP provides valid estimates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed whitespace (asvitkine's comment) Created 4 years, 7 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/base/network_quality_estimator.cc ('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/base/network_quality_estimator.h" 5 #include "net/base/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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 private: 949 private:
950 // Keeps track of number of times different functions were called. 950 // Keeps track of number of times different functions were called.
951 mutable size_t get_rtt_count_; 951 mutable size_t get_rtt_count_;
952 952
953 DISALLOW_COPY_AND_ASSIGN(InvalidExternalEstimateProvider); 953 DISALLOW_COPY_AND_ASSIGN(InvalidExternalEstimateProvider);
954 }; 954 };
955 955
956 // Tests if the RTT value from external estimate provider is discarded if the 956 // Tests if the RTT value from external estimate provider is discarded if the
957 // external estimate provider is invalid. 957 // external estimate provider is invalid.
958 TEST(NetworkQualityEstimatorTest, InvalidExternalEstimateProvider) { 958 TEST(NetworkQualityEstimatorTest, InvalidExternalEstimateProvider) {
959 base::HistogramTester histogram_tester;
959 InvalidExternalEstimateProvider* invalid_external_estimate_provider = 960 InvalidExternalEstimateProvider* invalid_external_estimate_provider =
960 new InvalidExternalEstimateProvider(); 961 new InvalidExternalEstimateProvider();
961 std::unique_ptr<ExternalEstimateProvider> external_estimate_provider( 962 std::unique_ptr<ExternalEstimateProvider> external_estimate_provider(
962 invalid_external_estimate_provider); 963 invalid_external_estimate_provider);
963 964
964 TestNetworkQualityEstimator estimator(std::map<std::string, std::string>(), 965 TestNetworkQualityEstimator estimator(std::map<std::string, std::string>(),
965 std::move(external_estimate_provider)); 966 std::move(external_estimate_provider));
966 967
967 base::TimeDelta rtt; 968 base::TimeDelta rtt;
968 int32_t kbps; 969 int32_t kbps;
969 EXPECT_EQ(1U, invalid_external_estimate_provider->get_rtt_count()); 970 EXPECT_EQ(1U, invalid_external_estimate_provider->get_rtt_count());
970 EXPECT_FALSE(estimator.GetURLRequestRTTEstimate(&rtt)); 971 EXPECT_FALSE(estimator.GetURLRequestRTTEstimate(&rtt));
971 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); 972 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps));
973 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 3);
974
975 histogram_tester.ExpectBucketCount(
976 "NQE.ExternalEstimateProviderStatus",
977 1 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE */, 1);
978 histogram_tester.ExpectBucketCount(
979 "NQE.ExternalEstimateProviderStatus",
980 2 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED */, 1);
981 histogram_tester.ExpectBucketCount(
982 "NQE.ExternalEstimateProviderStatus",
983 3 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL */, 1);
984 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProvider.RTT", 0);
985 histogram_tester.ExpectTotalCount(
986 "NQE.ExternalEstimateProvider.DownlinkBandwidth", 0);
972 } 987 }
973 988
974 class TestExternalEstimateProvider : public ExternalEstimateProvider { 989 class TestExternalEstimateProvider : public ExternalEstimateProvider {
975 public: 990 public:
976 TestExternalEstimateProvider(base::TimeDelta rtt, 991 TestExternalEstimateProvider(base::TimeDelta rtt,
977 int32_t downstream_throughput_kbps) 992 int32_t downstream_throughput_kbps)
978 : rtt_(rtt), 993 : rtt_(rtt),
979 downstream_throughput_kbps_(downstream_throughput_kbps), 994 downstream_throughput_kbps_(downstream_throughput_kbps),
980 time_since_last_update_(base::TimeDelta::FromSeconds(1)), 995 time_since_last_update_(base::TimeDelta::FromSeconds(1)),
981 get_time_since_last_update_count_(0), 996 get_time_since_last_update_count_(0),
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 mutable size_t get_rtt_count_; 1061 mutable size_t get_rtt_count_;
1047 mutable size_t get_downstream_throughput_kbps_count_; 1062 mutable size_t get_downstream_throughput_kbps_count_;
1048 mutable size_t update_count_; 1063 mutable size_t update_count_;
1049 1064
1050 DISALLOW_COPY_AND_ASSIGN(TestExternalEstimateProvider); 1065 DISALLOW_COPY_AND_ASSIGN(TestExternalEstimateProvider);
1051 }; 1066 };
1052 1067
1053 // Tests if the external estimate provider is called in the constructor and 1068 // Tests if the external estimate provider is called in the constructor and
1054 // on network change notification. 1069 // on network change notification.
1055 TEST(NetworkQualityEstimatorTest, TestExternalEstimateProvider) { 1070 TEST(NetworkQualityEstimatorTest, TestExternalEstimateProvider) {
1071 base::HistogramTester histogram_tester;
1056 TestExternalEstimateProvider* test_external_estimate_provider = 1072 TestExternalEstimateProvider* test_external_estimate_provider =
1057 new TestExternalEstimateProvider(base::TimeDelta::FromMilliseconds(1), 1073 new TestExternalEstimateProvider(base::TimeDelta::FromMilliseconds(1),
1058 100); 1074 100);
1059 std::unique_ptr<ExternalEstimateProvider> external_estimate_provider( 1075 std::unique_ptr<ExternalEstimateProvider> external_estimate_provider(
1060 test_external_estimate_provider); 1076 test_external_estimate_provider);
1061 std::map<std::string, std::string> variation_params; 1077 std::map<std::string, std::string> variation_params;
1062 TestNetworkQualityEstimator estimator(variation_params, 1078 TestNetworkQualityEstimator estimator(variation_params,
1063 std::move(external_estimate_provider)); 1079 std::move(external_estimate_provider));
1064 1080
1065 base::TimeDelta rtt; 1081 base::TimeDelta rtt;
1066 int32_t kbps; 1082 int32_t kbps;
1067 EXPECT_TRUE(estimator.GetURLRequestRTTEstimate(&rtt)); 1083 EXPECT_TRUE(estimator.GetURLRequestRTTEstimate(&rtt));
1068 EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); 1084 EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps));
1069 1085
1086 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProviderStatus", 5);
1087
1088 histogram_tester.ExpectBucketCount(
1089 "NQE.ExternalEstimateProviderStatus",
1090 1 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE */, 1);
1091 histogram_tester.ExpectBucketCount(
1092 "NQE.ExternalEstimateProviderStatus",
1093 2 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED */, 1);
1094 histogram_tester.ExpectBucketCount(
1095 "NQE.ExternalEstimateProviderStatus",
1096 3 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL */, 1);
1097 histogram_tester.ExpectBucketCount(
1098 "NQE.ExternalEstimateProviderStatus",
1099 5 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE */, 1);
1100 histogram_tester.ExpectBucketCount(
1101 "NQE.ExternalEstimateProviderStatus",
1102 6 /* EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE */,
1103 1);
1104 histogram_tester.ExpectTotalCount("NQE.ExternalEstimateProvider.RTT", 1);
1105 histogram_tester.ExpectBucketCount("NQE.ExternalEstimateProvider.RTT", 1, 1);
1106
1107 histogram_tester.ExpectTotalCount(
1108 "NQE.ExternalEstimateProvider.DownlinkBandwidth", 1);
1109 histogram_tester.ExpectBucketCount(
1110 "NQE.ExternalEstimateProvider.DownlinkBandwidth", 100, 1);
1111
1070 EXPECT_EQ( 1112 EXPECT_EQ(
1071 1U, test_external_estimate_provider->get_time_since_last_update_count()); 1113 1U, test_external_estimate_provider->get_time_since_last_update_count());
1072 EXPECT_EQ(1U, test_external_estimate_provider->get_rtt_count()); 1114 EXPECT_EQ(1U, test_external_estimate_provider->get_rtt_count());
1073 EXPECT_EQ( 1115 EXPECT_EQ(
1074 1U, 1116 1U,
1075 test_external_estimate_provider->get_downstream_throughput_kbps_count()); 1117 test_external_estimate_provider->get_downstream_throughput_kbps_count());
1076 1118
1077 // Change network type to WiFi. Number of queries to External estimate 1119 // Change network type to WiFi. Number of queries to External estimate
1078 // provider must increment. 1120 // provider must increment.
1079 estimator.SimulateNetworkChangeTo( 1121 estimator.SimulateNetworkChangeTo(
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 } 1332 }
1291 // At least one notification should be received per socket performance 1333 // At least one notification should be received per socket performance
1292 // watcher. 1334 // watcher.
1293 EXPECT_LE(1U, after_count_tcp_rtt_observations - 1335 EXPECT_LE(1U, after_count_tcp_rtt_observations -
1294 before_count_tcp_rtt_observations) 1336 before_count_tcp_rtt_observations)
1295 << i; 1337 << i;
1296 } 1338 }
1297 } 1339 }
1298 1340
1299 } // namespace net 1341 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_quality_estimator.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698