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

Unified Diff: components/variations/variations_associated_data.h

Issue 2145963002: Add simpler API for changing parameters in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A few typos. 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
Index: components/variations/variations_associated_data.h
diff --git a/components/variations/variations_associated_data.h b/components/variations/variations_associated_data.h
index 3eb9567cc3afe41848602b2fc9a2eabdaa00de77..1e3833b6b4720688359bef665871f122e30f5303 100644
--- a/components/variations/variations_associated_data.h
+++ b/components/variations/variations_associated_data.h
@@ -164,6 +164,29 @@ std::string GetVariationParamValueByFeature(const base::Feature& feature,
// Expose some functions for testing.
namespace testing {
+// Use this class as a member in your test class to set variation params for
+// your tests. You can directly set the parameters in the constructor (if they
Alexei Svitkine (slow) 2016/07/15 14:51:01 Also mention that it creates a FieldTrialList as a
jkrcal 2016/07/18 13:09:01 Done.
+// are used by other members upon construction). You can change them later
+// arbitrarily many times using the SetVariationParams function. The parameters
+// are automatically cleared when this class is destructed so it works well for
Alexei Svitkine (slow) 2016/07/15 14:51:01 Please make this sentence more precise to specify
jkrcal 2016/07/18 13:09:01 Done.
+// multiple tests of a given test class.
+class VariationParamsManager {
+ public:
+ VariationParamsManager(const std::string& trial_name,
+ const std::map<std::string, std::string>& params);
+
Alexei Svitkine (slow) 2016/07/15 14:51:01 Nit: No need for empty line here.
jkrcal 2016/07/18 13:09:01 Done.
+ ~VariationParamsManager();
+
+ // Associates |params| with the given |trial_name|. It creates a new group,
+ // used only for testing. Between two calls of this function,
+ // ClearAllVariationParams() has to be called.
+ void SetVariationParams(const std::string& trial_name,
+ const std::map<std::string, std::string>& params);
+
+ private:
+ std::unique_ptr<base::FieldTrialList> field_trial_list_;
+};
Alexei Svitkine (slow) 2016/07/15 14:51:01 DISALLOW_COPY_AND_ASSIGN()
jkrcal 2016/07/18 13:09:01 Done.
+
// Clears all of the mapped associations.
void ClearAllVariationIDs();

Powered by Google App Engine
This is Rietveld 408576698