andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 | [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 04:47:31 | [diff] [blame] | 11 | #include "test/field_trial.h" |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 | [diff] [blame] | 12 | |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 | [diff] [blame] | 13 | #include <string> |
| 14 | |
Danil Chapovalov | 385b6c5 | 2022-04-08 14:01:50 | [diff] [blame] | 15 | #include "absl/strings/string_view.h" |
Mirko Bonadei | f3db00f | 2021-08-23 15:39:58 | [diff] [blame] | 16 | #include "rtc_base/checks.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 17 | #include "system_wrappers/include/field_trial.h" |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 | [diff] [blame] | 20 | namespace test { |
pbos | 19492f1 | 2015-07-07 15:22:27 | [diff] [blame] | 21 | |
Danil Chapovalov | 385b6c5 | 2022-04-08 14:01:50 | [diff] [blame] | 22 | ScopedFieldTrials::ScopedFieldTrials(absl::string_view config) |
| 23 | : current_field_trials_(config), |
| 24 | previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) { |
| 25 | RTC_CHECK(webrtc::field_trial::FieldTrialsStringIsValid( |
| 26 | current_field_trials_.c_str())) |
| 27 | << "Invalid field trials string: " << current_field_trials_; |
Bjorn Terelius | edab301 | 2018-01-31 16:23:40 | [diff] [blame] | 28 | webrtc::field_trial::InitFieldTrialsFromString(current_field_trials_.c_str()); |
pbos | 19492f1 | 2015-07-07 15:22:27 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | ScopedFieldTrials::~ScopedFieldTrials() { |
Mirko Bonadei | f3db00f | 2021-08-23 15:39:58 | [diff] [blame] | 32 | RTC_CHECK( |
| 33 | webrtc::field_trial::FieldTrialsStringIsValid(previous_field_trials_)) |
| 34 | << "Invalid field trials string: " << previous_field_trials_; |
phoglund | 37ebcf0 | 2016-01-08 13:04:57 | [diff] [blame] | 35 | webrtc::field_trial::InitFieldTrialsFromString(previous_field_trials_); |
pbos | 19492f1 | 2015-07-07 15:22:27 | [diff] [blame] | 36 | } |
| 37 | |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 | [diff] [blame] | 38 | } // namespace test |
| 39 | } // namespace webrtc |