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

Unified Diff: chrome/browser/metrics/variations_service_unittest.cc

Issue 10576003: VariationsService now supports wildcard in min/max version (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: addressed brettw's comment Created 8 years, 5 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
« no previous file with comments | « chrome/browser/metrics/variations_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/variations_service_unittest.cc
===================================================================
--- chrome/browser/metrics/variations_service_unittest.cc (revision 145458)
+++ chrome/browser/metrics/variations_service_unittest.cc (working copy)
@@ -130,6 +130,13 @@
{ "1.3.2", "1.2.3", false },
{ "2.1.2", "1.2.3", false },
{ "0.3.4", "1.2.3", true },
+ // Wildcards.
+ { "1.*", "1.2.3", true },
+ { "1.2.*", "1.2.3", true },
+ { "1.2.3.*", "1.2.3", true },
+ { "1.2.4.*", "1.2.3", false },
+ { "2.*", "1.2.3", false },
+ { "0.3.*", "1.2.3", true },
};
const struct {
@@ -142,6 +149,15 @@
{ "1.2.4", "1.2.3", true },
{ "2.1.1", "1.2.3", true },
{ "2.1.1", "2.3.4", false },
+ // Wildcards
+ { "2.1.*", "2.3.4", false },
+ { "2.*", "2.3.4", true },
+ { "2.3.*", "2.3.4", true },
+ { "2.3.4.*", "2.3.4", true },
+ { "2.3.4.0.*", "2.3.4", true },
+ { "2.4.*", "2.3.4", true },
+ { "1.3.*", "2.3.4", false },
+ { "1.*", "2.3.4", false },
};
chrome_variations::Study_Filter filter;
@@ -154,7 +170,7 @@
const bool result =
VariationsService::CheckStudyVersion(filter, min_test_cases[i].version);
EXPECT_EQ(min_test_cases[i].expected_result, result) <<
- "Case " << i << " failed!";
+ "Min. version case " << i << " failed!";
}
filter.clear_min_version();
@@ -163,7 +179,7 @@
const bool result =
VariationsService::CheckStudyVersion(filter, max_test_cases[i].version);
EXPECT_EQ(max_test_cases[i].expected_result, result) <<
- "Case " << i << " failed!";
+ "Max version case " << i << " failed!";
}
// Check intersection semantics.
@@ -189,20 +205,6 @@
}
}
-// The current client logic does not handle version number strings containing
-// wildcards. Check that any such values received from the server result in the
-// study being disqualified.
-TEST(VariationsServiceTest, CheckStudyVersionWildcards) {
- chrome_variations::Study_Filter filter;
-
- filter.set_min_version("1.0.*");
- EXPECT_FALSE(VariationsService::CheckStudyVersion(filter, "1.2.3"));
-
- filter.clear_min_version();
- filter.set_max_version("2.0.*");
- EXPECT_FALSE(VariationsService::CheckStudyVersion(filter, "1.2.3"));
-}
-
TEST(VariationsServiceTest, CheckStudyStartDate) {
const base::Time now = base::Time::Now();
const base::TimeDelta delta = base::TimeDelta::FromHours(1);
@@ -271,6 +273,34 @@
EXPECT_TRUE(valid);
EXPECT_EQ(300, total_probability);
+ // Min version checks.
+ study.mutable_filter()->set_min_version("1.2.3.*");
+ valid = VariationsService::ValidateStudyAndComputeTotalProbability(
+ study, &total_probability);
+ EXPECT_TRUE(valid);
+ study.mutable_filter()->set_min_version("1.*.3");
+ valid = VariationsService::ValidateStudyAndComputeTotalProbability(
+ study, &total_probability);
+ EXPECT_FALSE(valid);
+ study.mutable_filter()->set_min_version("1.2.3");
+ valid = VariationsService::ValidateStudyAndComputeTotalProbability(
+ study, &total_probability);
+ EXPECT_TRUE(valid);
+
+ // Max version checks.
+ study.mutable_filter()->set_max_version("2.3.4.*");
+ valid = VariationsService::ValidateStudyAndComputeTotalProbability(
+ study, &total_probability);
+ EXPECT_TRUE(valid);
+ study.mutable_filter()->set_max_version("*.3");
+ valid = VariationsService::ValidateStudyAndComputeTotalProbability(
+ study, &total_probability);
+ EXPECT_FALSE(valid);
+ study.mutable_filter()->set_max_version("2.3.4");
+ valid = VariationsService::ValidateStudyAndComputeTotalProbability(
+ study, &total_probability);
+ EXPECT_TRUE(valid);
+
study.clear_default_experiment_name();
valid = VariationsService::ValidateStudyAndComputeTotalProbability(study,
&total_probability);
« no previous file with comments | « chrome/browser/metrics/variations_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698