| 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/feature_list.h" |
| 11 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 11 #include "base/metrics/field_trial_params.h" | 13 #include "base/metrics/field_trial_params.h" |
| 12 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 13 #include "components/variations/variations_associated_data.h" | 15 #include "components/variations/variations_associated_data.h" |
| 14 | 16 |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 18 |
| 17 namespace previews { | 19 namespace previews { |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 34 EXPECT_TRUE(base::AssociateFieldTrialParams(kClientSidePreviewsFieldTrial, | 36 EXPECT_TRUE(base::AssociateFieldTrialParams(kClientSidePreviewsFieldTrial, |
| 35 kEnabled, params)); | 37 kEnabled, params)); |
| 36 EXPECT_TRUE(base::FieldTrialList::CreateFieldTrial( | 38 EXPECT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 37 kClientSidePreviewsFieldTrial, kEnabled)); | 39 kClientSidePreviewsFieldTrial, kEnabled)); |
| 38 | 40 |
| 39 EXPECT_TRUE(IsIncludedInClientSidePreviewsExperimentsFieldTrial()); | 41 EXPECT_TRUE(IsIncludedInClientSidePreviewsExperimentsFieldTrial()); |
| 40 EXPECT_TRUE(params::IsOfflinePreviewsEnabled()); | 42 EXPECT_TRUE(params::IsOfflinePreviewsEnabled()); |
| 41 variations::testing::ClearAllVariationParams(); | 43 variations::testing::ClearAllVariationParams(); |
| 42 } | 44 } |
| 43 | 45 |
| 46 // Verifies that we can enable offline previews via comand line. |
| 47 TEST(PreviewsExperimentsTest, TestCommandLineOfflinePage) { |
| 48 EXPECT_FALSE(IsIncludedInClientSidePreviewsExperimentsFieldTrial()); |
| 49 EXPECT_FALSE(params::IsOfflinePreviewsEnabled()); |
| 50 |
| 51 std::unique_ptr<base::FeatureList> feature_list = |
| 52 base::MakeUnique<base::FeatureList>(); |
| 53 |
| 54 // The feature is explicitly enabled on the command-line. |
| 55 feature_list->InitializeFromCommandLine("OfflinePreviews", ""); |
| 56 base::FeatureList::ClearInstanceForTesting(); |
| 57 base::FeatureList::SetInstance(std::move(feature_list)); |
| 58 |
| 59 EXPECT_FALSE(IsIncludedInClientSidePreviewsExperimentsFieldTrial()); |
| 60 EXPECT_TRUE(params::IsOfflinePreviewsEnabled()); |
| 61 base::FeatureList::ClearInstanceForTesting(); |
| 62 } |
| 63 |
| 44 // Verifies that the default params are correct, and that custom params can be | 64 // Verifies that the default params are correct, and that custom params can be |
| 45 // set, for both the previews blacklist and offline previews. | 65 // set, for both the previews blacklist and offline previews. |
| 46 TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) { | 66 TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) { |
| 47 // Verify that the default params are correct. | 67 // Verify that the default params are correct. |
| 48 EXPECT_EQ(4u, params::MaxStoredHistoryLengthForPerHostBlackList()); | 68 EXPECT_EQ(4u, params::MaxStoredHistoryLengthForPerHostBlackList()); |
| 49 EXPECT_EQ(10u, params::MaxStoredHistoryLengthForHostIndifferentBlackList()); | 69 EXPECT_EQ(10u, params::MaxStoredHistoryLengthForHostIndifferentBlackList()); |
| 50 EXPECT_EQ(100u, params::MaxInMemoryHostsInBlackList()); | 70 EXPECT_EQ(100u, params::MaxInMemoryHostsInBlackList()); |
| 51 EXPECT_EQ(2, params::PerHostBlackListOptOutThreshold()); | 71 EXPECT_EQ(2, params::PerHostBlackListOptOutThreshold()); |
| 52 EXPECT_EQ(4, params::HostIndifferentBlackListOptOutThreshold()); | 72 EXPECT_EQ(4, params::HostIndifferentBlackListOptOutThreshold()); |
| 53 EXPECT_EQ(base::TimeDelta::FromDays(30), params::PerHostBlackListDuration()); | 73 EXPECT_EQ(base::TimeDelta::FromDays(30), params::PerHostBlackListDuration()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 EXPECT_EQ(10, params::ClientLoFiVersion()); | 166 EXPECT_EQ(10, params::ClientLoFiVersion()); |
| 147 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_3G, | 167 EXPECT_EQ(net::EFFECTIVE_CONNECTION_TYPE_3G, |
| 148 params::EffectiveConnectionTypeThresholdForClientLoFi()); | 168 params::EffectiveConnectionTypeThresholdForClientLoFi()); |
| 149 | 169 |
| 150 variations::testing::ClearAllVariationParams(); | 170 variations::testing::ClearAllVariationParams(); |
| 151 } | 171 } |
| 152 | 172 |
| 153 } // namespace | 173 } // namespace |
| 154 | 174 |
| 155 } // namespace previews | 175 } // namespace previews |
| OLD | NEW |