OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/nqe/network_quality_estimator_params.h" |
| 6 |
| 7 #include <map> |
| 8 #include <string> |
| 9 |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace net { |
| 13 |
| 14 namespace nqe { |
| 15 |
| 16 namespace internal { |
| 17 |
| 18 namespace { |
| 19 |
| 20 // Tests if |weight_multiplier_per_second()| returns correct value for various |
| 21 // values of half life parameter. |
| 22 TEST(NetworkQualityEstimatorParamsTest, HalfLifeParam) { |
| 23 std::map<std::string, std::string> variation_params; |
| 24 |
| 25 const struct { |
| 26 std::string description; |
| 27 std::string variation_params_value; |
| 28 double expected_weight_multiplier; |
| 29 } tests[] = { |
| 30 {"Half life parameter is not set, default value should be used", |
| 31 std::string(), 0.988}, |
| 32 {"Half life parameter is set to negative, default value should be used", |
| 33 "-100", 0.988}, |
| 34 {"Half life parameter is set to zero, default value should be used", "0", |
| 35 0.988}, |
| 36 {"Half life parameter is set correctly", "10", 0.933}, |
| 37 }; |
| 38 |
| 39 for (const auto& test : tests) { |
| 40 variation_params["HalfLifeSeconds"] = test.variation_params_value; |
| 41 NetworkQualityEstimatorParams params(variation_params); |
| 42 EXPECT_NEAR(test.expected_weight_multiplier, |
| 43 params.weight_multiplier_per_second(), 0.001) |
| 44 << test.description; |
| 45 } |
| 46 } |
| 47 |
| 48 } // namespace |
| 49 |
| 50 } // namespace internal |
| 51 |
| 52 } // namespace nqe |
| 53 |
| 54 } // namespace net |
OLD | NEW |