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

Unified Diff: components/variations/study_filtering_unittest.cc

Issue 2488173005: Adding support for exclude locales to variations. (Closed)
Patch Set: fix typo in comment Created 4 years, 1 month 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
« no previous file with comments | « components/variations/study_filtering.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/study_filtering_unittest.cc
diff --git a/components/variations/study_filtering_unittest.cc b/components/variations/study_filtering_unittest.cc
index 0c9dfa06e358860778445a887efa284da099c315..d8008cf26952d54416de820eae5180c6c402f594 100644
--- a/components/variations/study_filtering_unittest.cc
+++ b/components/variations/study_filtering_unittest.cc
@@ -130,17 +130,27 @@ TEST(VariationsStudyFilteringTest, CheckStudyFormFactor) {
TEST(VariationsStudyFilteringTest, CheckStudyLocale) {
struct {
const char* filter_locales;
+ const char* exclude_locales;
bool en_us_result;
bool en_ca_result;
bool fr_result;
} test_cases[] = {
- {"en-US", true, false, false},
- {"en-US,en-CA,fr", true, true, true},
- {"en-US,en-CA,en-GB", true, true, false},
- {"en-GB,en-CA,en-US", true, true, false},
- {"ja,kr,vi", false, false, false},
- {"fr-CA", false, false, false},
- {"", true, true, true},
+ {"en-US", "", true, false, false},
+ // Tests that locale overrides exclude_locale, when both are given. This
+ // should not occur in practice though.
+ {"en-US", "en-US", true, false, false},
+ {"en-US,en-CA,fr", "", true, true, true},
+ {"en-US,en-CA,en-GB", "", true, true, false},
+ {"en-GB,en-CA,en-US", "", true, true, false},
+ {"ja,kr,vi", "", false, false, false},
+ {"fr-CA", "", false, false, false},
+ {"", "", true, true, true},
+ {"", "en-US", false, true, true},
+ {"", "en-US,en-CA,fr", false, false, false},
+ {"", "en-US,en-CA,en-GB", false, false, true},
+ {"", "en-GB,en-CA,en-US", false, false, true},
+ {"", "ja,kr,vi", true, true, true},
+ {"", "fr-CA", true, true, true},
};
for (size_t i = 0; i < arraysize(test_cases); ++i) {
@@ -149,6 +159,10 @@ TEST(VariationsStudyFilteringTest, CheckStudyLocale) {
test_cases[i].filter_locales, ",",
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL))
filter.add_locale(locale);
+ for (const std::string& exclude_locale :
+ base::SplitString(test_cases[i].exclude_locales, ",",
+ base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL))
+ filter.add_exclude_locale(exclude_locale);
EXPECT_EQ(test_cases[i].en_us_result,
internal::CheckStudyLocale(filter, "en-US"));
EXPECT_EQ(test_cases[i].en_ca_result,
« no previous file with comments | « components/variations/study_filtering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698