| 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/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 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 histogram_tester.ExpectUniqueSample("NQE.Prefs.ReadSize", read_prefs.size(), | 2653 histogram_tester.ExpectUniqueSample("NQE.Prefs.ReadSize", read_prefs.size(), |
| 2654 1); | 2654 1); |
| 2655 | 2655 |
| 2656 // Taken from network_quality_estimator_params.cc. | 2656 // Taken from network_quality_estimator_params.cc. |
| 2657 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1800), | 2657 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1800), |
| 2658 rtt_observer.last_rtt( | 2658 rtt_observer.last_rtt( |
| 2659 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE)); | 2659 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE)); |
| 2660 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1500), | 2660 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1500), |
| 2661 rtt_observer.last_rtt( | 2661 rtt_observer.last_rtt( |
| 2662 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE)); | 2662 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE)); |
| 2663 EXPECT_EQ(0u, throughput_observer.observations().size()); | 2663 EXPECT_EQ(1u, throughput_observer.observations().size()); |
| 2664 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1800), | 2664 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1800), |
| 2665 rtt_throughput_observer.http_rtt()); | 2665 rtt_throughput_observer.http_rtt()); |
| 2666 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1500), | 2666 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1500), |
| 2667 rtt_throughput_observer.transport_rtt()); | 2667 rtt_throughput_observer.transport_rtt()); |
| 2668 EXPECT_EQ(nqe::internal::kInvalidThroughput, | 2668 EXPECT_EQ(75, rtt_throughput_observer.downstream_throughput_kbps()); |
| 2669 rtt_throughput_observer.downstream_throughput_kbps()); | |
| 2670 EXPECT_LE( | 2669 EXPECT_LE( |
| 2671 1u, | 2670 1u, |
| 2672 effective_connection_type_observer.effective_connection_types().size()); | 2671 effective_connection_type_observer.effective_connection_types().size()); |
| 2673 // Compare the ECT stored in prefs with the observer's last entry. | 2672 // Compare the ECT stored in prefs with the observer's last entry. |
| 2674 EXPECT_EQ( | 2673 EXPECT_EQ( |
| 2675 read_prefs[nqe::internal::NetworkID( | 2674 read_prefs[nqe::internal::NetworkID( |
| 2676 NetworkChangeNotifier::CONNECTION_WIFI, network_name)] | 2675 NetworkChangeNotifier::CONNECTION_WIFI, network_name)] |
| 2677 .effective_connection_type(), | 2676 .effective_connection_type(), |
| 2678 effective_connection_type_observer.effective_connection_types().back()); | 2677 effective_connection_type_observer.effective_connection_types().back()); |
| 2679 | 2678 |
| 2680 // Change to a different connection type. | 2679 // Change to a different connection type. |
| 2681 network_name = "test_ect_slow_2g"; | 2680 network_name = "test_ect_slow_2g"; |
| 2682 estimator.SimulateNetworkChange( | 2681 estimator.SimulateNetworkChange( |
| 2683 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, network_name); | 2682 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, network_name); |
| 2684 | 2683 |
| 2685 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3600), | 2684 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3600), |
| 2686 rtt_observer.last_rtt( | 2685 rtt_observer.last_rtt( |
| 2687 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE)); | 2686 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE)); |
| 2688 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3000), | 2687 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3000), |
| 2689 rtt_observer.last_rtt( | 2688 rtt_observer.last_rtt( |
| 2690 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE)); | 2689 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE)); |
| 2691 EXPECT_EQ(0u, throughput_observer.observations().size()); | 2690 EXPECT_EQ(2U, throughput_observer.observations().size()); |
| 2692 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3600), | 2691 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3600), |
| 2693 rtt_throughput_observer.http_rtt()); | 2692 rtt_throughput_observer.http_rtt()); |
| 2694 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3000), | 2693 EXPECT_EQ(base::TimeDelta::FromMilliseconds(3000), |
| 2695 rtt_throughput_observer.transport_rtt()); | 2694 rtt_throughput_observer.transport_rtt()); |
| 2696 EXPECT_EQ(nqe::internal::kInvalidThroughput, | 2695 EXPECT_EQ(40, rtt_throughput_observer.downstream_throughput_kbps()); |
| 2697 rtt_throughput_observer.downstream_throughput_kbps()); | |
| 2698 EXPECT_LE( | 2696 EXPECT_LE( |
| 2699 2u, | 2697 2u, |
| 2700 effective_connection_type_observer.effective_connection_types().size()); | 2698 effective_connection_type_observer.effective_connection_types().size()); |
| 2701 // Compare with the last entry. | 2699 // Compare with the last entry. |
| 2702 EXPECT_EQ( | 2700 EXPECT_EQ( |
| 2703 read_prefs[nqe::internal::NetworkID( | 2701 read_prefs[nqe::internal::NetworkID( |
| 2704 NetworkChangeNotifier::CONNECTION_WIFI, network_name)] | 2702 NetworkChangeNotifier::CONNECTION_WIFI, network_name)] |
| 2705 .effective_connection_type(), | 2703 .effective_connection_type(), |
| 2706 effective_connection_type_observer.effective_connection_types().back()); | 2704 effective_connection_type_observer.effective_connection_types().back()); |
| 2707 | 2705 |
| 2708 // Cleanup. | 2706 // Cleanup. |
| 2709 estimator.RemoveRTTObserver(&rtt_observer); | 2707 estimator.RemoveRTTObserver(&rtt_observer); |
| 2710 estimator.RemoveThroughputObserver(&throughput_observer); | 2708 estimator.RemoveThroughputObserver(&throughput_observer); |
| 2711 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); | 2709 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); |
| 2712 estimator.RemoveEffectiveConnectionTypeObserver( | 2710 estimator.RemoveEffectiveConnectionTypeObserver( |
| 2713 &effective_connection_type_observer); | 2711 &effective_connection_type_observer); |
| 2714 } | 2712 } |
| 2715 | 2713 |
| 2716 } // namespace net | 2714 } // namespace net |
| OLD | NEW |