Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: components/variations/variations_seed_processor_unittest.cc

Issue 2614443002: Supporting study definitions without default groups and end_date filtering. (Closed)
Patch Set: rkaplow's comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
381 study.clear_default_experiment_name(); 382 study.clear_default_experiment_name();
382 EXPECT_FALSE(processed_study.Init(&study, false)); 383 EXPECT_TRUE(processed_study.Init(&study, false));
383 384
384 study.set_default_experiment_name("xyz"); 385 study.set_default_experiment_name("xyz");
385 EXPECT_FALSE(processed_study.Init(&study, false)); 386 EXPECT_FALSE(processed_study.Init(&study, false));
386 387
387 study.set_default_experiment_name("def"); 388 study.set_default_experiment_name("def");
388 default_group->clear_name(); 389 default_group->clear_name();
389 EXPECT_FALSE(processed_study.Init(&study, false)); 390 EXPECT_FALSE(processed_study.Init(&study, false));
390 391
391 default_group->set_name("def"); 392 default_group->set_name("def");
392 EXPECT_TRUE(processed_study.Init(&study, false)); 393 EXPECT_TRUE(processed_study.Init(&study, false));
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 EXPECT_TRUE(CreateTrialFromStudyWithFeatureList(study, feature_list.get())); 839 EXPECT_TRUE(CreateTrialFromStudyWithFeatureList(study, feature_list.get()));
839 base::test::ScopedFeatureList scoped_feature_list; 840 base::test::ScopedFeatureList scoped_feature_list;
840 scoped_feature_list.InitWithFeatureList(std::move(feature_list)); 841 scoped_feature_list.InitWithFeatureList(std::move(feature_list));
841 842
842 // Tthe feature should not be enabled, because the study is expired. 843 // Tthe feature should not be enabled, because the study is expired.
843 EXPECT_EQ(test_case.expected_feature_enabled, 844 EXPECT_EQ(test_case.expected_feature_enabled,
844 base::FeatureList::IsEnabled(test_case.feature)); 845 base::FeatureList::IsEnabled(test_case.feature));
845 } 846 }
846 } 847 }
847 848
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
848 TEST_F(VariationsSeedProcessorTest, LowEntropyStudyTest) { 866 TEST_F(VariationsSeedProcessorTest, LowEntropyStudyTest) {
849 const std::string kTrial1Name = "A"; 867 const std::string kTrial1Name = "A";
850 const std::string kTrial2Name = "B"; 868 const std::string kTrial2Name = "B";
851 const std::string kGroup1Name = "AA"; 869 const std::string kGroup1Name = "AA";
852 const std::string kDefaultName = "Default"; 870 const std::string kDefaultName = "Default";
853 871
854 VariationsSeed seed; 872 VariationsSeed seed;
855 Study* study1 = seed.add_study(); 873 Study* study1 = seed.add_study();
856 study1->set_name(kTrial1Name); 874 study1->set_name(kTrial1Name);
857 study1->set_consistency(variations::Study_Consistency_PERMANENT); 875 study1->set_consistency(variations::Study_Consistency_PERMANENT);
(...skipping 26 matching lines...) Expand all
884 // Since no experiment in study1 sends experiment IDs, it will use the high 902 // Since no experiment in study1 sends experiment IDs, it will use the high
885 // entropy provider, which selects the non-default group. 903 // entropy provider, which selects the non-default group.
886 EXPECT_EQ(kGroup1Name, base::FieldTrialList::FindFullName(kTrial1Name)); 904 EXPECT_EQ(kGroup1Name, base::FieldTrialList::FindFullName(kTrial1Name));
887 905
888 // Since an experiment in study2 has google_web_experiment_id set, it will use 906 // Since an experiment in study2 has google_web_experiment_id set, it will use
889 // the low entropy provider, which selects the default group. 907 // the low entropy provider, which selects the default group.
890 EXPECT_EQ(kDefaultName, base::FieldTrialList::FindFullName(kTrial2Name)); 908 EXPECT_EQ(kDefaultName, base::FieldTrialList::FindFullName(kTrial2Name));
891 } 909 }
892 910
893 } // namespace variations 911 } // namespace variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698