| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/variations/variations_seed_processor.h" | 5 #include "components/variations/variations_seed_processor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 EXPECT_TRUE(processed_study.Init(&study, false)); | 371 EXPECT_TRUE(processed_study.Init(&study, false)); |
| 372 | 372 |
| 373 // Max version checks. | 373 // Max version checks. |
| 374 study.mutable_filter()->set_max_version("2.3.4.*"); | 374 study.mutable_filter()->set_max_version("2.3.4.*"); |
| 375 EXPECT_TRUE(processed_study.Init(&study, false)); | 375 EXPECT_TRUE(processed_study.Init(&study, false)); |
| 376 study.mutable_filter()->set_max_version("*.3"); | 376 study.mutable_filter()->set_max_version("*.3"); |
| 377 EXPECT_FALSE(processed_study.Init(&study, false)); | 377 EXPECT_FALSE(processed_study.Init(&study, false)); |
| 378 study.mutable_filter()->set_max_version("2.3.4"); | 378 study.mutable_filter()->set_max_version("2.3.4"); |
| 379 EXPECT_TRUE(processed_study.Init(&study, false)); | 379 EXPECT_TRUE(processed_study.Init(&study, false)); |
| 380 | 380 |
| 381 // A blank default study is allowed. | |
| 382 study.clear_default_experiment_name(); | 381 study.clear_default_experiment_name(); |
| 383 EXPECT_TRUE(processed_study.Init(&study, false)); | 382 EXPECT_FALSE(processed_study.Init(&study, false)); |
| 384 | 383 |
| 385 study.set_default_experiment_name("xyz"); | 384 study.set_default_experiment_name("xyz"); |
| 386 EXPECT_FALSE(processed_study.Init(&study, false)); | 385 EXPECT_FALSE(processed_study.Init(&study, false)); |
| 387 | 386 |
| 388 study.set_default_experiment_name("def"); | 387 study.set_default_experiment_name("def"); |
| 389 default_group->clear_name(); | 388 default_group->clear_name(); |
| 390 EXPECT_FALSE(processed_study.Init(&study, false)); | 389 EXPECT_FALSE(processed_study.Init(&study, false)); |
| 391 | 390 |
| 392 default_group->set_name("def"); | 391 default_group->set_name("def"); |
| 393 EXPECT_TRUE(processed_study.Init(&study, false)); | 392 EXPECT_TRUE(processed_study.Init(&study, false)); |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 EXPECT_TRUE(CreateTrialFromStudyWithFeatureList(study, feature_list.get())); | 838 EXPECT_TRUE(CreateTrialFromStudyWithFeatureList(study, feature_list.get())); |
| 840 base::test::ScopedFeatureList scoped_feature_list; | 839 base::test::ScopedFeatureList scoped_feature_list; |
| 841 scoped_feature_list.InitWithFeatureList(std::move(feature_list)); | 840 scoped_feature_list.InitWithFeatureList(std::move(feature_list)); |
| 842 | 841 |
| 843 // Tthe feature should not be enabled, because the study is expired. | 842 // Tthe feature should not be enabled, because the study is expired. |
| 844 EXPECT_EQ(test_case.expected_feature_enabled, | 843 EXPECT_EQ(test_case.expected_feature_enabled, |
| 845 base::FeatureList::IsEnabled(test_case.feature)); | 844 base::FeatureList::IsEnabled(test_case.feature)); |
| 846 } | 845 } |
| 847 } | 846 } |
| 848 | 847 |
| 849 TEST_F(VariationsSeedProcessorTest, NoDefaultExperiment) { | |
| 850 base::FieldTrialList field_trial_list(nullptr); | |
| 851 | |
| 852 Study study; | |
| 853 study.set_name("Study1"); | |
| 854 | |
| 855 AddExperiment("A", 1, &study); | |
| 856 | |
| 857 EXPECT_TRUE(CreateTrialFromStudy(study)); | |
| 858 | |
| 859 base::FieldTrial* trial = base::FieldTrialList::Find("Study1"); | |
| 860 trial->Disable(); | |
| 861 | |
| 862 EXPECT_EQ(ProcessedStudy::kGenericDefaultExperimentName, | |
| 863 base::FieldTrialList::FindFullName("Study1")); | |
| 864 } | |
| 865 | |
| 866 TEST_F(VariationsSeedProcessorTest, LowEntropyStudyTest) { | 848 TEST_F(VariationsSeedProcessorTest, LowEntropyStudyTest) { |
| 867 const std::string kTrial1Name = "A"; | 849 const std::string kTrial1Name = "A"; |
| 868 const std::string kTrial2Name = "B"; | 850 const std::string kTrial2Name = "B"; |
| 869 const std::string kGroup1Name = "AA"; | 851 const std::string kGroup1Name = "AA"; |
| 870 const std::string kDefaultName = "Default"; | 852 const std::string kDefaultName = "Default"; |
| 871 | 853 |
| 872 VariationsSeed seed; | 854 VariationsSeed seed; |
| 873 Study* study1 = seed.add_study(); | 855 Study* study1 = seed.add_study(); |
| 874 study1->set_name(kTrial1Name); | 856 study1->set_name(kTrial1Name); |
| 875 study1->set_consistency(variations::Study_Consistency_PERMANENT); | 857 study1->set_consistency(variations::Study_Consistency_PERMANENT); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 902 // Since no experiment in study1 sends experiment IDs, it will use the high | 884 // Since no experiment in study1 sends experiment IDs, it will use the high |
| 903 // entropy provider, which selects the non-default group. | 885 // entropy provider, which selects the non-default group. |
| 904 EXPECT_EQ(kGroup1Name, base::FieldTrialList::FindFullName(kTrial1Name)); | 886 EXPECT_EQ(kGroup1Name, base::FieldTrialList::FindFullName(kTrial1Name)); |
| 905 | 887 |
| 906 // Since an experiment in study2 has google_web_experiment_id set, it will use | 888 // Since an experiment in study2 has google_web_experiment_id set, it will use |
| 907 // the low entropy provider, which selects the default group. | 889 // the low entropy provider, which selects the default group. |
| 908 EXPECT_EQ(kDefaultName, base::FieldTrialList::FindFullName(kTrial2Name)); | 890 EXPECT_EQ(kDefaultName, base::FieldTrialList::FindFullName(kTrial2Name)); |
| 909 } | 891 } |
| 910 | 892 |
| 911 } // namespace variations | 893 } // namespace variations |
| OLD | NEW |