| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/previews/core/previews_experiments.h" | 5 #include "components/previews/core/previews_experiments.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 EXPECT_EQ(2, params::PerHostBlackListOptOutThreshold()); | 51 EXPECT_EQ(2, params::PerHostBlackListOptOutThreshold()); |
| 52 EXPECT_EQ(4, params::HostIndifferentBlackListOptOutThreshold()); | 52 EXPECT_EQ(4, params::HostIndifferentBlackListOptOutThreshold()); |
| 53 EXPECT_EQ(base::TimeDelta::FromDays(30), params::PerHostBlackListDuration()); | 53 EXPECT_EQ(base::TimeDelta::FromDays(30), params::PerHostBlackListDuration()); |
| 54 EXPECT_EQ(base::TimeDelta::FromDays(365 * 100), | 54 EXPECT_EQ(base::TimeDelta::FromDays(365 * 100), |
| 55 params::HostIndifferentBlackListPerHostDuration()); | 55 params::HostIndifferentBlackListPerHostDuration()); |
| 56 EXPECT_EQ(base::TimeDelta::FromSeconds(60 * 5), | 56 EXPECT_EQ(base::TimeDelta::FromSeconds(60 * 5), |
| 57 params::SingleOptOutDuration()); | 57 params::SingleOptOutDuration()); |
| 58 EXPECT_EQ(base::TimeDelta::FromDays(7), | 58 EXPECT_EQ(base::TimeDelta::FromDays(7), |
| 59 params::OfflinePreviewFreshnessDuration()); | 59 params::OfflinePreviewFreshnessDuration()); |
| 60 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G, | 60 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G, |
| 61 params::EffectiveConnectionTypeThresholdForOffline()); | 61 params::EffectiveConnectionTypeThreshold()); |
| 62 EXPECT_EQ(0, params::OfflinePreviewsVersion()); | 62 EXPECT_EQ(0, params::OfflinePreviewsVersion()); |
| 63 | 63 |
| 64 base::FieldTrialList field_trial_list(nullptr); | 64 base::FieldTrialList field_trial_list(nullptr); |
| 65 | 65 |
| 66 // Set some custom params. Somewhat random yet valid values. | 66 // Set some custom params. Somewhat random yet valid values. |
| 67 std::map<std::string, std::string> custom_params = { | 67 std::map<std::string, std::string> custom_params = { |
| 68 {"per_host_max_stored_history_length", "3"}, | 68 {"per_host_max_stored_history_length", "3"}, |
| 69 {"host_indifferent_max_stored_history_length", "4"}, | 69 {"host_indifferent_max_stored_history_length", "4"}, |
| 70 {"max_hosts_in_blacklist", "13"}, | 70 {"max_hosts_in_blacklist", "13"}, |
| 71 {"per_host_opt_out_threshold", "12"}, | 71 {"per_host_opt_out_threshold", "12"}, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 87 EXPECT_EQ(13u, params::MaxInMemoryHostsInBlackList()); | 87 EXPECT_EQ(13u, params::MaxInMemoryHostsInBlackList()); |
| 88 EXPECT_EQ(12, params::PerHostBlackListOptOutThreshold()); | 88 EXPECT_EQ(12, params::PerHostBlackListOptOutThreshold()); |
| 89 EXPECT_EQ(84, params::HostIndifferentBlackListOptOutThreshold()); | 89 EXPECT_EQ(84, params::HostIndifferentBlackListOptOutThreshold()); |
| 90 EXPECT_EQ(base::TimeDelta::FromDays(99), params::PerHostBlackListDuration()); | 90 EXPECT_EQ(base::TimeDelta::FromDays(99), params::PerHostBlackListDuration()); |
| 91 EXPECT_EQ(base::TimeDelta::FromDays(64), | 91 EXPECT_EQ(base::TimeDelta::FromDays(64), |
| 92 params::HostIndifferentBlackListPerHostDuration()); | 92 params::HostIndifferentBlackListPerHostDuration()); |
| 93 EXPECT_EQ(base::TimeDelta::FromSeconds(28), params::SingleOptOutDuration()); | 93 EXPECT_EQ(base::TimeDelta::FromSeconds(28), params::SingleOptOutDuration()); |
| 94 EXPECT_EQ(base::TimeDelta::FromDays(12), | 94 EXPECT_EQ(base::TimeDelta::FromDays(12), |
| 95 params::OfflinePreviewFreshnessDuration()); | 95 params::OfflinePreviewFreshnessDuration()); |
| 96 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_4G, | 96 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_4G, |
| 97 params::EffectiveConnectionTypeThresholdForOffline()); | 97 params::EffectiveConnectionTypeThreshold()); |
| 98 EXPECT_EQ(10, params::OfflinePreviewsVersion()); | 98 EXPECT_EQ(10, params::OfflinePreviewsVersion()); |
| 99 | 99 |
| 100 variations::testing::ClearAllVariationParams(); | 100 variations::testing::ClearAllVariationParams(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 TEST(PreviewsExperimentsTest, TestClientLoFiDisabledByDefault) { | 103 TEST(PreviewsExperimentsTest, TestClientLoFiDisabledByDefault) { |
| 104 base::FieldTrialList field_trial_list(nullptr); | 104 base::FieldTrialList field_trial_list(nullptr); |
| 105 EXPECT_FALSE(params::IsClientLoFiEnabled()); | 105 EXPECT_FALSE(params::IsClientLoFiEnabled()); |
| 106 } | 106 } |
| 107 | 107 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 118 base::FieldTrialList::CreateFieldTrial(kClientLoFiFieldTrial, kEnabled)); | 118 base::FieldTrialList::CreateFieldTrial(kClientLoFiFieldTrial, kEnabled)); |
| 119 EXPECT_TRUE(params::IsClientLoFiEnabled()); | 119 EXPECT_TRUE(params::IsClientLoFiEnabled()); |
| 120 } | 120 } |
| 121 | 121 |
| 122 TEST(PreviewsExperimentsTest, TestEnableClientLoFiWithDefaultParams) { | 122 TEST(PreviewsExperimentsTest, TestEnableClientLoFiWithDefaultParams) { |
| 123 base::FieldTrialList field_trial_list(nullptr); | 123 base::FieldTrialList field_trial_list(nullptr); |
| 124 EXPECT_TRUE( | 124 EXPECT_TRUE( |
| 125 base::FieldTrialList::CreateFieldTrial(kClientLoFiFieldTrial, kEnabled)); | 125 base::FieldTrialList::CreateFieldTrial(kClientLoFiFieldTrial, kEnabled)); |
| 126 | 126 |
| 127 EXPECT_TRUE(params::IsClientLoFiEnabled()); | 127 EXPECT_TRUE(params::IsClientLoFiEnabled()); |
| 128 EXPECT_EQ(0, params::ClientLoFiVersion()); | 128 EXPECT_EQ(0, params::LoFiVersion()); |
| 129 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G, | 129 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_2G, |
| 130 params::EffectiveConnectionTypeThresholdForClientLoFi()); | 130 params::EffectiveConnectionTypeThresholdForLoFi()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 TEST(PreviewsExperimentsTest, TestEnableClientLoFiWithCustomParams) { | 133 TEST(PreviewsExperimentsTest, TestEnableClientLoFiWithCustomParams) { |
| 134 base::FieldTrialList field_trial_list(nullptr); | 134 base::FieldTrialList field_trial_list(nullptr); |
| 135 | 135 |
| 136 // Set some custom params for Client LoFi. | 136 // Set some custom params for Client LoFi. |
| 137 std::map<std::string, std::string> custom_params = { | 137 std::map<std::string, std::string> custom_params = { |
| 138 {"version", "10"}, {"max_allowed_effective_connection_type", "3G"}, | 138 {"version", "10"}, {"max_allowed_effective_connection_type", "3G"}, |
| 139 }; | 139 }; |
| 140 EXPECT_TRUE(base::AssociateFieldTrialParams(kClientLoFiFieldTrial, kEnabled, | 140 EXPECT_TRUE(base::AssociateFieldTrialParams(kClientLoFiFieldTrial, kEnabled, |
| 141 custom_params)); | 141 custom_params)); |
| 142 EXPECT_TRUE( | 142 EXPECT_TRUE( |
| 143 base::FieldTrialList::CreateFieldTrial(kClientLoFiFieldTrial, kEnabled)); | 143 base::FieldTrialList::CreateFieldTrial(kClientLoFiFieldTrial, kEnabled)); |
| 144 | 144 |
| 145 EXPECT_TRUE(params::IsClientLoFiEnabled()); | 145 EXPECT_TRUE(params::IsClientLoFiEnabled()); |
| 146 EXPECT_EQ(10, params::ClientLoFiVersion()); | 146 EXPECT_EQ(10, params::LoFiVersion()); |
| 147 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_3G, | 147 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_3G, |
| 148 params::EffectiveConnectionTypeThresholdForClientLoFi()); | 148 params::EffectiveConnectionTypeThresholdForLoFi()); |
| 149 | 149 |
| 150 variations::testing::ClearAllVariationParams(); | 150 variations::testing::ClearAllVariationParams(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace | 153 } // namespace |
| 154 | 154 |
| 155 } // namespace previews | 155 } // namespace previews |
| OLD | NEW |