OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_TEST_FIELD_TRIAL_H_ | 11 #ifndef WEBRTC_TEST_FIELD_TRIAL_H_ |
12 #define WEBRTC_TEST_FIELD_TRIAL_H_ | 12 #define WEBRTC_TEST_FIELD_TRIAL_H_ |
13 | 13 |
14 #include <string> | 14 #include <string> |
| 15 #include <map> |
15 | 16 |
16 namespace webrtc { | 17 namespace webrtc { |
17 namespace test { | 18 namespace test { |
18 | 19 |
19 // Parses enabled field trials from a string config, such as the one passed | 20 // Parses enabled field trials from a string config, such as the one passed |
20 // to chrome's argument --force-fieldtrials and initializes webrtc::field_trial | 21 // to chrome's argument --force-fieldtrials and initializes webrtc::field_trial |
21 // with such a config. | 22 // with such a config. |
22 // E.g.: | 23 // E.g.: |
23 // "WebRTC-experimentFoo/Enabled/WebRTC-experimentBar/Enabled100kbps/" | 24 // "WebRTC-experimentFoo/Enabled/WebRTC-experimentBar/Enabled100kbps/" |
24 // Assigns the process to group "Enabled" on WebRTCExperimentFoo trial | 25 // Assigns the process to group "Enabled" on WebRTCExperimentFoo trial |
25 // and to group "Enabled100kbps" on WebRTCExperimentBar. | 26 // and to group "Enabled100kbps" on WebRTCExperimentBar. |
26 // | 27 // |
27 // E.g. invalid config: | 28 // E.g. invalid config: |
28 // "WebRTC-experiment1/Enabled" (note missing / separator at the end). | 29 // "WebRTC-experiment1/Enabled" (note missing / separator at the end). |
29 // | 30 // |
30 // Note: This method crashes with an error message if an invalid config is | 31 // Note: This method crashes with an error message if an invalid config is |
31 // passed to it. That can be used to find out if a binary is parsing the flags. | 32 // passed to it. That can be used to find out if a binary is parsing the flags. |
32 void InitFieldTrialsFromString(const std::string& config); | 33 void InitFieldTrialsFromString(const std::string& config); |
33 | 34 |
| 35 // This class is used to override field-trial configs within specific tests. |
| 36 // After this class goes out of scope previous field trials will be restored. |
| 37 class ScopedFieldTrials { |
| 38 public: |
| 39 explicit ScopedFieldTrials(const std::string& config); |
| 40 ~ScopedFieldTrials(); |
| 41 private: |
| 42 const std::map<std::string, std::string> previous_field_trials_; |
| 43 }; |
| 44 |
34 } // namespace test | 45 } // namespace test |
35 } // namespace webrtc | 46 } // namespace webrtc |
36 | 47 |
37 #endif // WEBRTC_TEST_FIELD_TRIAL_H_ | 48 #endif // WEBRTC_TEST_FIELD_TRIAL_H_ |
OLD | NEW |