Commit fcd88650 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Do not instantiate base::FieldTrialList explicitly in tests

The test suite already instantiates a FieldTrialList as per
https://chromium-review.googlesource.com/c/chromium/src/+/1883567 so
it's no longer necessary to do so explicitly in tests.

This patch addresses unit tests under:
/components/previews

This CL was uploaded by git cl split.

R=dougarnett@chromium.org

Bug: 1018667
Change-Id: I961f06327e484ce15d377f60fb7fd1b1d2f12050
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1917364
Auto-Submit: Mikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarDoug Arnett <dougarnett@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715745}
parent 5b163738
...@@ -433,8 +433,7 @@ class PreviewsDeciderImplTest ...@@ -433,8 +433,7 @@ class PreviewsDeciderImplTest
: public optimization_guide::ProtoDatabaseProviderTestBase { : public optimization_guide::ProtoDatabaseProviderTestBase {
public: public:
PreviewsDeciderImplTest() PreviewsDeciderImplTest()
: field_trial_list_(nullptr), : previews_decider_impl_(nullptr),
previews_decider_impl_(nullptr),
optimization_guide_service_( optimization_guide_service_(
task_environment_.GetMainThreadTaskRunner()) { task_environment_.GetMainThreadTaskRunner()) {
clock_.SetNow(base::Time::Now()); clock_.SetNow(base::Time::Now());
...@@ -514,7 +513,6 @@ class PreviewsDeciderImplTest ...@@ -514,7 +513,6 @@ class PreviewsDeciderImplTest
private: private:
base::test::TaskEnvironment task_environment_; base::test::TaskEnvironment task_environment_;
base::FieldTrialList field_trial_list_;
TestPreviewsDeciderImpl* previews_decider_impl_; TestPreviewsDeciderImpl* previews_decider_impl_;
optimization_guide::OptimizationGuideService optimization_guide_service_; optimization_guide::OptimizationGuideService optimization_guide_service_;
TestPreviewsOptimizationGuide* previews_opt_guide_; TestPreviewsOptimizationGuide* previews_opt_guide_;
......
...@@ -89,7 +89,7 @@ class TestPreviewsBlackList : public PreviewsBlackList { ...@@ -89,7 +89,7 @@ class TestPreviewsBlackList : public PreviewsBlackList {
class PreviewsBlackListTest : public testing::Test { class PreviewsBlackListTest : public testing::Test {
public: public:
PreviewsBlackListTest() : field_trial_list_(nullptr), passed_reasons_({}) {} PreviewsBlackListTest() : passed_reasons_({}) {}
~PreviewsBlackListTest() override {} ~PreviewsBlackListTest() override {}
void TearDown() override { variations::testing::ClearAllVariationParams(); } void TearDown() override { variations::testing::ClearAllVariationParams(); }
...@@ -159,7 +159,6 @@ class PreviewsBlackListTest : public testing::Test { ...@@ -159,7 +159,6 @@ class PreviewsBlackListTest : public testing::Test {
base::SimpleTestClock test_clock_; base::SimpleTestClock test_clock_;
std::map<std::string, std::string> params_; std::map<std::string, std::string> params_;
base::FieldTrialList field_trial_list_;
std::unique_ptr<TestPreviewsBlackList> black_list_; std::unique_ptr<TestPreviewsBlackList> black_list_;
std::vector<PreviewsEligibilityReason> passed_reasons_; std::vector<PreviewsEligibilityReason> passed_reasons_;
......
...@@ -53,8 +53,6 @@ TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) { ...@@ -53,8 +53,6 @@ TEST(PreviewsExperimentsTest, TestParamsForBlackListAndOffline) {
params::GetECTThresholdForPreview(PreviewsType::NOSCRIPT)); params::GetECTThresholdForPreview(PreviewsType::NOSCRIPT));
EXPECT_EQ(0, params::OfflinePreviewsVersion()); EXPECT_EQ(0, params::OfflinePreviewsVersion());
base::FieldTrialList field_trial_list(nullptr);
// Set some custom params. Somewhat random yet valid values. // Set some custom params. Somewhat random yet valid values.
std::map<std::string, std::string> custom_params = { std::map<std::string, std::string> custom_params = {
{"per_host_max_stored_history_length", "3"}, {"per_host_max_stored_history_length", "3"},
...@@ -245,7 +243,6 @@ TEST(PreviewsExperimentsTest, TestShouldExcludeMediaSuffix) { ...@@ -245,7 +243,6 @@ TEST(PreviewsExperimentsTest, TestShouldExcludeMediaSuffix) {
} }
TEST(PreviewsExperimentsTest, TestPreviewsEligibleForUserConsistentStudy) { TEST(PreviewsExperimentsTest, TestPreviewsEligibleForUserConsistentStudy) {
base::FieldTrialList field_trial_list(nullptr);
EXPECT_TRUE(base::FieldTrialList::CreateFieldTrial("CoinFlipPreviews", EXPECT_TRUE(base::FieldTrialList::CreateFieldTrial("CoinFlipPreviews",
"NonCoinFlipGroup")); "NonCoinFlipGroup"));
...@@ -347,10 +344,6 @@ TEST(PreviewsExperimentsTest, TestPreviewsEligibleForUserConsistentStudy) { ...@@ -347,10 +344,6 @@ TEST(PreviewsExperimentsTest, TestPreviewsEligibleForUserConsistentStudy) {
} }
TEST(PreviewsExperimentsTest, TestLitePageServerPreviewsCoinFlipExperiment) { TEST(PreviewsExperimentsTest, TestLitePageServerPreviewsCoinFlipExperiment) {
base::FieldTrialList field_trial_list(nullptr);
EXPECT_TRUE(base::FieldTrialList::CreateFieldTrial(
kPreviewsFieldTrial, "LitePageServerPreviewsCoinFlipExperimentGroup"));
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeaturesAndParameters( scoped_feature_list.InitWithFeaturesAndParameters(
{{features::kLitePageServerPreviewsUserConsistentStudy, {{features::kLitePageServerPreviewsUserConsistentStudy,
...@@ -363,6 +356,9 @@ TEST(PreviewsExperimentsTest, TestLitePageServerPreviewsCoinFlipExperiment) { ...@@ -363,6 +356,9 @@ TEST(PreviewsExperimentsTest, TestLitePageServerPreviewsCoinFlipExperiment) {
{features::kEligibleForUserConsistentStudy, {features::kEligibleForUserConsistentStudy,
features::kDeferAllScriptPreviews}); features::kDeferAllScriptPreviews});
EXPECT_TRUE(base::FieldTrialList::CreateFieldTrial(
kPreviewsFieldTrial, "LitePageServerPreviewsCoinFlipExperimentGroup"));
EXPECT_TRUE(params::IsLitePageServerPreviewsEnabled()); EXPECT_TRUE(params::IsLitePageServerPreviewsEnabled());
EXPECT_EQ(222, params::LitePageServerPreviewsVersion()); EXPECT_EQ(222, params::LitePageServerPreviewsVersion());
EXPECT_EQ(GURL("https://coinflippreviewhost.org/"), EXPECT_EQ(GURL("https://coinflippreviewhost.org/"),
...@@ -371,10 +367,6 @@ TEST(PreviewsExperimentsTest, TestLitePageServerPreviewsCoinFlipExperiment) { ...@@ -371,10 +367,6 @@ TEST(PreviewsExperimentsTest, TestLitePageServerPreviewsCoinFlipExperiment) {
} }
TEST(PreviewsExperimentsTest, TestDeferAllScriptPreviewsCoinFlipExperiment) { TEST(PreviewsExperimentsTest, TestDeferAllScriptPreviewsCoinFlipExperiment) {
base::FieldTrialList field_trial_list(nullptr);
EXPECT_TRUE(base::FieldTrialList::CreateFieldTrial(
kPreviewsFieldTrial, "DeferAllScriptPreviewsCoinFlipExperimentGroup"));
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeaturesAndParameters( scoped_feature_list.InitWithFeaturesAndParameters(
{{features::kDeferAllScriptPreviewsUserConsistentStudy, {{features::kDeferAllScriptPreviewsUserConsistentStudy,
...@@ -383,6 +375,9 @@ TEST(PreviewsExperimentsTest, TestDeferAllScriptPreviewsCoinFlipExperiment) { ...@@ -383,6 +375,9 @@ TEST(PreviewsExperimentsTest, TestDeferAllScriptPreviewsCoinFlipExperiment) {
{features::kEligibleForUserConsistentStudy, {features::kEligibleForUserConsistentStudy,
features::kLitePageServerPreviews}); features::kLitePageServerPreviews});
EXPECT_TRUE(base::FieldTrialList::CreateFieldTrial(
kPreviewsFieldTrial, "DeferAllScriptPreviewsCoinFlipExperimentGroup"));
EXPECT_TRUE(params::IsDeferAllScriptPreviewsEnabled()); EXPECT_TRUE(params::IsDeferAllScriptPreviewsEnabled());
EXPECT_EQ(444, params::DeferAllScriptPreviewsVersion()); EXPECT_EQ(444, params::DeferAllScriptPreviewsVersion());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment