OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ | 5 #ifndef COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ |
6 #define COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ | 6 #define COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 // variation params, returns false and does not modify |params|. Calling this | 157 // variation params, returns false and does not modify |params|. Calling this |
158 // function will result in the associated field trial being marked as active if | 158 // function will result in the associated field trial being marked as active if |
159 // found (i.e. group() will be called on it), if it wasn't already. Currently, | 159 // found (i.e. group() will be called on it), if it wasn't already. Currently, |
160 // this information is only available from the browser process. Thread safe. | 160 // this information is only available from the browser process. Thread safe. |
161 std::string GetVariationParamValueByFeature(const base::Feature& feature, | 161 std::string GetVariationParamValueByFeature(const base::Feature& feature, |
162 const std::string& param_name); | 162 const std::string& param_name); |
163 | 163 |
164 // Expose some functions for testing. | 164 // Expose some functions for testing. |
165 namespace testing { | 165 namespace testing { |
166 | 166 |
167 // Use this class as a member in your test class to set variation params for | |
168 // 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.
| |
169 // are used by other members upon construction). You can change them later | |
170 // arbitrarily many times using the SetVariationParams function. The parameters | |
171 // 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.
| |
172 // multiple tests of a given test class. | |
173 class VariationParamsManager { | |
174 public: | |
175 VariationParamsManager(const std::string& trial_name, | |
176 const std::map<std::string, std::string>& params); | |
177 | |
Alexei Svitkine (slow)
2016/07/15 14:51:01
Nit: No need for empty line here.
jkrcal
2016/07/18 13:09:01
Done.
| |
178 ~VariationParamsManager(); | |
179 | |
180 // Associates |params| with the given |trial_name|. It creates a new group, | |
181 // used only for testing. Between two calls of this function, | |
182 // ClearAllVariationParams() has to be called. | |
183 void SetVariationParams(const std::string& trial_name, | |
184 const std::map<std::string, std::string>& params); | |
185 | |
186 private: | |
187 std::unique_ptr<base::FieldTrialList> field_trial_list_; | |
188 }; | |
Alexei Svitkine (slow)
2016/07/15 14:51:01
DISALLOW_COPY_AND_ASSIGN()
jkrcal
2016/07/18 13:09:01
Done.
| |
189 | |
167 // Clears all of the mapped associations. | 190 // Clears all of the mapped associations. |
168 void ClearAllVariationIDs(); | 191 void ClearAllVariationIDs(); |
169 | 192 |
170 // Clears all of the associated params. | 193 // Clears all of the associated params. |
171 void ClearAllVariationParams(); | 194 void ClearAllVariationParams(); |
172 | 195 |
173 } // namespace testing | 196 } // namespace testing |
174 | 197 |
175 } // namespace variations | 198 } // namespace variations |
176 | 199 |
177 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ | 200 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ |
OLD | NEW |