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

Unified Diff: components/variations/variations_associated_data.cc

Issue 2145963002: Add simpler API for changing parameters in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Alexei's comments Created 4 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 | « components/variations/variations_associated_data.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/variations_associated_data.cc
diff --git a/components/variations/variations_associated_data.cc b/components/variations/variations_associated_data.cc
index 9aa51d379f3d884a094d208d621e0d4eaacbe7f8..d7dda4b97d188a4c208e11ab5f35ba86551cdb94 100644
--- a/components/variations/variations_associated_data.cc
+++ b/components/variations/variations_associated_data.cc
@@ -16,6 +16,8 @@ namespace variations {
namespace {
+const char kGroupTesting[] = "Testing";
+
// The internal singleton accessor for the map, used to keep it thread-safe.
class GroupMapAccessor {
public:
@@ -252,6 +254,26 @@ std::string GetVariationParamValueByFeature(const base::Feature& feature,
// They simply wrap existing functions in this file.
namespace testing {
+VariationParamsManager::VariationParamsManager(
+ const std::string& trial_name,
+ const std::map<std::string, std::string>& params) {
+ SetVariationParams(trial_name, params);
+}
+
+VariationParamsManager::~VariationParamsManager() {
+ ClearAllVariationIDs();
+ ClearAllVariationParams();
+ field_trial_list_.reset();
+}
+
+void VariationParamsManager::SetVariationParams(
+ const std::string& trial_name,
+ const std::map<std::string, std::string>& params) {
+ field_trial_list_.reset(new base::FieldTrialList(nullptr));
+ variations::AssociateVariationParams(trial_name, kGroupTesting, params);
+ base::FieldTrialList::CreateFieldTrial(trial_name, kGroupTesting);
+}
+
void ClearAllVariationIDs() {
GroupMapAccessor::GetInstance()->ClearAllMapsForTesting();
}
« no previous file with comments | « components/variations/variations_associated_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698