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

Unified Diff: net/base/network_quality_estimator_unittest.cc

Issue 1273173002: Added Network Quality Estimator Real-time interface to Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from tbansal Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: net/base/network_quality_estimator_unittest.cc
diff --git a/net/base/network_quality_estimator_unittest.cc b/net/base/network_quality_estimator_unittest.cc
index 6790bb7637b6dae14fff943c90f447bd0a14c3b0..169d154590b7899f0b0f67a7e4f4da56eeb8cfc1 100644
--- a/net/base/network_quality_estimator_unittest.cc
+++ b/net/base/network_quality_estimator_unittest.cc
@@ -224,18 +224,22 @@ TEST(NetworkQualityEstimatorTest, PercentileSameTimestamps) {
// samples. This helps in verifying that the order of samples does not matter.
for (int i = 1; i <= 99; i += 2) {
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(i, now));
+ NetworkQualityEstimator::Observation(
+ i, now, NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(i, now));
+ NetworkQualityEstimator::Observation(
+ i, now, NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
EXPECT_TRUE(estimator.GetRTTEstimate(&rtt));
EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps));
}
for (int i = 2; i <= 100; i += 2) {
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(i, now));
+ NetworkQualityEstimator::Observation(
+ i, now, NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(i, now));
+ NetworkQualityEstimator::Observation(
+ i, now, NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
EXPECT_TRUE(estimator.GetRTTEstimate(&rtt));
EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps));
}
@@ -276,17 +280,23 @@ TEST(NetworkQualityEstimatorTest, PercentileDifferentTimestamps) {
// First 50 samples have very old timestamp.
for (int i = 1; i <= 50; ++i) {
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(i, very_old));
+ NetworkQualityEstimator::Observation(
+ i, very_old,
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(i, very_old));
+ NetworkQualityEstimator::Observation(
+ i, very_old,
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
}
// Next 50 (i.e., from 51 to 100) have recent timestamp.
for (int i = 51; i <= 100; ++i) {
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(i, now));
+ NetworkQualityEstimator::Observation(
+ i, now, NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(i, now));
+ NetworkQualityEstimator::Observation(
+ i, now, NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
}
// Older samples have very little weight. So, all percentiles are >= 51
@@ -495,9 +505,13 @@ TEST(NetworkQualityEstimatorTest, TestCaching) {
// Cache entry will not be added for (NONE, "").
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(1, base::TimeTicks::Now()));
+ NetworkQualityEstimator::Observation(
+ 1, base::TimeTicks::Now(),
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(1000, base::TimeTicks::Now()));
+ NetworkQualityEstimator::Observation(
+ 1000, base::TimeTicks::Now(),
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.SimulateNetworkChangeTo(
NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-1");
EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size());
@@ -506,9 +520,13 @@ TEST(NetworkQualityEstimatorTest, TestCaching) {
// Also, set the network quality for (2G, "test1") so that it is stored in
// the cache.
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(1, base::TimeTicks::Now()));
+ NetworkQualityEstimator::Observation(
+ 1, base::TimeTicks::Now(),
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(1000, base::TimeTicks::Now()));
+ NetworkQualityEstimator::Observation(
+ 1000, base::TimeTicks::Now(),
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.SimulateNetworkChangeTo(
NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-1");
@@ -518,9 +536,13 @@ TEST(NetworkQualityEstimatorTest, TestCaching) {
// Also, set the network quality for (3G, "test1") so that it is stored in
// the cache.
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(2, base::TimeTicks::Now()));
+ NetworkQualityEstimator::Observation(
+ 2, base::TimeTicks::Now(),
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(500, base::TimeTicks::Now()));
+ NetworkQualityEstimator::Observation(
+ 500, base::TimeTicks::Now(),
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.SimulateNetworkChangeTo(
NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-2");
EXPECT_EQ(++expected_cache_size, estimator.cached_network_qualities_.size());
@@ -583,9 +605,13 @@ TEST(NetworkQualityEstimatorTest, TestLRUCacheMaximumSize) {
base::TimeTicks update_time_of_network_100;
for (size_t i = 0; i < network_count; ++i) {
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(2, base::TimeTicks::Now()));
+ NetworkQualityEstimator::Observation(
+ 2, base::TimeTicks::Now(),
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(500, base::TimeTicks::Now()));
+ NetworkQualityEstimator::Observation(
+ 500, base::TimeTicks::Now(),
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
if (i == 100)
update_time_of_network_100 = base::TimeTicks::Now();
@@ -601,9 +627,13 @@ TEST(NetworkQualityEstimatorTest, TestLRUCacheMaximumSize) {
}
// One more call so that the last network is also written to cache.
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(2, base::TimeTicks::Now()));
+ NetworkQualityEstimator::Observation(
+ 2, base::TimeTicks::Now(),
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(500, base::TimeTicks::Now()));
+ NetworkQualityEstimator::Observation(
+ 500, base::TimeTicks::Now(),
+ NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.SimulateNetworkChangeTo(
net::NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI,
base::IntToString(network_count - 1));
@@ -629,14 +659,18 @@ TEST(NetworkQualityEstimatorTest, TestGetMedianRTTSince) {
// First sample has very old timestamp.
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(1, old));
+ NetworkQualityEstimator::Observation(
+ 1, old, NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(1, old));
+ NetworkQualityEstimator::Observation(
+ 1, old, NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.downstream_throughput_kbps_observations_.AddObservation(
- NetworkQualityEstimator::Observation(100, now));
+ NetworkQualityEstimator::Observation(
+ 100, now, NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
estimator.rtt_msec_observations_.AddObservation(
- NetworkQualityEstimator::Observation(100, now));
+ NetworkQualityEstimator::Observation(
+ 100, now, NetworkQualityEstimator::OBSERVATION_SOURCE_URL_REQUEST));
base::TimeDelta rtt;
EXPECT_FALSE(estimator.GetRecentMedianRTT(
« net/base/network_quality_estimator.h ('K') | « net/base/network_quality_estimator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698