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 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 // Entry will be added for (2G, "test1"). | 505 // Entry will be added for (2G, "test1"). |
506 // Also, set the network quality for (2G, "test1") so that it is stored in | 506 // Also, set the network quality for (2G, "test1") so that it is stored in |
507 // the cache. | 507 // the cache. |
508 estimator.downstream_throughput_kbps_observations_.AddObservation( | 508 estimator.downstream_throughput_kbps_observations_.AddObservation( |
509 NetworkQualityEstimator::Observation(1, base::TimeTicks::Now())); | 509 NetworkQualityEstimator::Observation(1, base::TimeTicks::Now())); |
510 estimator.rtt_msec_observations_.AddObservation( | 510 estimator.rtt_msec_observations_.AddObservation( |
511 NetworkQualityEstimator::Observation(1000, base::TimeTicks::Now())); | 511 NetworkQualityEstimator::Observation(1000, base::TimeTicks::Now())); |
512 | 512 |
513 estimator.SimulateNetworkChangeTo( | 513 estimator.SimulateNetworkChangeTo( |
514 NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-1"); | 514 NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-1"); |
515 EXPECT_EQ(++expected_cache_size, estimator.cached_network_qualities_.size()); | 515 ++expected_cache_size; |
| 516 EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); |
516 | 517 |
517 // Entry will be added for (3G, "test1"). | 518 // Entry will be added for (3G, "test1"). |
518 // Also, set the network quality for (3G, "test1") so that it is stored in | 519 // Also, set the network quality for (3G, "test1") so that it is stored in |
519 // the cache. | 520 // the cache. |
520 estimator.downstream_throughput_kbps_observations_.AddObservation( | 521 estimator.downstream_throughput_kbps_observations_.AddObservation( |
521 NetworkQualityEstimator::Observation(2, base::TimeTicks::Now())); | 522 NetworkQualityEstimator::Observation(2, base::TimeTicks::Now())); |
522 estimator.rtt_msec_observations_.AddObservation( | 523 estimator.rtt_msec_observations_.AddObservation( |
523 NetworkQualityEstimator::Observation(500, base::TimeTicks::Now())); | 524 NetworkQualityEstimator::Observation(500, base::TimeTicks::Now())); |
524 estimator.SimulateNetworkChangeTo( | 525 estimator.SimulateNetworkChangeTo( |
525 NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-2"); | 526 NetworkChangeNotifier::ConnectionType::CONNECTION_3G, "test-2"); |
526 EXPECT_EQ(++expected_cache_size, estimator.cached_network_qualities_.size()); | 527 ++expected_cache_size; |
| 528 EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); |
527 | 529 |
528 // Entry will not be added for (3G, "test2"). | 530 // Entry will not be added for (3G, "test2"). |
529 estimator.SimulateNetworkChangeTo( | 531 estimator.SimulateNetworkChangeTo( |
530 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-1"); | 532 NetworkChangeNotifier::ConnectionType::CONNECTION_2G, "test-1"); |
531 EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); | 533 EXPECT_EQ(expected_cache_size, estimator.cached_network_qualities_.size()); |
532 | 534 |
533 // Read the network quality for (2G, "test-1"). | 535 // Read the network quality for (2G, "test-1"). |
534 EXPECT_TRUE(estimator.ReadCachedNetworkQualityEstimate()); | 536 EXPECT_TRUE(estimator.ReadCachedNetworkQualityEstimate()); |
535 | 537 |
536 base::TimeDelta rtt; | 538 base::TimeDelta rtt; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 648 |
647 int32_t downstream_throughput_kbps; | 649 int32_t downstream_throughput_kbps; |
648 EXPECT_FALSE(estimator.GetRecentMedianDownlinkThroughputKbps( | 650 EXPECT_FALSE(estimator.GetRecentMedianDownlinkThroughputKbps( |
649 now + base::TimeDelta::FromSeconds(10), &downstream_throughput_kbps)); | 651 now + base::TimeDelta::FromSeconds(10), &downstream_throughput_kbps)); |
650 EXPECT_TRUE(estimator.GetRecentMedianDownlinkThroughputKbps( | 652 EXPECT_TRUE(estimator.GetRecentMedianDownlinkThroughputKbps( |
651 now, &downstream_throughput_kbps)); | 653 now, &downstream_throughput_kbps)); |
652 EXPECT_EQ(100, downstream_throughput_kbps); | 654 EXPECT_EQ(100, downstream_throughput_kbps); |
653 } | 655 } |
654 | 656 |
655 } // namespace net | 657 } // namespace net |
OLD | NEW |