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 | #include "test/field_trial.h" |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 12 | |
| 13 | #include <algorithm> |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 14 | #include <cstdio> |
| 15 | #include <cstdlib> |
| 16 | #include <map> |
| 17 | #include <string> |
| 18 | |
Mirko Bonadei | f3db00f | 2021-08-23 17:39:58 +0200 | [diff] [blame^] | 19 | #include "rtc_base/checks.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "system_wrappers/include/field_trial.h" |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 23 | namespace test { |
Jonas Olsson | 5b2eda4 | 2019-06-11 14:29:40 +0200 | [diff] [blame] | 24 | void ValidateFieldTrialsStringOrDie(const std::string&) {} |
pbos | 19492f1 | 2015-07-07 08:22:27 -0700 | [diff] [blame] | 25 | |
| 26 | ScopedFieldTrials::ScopedFieldTrials(const std::string& config) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 27 | : previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) { |
Mirko Bonadei | f3db00f | 2021-08-23 17:39:58 +0200 | [diff] [blame^] | 28 | RTC_CHECK(webrtc::field_trial::FieldTrialsStringIsValid(config.c_str())) |
| 29 | << "Invalid field trials string: " << config; |
phoglund | 37ebcf0 | 2016-01-08 05:04:57 -0800 | [diff] [blame] | 30 | current_field_trials_ = config; |
Bjorn Terelius | edab301 | 2018-01-31 17:23:40 +0100 | [diff] [blame] | 31 | webrtc::field_trial::InitFieldTrialsFromString(current_field_trials_.c_str()); |
pbos | 19492f1 | 2015-07-07 08:22:27 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | ScopedFieldTrials::~ScopedFieldTrials() { |
Mirko Bonadei | f3db00f | 2021-08-23 17:39:58 +0200 | [diff] [blame^] | 35 | RTC_CHECK( |
| 36 | webrtc::field_trial::FieldTrialsStringIsValid(previous_field_trials_)) |
| 37 | << "Invalid field trials string: " << previous_field_trials_; |
phoglund | 37ebcf0 | 2016-01-08 05:04:57 -0800 | [diff] [blame] | 38 | webrtc::field_trial::InitFieldTrialsFromString(previous_field_trials_); |
pbos | 19492f1 | 2015-07-07 08:22:27 -0700 | [diff] [blame] | 39 | } |
| 40 | |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 41 | } // namespace test |
| 42 | } // namespace webrtc |