andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef TEST_FIELD_TRIAL_H_ |
| 12 | #define TEST_FIELD_TRIAL_H_ |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 13 | |
pbos | 19492f1 | 2015-07-07 08:22:27 -0700 | [diff] [blame] | 14 | #include <map> |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 15 | #include <string> |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | namespace test { |
| 19 | |
| 20 | // Parses enabled field trials from a string config, such as the one passed |
| 21 | // to chrome's argument --force-fieldtrials and initializes webrtc::field_trial |
| 22 | // with such a config. |
| 23 | // E.g.: |
| 24 | // "WebRTC-experimentFoo/Enabled/WebRTC-experimentBar/Enabled100kbps/" |
| 25 | // Assigns the process to group "Enabled" on WebRTCExperimentFoo trial |
| 26 | // and to group "Enabled100kbps" on WebRTCExperimentBar. |
| 27 | // |
| 28 | // E.g. invalid config: |
| 29 | // "WebRTC-experiment1/Enabled" (note missing / separator at the end). |
| 30 | // |
| 31 | // Note: This method crashes with an error message if an invalid config is |
| 32 | // passed to it. That can be used to find out if a binary is parsing the flags. |
Bjorn Terelius | edab301 | 2018-01-31 17:23:40 +0100 | [diff] [blame] | 33 | void ValidateFieldTrialsStringOrDie(const std::string& config); |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 34 | |
pbos | 19492f1 | 2015-07-07 08:22:27 -0700 | [diff] [blame] | 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(); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 41 | |
pbos | 19492f1 | 2015-07-07 08:22:27 -0700 | [diff] [blame] | 42 | private: |
phoglund | 37ebcf0 | 2016-01-08 05:04:57 -0800 | [diff] [blame] | 43 | std::string current_field_trials_; |
| 44 | const char* previous_field_trials_; |
pbos | 19492f1 | 2015-07-07 08:22:27 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 47 | } // namespace test |
| 48 | } // namespace webrtc |
| 49 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 50 | #endif // TEST_FIELD_TRIAL_H_ |