blob: 3d6c6ac61708ebbcb1fd2bfe6b250046dbcbd4c5 [file] [log] [blame]
andresp@webrtc.org60015d22014-05-16 09:39:51 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#include "test/field_trial.h"
andresp@webrtc.org60015d22014-05-16 09:39:51 +000012
andresp@webrtc.org60015d22014-05-16 09:39:51 +000013#include <string>
14
Danil Chapovalov385b6c52022-04-08 16:01:50 +020015#include "absl/strings/string_view.h"
Mirko Bonadeif3db00f2021-08-23 17:39:58 +020016#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "system_wrappers/include/field_trial.h"
andresp@webrtc.org60015d22014-05-16 09:39:51 +000018
19namespace webrtc {
andresp@webrtc.org60015d22014-05-16 09:39:51 +000020namespace test {
pbos19492f12015-07-07 08:22:27 -070021
Danil Chapovalov385b6c52022-04-08 16:01:50 +020022ScopedFieldTrials::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 Tereliusedab3012018-01-31 17:23:40 +010028 webrtc::field_trial::InitFieldTrialsFromString(current_field_trials_.c_str());
pbos19492f12015-07-07 08:22:27 -070029}
30
31ScopedFieldTrials::~ScopedFieldTrials() {
Mirko Bonadeif3db00f2021-08-23 17:39:58 +020032 RTC_CHECK(
33 webrtc::field_trial::FieldTrialsStringIsValid(previous_field_trials_))
34 << "Invalid field trials string: " << previous_field_trials_;
phoglund37ebcf02016-01-08 05:04:57 -080035 webrtc::field_trial::InitFieldTrialsFromString(previous_field_trials_);
pbos19492f12015-07-07 08:22:27 -070036}
37
andresp@webrtc.org60015d22014-05-16 09:39:51 +000038} // namespace test
39} // namespace webrtc