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

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

Issue 2875073004: Move more variables to NQE params class (Closed)
Patch Set: ryansturm comments Created 3 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/nqe/network_quality_estimator_params_unittest.cc ('k') | no next file » | 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/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 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after
2806 } tests[] = { 2806 } tests[] = {
2807 { 2807 {
2808 false, 2808 false,
2809 }, 2809 },
2810 { 2810 {
2811 true, 2811 true,
2812 }, 2812 },
2813 }; 2813 };
2814 2814
2815 for (const auto& test : tests) { 2815 for (const auto& test : tests) {
2816 TestNetworkQualitiesCacheObserver observer;
2817 std::map<std::string, std::string> variation_params; 2816 std::map<std::string, std::string> variation_params;
2818 if (test.use_transport_rtt) { 2817 if (test.use_transport_rtt) {
2819 variation_params["effective_connection_type_algorithm"] = 2818 variation_params["effective_connection_type_algorithm"] =
2820 "TransportRTTOrDownstreamThroughput"; 2819 "TransportRTTOrDownstreamThroughput";
2821 } 2820 }
2822 TestNetworkQualityEstimator estimator(variation_params); 2821 TestNetworkQualityEstimator estimator(variation_params);
2823
2824 // Typical network quality should not be set for Unknown and Offline.
2825 for (size_t i = EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
2826 i <= EFFECTIVE_CONNECTION_TYPE_OFFLINE; ++i) {
2827 EXPECT_EQ(nqe::internal::InvalidRTT(),
2828 estimator.typical_network_quality_[i].http_rtt());
2829
2830 EXPECT_EQ(nqe::internal::InvalidRTT(),
2831 estimator.typical_network_quality_[i].transport_rtt());
2832 }
2833
2834 // Typical network quality should be set for other effective connection
2835 // types.
2836 for (size_t i = EFFECTIVE_CONNECTION_TYPE_SLOW_2G;
2837 i <= EFFECTIVE_CONNECTION_TYPE_3G; ++i) {
2838 // The typical RTT for an effective connection type should be at least as
2839 // much as the threshold RTT.
2840 EXPECT_NE(nqe::internal::InvalidRTT(),
2841 estimator.typical_network_quality_[i].http_rtt());
2842 EXPECT_GT(estimator.typical_network_quality_[i].http_rtt(),
2843 estimator.connection_thresholds_[i].http_rtt());
2844
2845 EXPECT_NE(nqe::internal::InvalidRTT(),
2846 estimator.typical_network_quality_[i].transport_rtt());
2847 EXPECT_GT(estimator.typical_network_quality_[i].transport_rtt(),
2848 estimator.connection_thresholds_[i].transport_rtt());
2849
2850 // The typical throughput for an effective connection type should not be
2851 // more than the threshold throughput.
2852 if (estimator.connection_thresholds_[i].downstream_throughput_kbps() !=
2853 nqe::internal::kInvalidThroughput) {
2854 EXPECT_LT(
2855 estimator.typical_network_quality_[i].downstream_throughput_kbps(),
2856 estimator.connection_thresholds_[i].downstream_throughput_kbps());
2857 }
2858 }
2859
2860 // The typical network quality of 4G connection should be at least as fast
2861 // as the threshold for 3G connection.
2862 EXPECT_LT(estimator.typical_network_quality_[EFFECTIVE_CONNECTION_TYPE_4G]
2863 .http_rtt(),
2864 estimator.connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_3G]
2865 .http_rtt());
2866 EXPECT_LT(estimator.typical_network_quality_[EFFECTIVE_CONNECTION_TYPE_4G]
2867 .transport_rtt(),
2868 estimator.connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_3G]
2869 .transport_rtt());
2870 if (estimator.connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_3G]
2871 .downstream_throughput_kbps() !=
2872 nqe::internal::kInvalidThroughput) {
2873 EXPECT_GT(estimator.typical_network_quality_[EFFECTIVE_CONNECTION_TYPE_4G]
2874 .downstream_throughput_kbps(),
2875 estimator.connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_3G]
2876 .downstream_throughput_kbps());
2877 }
2878
2879 TestDelegate test_delegate; 2822 TestDelegate test_delegate;
2880 TestURLRequestContext context(true); 2823 TestURLRequestContext context(true);
2881 context.set_network_quality_estimator(&estimator); 2824 context.set_network_quality_estimator(&estimator);
2882 context.Init(); 2825 context.Init();
2883 2826
2884 for (size_t effective_connection_type = EFFECTIVE_CONNECTION_TYPE_SLOW_2G; 2827 for (size_t effective_connection_type = EFFECTIVE_CONNECTION_TYPE_SLOW_2G;
2885 effective_connection_type <= EFFECTIVE_CONNECTION_TYPE_4G; 2828 effective_connection_type <= EFFECTIVE_CONNECTION_TYPE_4G;
2886 ++effective_connection_type) { 2829 ++effective_connection_type) {
2887 // Set the RTT and throughput values to the typical values for 2830 // Set the RTT and throughput values to the typical values for
2888 // |effective_connection_type|. The effective connection type should be 2831 // |effective_connection_type|. The effective connection type should be
2889 // computed as |effective_connection_type|. 2832 // computed as |effective_connection_type|.
2890 estimator.set_start_time_null_http_rtt( 2833 estimator.set_start_time_null_http_rtt(
2891 estimator.typical_network_quality_[effective_connection_type] 2834 estimator.params_
2835 .TypicalNetworkQuality(static_cast<EffectiveConnectionType>(
2836 effective_connection_type))
2892 .http_rtt()); 2837 .http_rtt());
2893 estimator.set_start_time_null_transport_rtt( 2838 estimator.set_start_time_null_transport_rtt(
2894 estimator.typical_network_quality_[effective_connection_type] 2839 estimator.params_
2840 .TypicalNetworkQuality(static_cast<EffectiveConnectionType>(
2841 effective_connection_type))
2895 .transport_rtt()); 2842 .transport_rtt());
2896 estimator.set_start_time_null_downlink_throughput_kbps(INT32_MAX); 2843 estimator.set_start_time_null_downlink_throughput_kbps(INT32_MAX);
2897 2844
2898 // Force recomputation of effective connection type by starting a main 2845 // Force recomputation of effective connection type by starting a main
2899 // frame request. 2846 // frame request.
2900 std::unique_ptr<URLRequest> request( 2847 std::unique_ptr<URLRequest> request(
2901 context.CreateRequest(estimator.GetEchoURL(), DEFAULT_PRIORITY, 2848 context.CreateRequest(estimator.GetEchoURL(), DEFAULT_PRIORITY,
2902 &test_delegate, TRAFFIC_ANNOTATION_FOR_TESTS)); 2849 &test_delegate, TRAFFIC_ANNOTATION_FOR_TESTS));
2903 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED); 2850 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
2904 request->Start(); 2851 request->Start();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
3112 3059
3113 // Cleanup. 3060 // Cleanup.
3114 estimator.RemoveRTTObserver(&rtt_observer); 3061 estimator.RemoveRTTObserver(&rtt_observer);
3115 estimator.RemoveThroughputObserver(&throughput_observer); 3062 estimator.RemoveThroughputObserver(&throughput_observer);
3116 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer); 3063 estimator.RemoveRTTAndThroughputEstimatesObserver(&rtt_throughput_observer);
3117 estimator.RemoveEffectiveConnectionTypeObserver( 3064 estimator.RemoveEffectiveConnectionTypeObserver(
3118 &effective_connection_type_observer); 3065 &effective_connection_type_observer);
3119 } 3066 }
3120 3067
3121 } // namespace net 3068 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator_params_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698