| 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/base/network_quality_estimator.h" | 5 #include "net/base/network_quality_estimator.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 367 |
| 368 // Verifies that the percentiles are correctly computed. Observations have | 368 // Verifies that the percentiles are correctly computed. Observations have |
| 369 // different timestamps with half the observations being very old and the rest | 369 // different timestamps with half the observations being very old and the rest |
| 370 // of them being very recent. Percentiles should factor in recent observations | 370 // of them being very recent. Percentiles should factor in recent observations |
| 371 // much more heavily than older samples. Kbps percentiles must be in decreasing | 371 // much more heavily than older samples. Kbps percentiles must be in decreasing |
| 372 // order. RTT percentiles must be in increasing order. | 372 // order. RTT percentiles must be in increasing order. |
| 373 TEST(NetworkQualityEstimatorTest, PercentileDifferentTimestamps) { | 373 TEST(NetworkQualityEstimatorTest, PercentileDifferentTimestamps) { |
| 374 std::map<std::string, std::string> variation_params; | 374 std::map<std::string, std::string> variation_params; |
| 375 TestNetworkQualityEstimator estimator(variation_params); | 375 TestNetworkQualityEstimator estimator(variation_params); |
| 376 base::TimeTicks now = base::TimeTicks::Now(); | 376 base::TimeTicks now = base::TimeTicks::Now(); |
| 377 base::TimeTicks very_old = base::TimeTicks::UnixEpoch(); | 377 base::TimeTicks very_old = now - base::TimeDelta::FromDays(365); |
| 378 | 378 |
| 379 // First 50 samples have very old timestamp. | 379 // First 50 samples have very old timestamp. |
| 380 for (int i = 1; i <= 50; ++i) { | 380 for (int i = 1; i <= 50; ++i) { |
| 381 estimator.downstream_throughput_kbps_observations_.AddObservation( | 381 estimator.downstream_throughput_kbps_observations_.AddObservation( |
| 382 NetworkQualityEstimator::ThroughputObservation( | 382 NetworkQualityEstimator::ThroughputObservation( |
| 383 i, very_old, NetworkQualityEstimator::URL_REQUEST)); | 383 i, very_old, NetworkQualityEstimator::URL_REQUEST)); |
| 384 estimator.rtt_observations_.AddObservation( | 384 estimator.rtt_observations_.AddObservation( |
| 385 NetworkQualityEstimator::RttObservation( | 385 NetworkQualityEstimator::RttObservation( |
| 386 base::TimeDelta::FromMilliseconds(i), very_old, | 386 base::TimeDelta::FromMilliseconds(i), very_old, |
| 387 NetworkQualityEstimator::URL_REQUEST)); | 387 NetworkQualityEstimator::URL_REQUEST)); |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 | 1105 |
| 1106 EXPECT_EQ(4U, rtt_observer.observations().size()); | 1106 EXPECT_EQ(4U, rtt_observer.observations().size()); |
| 1107 EXPECT_EQ(2U, throughput_observer.observations().size()); | 1107 EXPECT_EQ(2U, throughput_observer.observations().size()); |
| 1108 | 1108 |
| 1109 EXPECT_EQ(tcp_rtt.InMilliseconds(), rtt_observer.observations().at(2).rtt_ms); | 1109 EXPECT_EQ(tcp_rtt.InMilliseconds(), rtt_observer.observations().at(2).rtt_ms); |
| 1110 EXPECT_EQ(quic_rtt.InMilliseconds(), | 1110 EXPECT_EQ(quic_rtt.InMilliseconds(), |
| 1111 rtt_observer.observations().at(3).rtt_ms); | 1111 rtt_observer.observations().at(3).rtt_ms); |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 } // namespace net | 1114 } // namespace net |
| OLD | NEW |