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

Unified Diff: components/variations/study_filtering_unittest.cc

Issue 2614443002: Supporting study definitions without default groups and end_date filtering. (Closed)
Patch Set: Created 3 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: components/variations/study_filtering_unittest.cc
diff --git a/components/variations/study_filtering_unittest.cc b/components/variations/study_filtering_unittest.cc
index d8008cf26952d54416de820eae5180c6c402f594..4f90824e3f22ccf60d3e7090b84f23b9757f5f6b 100644
--- a/components/variations/study_filtering_unittest.cc
+++ b/components/variations/study_filtering_unittest.cc
@@ -227,9 +227,11 @@ TEST(VariationsStudyFilteringTest, CheckStudyStartDate) {
const base::Time start_date;
bool expected_result;
} start_test_cases[] = {
- { now - delta, true },
- { now, true },
- { now + delta, false },
+ {now - delta, true},
+ // Note, the proto start_date is truncated to seconds, but the reference
+ // date isn't.
+ {now, true},
+ {now + delta, false},
};
Study_Filter filter;
@@ -245,6 +247,29 @@ TEST(VariationsStudyFilteringTest, CheckStudyStartDate) {
}
}
+TEST(VariationsStudyFilteringTest, CheckStudyEndDate) {
+ const base::Time now = base::Time::Now();
+ const base::TimeDelta delta = base::TimeDelta::FromHours(1);
+ const struct {
+ const base::Time end_date;
+ bool expected_result;
+ } start_test_cases[] = {
+ {now - delta, false}, {now + delta, true},
+ };
+
+ Study_Filter filter;
+
+ // Start date not set should result in true.
rkaplow 2017/01/04 15:58:25 End
jwd 2017/01/04 21:10:23 Done.
+ EXPECT_TRUE(internal::CheckStudyEndDate(filter, now));
+
+ for (size_t i = 0; i < arraysize(start_test_cases); ++i) {
+ filter.set_end_date(TimeToProtoTime(start_test_cases[i].end_date));
+ const bool result = internal::CheckStudyEndDate(filter, now);
+ EXPECT_EQ(start_test_cases[i].expected_result, result) << "Case " << i
+ << " failed!";
+ }
+}
+
TEST(VariationsStudyFilteringTest, CheckStudyVersion) {
const struct {
const char* min_version;
@@ -573,8 +598,9 @@ TEST(VariationsStudyFilteringTest, ValidateStudy) {
study.mutable_filter()->set_max_version("2.3.4");
EXPECT_TRUE(processed_study.Init(&study, false));
+ // A blank default study is allowed.
study.clear_default_experiment_name();
- EXPECT_FALSE(processed_study.Init(&study, false));
+ EXPECT_TRUE(processed_study.Init(&study, false));
study.set_default_experiment_name("xyz");
EXPECT_FALSE(processed_study.Init(&study, false));

Powered by Google App Engine
This is Rietveld 408576698