| 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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 // Tests that |GetEffectiveConnectionType| returns correct connection type when | 778 // Tests that |GetEffectiveConnectionType| returns correct connection type when |
| 779 // only RTT thresholds are specified in the variation params. | 779 // only RTT thresholds are specified in the variation params. |
| 780 TEST(NetworkQualityEstimatorTest, ObtainThresholdsOnlyRTT) { | 780 TEST(NetworkQualityEstimatorTest, ObtainThresholdsOnlyRTT) { |
| 781 std::map<std::string, std::string> variation_params; | 781 std::map<std::string, std::string> variation_params; |
| 782 | 782 |
| 783 variation_params["Offline.ThresholdMedianHttpRTTMsec"] = "4000"; | 783 variation_params["Offline.ThresholdMedianHttpRTTMsec"] = "4000"; |
| 784 variation_params["Slow2G.ThresholdMedianHttpRTTMsec"] = "2000"; | 784 variation_params["Slow2G.ThresholdMedianHttpRTTMsec"] = "2000"; |
| 785 variation_params["2G.ThresholdMedianHttpRTTMsec"] = "1000"; | 785 variation_params["2G.ThresholdMedianHttpRTTMsec"] = "1000"; |
| 786 variation_params["3G.ThresholdMedianHttpRTTMsec"] = "500"; | 786 variation_params["3G.ThresholdMedianHttpRTTMsec"] = "500"; |
| 787 variation_params["4G.ThresholdMedianHttpRTTMsec"] = "300"; | 787 variation_params["4G.ThresholdMedianHttpRTTMsec"] = "300"; |
| 788 variation_params["Broadband.ThresholdMedianHttpRTTMsec"] = "100"; | |
| 789 | 788 |
| 790 TestNetworkQualityEstimator estimator(variation_params); | 789 TestNetworkQualityEstimator estimator(variation_params); |
| 791 | 790 |
| 792 // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType | 791 // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType |
| 793 // does not return Offline if the device is offline. | 792 // does not return Offline if the device is offline. |
| 794 estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, | 793 estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, |
| 795 "test"); | 794 "test"); |
| 796 | 795 |
| 797 const struct { | 796 const struct { |
| 798 int32_t rtt_msec; | 797 int32_t rtt_msec; |
| 799 EffectiveConnectionType expected_conn_type; | 798 EffectiveConnectionType expected_conn_type; |
| 800 } tests[] = { | 799 } tests[] = { |
| 801 {5000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 800 {5000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 802 {4000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 801 {4000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 803 {3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 802 {3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 804 {2000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 803 {2000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 805 {1500, EFFECTIVE_CONNECTION_TYPE_2G}, | 804 {1500, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 806 {1000, EFFECTIVE_CONNECTION_TYPE_2G}, | 805 {1000, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 807 {700, EFFECTIVE_CONNECTION_TYPE_3G}, | 806 {700, EFFECTIVE_CONNECTION_TYPE_3G}, |
| 808 {500, EFFECTIVE_CONNECTION_TYPE_3G}, | 807 {500, EFFECTIVE_CONNECTION_TYPE_3G}, |
| 809 {400, EFFECTIVE_CONNECTION_TYPE_4G}, | 808 {400, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 810 {300, EFFECTIVE_CONNECTION_TYPE_4G}, | 809 {300, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 811 {200, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 810 {200, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 812 {100, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 811 {100, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 813 {20, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 812 {20, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 814 }; | 813 }; |
| 815 | 814 |
| 816 for (const auto& test : tests) { | 815 for (const auto& test : tests) { |
| 817 estimator.set_http_rtt(base::TimeDelta::FromMilliseconds(test.rtt_msec)); | 816 estimator.set_http_rtt(base::TimeDelta::FromMilliseconds(test.rtt_msec)); |
| 818 estimator.set_recent_http_rtt( | 817 estimator.set_recent_http_rtt( |
| 819 base::TimeDelta::FromMilliseconds(test.rtt_msec)); | 818 base::TimeDelta::FromMilliseconds(test.rtt_msec)); |
| 820 estimator.set_downlink_throughput_kbps(INT32_MAX); | 819 estimator.set_downlink_throughput_kbps(INT32_MAX); |
| 821 estimator.set_recent_downlink_throughput_kbps(INT32_MAX); | 820 estimator.set_recent_downlink_throughput_kbps(INT32_MAX); |
| 822 EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); | 821 EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); |
| 823 } | 822 } |
| 824 } | 823 } |
| 825 | 824 |
| 826 // Tests that default transport RTT thresholds for different effective | 825 // Tests that default transport RTT thresholds for different effective |
| 827 // connection types are correctly set. | 826 // connection types are correctly set. |
| 828 TEST(NetworkQualityEstimatorTest, DefaultTransportRTTBasedThresholds) { | 827 TEST(NetworkQualityEstimatorTest, DefaultTransportRTTBasedThresholds) { |
| 829 const struct { | 828 const struct { |
| 830 bool override_defaults_using_variation_params; | 829 bool override_defaults_using_variation_params; |
| 831 int32_t transport_rtt_msec; | 830 int32_t transport_rtt_msec; |
| 832 EffectiveConnectionType expected_conn_type; | 831 EffectiveConnectionType expected_conn_type; |
| 833 } tests[] = { | 832 } tests[] = { |
| 834 // When the variation params do not override connection thresholds, | 833 // When the variation params do not override connection thresholds, |
| 835 // default values should be used. | 834 // default values should be used. |
| 836 {false, 5000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 835 {false, 5000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 837 {false, 4000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 836 {false, 4000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 838 {false, 3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 837 {false, 3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 839 {false, 2000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 838 {false, 2000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 840 {false, 1500, EFFECTIVE_CONNECTION_TYPE_2G}, | 839 {false, 1500, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 841 {false, 1000, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 840 {false, 1000, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 842 {false, 20, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 841 {false, 20, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 843 // Override default thresholds using variation params. | 842 // Override default thresholds using variation params. |
| 844 {true, 5000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 843 {true, 5000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 845 {true, 4000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 844 {true, 4000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 846 {true, 3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 845 {true, 3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 847 {true, 2000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 846 {true, 2000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 848 {true, 1500, EFFECTIVE_CONNECTION_TYPE_2G}, | 847 {true, 1500, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 849 {true, 1000, EFFECTIVE_CONNECTION_TYPE_2G}, | 848 {true, 1000, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 850 {true, 20, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 849 {true, 20, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 851 }; | 850 }; |
| 852 | 851 |
| 853 for (const auto& test : tests) { | 852 for (const auto& test : tests) { |
| 854 std::map<std::string, std::string> variation_params; | 853 std::map<std::string, std::string> variation_params; |
| 855 variation_params["effective_connection_type_algorithm"] = | 854 variation_params["effective_connection_type_algorithm"] = |
| 856 "TransportRTTOrDownstreamThroughput"; | 855 "TransportRTTOrDownstreamThroughput"; |
| 857 if (test.override_defaults_using_variation_params) { | 856 if (test.override_defaults_using_variation_params) { |
| 858 variation_params["Offline.ThresholdMedianTransportRTTMsec"] = "4000"; | 857 variation_params["Offline.ThresholdMedianTransportRTTMsec"] = "4000"; |
| 859 variation_params["Slow2G.ThresholdMedianTransportRTTMsec"] = "2000"; | 858 variation_params["Slow2G.ThresholdMedianTransportRTTMsec"] = "2000"; |
| 860 variation_params["2G.ThresholdMedianTransportRTTMsec"] = "1000"; | 859 variation_params["2G.ThresholdMedianTransportRTTMsec"] = "1000"; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 885 int32_t http_rtt_msec; | 884 int32_t http_rtt_msec; |
| 886 EffectiveConnectionType expected_conn_type; | 885 EffectiveConnectionType expected_conn_type; |
| 887 } tests[] = { | 886 } tests[] = { |
| 888 // When the variation params do not override connection thresholds, | 887 // When the variation params do not override connection thresholds, |
| 889 // default values should be used. | 888 // default values should be used. |
| 890 {false, 5000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 889 {false, 5000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 891 {false, 4000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 890 {false, 4000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 892 {false, 3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 891 {false, 3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 893 {false, 2000, EFFECTIVE_CONNECTION_TYPE_2G}, | 892 {false, 2000, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 894 {false, 1500, EFFECTIVE_CONNECTION_TYPE_2G}, | 893 {false, 1500, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 895 {false, 1000, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 894 {false, 1000, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 896 {false, 20, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 895 {false, 20, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 897 // Override default thresholds using variation params. | 896 // Override default thresholds using variation params. |
| 898 {true, 5000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 897 {true, 5000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 899 {true, 4000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 898 {true, 4000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 900 {true, 3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 899 {true, 3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 901 {true, 2000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 900 {true, 2000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 902 {true, 1500, EFFECTIVE_CONNECTION_TYPE_2G}, | 901 {true, 1500, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 903 {true, 1000, EFFECTIVE_CONNECTION_TYPE_2G}, | 902 {true, 1000, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 904 {true, 20, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 903 {true, 20, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 905 }; | 904 }; |
| 906 | 905 |
| 907 for (const auto& test : tests) { | 906 for (const auto& test : tests) { |
| 908 std::map<std::string, std::string> variation_params; | 907 std::map<std::string, std::string> variation_params; |
| 909 if (test.override_defaults_using_variation_params) { | 908 if (test.override_defaults_using_variation_params) { |
| 910 variation_params["Offline.ThresholdMedianHttpRTTMsec"] = "4000"; | 909 variation_params["Offline.ThresholdMedianHttpRTTMsec"] = "4000"; |
| 911 variation_params["Slow2G.ThresholdMedianHttpRTTMsec"] = "2000"; | 910 variation_params["Slow2G.ThresholdMedianHttpRTTMsec"] = "2000"; |
| 912 variation_params["2G.ThresholdMedianHttpRTTMsec"] = "1000"; | 911 variation_params["2G.ThresholdMedianHttpRTTMsec"] = "1000"; |
| 913 } | 912 } |
| 914 | 913 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 934 TEST(NetworkQualityEstimatorTest, ObtainThresholdsOnlyTransportRTT) { | 933 TEST(NetworkQualityEstimatorTest, ObtainThresholdsOnlyTransportRTT) { |
| 935 std::map<std::string, std::string> variation_params; | 934 std::map<std::string, std::string> variation_params; |
| 936 variation_params["effective_connection_type_algorithm"] = | 935 variation_params["effective_connection_type_algorithm"] = |
| 937 "TransportRTTOrDownstreamThroughput"; | 936 "TransportRTTOrDownstreamThroughput"; |
| 938 | 937 |
| 939 variation_params["Offline.ThresholdMedianTransportRTTMsec"] = "4000"; | 938 variation_params["Offline.ThresholdMedianTransportRTTMsec"] = "4000"; |
| 940 variation_params["Slow2G.ThresholdMedianTransportRTTMsec"] = "2000"; | 939 variation_params["Slow2G.ThresholdMedianTransportRTTMsec"] = "2000"; |
| 941 variation_params["2G.ThresholdMedianTransportRTTMsec"] = "1000"; | 940 variation_params["2G.ThresholdMedianTransportRTTMsec"] = "1000"; |
| 942 variation_params["3G.ThresholdMedianTransportRTTMsec"] = "500"; | 941 variation_params["3G.ThresholdMedianTransportRTTMsec"] = "500"; |
| 943 variation_params["4G.ThresholdMedianTransportRTTMsec"] = "300"; | 942 variation_params["4G.ThresholdMedianTransportRTTMsec"] = "300"; |
| 944 variation_params["Broadband.ThresholdMedianTransportRTTMsec"] = "100"; | |
| 945 | 943 |
| 946 TestNetworkQualityEstimator estimator(variation_params); | 944 TestNetworkQualityEstimator estimator(variation_params); |
| 947 | 945 |
| 948 // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType | 946 // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType |
| 949 // does not return Offline if the device is offline. | 947 // does not return Offline if the device is offline. |
| 950 estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, | 948 estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, |
| 951 "test"); | 949 "test"); |
| 952 | 950 |
| 953 const struct { | 951 const struct { |
| 954 int32_t transport_rtt_msec; | 952 int32_t transport_rtt_msec; |
| 955 EffectiveConnectionType expected_conn_type; | 953 EffectiveConnectionType expected_conn_type; |
| 956 } tests[] = { | 954 } tests[] = { |
| 957 {5000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 955 {5000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 958 {4000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 956 {4000, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 959 {3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 957 {3000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 960 {2000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 958 {2000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 961 {1500, EFFECTIVE_CONNECTION_TYPE_2G}, | 959 {1500, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 962 {1000, EFFECTIVE_CONNECTION_TYPE_2G}, | 960 {1000, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 963 {700, EFFECTIVE_CONNECTION_TYPE_3G}, | 961 {700, EFFECTIVE_CONNECTION_TYPE_3G}, |
| 964 {500, EFFECTIVE_CONNECTION_TYPE_3G}, | 962 {500, EFFECTIVE_CONNECTION_TYPE_3G}, |
| 965 {400, EFFECTIVE_CONNECTION_TYPE_4G}, | 963 {400, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 966 {300, EFFECTIVE_CONNECTION_TYPE_4G}, | 964 {300, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 967 {200, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 965 {200, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 968 {100, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 966 {100, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 969 {20, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 967 {20, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 970 }; | 968 }; |
| 971 | 969 |
| 972 for (const auto& test : tests) { | 970 for (const auto& test : tests) { |
| 973 estimator.set_transport_rtt( | 971 estimator.set_transport_rtt( |
| 974 base::TimeDelta::FromMilliseconds(test.transport_rtt_msec)); | 972 base::TimeDelta::FromMilliseconds(test.transport_rtt_msec)); |
| 975 estimator.set_recent_transport_rtt( | 973 estimator.set_recent_transport_rtt( |
| 976 base::TimeDelta::FromMilliseconds(test.transport_rtt_msec)); | 974 base::TimeDelta::FromMilliseconds(test.transport_rtt_msec)); |
| 977 estimator.set_downlink_throughput_kbps(INT32_MAX); | 975 estimator.set_downlink_throughput_kbps(INT32_MAX); |
| 978 estimator.set_recent_downlink_throughput_kbps(INT32_MAX); | 976 estimator.set_recent_downlink_throughput_kbps(INT32_MAX); |
| 979 EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); | 977 EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); |
| 980 } | 978 } |
| 981 } | 979 } |
| 982 | 980 |
| 983 // Tests that |GetEffectiveConnectionType| returns correct connection type when | 981 // Tests that |GetEffectiveConnectionType| returns correct connection type when |
| 984 // both HTTP RTT and throughput thresholds are specified in the variation | 982 // both HTTP RTT and throughput thresholds are specified in the variation |
| 985 // params. | 983 // params. |
| 986 TEST(NetworkQualityEstimatorTest, ObtainThresholdsHttpRTTandThroughput) { | 984 TEST(NetworkQualityEstimatorTest, ObtainThresholdsHttpRTTandThroughput) { |
| 987 std::map<std::string, std::string> variation_params; | 985 std::map<std::string, std::string> variation_params; |
| 988 | 986 |
| 989 variation_params["Offline.ThresholdMedianHttpRTTMsec"] = "4000"; | 987 variation_params["Offline.ThresholdMedianHttpRTTMsec"] = "4000"; |
| 990 variation_params["Slow2G.ThresholdMedianHttpRTTMsec"] = "2000"; | 988 variation_params["Slow2G.ThresholdMedianHttpRTTMsec"] = "2000"; |
| 991 variation_params["2G.ThresholdMedianHttpRTTMsec"] = "1000"; | 989 variation_params["2G.ThresholdMedianHttpRTTMsec"] = "1000"; |
| 992 variation_params["3G.ThresholdMedianHttpRTTMsec"] = "500"; | 990 variation_params["3G.ThresholdMedianHttpRTTMsec"] = "500"; |
| 993 variation_params["4G.ThresholdMedianHttpRTTMsec"] = "300"; | 991 variation_params["4G.ThresholdMedianHttpRTTMsec"] = "300"; |
| 994 variation_params["Broadband.ThresholdMedianHttpRTTMsec"] = "100"; | |
| 995 | 992 |
| 996 variation_params["Offline.ThresholdMedianKbps"] = "10"; | 993 variation_params["Offline.ThresholdMedianKbps"] = "10"; |
| 997 variation_params["Slow2G.ThresholdMedianKbps"] = "100"; | 994 variation_params["Slow2G.ThresholdMedianKbps"] = "100"; |
| 998 variation_params["2G.ThresholdMedianKbps"] = "300"; | 995 variation_params["2G.ThresholdMedianKbps"] = "300"; |
| 999 variation_params["3G.ThresholdMedianKbps"] = "500"; | 996 variation_params["3G.ThresholdMedianKbps"] = "500"; |
| 1000 variation_params["4G.ThresholdMedianKbps"] = "1000"; | 997 variation_params["4G.ThresholdMedianKbps"] = "1000"; |
| 1001 variation_params["Broadband.ThresholdMedianKbps"] = "2000"; | |
| 1002 | 998 |
| 1003 TestNetworkQualityEstimator estimator(variation_params); | 999 TestNetworkQualityEstimator estimator(variation_params); |
| 1004 | 1000 |
| 1005 // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType | 1001 // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType |
| 1006 // does not return Offline if the device is offline. | 1002 // does not return Offline if the device is offline. |
| 1007 estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, | 1003 estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, |
| 1008 "test"); | 1004 "test"); |
| 1009 | 1005 |
| 1010 const struct { | 1006 const struct { |
| 1011 int32_t rtt_msec; | 1007 int32_t rtt_msec; |
| 1012 int32_t downlink_throughput_kbps; | 1008 int32_t downlink_throughput_kbps; |
| 1013 EffectiveConnectionType expected_conn_type; | 1009 EffectiveConnectionType expected_conn_type; |
| 1014 } tests[] = { | 1010 } tests[] = { |
| 1015 // Set RTT to a very low value to observe the effect of throughput. | 1011 // Set RTT to a very low value to observe the effect of throughput. |
| 1016 // Throughput is the bottleneck. | 1012 // Throughput is the bottleneck. |
| 1017 {1, 5, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 1013 {1, 5, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 1018 {1, 10, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 1014 {1, 10, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 1019 {1, 50, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 1015 {1, 50, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 1020 {1, 100, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 1016 {1, 100, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 1021 {1, 150, EFFECTIVE_CONNECTION_TYPE_2G}, | 1017 {1, 150, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 1022 {1, 300, EFFECTIVE_CONNECTION_TYPE_2G}, | 1018 {1, 300, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 1023 {1, 400, EFFECTIVE_CONNECTION_TYPE_3G}, | 1019 {1, 400, EFFECTIVE_CONNECTION_TYPE_3G}, |
| 1024 {1, 500, EFFECTIVE_CONNECTION_TYPE_3G}, | 1020 {1, 500, EFFECTIVE_CONNECTION_TYPE_3G}, |
| 1025 {1, 700, EFFECTIVE_CONNECTION_TYPE_4G}, | 1021 {1, 700, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 1026 {1, 1000, EFFECTIVE_CONNECTION_TYPE_4G}, | 1022 {1, 1000, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 1027 {1, 1500, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 1023 {1, 1500, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 1028 {1, 2500, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 1024 {1, 2500, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 1029 // Set both RTT and throughput. RTT is the bottleneck. | 1025 // Set both RTT and throughput. RTT is the bottleneck. |
| 1030 {3000, 25000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 1026 {3000, 25000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 1031 {700, 25000, EFFECTIVE_CONNECTION_TYPE_3G}, | 1027 {700, 25000, EFFECTIVE_CONNECTION_TYPE_3G}, |
| 1032 }; | 1028 }; |
| 1033 | 1029 |
| 1034 for (const auto& test : tests) { | 1030 for (const auto& test : tests) { |
| 1035 estimator.set_http_rtt(base::TimeDelta::FromMilliseconds(test.rtt_msec)); | 1031 estimator.set_http_rtt(base::TimeDelta::FromMilliseconds(test.rtt_msec)); |
| 1036 estimator.set_recent_http_rtt( | 1032 estimator.set_recent_http_rtt( |
| 1037 base::TimeDelta::FromMilliseconds(test.rtt_msec)); | 1033 base::TimeDelta::FromMilliseconds(test.rtt_msec)); |
| 1038 estimator.set_downlink_throughput_kbps(test.downlink_throughput_kbps); | 1034 estimator.set_downlink_throughput_kbps(test.downlink_throughput_kbps); |
| 1039 estimator.set_recent_downlink_throughput_kbps( | 1035 estimator.set_recent_downlink_throughput_kbps( |
| 1040 test.downlink_throughput_kbps); | 1036 test.downlink_throughput_kbps); |
| 1041 EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); | 1037 EXPECT_EQ(test.expected_conn_type, estimator.GetEffectiveConnectionType()); |
| 1042 } | 1038 } |
| 1043 } | 1039 } |
| 1044 | 1040 |
| 1045 // Tests that |GetEffectiveConnectionType| returns correct connection type when | 1041 // Tests that |GetEffectiveConnectionType| returns correct connection type when |
| 1046 // both transport RTT and throughput thresholds are specified in the variation | 1042 // both transport RTT and throughput thresholds are specified in the variation |
| 1047 // params. | 1043 // params. |
| 1048 TEST(NetworkQualityEstimatorTest, ObtainThresholdsTransportRTTandThroughput) { | 1044 TEST(NetworkQualityEstimatorTest, ObtainThresholdsTransportRTTandThroughput) { |
| 1049 std::map<std::string, std::string> variation_params; | 1045 std::map<std::string, std::string> variation_params; |
| 1050 variation_params["effective_connection_type_algorithm"] = | 1046 variation_params["effective_connection_type_algorithm"] = |
| 1051 "TransportRTTOrDownstreamThroughput"; | 1047 "TransportRTTOrDownstreamThroughput"; |
| 1052 | 1048 |
| 1053 variation_params["Offline.ThresholdMedianTransportRTTMsec"] = "4000"; | 1049 variation_params["Offline.ThresholdMedianTransportRTTMsec"] = "4000"; |
| 1054 variation_params["Slow2G.ThresholdMedianTransportRTTMsec"] = "2000"; | 1050 variation_params["Slow2G.ThresholdMedianTransportRTTMsec"] = "2000"; |
| 1055 variation_params["2G.ThresholdMedianTransportRTTMsec"] = "1000"; | 1051 variation_params["2G.ThresholdMedianTransportRTTMsec"] = "1000"; |
| 1056 variation_params["3G.ThresholdMedianTransportRTTMsec"] = "500"; | 1052 variation_params["3G.ThresholdMedianTransportRTTMsec"] = "500"; |
| 1057 variation_params["4G.ThresholdMedianTransportRTTMsec"] = "300"; | 1053 variation_params["4G.ThresholdMedianTransportRTTMsec"] = "300"; |
| 1058 variation_params["Broadband.ThresholdMedianTransportRTTMsec"] = "100"; | |
| 1059 | 1054 |
| 1060 variation_params["Offline.ThresholdMedianKbps"] = "10"; | 1055 variation_params["Offline.ThresholdMedianKbps"] = "10"; |
| 1061 variation_params["Slow2G.ThresholdMedianKbps"] = "100"; | 1056 variation_params["Slow2G.ThresholdMedianKbps"] = "100"; |
| 1062 variation_params["2G.ThresholdMedianKbps"] = "300"; | 1057 variation_params["2G.ThresholdMedianKbps"] = "300"; |
| 1063 variation_params["3G.ThresholdMedianKbps"] = "500"; | 1058 variation_params["3G.ThresholdMedianKbps"] = "500"; |
| 1064 variation_params["4G.ThresholdMedianKbps"] = "1000"; | 1059 variation_params["4G.ThresholdMedianKbps"] = "1000"; |
| 1065 variation_params["Broadband.ThresholdMedianKbps"] = "2000"; | |
| 1066 | 1060 |
| 1067 TestNetworkQualityEstimator estimator(variation_params); | 1061 TestNetworkQualityEstimator estimator(variation_params); |
| 1068 | 1062 |
| 1069 // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType | 1063 // Simulate the connection type as Wi-Fi so that GetEffectiveConnectionType |
| 1070 // does not return Offline if the device is offline. | 1064 // does not return Offline if the device is offline. |
| 1071 estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, | 1065 estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, |
| 1072 "test"); | 1066 "test"); |
| 1073 | 1067 |
| 1074 const struct { | 1068 const struct { |
| 1075 int32_t transport_rtt_msec; | 1069 int32_t transport_rtt_msec; |
| 1076 int32_t downlink_throughput_kbps; | 1070 int32_t downlink_throughput_kbps; |
| 1077 EffectiveConnectionType expected_conn_type; | 1071 EffectiveConnectionType expected_conn_type; |
| 1078 } tests[] = { | 1072 } tests[] = { |
| 1079 // Set RTT to a very low value to observe the effect of throughput. | 1073 // Set RTT to a very low value to observe the effect of throughput. |
| 1080 // Throughput is the bottleneck. | 1074 // Throughput is the bottleneck. |
| 1081 {1, 5, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 1075 {1, 5, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 1082 {1, 10, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, | 1076 {1, 10, EFFECTIVE_CONNECTION_TYPE_OFFLINE}, |
| 1083 {1, 50, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 1077 {1, 50, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 1084 {1, 100, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 1078 {1, 100, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 1085 {1, 150, EFFECTIVE_CONNECTION_TYPE_2G}, | 1079 {1, 150, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 1086 {1, 300, EFFECTIVE_CONNECTION_TYPE_2G}, | 1080 {1, 300, EFFECTIVE_CONNECTION_TYPE_2G}, |
| 1087 {1, 400, EFFECTIVE_CONNECTION_TYPE_3G}, | 1081 {1, 400, EFFECTIVE_CONNECTION_TYPE_3G}, |
| 1088 {1, 500, EFFECTIVE_CONNECTION_TYPE_3G}, | 1082 {1, 500, EFFECTIVE_CONNECTION_TYPE_3G}, |
| 1089 {1, 700, EFFECTIVE_CONNECTION_TYPE_4G}, | 1083 {1, 700, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 1090 {1, 1000, EFFECTIVE_CONNECTION_TYPE_4G}, | 1084 {1, 1000, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 1091 {1, 1500, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 1085 {1, 1500, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 1092 {1, 2500, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 1086 {1, 2500, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 1093 // Set both RTT and throughput. RTT is the bottleneck. | 1087 // Set both RTT and throughput. RTT is the bottleneck. |
| 1094 {3000, 25000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, | 1088 {3000, 25000, EFFECTIVE_CONNECTION_TYPE_SLOW_2G}, |
| 1095 {700, 25000, EFFECTIVE_CONNECTION_TYPE_3G}, | 1089 {700, 25000, EFFECTIVE_CONNECTION_TYPE_3G}, |
| 1096 }; | 1090 }; |
| 1097 | 1091 |
| 1098 for (const auto& test : tests) { | 1092 for (const auto& test : tests) { |
| 1099 estimator.set_transport_rtt( | 1093 estimator.set_transport_rtt( |
| 1100 base::TimeDelta::FromMilliseconds(test.transport_rtt_msec)); | 1094 base::TimeDelta::FromMilliseconds(test.transport_rtt_msec)); |
| 1101 estimator.set_recent_transport_rtt( | 1095 estimator.set_recent_transport_rtt( |
| 1102 base::TimeDelta::FromMilliseconds(test.transport_rtt_msec)); | 1096 base::TimeDelta::FromMilliseconds(test.transport_rtt_msec)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1131 TestNetworkQualityEstimator estimator(variation_params); | 1125 TestNetworkQualityEstimator estimator(variation_params); |
| 1132 EXPECT_NEAR(test.expected_weight_multiplier, | 1126 EXPECT_NEAR(test.expected_weight_multiplier, |
| 1133 estimator.weight_multiplier_per_second_, 0.001) | 1127 estimator.weight_multiplier_per_second_, 0.001) |
| 1134 << test.description; | 1128 << test.description; |
| 1135 } | 1129 } |
| 1136 } | 1130 } |
| 1137 | 1131 |
| 1138 TEST(NetworkQualityEstimatorTest, TestGetMetricsSince) { | 1132 TEST(NetworkQualityEstimatorTest, TestGetMetricsSince) { |
| 1139 std::map<std::string, std::string> variation_params; | 1133 std::map<std::string, std::string> variation_params; |
| 1140 | 1134 |
| 1141 const base::TimeDelta rtt_threshold_4g = | 1135 const base::TimeDelta rtt_threshold_3g = |
| 1142 base::TimeDelta::FromMilliseconds(30); | 1136 base::TimeDelta::FromMilliseconds(30); |
| 1143 const base::TimeDelta rtt_threshold_broadband = | 1137 const base::TimeDelta rtt_threshold_4g = base::TimeDelta::FromMilliseconds(1); |
| 1144 base::TimeDelta::FromMilliseconds(1); | |
| 1145 | 1138 |
| 1139 variation_params["3G.ThresholdMedianHttpRTTMsec"] = |
| 1140 base::IntToString(rtt_threshold_3g.InMilliseconds()); |
| 1146 variation_params["4G.ThresholdMedianHttpRTTMsec"] = | 1141 variation_params["4G.ThresholdMedianHttpRTTMsec"] = |
| 1147 base::IntToString(rtt_threshold_4g.InMilliseconds()); | 1142 base::IntToString(rtt_threshold_4g.InMilliseconds()); |
| 1148 variation_params["Broadband.ThresholdMedianHttpRTTMsec"] = | |
| 1149 base::IntToString(rtt_threshold_broadband.InMilliseconds()); | |
| 1150 variation_params["HalfLifeSeconds"] = "300000"; | 1143 variation_params["HalfLifeSeconds"] = "300000"; |
| 1151 | 1144 |
| 1152 TestNetworkQualityEstimator estimator(variation_params); | 1145 TestNetworkQualityEstimator estimator(variation_params); |
| 1153 base::TimeTicks now = base::TimeTicks::Now(); | 1146 base::TimeTicks now = base::TimeTicks::Now(); |
| 1154 base::TimeTicks old = now - base::TimeDelta::FromMilliseconds(1); | 1147 base::TimeTicks old = now - base::TimeDelta::FromMilliseconds(1); |
| 1155 ASSERT_NE(old, now); | 1148 ASSERT_NE(old, now); |
| 1156 | 1149 |
| 1157 estimator.SimulateNetworkChangeTo( | 1150 estimator.SimulateNetworkChangeTo( |
| 1158 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test"); | 1151 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test"); |
| 1159 | 1152 |
| 1160 const int32_t old_downlink_kbps = 1; | 1153 const int32_t old_downlink_kbps = 1; |
| 1161 const base::TimeDelta old_url_rtt = base::TimeDelta::FromMilliseconds(1); | 1154 const base::TimeDelta old_url_rtt = base::TimeDelta::FromMilliseconds(1); |
| 1162 const base::TimeDelta old_tcp_rtt = base::TimeDelta::FromMilliseconds(10); | 1155 const base::TimeDelta old_tcp_rtt = base::TimeDelta::FromMilliseconds(10); |
| 1163 | 1156 |
| 1164 DCHECK_LT(old_url_rtt, rtt_threshold_4g); | 1157 DCHECK_LT(old_url_rtt, rtt_threshold_3g); |
| 1165 DCHECK_LT(old_tcp_rtt, rtt_threshold_4g); | 1158 DCHECK_LT(old_tcp_rtt, rtt_threshold_3g); |
| 1166 | 1159 |
| 1167 // First sample has very old timestamp. | 1160 // First sample has very old timestamp. |
| 1168 for (size_t i = 0; i < 2; ++i) { | 1161 for (size_t i = 0; i < 2; ++i) { |
| 1169 estimator.downstream_throughput_kbps_observations_.AddObservation( | 1162 estimator.downstream_throughput_kbps_observations_.AddObservation( |
| 1170 NetworkQualityEstimator::ThroughputObservation( | 1163 NetworkQualityEstimator::ThroughputObservation( |
| 1171 old_downlink_kbps, old, | 1164 old_downlink_kbps, old, |
| 1172 NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); | 1165 NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); |
| 1173 estimator.rtt_observations_.AddObservation( | 1166 estimator.rtt_observations_.AddObservation( |
| 1174 NetworkQualityEstimator::RttObservation( | 1167 NetworkQualityEstimator::RttObservation( |
| 1175 old_url_rtt, old, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); | 1168 old_url_rtt, old, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); |
| 1176 estimator.rtt_observations_.AddObservation( | 1169 estimator.rtt_observations_.AddObservation( |
| 1177 NetworkQualityEstimator::RttObservation( | 1170 NetworkQualityEstimator::RttObservation( |
| 1178 old_tcp_rtt, old, NETWORK_QUALITY_OBSERVATION_SOURCE_TCP)); | 1171 old_tcp_rtt, old, NETWORK_QUALITY_OBSERVATION_SOURCE_TCP)); |
| 1179 } | 1172 } |
| 1180 | 1173 |
| 1181 const int32_t new_downlink_kbps = 100; | 1174 const int32_t new_downlink_kbps = 100; |
| 1182 const base::TimeDelta new_url_rtt = base::TimeDelta::FromMilliseconds(100); | 1175 const base::TimeDelta new_url_rtt = base::TimeDelta::FromMilliseconds(100); |
| 1183 const base::TimeDelta new_tcp_rtt = base::TimeDelta::FromMilliseconds(1000); | 1176 const base::TimeDelta new_tcp_rtt = base::TimeDelta::FromMilliseconds(1000); |
| 1184 | 1177 |
| 1185 DCHECK_NE(old_downlink_kbps, new_downlink_kbps); | 1178 DCHECK_NE(old_downlink_kbps, new_downlink_kbps); |
| 1186 DCHECK_NE(old_url_rtt, new_url_rtt); | 1179 DCHECK_NE(old_url_rtt, new_url_rtt); |
| 1187 DCHECK_NE(old_tcp_rtt, new_tcp_rtt); | 1180 DCHECK_NE(old_tcp_rtt, new_tcp_rtt); |
| 1181 DCHECK_GT(new_url_rtt, rtt_threshold_3g); |
| 1182 DCHECK_GT(new_tcp_rtt, rtt_threshold_3g); |
| 1188 DCHECK_GT(new_url_rtt, rtt_threshold_4g); | 1183 DCHECK_GT(new_url_rtt, rtt_threshold_4g); |
| 1189 DCHECK_GT(new_tcp_rtt, rtt_threshold_4g); | 1184 DCHECK_GT(new_tcp_rtt, rtt_threshold_4g); |
| 1190 DCHECK_GT(new_url_rtt, rtt_threshold_broadband); | |
| 1191 DCHECK_GT(new_tcp_rtt, rtt_threshold_broadband); | |
| 1192 | 1185 |
| 1193 estimator.downstream_throughput_kbps_observations_.AddObservation( | 1186 estimator.downstream_throughput_kbps_observations_.AddObservation( |
| 1194 NetworkQualityEstimator::ThroughputObservation( | 1187 NetworkQualityEstimator::ThroughputObservation( |
| 1195 new_downlink_kbps, now, | 1188 new_downlink_kbps, now, |
| 1196 NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); | 1189 NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); |
| 1197 estimator.rtt_observations_.AddObservation( | 1190 estimator.rtt_observations_.AddObservation( |
| 1198 NetworkQualityEstimator::RttObservation( | 1191 NetworkQualityEstimator::RttObservation( |
| 1199 new_url_rtt, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); | 1192 new_url_rtt, now, NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST)); |
| 1200 estimator.rtt_observations_.AddObservation( | 1193 estimator.rtt_observations_.AddObservation( |
| 1201 NetworkQualityEstimator::RttObservation( | 1194 NetworkQualityEstimator::RttObservation( |
| 1202 new_tcp_rtt, now, NETWORK_QUALITY_OBSERVATION_SOURCE_TCP)); | 1195 new_tcp_rtt, now, NETWORK_QUALITY_OBSERVATION_SOURCE_TCP)); |
| 1203 | 1196 |
| 1204 const struct { | 1197 const struct { |
| 1205 base::TimeTicks start_timestamp; | 1198 base::TimeTicks start_timestamp; |
| 1206 bool expect_network_quality_available; | 1199 bool expect_network_quality_available; |
| 1207 base::TimeDelta expected_http_rtt; | 1200 base::TimeDelta expected_http_rtt; |
| 1208 base::TimeDelta expected_transport_rtt; | 1201 base::TimeDelta expected_transport_rtt; |
| 1209 int32_t expected_downstream_throughput; | 1202 int32_t expected_downstream_throughput; |
| 1210 EffectiveConnectionType expected_effective_connection_type; | 1203 EffectiveConnectionType expected_effective_connection_type; |
| 1211 } tests[] = { | 1204 } tests[] = { |
| 1212 {now + base::TimeDelta::FromSeconds(10), false, | 1205 {now + base::TimeDelta::FromSeconds(10), false, |
| 1213 base::TimeDelta::FromMilliseconds(0), | 1206 base::TimeDelta::FromMilliseconds(0), |
| 1214 base::TimeDelta::FromMilliseconds(0), 0, | 1207 base::TimeDelta::FromMilliseconds(0), 0, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 1215 EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | |
| 1216 {now, true, new_url_rtt, new_tcp_rtt, new_downlink_kbps, | 1208 {now, true, new_url_rtt, new_tcp_rtt, new_downlink_kbps, |
| 1217 EFFECTIVE_CONNECTION_TYPE_4G}, | 1209 EFFECTIVE_CONNECTION_TYPE_3G}, |
| 1218 {old - base::TimeDelta::FromMicroseconds(500), true, old_url_rtt, | 1210 {old - base::TimeDelta::FromMicroseconds(500), true, old_url_rtt, |
| 1219 old_tcp_rtt, old_downlink_kbps, EFFECTIVE_CONNECTION_TYPE_BROADBAND}, | 1211 old_tcp_rtt, old_downlink_kbps, EFFECTIVE_CONNECTION_TYPE_4G}, |
| 1220 | 1212 |
| 1221 }; | 1213 }; |
| 1222 for (const auto& test : tests) { | 1214 for (const auto& test : tests) { |
| 1223 base::TimeDelta http_rtt; | 1215 base::TimeDelta http_rtt; |
| 1224 base::TimeDelta transport_rtt; | 1216 base::TimeDelta transport_rtt; |
| 1225 int32_t downstream_throughput_kbps; | 1217 int32_t downstream_throughput_kbps; |
| 1226 EXPECT_EQ( | 1218 EXPECT_EQ( |
| 1227 test.expect_network_quality_available, | 1219 test.expect_network_quality_available, |
| 1228 estimator.GetRecentHttpRTTMedian(test.start_timestamp, &http_rtt)); | 1220 estimator.GetRecentHttpRTTMedian(test.start_timestamp, &http_rtt)); |
| 1229 EXPECT_EQ(test.expect_network_quality_available, | 1221 EXPECT_EQ(test.expect_network_quality_available, |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2219 | 2211 |
| 2220 // Get the bits at index 18-24 which contain the resource fetch time. | 2212 // Get the bits at index 18-24 which contain the resource fetch time. |
| 2221 EXPECT_LE(0, (buckets.at(0).min >> kBitsPerMetric) % 128); | 2213 EXPECT_LE(0, (buckets.at(0).min >> kBitsPerMetric) % 128); |
| 2222 | 2214 |
| 2223 // Get the bits at index 25-31 which contain the resource load size. | 2215 // Get the bits at index 25-31 which contain the resource load size. |
| 2224 EXPECT_LE(0, (buckets.at(0).min) % 128); | 2216 EXPECT_LE(0, (buckets.at(0).min) % 128); |
| 2225 } | 2217 } |
| 2226 } | 2218 } |
| 2227 | 2219 |
| 2228 } // namespace net | 2220 } // namespace net |
| OLD | NEW |