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

Side by Side Diff: net/nqe/network_quality_estimator_params_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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_params.h" 5 #include "net/nqe/network_quality_estimator_params.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 27 matching lines...) Expand all
38 38
39 for (const auto& test : tests) { 39 for (const auto& test : tests) {
40 variation_params["HalfLifeSeconds"] = test.variation_params_value; 40 variation_params["HalfLifeSeconds"] = test.variation_params_value;
41 NetworkQualityEstimatorParams params(variation_params); 41 NetworkQualityEstimatorParams params(variation_params);
42 EXPECT_NEAR(test.expected_weight_multiplier, 42 EXPECT_NEAR(test.expected_weight_multiplier,
43 params.weight_multiplier_per_second(), 0.001) 43 params.weight_multiplier_per_second(), 0.001)
44 << test.description; 44 << test.description;
45 } 45 }
46 } 46 }
47 47
48 // Test that the typical network qualities are set correctly.
49 TEST(NetworkQualityEstimatorParamsTest, TypicalNetworkQualities) {
50 std::map<std::string, std::string> variation_params;
51 NetworkQualityEstimatorParams params(variation_params);
52
53 // Typical network quality should not be set for Unknown and Offline.
54 for (size_t i = EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
55 i <= EFFECTIVE_CONNECTION_TYPE_OFFLINE; ++i) {
56 EffectiveConnectionType ect = static_cast<EffectiveConnectionType>(i);
57 EXPECT_EQ(nqe::internal::InvalidRTT(),
58 params.TypicalNetworkQuality(ect).http_rtt());
59
60 EXPECT_EQ(nqe::internal::InvalidRTT(),
61 params.TypicalNetworkQuality(ect).transport_rtt());
62 }
63
64 // Typical network quality should be set for other effective connection
65 // types.
66 for (size_t i = EFFECTIVE_CONNECTION_TYPE_SLOW_2G;
67 i <= EFFECTIVE_CONNECTION_TYPE_3G; ++i) {
68 EffectiveConnectionType ect = static_cast<EffectiveConnectionType>(i);
69 // The typical RTT for an effective connection type should be at least as
70 // much as the threshold RTT.
71 EXPECT_NE(nqe::internal::InvalidRTT(),
72 params.TypicalNetworkQuality(ect).http_rtt());
73 EXPECT_GT(params.TypicalNetworkQuality(ect).http_rtt(),
74 params.ConnectionThreshold(ect).http_rtt());
75
76 EXPECT_NE(nqe::internal::InvalidRTT(),
77 params.TypicalNetworkQuality(ect).transport_rtt());
78 EXPECT_GT(params.TypicalNetworkQuality(ect).transport_rtt(),
79 params.ConnectionThreshold(ect).transport_rtt());
80
81 // The typical throughput for an effective connection type should not be
82 // more than the threshold throughput.
83 if (params.ConnectionThreshold(ect).downstream_throughput_kbps() !=
84 nqe::internal::kInvalidThroughput) {
85 EXPECT_LT(params.TypicalNetworkQuality(ect).downstream_throughput_kbps(),
86 params.ConnectionThreshold(ect).downstream_throughput_kbps());
87 }
88 }
89
90 // The typical network quality of 4G connection should be at least as fast
91 // as the threshold for 3G connection.
92 EXPECT_LT(
93 params.TypicalNetworkQuality(EFFECTIVE_CONNECTION_TYPE_4G).http_rtt(),
94 params.ConnectionThreshold(EFFECTIVE_CONNECTION_TYPE_3G).http_rtt());
95 EXPECT_LT(
96 params.TypicalNetworkQuality(EFFECTIVE_CONNECTION_TYPE_4G)
97 .transport_rtt(),
98 params.ConnectionThreshold(EFFECTIVE_CONNECTION_TYPE_3G).transport_rtt());
99 if (params.ConnectionThreshold(EFFECTIVE_CONNECTION_TYPE_3G)
100 .downstream_throughput_kbps() != nqe::internal::kInvalidThroughput) {
101 EXPECT_GT(params.TypicalNetworkQuality(EFFECTIVE_CONNECTION_TYPE_4G)
102 .downstream_throughput_kbps(),
103 params.ConnectionThreshold(EFFECTIVE_CONNECTION_TYPE_3G)
104 .downstream_throughput_kbps());
105 }
106 }
107
48 } // namespace 108 } // namespace
49 109
50 } // namespace internal 110 } // namespace internal
51 111
52 } // namespace nqe 112 } // namespace nqe
53 113
54 } // namespace net 114 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator_params.cc ('k') | net/nqe/network_quality_estimator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698